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 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