question

Olexii avatar image
0 Likes"
Olexii asked Olexii commented

How to access utilization pie chart values via code?

Hello! I am trying to access "37.68%" value from within the code to later put it in a global table at a certain time. Is it possible? I've seen people access a different dashboard values via a tree, but I cannot find any tree variable for the pie chart that would reflect "37.68%". Thanks!

1739554220984.png

FlexSim 24.2.1
dashboards
1739554220984.png (19.2 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.

1 Answer

Logan Gold avatar image
0 Likes"
Logan Gold answered Olexii commented

Hey @Olexii, my understanding is the utilization displayed in the State Pie chart is calculated on-the-fly/continuously. I don't think it's stored anywhere in the tree. However, you can use the same command that the chart uses, called getstatetableutilization(), to get an Object's utilization, like this:

  1. Object obj = Model.find("Processor1");
  2. string stateTableName = "StateTable1";
  3.  
  4. return getstatetableutilization(Table(StateTableName), obj.stats.state());

You just need to make sure to reference the correct Object when using this command. Also, it needs to be referenced as an Object in order for the stats property to be accessed. If you have it as a treenode, you can always cast it as an Object with the as() command:

  1. // Model.find() returns a treenode.
  2. return getstatetableutilization(Table("StateTable1"), Model.find("Processor1").as(Object).stats.state());
· 1
5 |100000

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