Decision Point Logic

Decision Point Logic

tyler_b2
Not applicable
31 Views
15 Replies
Message 1 of 16

Decision Point Logic

tyler_b2
Not applicable

[ FlexSim 20.1.1 ]

The goal is to receive 2 red packages to every 1 blue package within sink H. In sink H I have created a Count label to increment on every red and set to 0 with every blue.

At DP5 I was able to stop the red packages from flow when count ==2.

My issue then is nothing I tried could I get DP5 to release the product (when count ==0 again).

Is there a better trigger, object, or method to achieving this?

TBCA Inspection Intermediate.fsm

Thanks for your patience it's my first Sim!

Accepted solutions (1)
32 Views
15 Replies
Replies (15)
Message 2 of 16

braydn_t
Not applicable

@Tyler B2

I think I am not understanding what you are looking for. I have run through the model a couple times, and after a blue box goes in the sink, 2 red boxes do, unless the first path is blocked up by red boxes and blue boxes can't get through. Could you clarify, or send a gif or the model time of the issue you are seeing?

0 Likes
Message 3 of 16

tyler_b2
Not applicable

@Braydn T

My Apologies. I need DP5 to stop the item until my Count label within the sink returns to 0 or perhaps when a blue package passes DP9? I don't have the issue in this model specifically because I used this file as a save point since it 'works'.

The reason why it does not work is due to the fact I have simply delayed DP5 for 35 seconds, but what I actually need is for DP5 to hold the product until another blue package has gone through. If I only use the delay and a process with the blues is altered to finish faster then it's possible I send 2 blues.

You'll see the issue if you change the trigger in DP5 to:

On Arrival: Stop Item:
Condition: Model.find("Sink H").Count==2
Item: item

I didn't send the test file for clarity since my code was beginning to become a garbled mess.

0 Likes
Message 4 of 16

braydn_t
Not applicable

@Tyler B2

The easiest way to do this without changing how you have modeled so far is to send a message to DP5.

The code to resume an item is this:

Object involved = item;
    involved.up.as(Conveyor).itemData[involved].resume();

But to do this you will need to maintain a reference to the item. I would save the reference to the item as a label of DP5. You can do that in the On Arrival Trigger like this:

if (Model.find("Sink H").Count==2) {
    Object involved = item;
    current.labels.assert("item", item);
    involved.up.as(Conveyor).itemData[involved].stop();
}

that way you can access the item as the label.

I hope that helps!

0 Likes
Message 5 of 16

tyler_b2
Not applicable

Perhaps I didn't understand the implementation, I tried to apply the code and get the sink to send a message once the blue package is received.

Here is the error: time:
266.411898 exception: FlexScript exception: Property "up" accessed on invalid node. at MODEL:/DP5>variables/localType/onMessage

And the updated model:
TBCA Inspection Intermediate.fsm

Thank you for your guidance!

@Braydn T

0 Likes
Message 6 of 16

braydn_t
Not applicable

@Tyler B2

Our site doesn't maintain links and uploads if you edit posts right now (we are working with our partner answerhub to fix that), but in the meantime could you re upload your model?

0 Likes
Message 7 of 16

tyler_b2
Not applicable
0 Likes
Message 8 of 16

braydn_t
Not applicable

tbca udpated.fsm

@Tyler B2

You were close, you just needed to access the label instead of calling item directly. I should have been more clear about that.

0 Likes
Message 9 of 16

tyler_b2
Not applicable

Well now it runs the first time this happens like a charm, yet the second time there is no release?

I also receive the following:
time: 360.911898 exception: FlexScript exception: Property "up" accessed on invalid node. at MODEL:/DP5>variables/localType/onMessage

@Braydn T

0 Likes
Message 10 of 16

braydn_t
Not applicable

it looks like that label is being saved as null. Ill see what I can figure out.

0 Likes
Message 11 of 16

tyler_b2
Not applicable

I was noticing the same and was trying to remove the label entirely on message so it can create the new label on each condition.

0 Likes
Message 12 of 16

braydn_t
Not applicable

@Tyler B2

I ran this one until it stopped a couple times. I just changed the label value to 0, and then checked if it was 0. All the changes are in the onMessage trigger. tbca fixed.fsm

0 Likes
Message 13 of 16

tyler_b2
Not applicable

@Braydn T

And it released DP5 every time count reached zero? Mine isn't doing that for some reason.

I've tried getting DP5 to always accept the message to release the package and I've also tried to get the item name to match the item then send.
Both seemed to be useless.

0 Likes
Message 14 of 16

benjamin_w2
Not applicable

Hi @Tyler B2, Do you still need help with this?

0 Likes
Message 15 of 16

tyler_b2
Not applicable

@Benjamin W2 I went around it, I'd like to know how to make it or something similar work since this type of flow will be used often, but it is not urgent. Thank you!

0 Likes
Message 16 of 16

matt_long
Not applicable
Accepted solution

@Tyler B2 There are multiple methods for achieving this. You could have the Sink send a message back to the Decision Point when the Count label hits 0, but this requires the Sink to be aware of the Decision Point and you'll also have to store a label on the Decision Point that references the stopped item.

My preferred methods is to use Process Flow. I've attached a modified version of your model with a small process flow that uses listeners to accomplish your desired result.

28611-1589861267902.png

DP5 stops the red item when the Sink's Count label is 2 through the On Arrival trigger as before. I also have an Event-Triggered Source in Process Flow listening to the the On Arrival trigger. Each time that trigger is fired, a token is created and a label is assigned to that token that references the item at DP5. The token then checks the value of the Count label and if that value equals 2, then it moves the token through the flow otherwise it discards the token through the Sink.

The Wait for Count = 0 activity is a Wait For Event. It is listening for the Count label on the Sink to equal 0. In order to do this I did have to change the Count label from number data to tracked variable data. That allows you to add a listener to the On Change event of that label. (This can be accomplished by right clicking the Count label and select the menu Assign Data, then click Assign Tracked Variable Data). Alternatively you can listen to the Sink's On Arrival event and perform a similar check as the previous Decide, but the aforementioned method is simpler.

Once the Wait for Count = 0 receives the notification that the Count label equals 0, the token is released and the next activity Resume Item causes the red flow item to be released from DP5.

There are many ways you can use listeners in Process Flow to adjust this logic. For instance, if it was possible for a red flowitem to arrive at DP5 while another red flowitem is on the way to the Sink, you could have Process Flow keep a count of flowitems that have passed DP5 and then stop items when they arrive at DP5 without the Sink's Count label equaling 2.

Hopefully this helps.

tbca-inspection-intermediate-updated.fsm