I have a simulation where a QueueFile is read, and a correspdoning MU (A, B, or C) is triggered to move from it's buffer (Buffer_A, Buffer_B, Buffer_C) into a combined buffer.
I have the simulation waiting until there's room in the combined buffer, and waiting until there are values in the QueueFile. My simulation crashes before I get to second shift, though, always with this error:
"The list ...QueueFile is empty."
How is this so? The method just read and triggered an action according to the contents of the QueueFile.
Any ideas on how to avoid this error? Is there something about .top and .pop that I'm missing?
Here's my method:
waituntil Buffer.full = false if QueueFile.empty = true wait 5 elseif QueueFile.top = "A" if Buffer_A.empty = true repeat wait 10 until Buffer_A.empty = false end Buffer_A.cont.move(Buffer) QueueFile.pop elseif QueueFile.top = "B" if Buffer_B.empty = true repeat wait 10 until Buffer_B.empty = false end Buffer_B.cont.move(Buffer) QueueFile.pop elseif QueueFile.top = "C" if Buffer_C.empty = true repeat wait 10 until Buffer_C.empty = false end Buffer_C.cont.move(Buffer) QueueFile.pop end
Nothing else in my model uses .pop.
Any assistance you could provide would be very helpful.
Solved! Go to Solution.
until Buffer_A.empty = false
is very problematic.
So it may happen, that one method call is just running, while the generator starts the method again. The resulting behavior is chaotic.
There are other ways to do this:
Just include the condition Buffer_A.empty = false into the top conditions. If the condition is not met, nothing happens and the method waits for their next call e.g.
if Buffer.full or QueueFile.empty then return end if QueueFile.top = "A" and Buffer_A.empty =false then Buffer_A.cont.move(Buffer) QueueFile.pop elseif QueueFile.top = "B" and Buffer_B.empty = false then Buffer_B.cont.move(Buffer) QueueFile.pop elseif QueueFile.top = "C" and Buffer_C.empty = false then Buffer_C.cont.move(Buffer) QueueFile.pop end
freelance simulation specialist