question

Manuel Sinco avatar image
0 Likes"
Manuel Sinco asked Manuel Sinco commented

Which are the commands to update the start/warm up/stop time?

In the past, I tried to update the values directly from the tree by code, but it didn't work as I expected.

I want that a user can choose some values and based on them, update all those times.

FlexSim 19.1.0
start timeuser commandsstop timewarm up time
· 3
5 |100000

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

zacharyh avatar image zacharyh ♦ commented ·

Do you have a model that you are working on that would demonstrate what you are trying to achieve?

0 Likes 0 ·
Manuel Sinco avatar image Manuel Sinco zacharyh ♦ commented ·

I don't have any, those are specification to modules that I develop, but let me develop one. and I'll upload it.

0 Likes 0 ·
Manuel Sinco avatar image Manuel Sinco zacharyh ♦ commented ·

I'm attaching you an example of what I want to do, basically I want the commands that will update the start, stop time in simulation.Thanks.

update-start-stop-warm-up-time.fsm

0 Likes 0 ·

1 Answer

Matthew Gillespie avatar image
0 Likes"
Matthew Gillespie answered Manuel Sinco commented

20.0

This is much easier to do in version 20.0 since we added the DateTime.compose() method:

Table times = Table("GlobalTable1");
int row = 1;

int hour = times[row][4];
int day = times[row][1];
int month = times[row][2];
int year = times[row][3];

double startTime = DateTime.compose(year, month, day, hour, 0, 0, 0);
getmodelunit(START_TIME_NODE).value = startTime;

Before version 20.0

You can use the convert command to do this . *Note that this method uses the time formats defined in model settings.

starttimedashboard.fsm

For the Start Time:

Table times = Table("GlobalTable1");
int row = 1;

int hour = times[row][4];
int day = times[row][1];
int month = times[row][2];
int year = times[row][3];

string timeString =  (hour < 10 ? "0" : "") + string.fromNum(hour) + ":00:00 ";
string dateString = (day < 10 ? "0" : "") + string.fromNum(day) + "/" + (month < 10 ? "0" : "") + string.fromNum(month) + "/" + string.fromNum(year);

treenode startTime = getmodelunit(START_TIME_NODE);
startTime.value = convert(timeString + dateString, DATETIME_STR, FS_DATETIME);

For the Stop Time:

Table times = Table("GlobalTable1");
int row = 2;

int hour = times[row][4];
int day = times[row][1];
int month = times[row][2];
int year = times[row][3];

string timeString =  (hour < 10 ? "0" : "") + string.fromNum(hour) + ":00:00 ";
string dateString = (day < 10 ? "0" : "") + string.fromNum(day) + "/" + (month < 10 ? "0" : "") + string.fromNum(month) + "/" + string.fromNum(year);

treenode stopTimeNode = getmodelunit(STOP_TIME_NODE);
stopTimeNode.value = convert(timeString + dateString, DATETIME_STR, FS_DATETIME);

double duration = (getmodelunit(STOP_TIME) - getmodelunit(START_TIME)) / getmodelunit(TIME_MULTIPLE);
stoptime(duration);

· 4
5 |100000

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

Manuel Sinco avatar image Manuel Sinco commented ·

Thank you Matt, as you suggested it's easier in version 20.0. I appreciate your help, thank you.

0 Likes 0 ·
Manuel Sinco avatar image Manuel Sinco commented ·

Hello @Matthew Gillespie

Thanks for your answer, now I want to ask about how to change the warm up time. I saw that there's no similar command as stoptime().

Thanks.

0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Manuel Sinco commented ·

Here's an example of how to set the warm up time to time 1000:

double warmupDuration = 1000;

node("MAIN:/project/exec/warmup").value = warmupDuration;

double warmupT = convert(warmupDuration, MODEL_TIME, FS_DATETIME);
treenode warmupTime = getmodelunit(WARMUP_TIME_NODE);
warmupTime.value = warmupT;
applicationcommand("convertunixtime", warmupTime, warmupTime.value);
1 Like 1 ·
Manuel Sinco avatar image Manuel Sinco Matthew Gillespie ♦♦ commented ·

Thanks, @Matthew Gillespie, It's really useful.

0 Likes 0 ·