public class Bin extends QueueBased
store()
in the bin. Consumers make the Bin
deliver()
the products to use them up. If no or not enough units
of a product are available for the consumers, they have to wait in a queue
until new units are delivered by a producer.
The first sort criterion of the queue is highest queueing priorities first
(i.e. not using scheduling priorities - note that this is a somewhat arbitrary
choice, as the Bin
is derived from QueueBased
, which provides all the statistical functionality
for a queue.QueueBased
QueueBased.QueueAction
FIFO, LIFO, RANDOM, UNDEFINED
Constructor and Description |
---|
Bin(Model owner,
java.lang.String name,
int sortOrder,
int qCapacity,
long initialUnits,
boolean showInReport,
boolean showInTrace)
Constructor for a
Bin with a number of initial units of a product in it. |
Bin(Model owner,
java.lang.String name,
long initialUnits,
boolean showInReport,
boolean showInTrace)
Constructor for a
Bin with a number of initial units of a product in it. |
Modifier and Type | Method and Description |
---|---|
double |
avgAvail()
Returning the average number of products available in the bin over the
time since the last reset of the bin.
|
Reporter |
createDefaultReporter()
Returns a Reporter to produce a report about this Bin.
|
long |
getAvail()
Returns the number of units available at the moment.
|
long |
getConsumers()
Returns the number of consumers having visited the Bin.
|
long |
getInitial()
Returns the initial number of products in the bin.
|
long |
getMaximum()
Returns the maximum number of products in the bin.
|
boolean |
getPassBy()
Returns whether entities can pass by other entities which are enqueued
before them in the queue.
|
long |
getProducers()
Returns the number of producers having used the Bin.
|
java.lang.String |
getQueueStrategy()
Returns the implemented queueing discipline of the underlying queue as a
String, so it can be displayed in the report.
|
long |
getRefused()
Returns the number of entities refused to be enqueued in the queue,
because the capacity limit is reached.
|
void |
reset()
To reset the statistics of this bin.
|
boolean |
retrieve(long n)
Method for consumers to make the Bin deliver a number of n products.
|
void |
setPassBy(boolean newPassBy)
Sets the flag passBy to a new value.
|
void |
store(long n)
Method for producers to put a number of n new products in the Bin.
|
addObserver, averageLength, averageWaitTime, deleteObserver, getQueueLimit, length, maxLength, maxLengthAt, maxWaitTime, maxWaitTimeAt, minLength, minLengthAt, notifyObservers, setQueueImpWarning, stdDevLength, stdDevWaitTime, zeroWaits
getCorrespondingSchedulable, getDescription, getObservations, getReporter, incrementObservations, incrementObservations, reportIsOn, reportOff, reportOn, resetAt, setCorrespondingSchedulable, setDescription, setReporter
current, currentEntity, currentEntityAll, currentEvent, currentModel, currentSimProcess, debugIsOn, debugOff, debugOn, getModel, isExperimentCompatible, isModelCompatible, presentTime, sendDebugNote, sendMessage, sendTraceNote, sendWarning, skipTraceNote, skipTraceNote, traceIsOn, traceOff, traceOn
getName, getQuotedName, toString
public Bin(Model owner, java.lang.String name, int sortOrder, int qCapacity, long initialUnits, boolean showInReport, boolean showInTrace)
Bin
with a number of initial units of a product in it.
Waiting consumer processes are sorted (and thus activated) according to their
queueing priorities (highest first) and (if equal)
by a queuing discipline as defined by QueueBased
, e.g.
QueueBased.FIFO
or QueueBased.LIFO
.
The capacity limit of the underlying queue can be chosen, too.owner
- Model : The model this Bin is associated to.name
- java.lang.String : The Bin's namesortOrder
- int : determines the sort order of the underlying queue
implementation. Choose a constant from QueueBased
like QueueBased.FIFO
or
QueueBased.LIFO
or ...qCapacity
- int : The capacity of the queue, that is how many processes
can be enqueued. Zero (0) means unlimited capacity.initialUnits
- long : The units of a product the Bin starts with. Must be
positive.showInReport
- boolean : Flag, if Bin should produce a report or not.showInTrace
- boolean : Flag for trace to produce trace messages.public Bin(Model owner, java.lang.String name, long initialUnits, boolean showInReport, boolean showInTrace)
Bin
with a number of initial units of a product in it.
Waiting consumer processes are sorted (and thus activated) according to their
queueing priorities (highest first) and (if equal)
by FIFO. The capacity limit of the underlying queue is unlimited.owner
- Model : The model this Bin is associated to.name
- java.lang.String : The Bin's nameinitialUnits
- long : The units of a product the Bin starts with. Must be
positive.showInReport
- boolean : Flag, if Bin should produce a report or not.showInTrace
- boolean : Flag for trace to produce trace messages.public double avgAvail()
public Reporter createDefaultReporter()
public boolean retrieve(long n) throws SuspendExecution
n
- long : The number of products the Bin is delivering to the
consumer.true
if the specified number of units
have been delivered successfully, false
otherwise
(i.e. capacity limit of the queue is reached).SuspendExecution
public long getAvail()
public long getConsumers()
public long getInitial()
public long getMaximum()
public boolean getPassBy()
public long getProducers()
public java.lang.String getQueueStrategy()
public long getRefused()
public void reset()
QueueBased
is also
reset.reset
in class QueueBased
public void setPassBy(boolean newPassBy)
newPassBy
- boolean : The new value of passBy. Set it to true
if you want entities to pass by other entities which are
enqueued before them in the queue. Set it to
false
if you don't want entities to overtake
other entities in the queue.public void store(long n)
store()
new products n is positive. Producers can
always store products into the Bin and will never be inserted in a queue
and blocked, because the Bin has no capacity limit..n
- long : The number of products put into the Bin.