I am trying to find out how can I know how many items are currently stored in a buffer using Simpy. In my situation there is a machine that produces items and next they are stored in a buffer with limited capacity (2). So if the buffer is full, the machine should stop working.
global t1
global t2
with machine.request() as req:
yield req
if len(buffer.get_queue) >= 1:
yield env.timeout(t2 - t1)
machine = simpy.Resource(env,capacity= 1)
buffer = simpy.Store(env,capacity=2)
I tried to use len(buffer.get_queue)
, but this always returns 0. I have not been able to find another way to return the number of items which are stored in the buffer.
- t2-t1 is the time it takes for an item to leave the buffer after it has entered the buffer.