question

Michael avatar image
0 Likes"
Michael asked Joshua S commented

Create a global variable to represent production year

I would like to have easy access to the "production year," as I have process times and demand that changes from year to year.

What is the best way to do this?

My initial thought was to create a global variable, originally set to 2019. And then at the "start of the run," use custom code that sends a delayed message (delayed by 8760 hours, 1 year) to a dummy object that would increment the variable when it receives the message. Where should this custom code be stored?

I had also considered a macro ((current time / 8760) plus 2019) but that seemed like it might slow down the model re-calculating the date all the time.

Do you have any suggestions on how to proceed?

Thank you

FlexSim 18.2.0
global variables
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Joshua S avatar image
2 Likes"
Joshua S answered Joshua S commented

One method is to change the start date and time of the actual model, then call the date when you need to. You can do this by going to the edit tab, go down to model settings, then a screen will pop up that will allow you the change all that information. To call the current year you use Model.DateTime.Year, there's a whole list of other time references you can use as well as shown in the picture below


pic1.png (18.8 KiB)
· 6
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Michael avatar image Michael commented ·

Thank you Joshua - one of the reasons I hesitated to use the "actual" date was the variability in run time hours from year to year. For example, I would send a message to update source parameters every "year" ("year" defined to be a constant 8000 hours, for example). Is there a way to send a message every year, using the actual year in the model? (Please let me know if this is better asked as a separate question).

0 Likes 0 ·
Joshua S avatar image Joshua S Michael commented ·

This still relates entirely to your post previously. I should have thought of this earlier, but you can do this quite easily in process flow. Use an inter-arrival source activity that creates a token every "year" or 8760 hours, and then write whatever code in the following custom code activity for what you want to happen, whether it is a message, or it is changing global variables that you have assigned to the different processors or whatever needs to change based on a year rotation.

1 Like 1 ·
pic1.png (14.5 KiB)
Michael avatar image Michael Joshua S commented ·

Thank you for the good suggestion. Is there any way to use the 'real' dates? IE, at 12:01 on every January 1st, create a token.

0 Likes 0 ·
Show more comments