Cancel
Showing results for 
Search instead for 
Did you mean: 

blocking via a method

Pioneer
Pioneer

Hello,

 

I made a method for unloading parts out of a truck. I did this by moving the truck to a drain within the method and then create a number of parts in a buffer with this simple code:

 

@.move(TruckDrain);
Num_Parts := 0;
While Num_Parts < @.NumParts
loop
.MUs.Part.create(Buffer);
Num_Part := Num_Parts + 1;
end;

 

This works fine untill the buffer is full. Then the truck unloading should stop/wait until there is space in the buffer again, like blocking does when the machines are linked by a connector. Unfortunately it does not. The parts are still created but i don't know where they go. So in need to model blocking in my method so that the creation of the parts is blocked until there is space in the buffer again. Do i have to do this with the waituntil function or is there an easier way to do it??

 

Thanks in advance,

 

Steven Blom

3 REPLIES

Re: blocking via a method

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

waituntil could work. But the drain will delete your truck in this time. So you need to re-arrange your method, e.g.

 

@.move(TruckDrain);
Num_Parts := @.NumParts;

for local i:=1 to Num_Parts Loop
  -- wait for a free place in the buffer
   waituntil buffer.full=false prio 1;
  .MUs.Part.create(Buffer);
next;
Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: blocking via a method

Pioneer
Pioneer

Thanks for your help! I allready had something like this only i thought it did not work but I made a mistake somewhere else in the model... Now it works. Is It also possible to give a value to a user defined atributed of the created MU right away? So not at the next station but in the same method?

 

Steven Blom

Re: blocking via a method

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

yes, the method create returns a reference to the created object. With this reference you can also change user defines attributes.

 

@.move(TruckDrain);
Num_Parts := @.NumParts;

local part:object;

for local i:=1 to Num_Parts Loop
  -- wait for a free place in the buffer
   waituntil buffer.full=false prio 1;
  part:= .MUs.Part.create(Buffer);
  --set your Attribute 
  part.yourAttribute:=yourValue;
next;
Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net