ground storage queue discipline

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
15497
Posts: 9
Joined: Tuesday 15 October, 2019 - 15:48

ground storage queue discipline

Post by 15497 »

Dear forum,

I am using the ground storage atom in my simulation model. I use it as a warehouse between one machine1 and 4 following queues (buffer1, buffer2, buffer3, buffer4). machine1 produces products for all of the next 4 buffers. A label on the products called [prio1]/[prio2]/[prio3]/[prio4] specifies the correct followup buffer.

I need the ground storage to constantly check if there is a buffer that's not filled with 2 products. If there aren't 2 products in a buffer, the ground storage needs to check if there are products in the ground storage for this queue.

I am currently using the following code. I use this code on the "product to send" of the ground storage, but its not entirely working. Sometimes products are present in the ground storage model that are intended for a certain machine but are not sent immediately despite the correct labels

Code: Select all

If(and(
      RDM1content>0,
      buffer1=0),
  findqueuepos([prio1],2),                    
   
  If(and(
        RDM2content>0,
        buffer2=0),                                                    
    findqueuepos([prio2],2),
   
    If(and(
          RDM3content>0,
          buffer3=0),                        
      findqueuepos([prio3],2),
 
      If(and(
            RDM4content>0,
            buffer4=0),                          
        findqueuepos([prio4],2),
       
        If(and(
              RDM1content>0,
              buffer1=1),             
          findqueuepos([prio1],2),
 
          If(and(
                RDM2content>0,
                buffer2=1),                           
            findqueuepos([prio2],2),
 
            If(and(
                  RDM3content>0,
                  buffer3=1),                        
              findqueuepos([prio3],2),
 
              If(and(
                    RDM4content>0,
                    buffer4=1),    
                findqueuepos([prio4],2)
               
                
                
                ) 
              )
            )
          )
        )
      )
    )
  ) 
on every buffer I use inc(buffer1)/inc(buffer2)/inc(buffer3)/inc(buffer4) whenever a product enters and dec(buffer1)/dec(buffer2)/dec(buffer3)/dec(buffer4) whenever a product exits the buffer.

On the ground storage I use inc(rdm1content)/inc(rdm2content)/inc(rdm3content)/inc(rdm4content) whenever a product labeled [prio1]/[prio2]/[prio3]/[prio4] enters the ground storage and dec(rdm1content)/dec(rdm2content)/dec(rdm3content)/dec(rdm4content) whenever a product labeled [prio1]/[prio2]/[prio3]/[prio4] exits the ground storage.

How can I make sure the ground storage fills the buffers with the right products in ascending order of the label value [prio1]/[prio2]/[prio3]/[prio4] if it has products for this buffer?

Thank you in advance,

Sam

User avatar
HarryBunnik
Posts: 327
Joined: Monday 07 February, 2011 - 11:22

Re: ground storage queue discipline

Post by HarryBunnik »

Ha Sam,

I've created a small example model to show you an option.

It is slightly working differently, since I place the control on the ExitTrigger of the Buffer (which has all a capacity of 2). Because that is the first moment where I know that I would like to search for replenishment of my buffer.

Originally I thought I would need an open and close output, but using a label([Prio], atmProduct) on my products with a value of 1, 2, 3 or 4 and use that on the send to statement of the ground storage seems to be sufficient to prevent products from slipping through.
  • So, to start at the beginning. On the source I place my label [Prio].
  • On the OnEntry I check if there is space for the arriving product (based on the label prio) in the related buffer. If so, then I place the product at the front of the storage, otherwise, I let it join storage at the end.
  • On the Send to statement I place that the product to sent, needs to be sent according to the label [Prio]
  • Then on the Exit trigger of the 4 buffers I have, I placed a function. The code of this function can be found in the "function editor" atom.
  • This function checks, based on the product leaving the buffer, what replacement is required. If there is one found, this product will be placed in front, so it can leave the storage. Otherwise, no correct product is found. When a product does arrive at a later stage, the code on the OnEntry of the storage will make sure it is directly sent through.
GroundStorage_v01.mod
(60.12 KiB) Downloaded 12 times
I hope that this principle also handles what you have in mind.

Success!

Harry

15497
Posts: 9
Joined: Tuesday 15 October, 2019 - 15:48

Re: ground storage queue discipline

Post by 15497 »

Hello Harry,

Thank you for your quick response and for taking the time to create an example model. I really appreciate it.

When I look at your model I understand most of it but not everything, which makes it hard to implement this strategy into my model. Because I use different labels than you did, it's hard to know which variables or labels I should change and which I don't need to change.

There is one thing that's different between our two models. You use 1 prio label and let the value define where it needs to be sent to. But I use 4 different labels, each label for their own machine, and the values on these labels define the sequence in which they should be sent to the corresponding buffer.

[prio1] for buffer 1
[prio2] for buffer 2
[prio3] for buffer 3
[prio4] for buffer 4

The values I add to these labels is the sequence they need to be produced by the machines.

So [prio1] with the value 1 should be the first to go to buffer1
[prio1] with the value 2 should be second
and so on...

The same goes for the other prio labels.

Does this change anything?

I hope you're able to help me a little bit more.

Thank you in advance!!

User avatar
HarryBunnik
Posts: 327
Joined: Monday 07 February, 2011 - 11:22

Re: ground storage queue discipline

Post by HarryBunnik »

Ha Sam,

That makes it a bit more difficult, but the same principles apply, only the code gets a bit more complicated. I would advise to split such information next time, so you'll have a label buffer and a level prio. That would have made the code easier.

I've adjusted the model to reflect your problem.
  • I added an Initiate atom with which I set a label on the buffers, indicating which buffer it is (I could do that using a TextCompare, but comparing text is a lot slower than comparing values).
  • I use now quite often the option to build up a string (Concat) and use that to find the correct label. As long as in the code calling a label a string is standing, ED is searching for that string. Normally it would be between square brackets ( [Prio1] ), but using ( Concat([Prio], String(4)) ) also returns a string ( [Prio4] ), which can be directly used (or via a local variable of the type vbString) to call the label value. This makes it possible to write code that is a lot more compact.
  • I've updated the code on the Entry Trigger of the storage to search for the correct buffer.
  • Also the function is updated. I added some comments to explain what I'm doing there.
  • And the SendTo statement of the Storage is slight changed.
I also updated the products a bit, which makes it easier to see what is going on and if the model is behaving correctly.
  • Now the size of the product reflects the buffer it is intended for. Smaller is a higher priority.
  • The color indicates the priority (red = 1, Blue = 2, Green = 3 and Purple = 4)
GroundStorage_v02.mod
(70.13 KiB) Downloaded 13 times
I hope it helps you further!

Gr. Harry

Post Reply