Emulation Control tag creates flowitems in Digital Twin model, but Decision Point routing sends all items to port 1

Emulation Control tag creates flowitems in Digital Twin model, but Decision Point routing sends all items to port 1

oaljarrahBEV2F
Contributor Contributor
321 Views
11 Replies
Message 1 of 12

Emulation Control tag creates flowitems in Digital Twin model, but Decision Point routing sends all items to port 1

oaljarrahBEV2F
Contributor
Contributor

Title: Digital twin: items created by Emulation Control action all route to port 1

Body:

I'm using a FlexSim 2026 Education license. I'm preparing a digital twin class for next semester, and I appreciate your help.  I built two models connected via KEPServerEX 6 (OPC DA).

Master model writes item type (1/2/3) to a tag. Twin model has an Emulation Control variable subscribed to that tag, with three Actions (Value 1, 2, 3). Each action is a Code Snippet that creates the matching item:

treenode template = first(rank(node("/Tools/FlowItemBin", model()), 1));
treenode newitem = insertcopy(template, model());
setitemtype(newitem, 1);
colorarray(newitem, 1);
setlabel(newitem, "Type", 1);
applicationcommand("trackdefaultsoncreate", newitem);
moveobject(newitem, Model.find("EntryTransfer1"));

All three actions fire — I get red, blue and green items in the correct sequence, so the colors prove the right action runs each time. But every item routes to lane 1.

The Decision Point trigger (same as in my working master model) is Case Function item.Type, Case 1 → current.outObjects[1], Case 2 → [2], Case 3 → [3].

Why doesn't my digital twin follow the master model? I'm struggling with it. 

Thanks.

0 Likes
Accepted solutions (1)
322 Views
11 Replies
Replies (11)
Message 2 of 12

joerg_vogel_HsH
Mentor
Mentor
setlabel(newitem, "Type", 1);

you hard coded this.

setitemtype and node are marked as deprecated. Especially itemtype has been replaced a long time ago by a standard label. 

0 Likes
Message 3 of 12

oaljarrahBEV2F
Contributor
Contributor

Thanks for taking a look. I appreciate it, but I'm afraid I don't quite follow.

0 Likes
Message 4 of 12

FelixMoehlmann
Collaborator
Collaborator

You are moving the items into "EntryTransfer1" which is positioned at the start of the lane 1 (which you don't need since the conveyors are connected to each other directly). The entry transfer at the start of the main conveyor is called "EntryTransfer4".

0 Likes
Message 5 of 12

oaljarrahBEV2F
Contributor
Contributor

Tried it, but the digital twin still behaves as if it has a mind of its own. Items appear, but not the way the master drives them.

0 Likes
Message 6 of 12

FelixMoehlmann
Collaborator
Collaborator

I haven't worked with OPC connections before but are essentially two options of how the sensor tags work.

1) They check the value in the specified update interval (1s) and always execute the code depending on the current value. This would mean the model creates one item per second no matter what.

2) The code is only executed when the value changes. So if two items with the same type arrive in succession, the second would not appear in the twin model.

In either case, resetting the tag value to 0 after an item is created in the twin model (and possibly reducing the update interval) should help.

0 Likes
Message 7 of 12

oaljarrahBEV2F
Contributor
Contributor

Tried both, still experiencing the same issue. 

0 Likes
Message 8 of 12

FelixMoehlmann
Collaborator
Collaborator

Let's take a step back. In your original question you wrote that the created items' color matches the expected sequence. Has this changed or does "mind of its own" allude to other differences/issues?

0 Likes
Message 9 of 12

oaljarrahBEV2F
Contributor
Contributor

Thanks for your response. I created a much simpler model to isolate the issue. The main problem is that the digital twin does not create the same number of flow items as the master model, even though the item colors follow the expected sequence. I'm not sure whether the issue is with my digital twin logic or the code I'm using to create the items. Any suggestions would be greatly appreciated.

0 Likes
Message 10 of 12

FelixMoehlmann
Collaborator
Collaborator
Accepted solution

I got the system to work (at least rudimentary) through a Modbus connection. The attached models are in version 26.0, but so were those in your original question, so I hope you can work with them. The important detail is that appears to be a bug (with Modbus connection at least) where FlexSim simply does not notice that a variable has been set to 0. So I used a holding register and switch it between -1 and 1.

Furthermore I would suggest you try to link the emulation variables to Variable activities in Process Flow. Through Event-Triggered Sources you can then get information when a value change was actually registered.

Screenshot 2026-07-20 161515.png

 

Message 11 of 12

oaljarrahBEV2F
Contributor
Contributor

I appreciate that. Now the digital twins flow items are created as master create them, but I'm not sure if coloring items included in this logic. 

0 Likes
Message 12 of 12

FelixMoehlmann
Collaborator
Collaborator

No the type is not yet taken from the other model. But that's not a big change.

 

0 Likes