question

Bichu K2 avatar image
0 Likes"
Bichu K2 asked Julivan S commented

How to access Current, Min, Max values of Tracked Variables from Subnode List

Hi,

I am trying to write some custom code to find, Which itemtype partiton in the Global Item list has higher content. I was planning to iterate through subnodes and accessing various values from "content" of various node.

I don't know which datatype this content is and how to access the value without hard-coding.

Also which is the best way to access many nested subnodes. Currently I feel whatever code I write is too verbose.

FlexSim 17.2.2
flexscripttracked variablestree node
tree.png (29.6 KiB)
code.png (16.4 KiB)
· 5
5 |100000

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

Arun Kr avatar image Arun Kr commented ·

Hi Bichu K2,

Try this, I have not checked.

double Average = TrackedVariableRef.average;
double Max = TrackedVariableRef.maximum;
double Min =TrackedVariableRef.minimum;

Tracked variable is now a variable type itself. Check out the TrackedVariable in the FlexScript API reference section.

Regards,

Arun KR

0 Likes 0 ·
Bichu K2 avatar image Bichu K2 Arun Kr commented ·

Hi Arun,

Thanks for your reply.

I have seen that option. My question is how will I get the TrackedVariableRef (in my case, "content" is a tracked variable for subnodes of partitons)

0 Likes 0 ·
Arun Kr avatar image Arun Kr Bichu K2 commented ·

Hi Bichu K2

Try like this. The idea is content is a statistic.Similarly other statistics can also be considered.

List itemList = List("ItemList");
double Average = itemList.stats.content.average;

Also, the easiest way to get a reference of the node or subnode is through the sampler. Click the sampler icon from your area of script and hover over through the nodes. The reference path will appear. You can choose the suitable one from it.

Regards,

Arun KR

0 Likes 0 ·
sampler.png (21.6 KiB)
Show more comments

1 Answer

Raja Sekaran avatar image
3 Likes"
Raja Sekaran answered Julivan S commented

Hi @Bichu K2 ,

This post may help you from another question Link

Thanks.

· 4
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 Raja Sekaran commented ·

@Bichu K2

Use the below code for version 17.2.2

int var1 = List("ItemList1").stats.partitionContent(partitionID).value;
int var2 = List("ItemList1").stats.partitionContent(partitionID).maximum;
int var3 = List("ItemList1").stats.partitionContent(partitionID).minimum;
0 Likes 0 ·
Raja Sekaran avatar image Raja Sekaran Raja Sekaran commented ·

@Bichu K2 Were you able to access the subnode values?

0 Likes 0 ·
Bichu K2 avatar image Bichu K2 Raja Sekaran commented ·

yes, I am able to acces values now, Thank you very much. But still I feel Flexscript is too verbose. They could have implemented something like

node.node.variable.value
0 Likes 0 ·
Julivan S avatar image Julivan S commented ·

Many thanks, helps a lot.

0 Likes 0 ·