Search code examples
simulationanylogic

Anylogic - Assembler should stop working for 2 hours after 10 assemblies done


The "Assembler" should stop working for 2 hours after 10 assemblies are done. How can I achieve that? enter image description here


Solution

  • There are so many ways to do this depending on what it means to stop working and what the implications are for the incoming parts.. but here's one option

    1. create a resourcePool called Machine, this will be used along with the technicians: enter image description here

    2. on the "on exit" action of the assembler do this (I use 9 instead of 10 because the out.count() doesn't count until the agent is completely out, so when it counts 9, it means that you have produced 10)

      if(self.out.count()==9){
      machine.set_capacity(0);
      create_MyDynamicEvent(2, HOUR);
      }

    3. In your dynamice event (that you have to create) you will add the following code:

      machine.set_capacity(1);

    A second option is to have a variable countAssembler count the number of items produced... then

    1. on exit you write countAssembler++;

    2. on enter delay you write the following:

      if(countAssembler==10){
      self.suspend(agent);
      create_MyDynamicEvent(2, HOUR,agent);
      }

    3. on the dynamic event you write:

      assembler.resume(agent);

    Don't forget to add the parameter needed in the dynamic event: dynamic event