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.
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.
Do you have a model that you are working on that would demonstrate what you are trying to achieve?
I don't have any, those are specification to modules that I develop, but let me develop one. and I'll upload it.
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.
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.
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);
Thank you Matt, as you suggested it's easier in version 20.0. I appreciate your help, thank you.
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.
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);
Thanks, @Matthew Gillespie, It's really useful.
13 People are following this question.
© 1993- FlexSim Software Products, Inc. All Rights Reserved.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.