question

Ashmita G avatar image
0 Likes"
Ashmita G asked Jason Lightfoot edited

Assign Station processing time on model reset trigger

Hi,

My model involves several stations, with different processing times. I came across the a model where the on Model reset trigger was employed to fetch the processing time values from a script and inserted into the processor.

The syntax I am speaking is as follows:

getvarnode("Processor1", "cycletime").value = 2; (or the number you want to assign)

When I tried the similar process for the stations however I was unable to implement it.

In the tree I could see station has a processTime mentioned, unlike in the processor where cycletime was mentioned.

Could someone guide me how to use the above syntax with respect to stations.

Thank you.

FlexSim 20.1.0
flexscriptflexsim 20.1.0stationsonresettrigger
5 |100000

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

Jason Lightfoot avatar image
1 Like"
Jason Lightfoot answered Jason Lightfoot edited

For a processor:

Object proc=Model.find("Processor1");
treenode varnode=getvarnode(proc,"cycletime");
varnode.value="return 2;";
buildnodeflexscript(varnode);

For a conveyor station:

Object station=Model.find("Station1");
treenode type=station.getVariable("type");
treenode varnode=type.subnodes["processTime"];
varnode.value="return 3;";
buildnodeflexscript(varnode);
· 2
5 |100000

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

Ashmita G avatar image Ashmita G commented ·

Hi @jason.lightfoot, thank you for the solution. It helps alot.

I have one query though, regarding how the second and third line are implemented.

In the code you used the line station.getVariable("type"). I understand this was to fetch the value from the tree, of the node called "type".

In the tree under variable, we have several subnodes, like type, localtype,etc. Under local type I could find the option of processTime. However, according to the code snippet, to the best of my understanding, it means to say under the node Type, fetch the subnode ProcessTime. How does it locate the process Time under "type" when in the tree it is under "localType"?

Could you please explain that part to me.

Thank you for the help, appreciate it.

flexsim_doubt_station1.PNG

1 Like 1 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Ashmita G commented ·

If the station is a custom type then the 'type' variable points to the localtype node, and if not it points to the type definition.

Note that this pertains to version prior to 21. In 21 the object management feature 'type' is removed for newly instantiated objects.

1 Like 1 ·
Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Joerg Vogel commented

Please, can you check, if the process time function source code returns a value? If this is the case, then you aren’t able to set a varnode, because you must write a source code to the node. For such cases where a function is more than just a number you can insert dynamic values indirectly by a label. The return value is a label value or a reference to a similar structure like a table cell. If the process time gets evaluated, then this function reads the label value. You change the number of the label whenever you like. The label is stored foe example at an object.

· 2
5 |100000

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

Ashmita G avatar image Ashmita G commented ·

Hi @Jörg Vogel, thank you for the prompt reply. Yes the source code does returns a value.

flexsim_doubt_station.PNG

I understand you mean to follow an approach similar to the one mentioned in this link:

https://answers.flexsim.com/questions/28665/change-process-time-of-station-point-in-conveyor.html

I have tried to use this method, it does work, however I was looking for a means whereby I wouldn't have to create labels on every station. As I had previously mentioned I have many stations in my model and creating a label for each becomes a bit tedious. Hence looking for a code which could address the issue without having to create the labels.

Thank you for the help. Appreciate it.

0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel Ashmita G commented ·

@Ashmita G, in such a case it is more a factor, how you apply the settings. There is the tool Edit Selected Objects, which transfers an attribute of one highlighted object (yellow frame) to all selected objects (red frame). You would create groups of similar attribute scheme. Then you select a group and transfer a setting to use a table cell, which keeps the process time. Alternatively you can do this with labels, global arrays or any other structure of storing values. If the default features don‘t work, you can write a code or set up a process flow which iterates over the group members and changes values or copies nodes.

0 Likes 0 ·