Cancel
Showing results for 
Search instead for 
Did you mean: 

How to create Method for Line?

Pioneer
Pioneer

Hi,

I'm a new user to Plant Simulation and I'm having a little problem in my simulation. I have two line in my model - Line1 and Line2. I have to simulate this situation: Line2 moves only when on Line1 is, for example, 3 MUs. I try to use metod but I dont know how to write it correctly.

 

This is the method I try to use for Line1 (controls, exit)

 

is
do
    if Line1.NumMU=3 then
        Line2.speed:=1;
       
    else
        Line2.speed:=0;
       
    end;
end;

 

Second metod which I try to use

 

is
   n : integer;
do
   n := Line1.statNumIn;
   if n = 3 then
       @.move(Line2);
   end;
end;

 

Does anyone know how to simulate this situation? Thank you for any help.

3 REPLIES 3

Re: How to create Method for Line?

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

Plant Simulation can observe values and trigger methods, if the value is changed. In your case you could observe numMu and switch on line 2, if the value of numMu is 3 and switch of, if not.

 

Select in Line1 Tools - Select Observers - New - Observed value --> select numMu in the field Executed Method Press the F4 key, then a method is inserted in your Line. Finish with ok. In the observer method you can check the value and react to the changes:

 

if line1.numMu=3 then

  line2.speed:=1;

else

 line2.speed:=0;

end;

 

The observer calls this method at every change of the number of MUs on the line1.

Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: How to create Method for Line?

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi WD,


at first we have to catch the event, when the speed of Line2 must be changed.

There are two events:
 1. A MU leaves the Line1.
 2. A MU enters the Line1.
You create an observer for the attribute NumMU of Line1:

Goto the menu of Line1 Tools > Select Observers.

Please check the following code:


(attribute: string; oldValue: any)
is
do
   if Line1.NumMU = 3 then
      Line2.speed := 1;
   else
      Line2.speed := 0;
   end;

end;

 

Regards,

Peter

Re: How to create Method for Line?

Pioneer
Pioneer

Thank You very much for Your help. I solved my problem