Hi @Axel Kohonen and @Mischa Spelt,
I did not have a syntax error, but your solution did not work in my model. not sure why.
I solved my problem with your help. Thanks!
Additionally I needed to ensure the code was only triggered on the first item entering the last processor. I added a Counter label that triggers an if-clause that resets the statistics of the model only on the first item entering the processor.
Also i added a globalvariable that is linked to an editable textbox in my dashboard so I easily can change my modelling horizon.
Thanks for your help!
In the end my code looks as follows;
/**Set stoptime after line is full*/
Object item = param(1);
Object current = ownerobject(c);
int port = param(2);
{ // ************* PickOption Start ************* //
treenode thenode = current.labels["Counter"];
double value = 1;
inc(thenode,value);
} // ******* PickOption End ******* //
{ // ************* PickOption Start ************* //
if (current.Counter == 1) {
stoptime(model().find("Tools/ModelUnits/ModelDateTime/current").value + model().find("Tools/GlobalVariables/modelling_time"));
resetstats();
}
} // ******* PickOption End ******* //