question

anon-user avatar image
0 Likes"
anon-user asked Matthew Gillespie edited

Change Model Start Time

About Model Units.


Is it possible to change the Model Start Time using FlexScript?

What FlexScript do I need to write?

FlexSim 19.0.9
flexsim 19.0.9start timemodel unitstime unitschange unit
· 1
5 |100000

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

Ben Wilson avatar image Ben Wilson ♦♦ commented ·

Hi anonymous user, was Matthew Gillespie's or Raja Sekaran's answer helpful? If so, please click the red "Accept" button on one of their answers. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

·
Matthew Gillespie avatar image
2 Likes"
Matthew Gillespie answered Matthew Gillespie edited

You should use the DateTime constructor.

For versions 21.1 and later use:

DateTime startTime = DateTime("9/11/2020 07:00:00", "%m/%d/%Y %I:%M:%S"); 
function_s(getmodelunit(START_TIME_NODE), "setDateTime", startTime);

If you want the warmup and stop times to keep the same relative model times you should update them too:

// Update the warmup and stop times so they keep the same model times
treenode warmupNode = getmodelunit(WARMUP_TIME_NODE);
function_s(warmupNode, "setModelTime", getsdtvalue(warmupNode, "modelTime"));

treenode stopNodes = getmodelunit(STOP_TIME_NODE);
for (int i = 1; i <= stopNodes.subnodes.length; i++) {
    treenode stopNode = stopNodes.subnodes[i];
    function_s(stopNode, "setModelTime", getsdtvalue(stopNode, "modelTime"));
}

For versions 20.0 - 21.0 use:

DateTime newStartTime = DateTime("9/11/2020 07:00:00", "%m/%d/%Y %I:%M:%S"); 
treenode startNode = getmodelunit(START_TIME_NODE); 
startNode.value = newStartTime.value; 
applicationcommand("convertunixtime", startNode, startNode.value);

For versions before 20.0:

See this answer: https://answers.flexsim.com/questions/79484/which-are-the-commands-to-update-the-startwarm-ups.html

5 |100000

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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