question

David Seo avatar image
0 Likes"
David Seo asked David Seo answered

using setitemtype with insertcopy() on Message trigger and ...

After using setitemtype() with insertcopy() on Message Trigger and then on Entry trigger, using getitemtype() is not reading the item type number.

event-pull-from-list-test-v201703-v096-without-pf.fsm

I want to use getitemtype() command OnEntry trigger after using setitemtype() with insertcopy() OnMessage trigger in Queue_In45.

The insertcopy() command make OnEntry triggered?

If using setitemtype() in next line of insertcopy(), is it invalid?

-----------------------------------------

OnMessage

for (int index = 1; index < numitems; index++) {

treenode newitem = insertcopy(template, destination);

setitemtype(newitem, index);

colorarray(newitem, getitemtype(newitem));

applicationcommand("trackdefaultsoncreate", newitem); }

--------------------------------------

OnEntry

item.labels.assert("PortNo").value = gettablenum("Arriv_Table", seq_no, 5);

item.labels.assert("iType").value = getitemtype(item);

item.Cont_Seq_No = seq_no;

cTable[seq_no][1] = item.Cont_Seq_No;

cTable[seq_no][2] = gettablestr("Arriv_Table", seq_no, 2);

cTable[seq_no][3] = item.PortNo;

cTable[seq_no][4] = time();

------------------------------------------

I want to know about it.

Help me.

FlexSim 17.0.3
entry triggerinsertcopy command
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
1 Like"
Jeff Nordgren answered

@david.seo,

The problem is that when the insertcopy() command is executed, it immediately places the new item into the queue, which causes the OnEntry code of the queue to execute. This happens before you set the itemtype or color. It's like a sendmessage() command, it executes immediately before returning the the next lines of code.

What you need to do in this case is to create the flowitem in the model() first rather than in the queue. Then, set the desired attributes on that item, THEN move it back into the queue (see your modified attached model). This way the OnEntry trigger of the queue does not fire until the item is moved back into the queue and after all the attributes on the item have been set.

Take a look at the attached model and see if this now does what you are wanting it to do.

event-pull-from-list-test-v201703-v096-without-pf.fsm


5 |100000

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

David Seo avatar image
0 Likes"
David Seo answered

Thank you.

I found the insertcopy() to trigger Entry trigger before going to next line step after question in this forum.

And I solved my problem in other way. But yuor way looks better than my way.

Yes. insertcopy() to model() and moveobject() not insertcopy() to current.

Thank you.

5 |100000

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