question

Mohamed Slama avatar image
0 Likes"
Mohamed Slama asked Mohamed Slama edited

Stop Item on onmessage trigger

Hi,

In my simulation I want that if the photoeye 2 is blocked, it should send a message to photo eye 1. Then the photo eye1 should stop the item at the photoeye 1 position when it receives the message. Please can you help to resolve this problem ?

un-deux.fsm

,

Choose One
photoeyestop itemon message trigger
un-deux.fsm (21.4 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.

Sam Stubbs avatar image
1 Like"
Sam Stubbs answered Mohamed Slama edited

I see that you had your Photoeye 2 send a message to Photoeye 1 on the OnBlock trigger. I merely added a first parameter (a "1") to the message.

So the next step was to create a snippet of code in the OnMessage trigger of Photo Eye 1. The code is simply one line that sets a label (called "stopitem") to current (Photoeye 1) with the value of that message parameter we added (1).

setlabel(current,"stopitem",msgparam(1));

Finally, we add a trigger to the OnBlock trigger of Photoeye 1, that checks if it has a "stopitem" label with a value of 1 (true) on itself, if so, then stop the item.

Here is you example with those changes I made.

5922-un-deux-1.fsm


5922-un-deux-1.fsm (18.6 KiB)
· 3
5 |100000

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

Mohamed Slama avatar image Mohamed Slama commented ·

stoppeur.fsm

@Sam Stubbs

First, I would like to thank you for your answer. That was very helpful.

Now I make some changes to the model to make the PE1 let the items resume when the PE2 is clear unfortunately it doesn't work. I did with the same way to block the items but it doesn't work.

Here is my modified model, can you please help me to resolve this problem.

Thank you very much.

0 Likes 0 ·
stoppeur.fsm (45.6 KiB)
Sam Stubbs avatar image Sam Stubbs ♦ Mohamed Slama commented ·

This looks like a separate issue than the first question. Do you mind posting it as a separate question? Sometimes when follow up questions are nested in old threads, the question gets lost. It's helpful for us if each new question has its own post.

0 Likes 0 ·
Mohamed Slama avatar image Mohamed Slama Sam Stubbs ♦ commented ·

@Sam Stubbs

Sorry, but I thought that I could write this question here because it's a continuation of the previous question.

Should I write it in a new post to get an answer ?

Thank you :)

0 Likes 0 ·
Steven Hamoen avatar image
1 Like"
Steven Hamoen answered Steven Hamoen edited

@Mohamed Slama Because the photocell or decision points do not have an onmessage trigger you should solve this differently. If you put a label on PE1 and set that label in PE2 to for instance 1, you can use the option Stop Item with the condition that the label should be 1

@Mohamed Slama @Sam Stubbs Sorry I totally overlooked the On Message trigger at the bottom!! But the concept still stands ;-)

5 |100000

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