I want to use code to set the start time and stop time, because later in the future my model will have various modes that the user can choose from (in a GUI comboList dropdown), and those modes will correlate to a different start and stop times (different points throughout a calendar year to test).
I have successfully been able to set the start time with code using the following:
DateTime startTime = DateTime("6/1/2023 08:00:00","%m/%d/%Y %H:%M:%S"); function_s(getmodelunit(START_TIME_NODE), "setDateTime", startTime);
I tried using something similar for stop time:
DateTime stopTime = DateTime("6/30/2023 17:00:00","%m/%d/%Y %H:%M:%S"); function_s(getmodelunit(STOP_TIME_NODE), "setDateTime", stopTime);
but this would have been too easy and it did not work.
Then I tried looking up where the stopTimes are located in the Tree to see if I could access the treeNode property, but I was unsuccessful.
This code was some of my failed attempts:
DateTime stopTime = DateTime("6/30/2023 18:01:00","%m/%d/%Y %H:%M:%S"); treenode stopTimeNode = getmodelunit(STOP_TIME_NODE); stopTimeNode.value = convert(stopTime, DateTime, FS_DATETIME); Model.find("Tools/ModelUnits/ModelDateTimes/stopTimes/1/dateTime") = stopTime;
How do I go about setting the stop time for the model with code. (I understand there can be multiple stop times, so I just want to always be able to change the first stop time and only have one stop time).