question

shanice.c avatar image
0 Likes"
shanice.c asked shanice.c commented

How to find flow item from string?

Hello, I have an external database, and I would change flow item also get some information from database. There problem in find flow item. I have printed out the "/Product1", next step is to assign token.producttake by using "model().find()".

1651571794659.png


1651571863054.png

FlexSim 22.0.0
string to pointer
1651571794659.png (141.3 KiB)
1651571863054.png (442.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.

Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered shanice.c commented

You don’t need the slash. The product need a unique name to find it successfully.
Alternatively you can store an item by its number inside FlexSim.
Command is tonum( a thing). A thing can be a node. Later you can convert this number back to a node by command tonode( from thing number).

· 10
5 |100000

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

shanice.c avatar image shanice.c commented ·

@Joerg Vogel Thank you for the response. I have tried not putting a slash, but still return no path. I found "?" could return the node reference. "token.producttake" could be assigned.

1651628665956.png

1651628643249.png

0 Likes 0 ·
1651628643249.png (141.0 KiB)
1651628665956.png (15.5 KiB)
Joerg Vogel avatar image Joerg Vogel shanice.c commented ·

@shanice.c , any search by method find will only work successfully, if you have a unique name for each item or object your are looking for! Typically products have equal names like “Product”. Such a Name won’t work, because it isn’t unique. I think you should go with Jason’s suggestion.

0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel shanice.c commented ·
Structal remark. A query result is always a table and not an array. This means you have to check a table cell by its row and column value. So far you check or assign values only by a column name for a row value.
0 Likes 0 ·
shanice.c avatar image shanice.c Joerg Vogel commented ·

@Joerg Vogel Thank you for your reminds, I might encounter these problems soon.

I could understand 2 things you said. My organization is trying to control Flexsim object by only give agv information it needs(such as fromstation, tostation, whatproduct), and is not going to use process flow to handle any logic in flexsim.

We try to write our logic using external codes, and put information into database. Objects in flexsim are not doing any logic, only query a table recording tasks to check if any tasks to do. If no, just stay there.

0 Likes 0 ·
Show more comments
Jason Lightfoot avatar image
1 Like"
Jason Lightfoot answered

It's better to push items to a list and then pull from that list using a WHERE clause or by partition than using find each time. That way you get a direct pointer (or array of pointers) to the item(s).

5 |100000

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