question

Peter avatar image
0 Likes"
Peter asked Jonah K commented

How to get the state of a resource?

How to get the state of a resource? I only want to unload my item at the processor if it is idle. So, I want to use a decision block that gets the state of the resource (numeric) and based on that decides the destination of the item.


FlexSim 23.2.0
resource 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.

Jason Lightfoot avatar image Jason Lightfoot ♦ commented ·
I think you need to provide us with some more information/context since this is the default availability mechanism when using port based destinations.
0 Likes 0 ·
Jonah K avatar image
1 Like"
Jonah K answered Jonah K commented

If I'm understanding correctly, you want to get the current state of the processor and assign it to a token label, so you can use it in your process flow logic. You can do this with this code:

Model.find("Processor1").as(Object).stats.state().valueString

By putting this code in the value field of an Assign Labels activity, you can get the current state of Processor1 and assign it to a token label. You can then use this token in decide activities, synchronize activities, etc. to perform the logic you want. I've demonstrated this in a simple model:

GetResourceStat.fsm


getresourcestat.fsm (29.8 KiB)
· 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.

Peter avatar image Peter commented ·

Thank your for the response! My resource is numeric, no a 3D object, so I only want to reference the state of my resource block in my process flow.


0 Likes 0 ·
Jonah K avatar image Jonah K ♦ Peter commented ·

You can get the numeric state of a processor with basically the same code:

Model.find("Processor1").as(Object).stats.state().value

If you want the state of a Resource, (a Process Flow resource activity) you can use the code Jason described in his answer.

0 Likes 0 ·
Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot edited

Peter upload your model - you're using words like processor, item and resource in your question where their meanings are ambiguous/interchangable and we need to know when something is 3D as opposed to pure process flow. Also what you're describing sounds like it can be better done using another method, so either the description could be better or we should be recommending another approach.

The Resource shared asset in a process flow doesn't have state - it has a content stats that will tell you how many tokens have acquired the shared assets. You can access that using something like this:

getstat(getactivity("ProcessFlow", "Resource"), "Content", STAT_CURRENT, current)

or you can find the available asset count:

getstat(getactivity("ProcessFlow", "Resource"), "ResourceAvailable", STAT_CURRENT, current)

In the case of numerical count or an array of numerical values, the asset that you see listed in the token's properties isn't something that has state either - it's an sdt coupling request/allocation that is transient, exists on a per token basis, and no longer exists once the asset is released.

1690649432835.png


1690649432835.png (5.9 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.

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.