Hi,
I was trying to create some tracked variables using code before the run start of the simulation model, after deleting the existing tracked variables other than TimeInSystem and WorkInProgress. Some exceptions are thrown after pressing the reset button and couldn't understand the reason What could be the reason?
Also attaching the model.
exception: Exception caught in TreeNode::callMemberFunction() c++/dll execution. Throwing... MAIN:/project/exec/globals/nodefunctions/resettrackedvariable c: MAIN:/project/exec/globals/nodefunctions/resettrackedvariable thisClass: MAIN:/project/exec/globals/nodefunctions/resettrackedvariable
exception: FlexScript exception: MAIN:/project/events/OnResetModel/reset tracked variables
exception: Exception Caught in ObjectFunction28__project_exec_globals_nodefunctions_resettrackedvariable object: MAIN:/project/exec/globals/nodefunctions/resettrackedvariable class: MAIN:/project/exec/globals/nodefunctions/resettrackedvariable
treenode TV = Model.find("Tools/TrackedVariables");
for(int k=TV.subnodes.length;k>=3;k--) // Removes existing tracked variables
{
string SubnodeName = TV.subnodes[k].name;
string Name = "Bay" + string.fromNum(k-2);
if(Name == SubnodeName)
{
treenode Subnode = TV.subnodes[k];
Subnode.destroy();
}
}
int NumOfBays = 7;
for(int k=9;k<=9 + NumOfBays;k++) // Adds new variables
{
TrackedVariable newTV = TrackedVariable.init(TV, STAT_TYPE_TIME_SERIES, 0.0, STAT_USE_HISTORY | STAT_IGNORE_WARMUP);
TV.last.name = "Bay" + string.fromNum(k-8);
}
Regards,SwamiSupport_TV.fsm
Arun KR