How to put arrival time in date and time format in source in Arrival schdeule

How to put arrival time in date and time format in source in Arrival schdeule

raashid_mohammed1
Not applicable
186 Views
5 Replies
Message 1 of 6

How to put arrival time in date and time format in source in Arrival schdeule

raashid_mohammed1
Not applicable

I have two questions

1. how to put arrival time in SOURCE arrival schedule in date and time format

for example something like this 8/2/2016 4:00:00 PM instead of seconds

2. how to change to simulation start date and time

currently my model runs with model start time

8:00:00 AM Thu 25 Aug 2016

how can change that before simulation run

please help

thanks

Raashid

0 Likes
Accepted solutions (1)
187 Views
5 Replies
Replies (5)
Message 2 of 6

logan_gold
Community Manager
Community Manager
Accepted solution

1.) The ArrivalTime column of a Source's Arrival Schedule always needs a value that is a number. However, you can use the convert() command to convert a date/time format into model time. So you could have a Global Table with all the date/time information you want to convert to be used in a Source's Arrival Schedule. Then, use something like the Source's OnReset trigger to convert the values in the Global Table to be used in the Arrival Schedule. Using 8:00:00 AM Thu 25 Aug 2016 as a model's start time, this command will return 3600:

convert("9:00:00 AM Thu 25 Aug 2016", DATETIME_STR, MODEL_TIME);

2.) Go to Edit, then Model Settings. The Model Settings window has two fields for Model Start Time - the time and date. You can make changes in either field to change the Model Start Time.

Message 3 of 6

raashid_mohammed1
Not applicable

Thank you

How do I connect global table to source arrival schedule ?

I know how to import directly from excel but don't know how to import from global table to source

For the model start time instead changing the time by going to the settings. is there a way I can lookup value and change the model start time on Model reset ?

0 Likes
Message 4 of 6

logan_gold
Community Manager
Community Manager

Here is an example model of how you can connect a Global Table to a Sourcen's arrival schedule:

sourceschedule-datetimeformat-example-v16-1-2.fsm

GlobalTable1 is set up with the time/date format I want to use in the Source. To use the convert() command, the format needs to be exactly what you see here.

In the Source's OnReset trigger, I used code to reference those times/dates in the Global Table, convert them into model time using the convert() command, then copy that number into the Source's Arrivals Table. I was able to use a command called getvarnode() to get a reference to the arrival table - it is a variable in the Source's tree called schedule. Since this variable is a table itself, I used the settablenum() command to make the changes.

To change the Model Start Time with code in the OnModelReset trigger, you'd need to do something like:

treenode startNode = node("/Tools/ModelUnits/ModelDateTime/start", model());
double startTime = convert("8:00:00 AM Fri 26 Aug 2016", DATETIME_STR, FS_DATETIME);
set(startNode, startTime);
applicationcommand("convertunixtime", startNode, startTime);

Where the first parameter in the convert() command (the string with the time and date) is the value that you want to change the model's start time to. That string is getting converted into a format called FlexSim datetime, which is a number that is needed in the application command called convertunixtime. So if you are starting with a different format, it needs to be converted into the FlexSim datetime format before being used in the convertunixtime application command.

Message 5 of 6

christophe_c21
Not applicable

@Logan Gold

I have the same problem.

I want to use a one year excel schedule by date, representing my Working order. Each working order includes a quantity of pieces to be produce.

How can I add some quantity in the exemple you have linked to your answer ?

For exemple,

I would like to have 25 pieces out of my source on the 01/08/2017 at 07:00 AM ?

0 Likes
Message 6 of 6

logan_gold
Community Manager
Community Manager

You would first want to add a column to the Global Table that contains the quantity for each work order. So column one is the time by date, and the second column is the quantity.

Then, add a couple more lines of code inside the for loop. Something like this:

double quantity = gettablenum("GlobalTable1", row, 2);
settablenum(schedule, row, 4, quantity);
0 Likes