question

Abhineet Mittal avatar image
0 Likes"
Abhineet Mittal asked Logan Gold answered

Need to access loadtime variable on task executor.

I am creating task executors as a input in the model. To describe in brief I am using dashboard input before the start of the model to create that number of operators.

I have set different speed and loadtime for different input/operators. I am easily able to access the maxspeed but couldn't find a way to access the loadtime on the operator.

Is there is specific flexscript that would allow me to do so? I understand it is a code node in the variables node of the operator.

Thanks

flexsim commandsvariant
5 |100000

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

Logan Gold avatar image
3 Likes"
Logan Gold answered

Since it is a code node, you'll need to treat the value of the node as text. If you want to change the load time of a Task Executer, you'll need to set the text of the node using setvarstr() and include any default variables you might need to use as part of the code. So you could do something like the following by using FlexScript somewhere else in the model (like the Model On Reset or in the same code that is creating the new Task Executer), where operator is a reference to the task executor you want to change:

setvarstr(operator, "loadtime", "Object item = param(1); Object current = ownerobject(c); treenode station = param(2); return /**/0/**direct*/;");
buildnodeflexscript(getvarnode(operator, "loadtime"));

This will set the load time to 0, so you will want to change where it has the 0 (after the return statement) to whatever the new load time needs to be. Also note that the /**/ and /**direct*/ text is to make the Load Time field in the task executer's properties window show whatever text is between the two. You can leave that out if you don't care what is shown in the properties window.

Another thing to note with the above code is if you were to look at the code editor for the load time after the change, you will only see one line of text, which is perfectly acceptable with FlexScript. If you wanted to make it look nicer when opening the code editor, you could do something like this:

setvarstr(operator, "loadtime", "Object item = param(1);\nObject current = ownerobject(c);\ntreenode station = param(2);\nreturn /**/0/**direct*/;");
buildnodeflexscript(getvarnode(operator, "loadtime"));

Where you can use the \n character to put in a new line (the same as hitting enter in the code editor) between lines of code.

Both examples include the buildnodeflexscript() command, which will make sure changes to the FlexScript node will take effect. In this case, using the getvarnode() command is needed to reference the load time node that we're changing on the task executer.

5 |100000

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

Raja Sekaran avatar image
0 Likes"
Raja Sekaran answered

@Abhineet Mittal

In the attached model, I have used process flow to set the different load and unload time for two operators based on global table input.

Hope this helps.

loadingtime.fsm

Thanks


loadingtime.fsm (39.5 KiB)
5 |100000

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