question

sanaz karamimoghaddam avatar image
0 Likes"
sanaz karamimoghaddam asked Logan Gold commented

referencing node numeric value of a zone partition

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

FlexSim 16.2.1
zone partitiontree nodereferencing
node-q.png (30.2 KiB)
zone-q.png (23.1 KiB)
· 3
5 |100000

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

Sam Stubbs avatar image Sam Stubbs ♦ commented ·

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 0 ·
sanaz karamimoghaddam avatar image sanaz karamimoghaddam Sam Stubbs ♦ commented ·
@Sam Stubbs

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

0 Likes 0 ·
Sam Stubbs avatar image Sam Stubbs ♦ sanaz karamimoghaddam commented ·

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 0 ·
Matt Long avatar image
2 Likes"
Matt Long answered Matt Long commented

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);
· 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.

sanaz karamimoghaddam avatar image sanaz karamimoghaddam commented ·

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 0 ·
Matt Long avatar image Matt Long sanaz karamimoghaddam commented ·

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 0 ·
Logan Gold avatar image
1 Like"
Logan Gold answered Logan Gold commented

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.

· 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.

sanaz karamimoghaddam avatar image sanaz karamimoghaddam commented ·

@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 0 ·
zoneref-q.png (99.2 KiB)
Logan Gold avatar image Logan Gold ♦♦ sanaz karamimoghaddam commented ·

@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.

1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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