question

Michael Kramer avatar image
0 Likes"
Michael Kramer asked Michael Kramer commented

How can I pull information from a token for use in custom code?

I am checking AGV battery level to determine if it needs to be routed to a charge station. Currently I have hard-coded the TE resource name and the logic works fine. What I need help with is making the decision independent of the TE name, perhaps pulling that information from the token. Below is a screen shot of the process flow and the code in the decision point block. Ideally I'd like to pass the TE name to the variable "tugger", which is used in the "agvinfo" function.

FlexSim 16.2.1
agv battery levelte name from token
· 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.

Jeff Nordgren avatar image Jeff Nordgren commented ·

@Michael Kramer

Mike,

It's tough to debug a graphic. Any way you can send your model or better yet a sample model showing the specific problem you are having?

0 Likes 0 ·
Michael Kramer avatar image Michael Kramer Jeff Nordgren commented ·

@Jeff Nordgren

Sure, model attached. The AGV hits the decision point between 7:49 and 7:50.

0 Likes 0 ·
model.fsm (1.1 MiB)

1 Answer

Matt Long avatar image
0 Likes"
Matt Long answered Michael Kramer commented

Your parent token has a reference to the AGV stored on the label "resource". All you need to do in your Decision activity AGV Battery Recharge is reference that label and get the name of it:

string tugger = getname(getlabel(token, "resource"));
· 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.

Michael Kramer avatar image Michael Kramer commented ·

Thank you, works great.

0 Likes 0 ·