Cancel
Showing results for 
Search instead for 
Did you mean: 

problem with condition in algorithm

Pioneer
Pioneer

Hello everyone

 

I would like use attached  algorithm in my model. I use this code

 

if some condition then

 

    if lastCycle=1 then

         @.move(machine2); 

         lastCycle:=0;

         print lastCycle;

     elseif lastCycle=0 then

          @.move(machine1); 

            lastCycle:=1;

           print lastCycle;

     end;

 

else

     @.move(machine1)

end;

 

Is see in consol thet lastCycle is 1, but condition: if lastCycle=1 then, don't execute. Could You help Me?

 

6 REPLIES

Re: problem with condition in algorithm

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi WD,

 

maybe the movement was not possible.

Please use the instruction

print @.move(machine2); 

 

Regards,

Peter

Re: problem with condition in algorithm

Pioneer
Pioneer

Hi,

 

I try this but nothin is change. Movement is possible, I swapped machine (singProc) on line and problem still exist. I print lastCycle and is 1 all time.

Re: problem with condition in algorithm

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi

 

therefore  it must be the external condition.

 

Please equip the else-branch with a corresponding print instruction.

When the else-branch is taken the exchange mechanism is not used.

 

Regards,

Peter

Re: problem with condition in algorithm

Siemens Experimenter Siemens Experimenter
Siemens Experimenter

Hi,

 

For LastCycle to be always zero, it implies it is not known globally... From my point of view.

So LastCycle must be a variable defined at frame level.

See attached model.

 

JP

Re: problem with condition in algorithm

Siemens Phenom Siemens Phenom
Siemens Phenom

Hello,

 

yes LastCycle is an object Variable on the toolbox Information Flow.

 

Sometimes the movement is impossible, like in your model.

 

Bild2.gif

The move method has a boolean result. You can use it:

 

if somecondition.value then
   if lastCycle=1 then
      if @.move(machine2) then
         lastCycle:=0;
         print lastCycle;
      end;
   elseif lastCycle=0 then     

   if @.move(machine1) then
        lastCycle:=1;
        print lastCycle;
      end;
   end;
else
     @.move(machine1)
end; 

 

Re: problem with condition in algorithm

Pioneer
Pioneer

Hello,

 

I use a global variable LastCycle and now condition work correctlu.

 

Thank You for help

WD