question

Joey A avatar image
0 Likes"
Joey A asked Joey A commented

Zone getstat not working

Hi,

I tried an answer form the flexsim community on how to count the number of tokens in my zone. It told me to use this code in the script (or decide activity): getstat(getactivity("Zone"), "Content", STAT_CURRENT) (link to question is here...https://answers.flexsim.com/questions/74314/reading-number-of-tokens-in-the-zone.html

Note: the link says to have type it this way but my script errored out: getstat(getactivity(processFlow,"Zone"), "Content", STAT_CURRENT). I could only get a value if i used the code in my first paragraph


However it keeps giving me a ridiculously high number (340282346638528859811704183484516925440.00).

Do you know what I'm doing wrong?

Joey

Zone count Help.fsm

FlexSim 23.0.5
zonezone statisticsgetstat
zone-count-help.fsm (46.8 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

·
Jason Lightfoot avatar image
1 Like"
Jason Lightfoot answered Joey A commented

Use:

getstat(getactivity("ProcessFlow","Zone"), "Content", STAT_CURRENT)
· 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.

Joey A avatar image Joey A commented ·
well that seems obvious haha. thank you!
0 Likes 0 ·
Joey A avatar image Joey A commented ·

Hi,


that fix worked in my example sheet and I'm not sure why it isn't working in my full simulation model. My best guess is its because I'm trying to reference something in an AGV process flow template


I'm using the following code to pull the token count and I'm getting the same large number I was getting before the fix

New code: getstat(getactivity("AGV","Trailer_Unloading"), "Content", STAT_CURRENT)

Note: i changed "ProcessFlow" to "AGV" so it referenced the correct process flow sheet. I also changed the "Zone" to "Trailer_Unloading" since that is the name of the zone.

Do you know why these changes are not working?

Joey

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Joey A commented ·

The AGV process flow is an Object/Instanced Process Flow and getactivity("AGV","Trailer_Unloading") doesn't allow us to specify the instance to use. If you change the zone to global then it will work as-is, but the zone will apply to all agv tokens.

To get the local zone content by instance it will be something like this:

Object activity=getactivity("AGV","Trailer_Unloading");
return node(">stats/instances/AGV1/content",activity).value;


0 Likes 0 ·
Joey A avatar image Joey A Jason Lightfoot ♦ commented ·
That worked. Thank you! and thank you for the explanations...its helps me learn how to use the software.
0 Likes 0 ·

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.