code to resume conveyor

code to resume conveyor

enrique.elizaga
Advocate Advocate
9 Views
4 Replies
Message 1 of 5

code to resume conveyor

enrique.elizaga
Advocate
Advocate

[ FlexSim 17.1.1 ]

can someone share a model that stops an item at a decision point and then resumes it upon receiving a message....i've been killing myself over this using process flow but I don't think it's necessary.

0 Likes
Accepted solutions (1)
10 Views
4 Replies
Replies (4)
Message 2 of 5

joerg_vogel_HsH
Mentor
Mentor

@dev, @Matthew Gillespie, @anthony.johnson, there is missing the right template to resume a stopped item in the decision point properties. It still stops the involved object and is referenced to a non existing label. I have copied the resume code to the OnMessage Trigger, which worked in previous versions fine. But now it doesn't.

please, can check this? many thanks.

regards Jörg

0 Likes
Message 3 of 5

arunTTT2P
Explorer
Explorer
Accepted solution

Hi @Enrique Elizaga,

Here is a sample model. The model has two photo eyes and one decision point in the conveyor. When the box blocks the first sensor the decision point stops the box. And when the box clears the second sensor a message is sent to the decision point to release the boxes. This cycle is repeated.

Regards,dpcontrol-akr.fsm

Arun KR

Message 4 of 5

enrique.elizaga
Advocate
Advocate

@Arun KR thank you for the sample model and logic, it worked marvelously and I am currently using it in multiple points accross the model. I am getting the following error message in some decision points, and I can't seem to find the problem:

FlexScript exception: Invalid down cast. Object is not an instance of the target type. at MODEL:/DP23>variables/localType/onMessage

Also:

Property "up" accessed on invalid node. at MODEL:/DP95>variables/localType/onMessage

The code used in onMessage:

Conveyor.DecisionPoint current = param(9); Object conveyor = param(10);

treenode item = current.REF;

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

0 Likes
Message 5 of 5

arunTTT2P
Explorer
Explorer

Hi @Enrique Elizaga ,

I was also getting the same error message, so I managed by adding some "objectexists" conditions. If the conveyor is curved use CurvedConveyor if condition instead of StraightConveyor, as given below in the code.

Object involved = current.REF; 
  if(involved)
  {
     if(classobject(involved.up)==library().find("?StraightConveyor"))
     {
      involved.up.as(Conveyor).itemData[involved].resume();
     }
  }