Hello!
The issue with releasing the operator indeed has to do with the reference to which atom it is called.
You can solve it by using labels again. When you call the operator (more in particular, when you call it at the server), it is assigned to the first atom (i.e. crate/product) inside the server. This products moves onto the container at the assembler and the operator should be released when it has finished the container.
The first time this is oke, as with the FreeOperator command there is a reference to the atom that was used to call the operator, which is the first atom on the container. However the second time, another atom was used to call the operator and thus releasing the operator fails.
This fix this, you can assign a label with the atom that was used to call the operator. So, OnEntry of the server you can do the following:
Code: Select all
If(
And(
Content(in(1,c)) >= valConvCutoff-1,
Label([CallOperator], c) = True
),
do(
Trace([assembler1: call operator]),
Label([CallOperator], c) := False,
{ * Store the reference to the atom that triggered the call of the operator * }
Label([CallReference], c) := i,
CallOperators(in(2,c),1,1)
)
)
OnExit of the conveyor, you can use this label to release the operator by the following code:
Code: Select all
if(
Content(c) = 0,
do(
CloseOutput(c),
Trace([conveyor1: free operator]),
FreeOperators(in(2,out(1,c)),vtp(Label([CallReference], Out(1, c))))
)
)
As you can see, we use the label assigned before as the second parameter in the FreeOperators function, by converting the value of the label to a pointer by "vtp".
Please try this code and return to this topic in case of any questions.
Kind regards,
Marvin