referencing node numeric value of a zone partition

referencing node numeric value of a zone partition

sanaz_karamimoghaddam
Not applicable
43 Views
9 Replies
Message 1 of 10

referencing node numeric value of a zone partition

sanaz_karamimoghaddam
Not applicable

[ FlexSim 16.2.1 ]

Hi all,

I have a label on my processflow, value of which should be the limit of a partition in a zone (the object expanded on the tree in the attached picture). I tried getvarnum command and referenced the node in the tree by using the drop done tool in code but it returns zero, so I assume I am either referencing the value using an incorrect code, or the partition limit value is not referenceable?

Thanks

node-q.pngzone-q.png

0 Likes
Accepted solutions (1)
44 Views
9 Replies
Replies (9)
Message 2 of 10

sam_stubbsYXX86
Community Manager
Community Manager

I don't know your model's application, but would it work to go the other way? Make the Process Flow label be a numeric value, and then have the partition number be a reference to your Process Flow label?

0 Likes
Message 3 of 10

logan_gold
Community Manager
Community Manager

Where are you using the getvarnum() command? It sounds like you are trying to reference the limitNode node that is being shown in the first picture, but that is the node that actually contains the number/code representing the limit of a partition in a zone. In other words, it is the node that contains the same 1.00 from the second picture and it sounds like you are trying to reference the limitNode node from within itself.

If what you are trying to do is reference a Process Flow label from the Partition Constraints tab of a zone instead (within the Limit field), then use the getlabel() command. I believe it is a naming error, but there is a label in the Limit field code called "zone" which actually references the Process Flow object. So in the Limit field, you can use this code:

getlabel(zone, "labelName")

Where "labelName" should be the name of the Process Flow label you are trying to reference.

Message 4 of 10

sanaz_karamimoghaddam
Not applicable
@Sam Stubbs

It works, Thanks. so is it not applicable to reference that variable from the tree?

0 Likes
Message 5 of 10

sanaz_karamimoghaddam
Not applicable

@Logan Gold,

Thanks for your response,

I was trying to use getvarnum() command on the trigger tab of process flow propertoes, on the setlabel code where the values for process flow labels are set. I was trying to set the value of that label of the process flow, to the value of the zone partition limit, so I wanted to reference this value from the tree as in the picture I attached here. (instead of using gettablenum(), I used getvarnum() )

zoneref-q.png

From your explanation, I got that instead of referencing "limit" node on the tree, I should have referenced the "limitNode" node on the tree, and the "limit" node itself is the value of the "limitNode". Am I right?

0 Likes
Message 6 of 10

sam_stubbsYXX86
Community Manager
Community Manager

I'm glad it worked! You can do it the first way, but if your model works the other way, then it would be simpler not to have to delve into the tree looking for the variables. It's generally better to access data from labels for dynamic values, than directly altering the values of the nodes from the tree, if it can be helped I've found.

0 Likes
Message 7 of 10

matt_long
Not applicable
Accepted solution

I would encourage you to not pull values directly from the tree within Process Flow activities. The structure is not guaranteed to stay the same for each FlexSim release, as well, the data may not be what you expect to be (ie limit vs limitNode). The Partition Constraint allows you to enter code for the Limit value. I would recommend either storing that data in a global variable or a label on the instance or Process Flow object. Then you type directly into the Limit field with something like:

myGlobalVariable //Global Variable
getlabel(processFlow, "labelName") //Label on the Process Flow
getlabel(current, "labelName") //Label on the instance object

It does look like the code header for the Partition Constraint Limit is wrong. It should be:

treenode instance = param(1);
treenode zone = param(2);
treenode processFlow = ownerobject(zone);
Message 8 of 10

sanaz_karamimoghaddam
Not applicable

Thanks @Matt Long

Just to know for future use, what are the cases that the usage of getvarnum() and getvarnode() on the tree are different? are there cases that any of these commands cannot be used to get a value?

0 Likes
Message 9 of 10

matt_long
Not applicable

Get varnum() and getvarnode() only look at a single layer of variables. When a variable node has subnodes, you have to access those through a path. Perhaps like this:

getnodenum(node("myNode", getvarnode(current, "myVariable")));

or

getnodenum(node(">variables/myVariable/myNode", current));
0 Likes
Message 10 of 10

logan_gold
Community Manager
Community Manager

@sanaz karamimoghaddam, I'm not actually sure what the limit treenode does in the tree. When you set the "Limit" field in the Partition Constraints tab of a Zone's properties, it does set the limitNode treenode, so you do want to reference that node in your OnReset trigger.

You can actually use the gettablenum() command just like the Sampler is showing you, because the partitionConstraints node is actually a table, where each row is a different partition constraint (they are usually added through Partition Constraints tab by clicking on the green plus sign button). So using the gettablenum() command would look something like this:

gettablenum(getvarnode(node("/Zone", current), "partitionConstraints"), 1, 3)

Where the "/Zone" string in the node() command is the name of your Zone resource. The 1 (the second parameter of gettablenum) is the rank of the Partition Constraint you want to affect (using a 1 gets the value you want from the first constraint, using a 2 gets the value of the second constraint, etc.). If you only have one partition constraint, just leave it as a 1.

You actually won't be able to use getvarnum() here, because the first parameter is an object that contains variables and the second parameter is the variable you want to get the value from. That object would be the Zone resource and the variable in this situation is the partitionConstraints node, which doesn't have the number data stored on it that you want because it is stored in subnode.