public class Stock extends QueueBased
store()
in the Stock. Consumers
make the Stock retrieve()
the products to use them up. A Stock
is also providing a process synchronization between producers and consumers.
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
Stock has a certain capacity. If the Stock is filled to it's capacity
producers have to wait in a queue until consumers are arriving and taking
units out of the Stock. Then the producers can fill up the freed space. This
is the major difference to the Bin.
The first sort criterion of the queues is highest queueing priorities first
(i.e. not using scheduling priorities - note that this is a somewhat arbitrary
choice, as the Stock
is derived from QueueBased
, which provides all the statistical functionality
for the consumer queue. The producer queue is managed by an internal ProcessQueue.QueueBased
,
Bin
QueueBased.QueueAction
FIFO, LIFO, RANDOM, UNDEFINED
Constructor and Description |
---|
Stock(Model owner,
java.lang.String name,
int prodSortOrder,
int prodQCapacity,
int consSortOrder,
int consQCapacity,
long initialUnits,
long capacity,
boolean showInReport,
boolean showInTrace)
Constructor for a
Stock with a certain capacity and a
certain number of initial units of a product in it. |
Stock(Model owner,
java.lang.String name,
long initialUnits,
long capacity,
boolean showInReport,
boolean showInTrace)
Constructor for a
Stock with a certain capacity and a
certain number of initial units of a product in it. |
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
The addPropertyChangeListener method was generated to support the
propertyChange field.
|
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
The addPropertyChangeListener method was generated to support the
propertyChange field.
|
double |
avgAvail()
Returning the average number of units available in the Stock over the
time since the last reset of the Stock.
|
Reporter |
createDefaultReporter()
Returns a Reporter to produce a report about this Stock.
|
void |
firePropertyChange(java.beans.PropertyChangeEvent evt)
The firePropertyChange method was generated to support the propertyChange
field.
|
void |
firePropertyChange(java.lang.String propertyName,
boolean oldValue,
boolean newValue)
The firePropertyChange method was generated to support the propertyChange
field.
|
void |
firePropertyChange(java.lang.String propertyName,
int oldValue,
int newValue)
The firePropertyChange method was generated to support the propertyChange
field.
|
void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
The firePropertyChange method was generated to support the propertyChange
field.
|
long |
getAvail()
Gets the available number of products in the Stock at the moment.
|
long |
getCapacity()
Gets the capacity property (long) value of this Stock, that is the number
of units this stock can hold at max.
|
java.lang.String |
getConsQueueStrategy()
Returns the implemented queueing discipline of the underlying consumer
queue as a String, so it can be displayed in the report.
|
long |
getConsRefused()
Returns the number of consumers that were refused to be enqueued because
the queue for consumers was full.
|
long |
getConsumers()
Gets the consumers property (long) value.
|
long |
getInitial()
Gets the initial number of products the Stock starts with.
|
long |
getMaximum()
Gets the maximum number of products in the Stock.
|
long |
getMinimum()
Gets the minimum number of units in the Stock so far (since the last
reset).
|
boolean |
getPassByConsumers()
Returns whether entities can pass by other entities which are enqueued
before them in the queue.
|
boolean |
getPassByProducers()
Returns whether entities can pass by other entities which are enqueued
before them in the queue.
|
java.lang.String |
getProdQueueStrategy()
Returns the implemented queueing discipline of the underlying queue for
producers as a String, so it can be displayed in the report.
|
long |
getProdRefused()
Returns the number of producers that were refused to be enqueued because
the queue for producers was full.
|
ProcessQueue<SimProcess> |
getProducerQueue()
Returns the queue where the producers are waiting to deliver their units.
|
long |
getProducers()
Gets the producers property (long) value.
|
long |
getRefused()
Gets the refused property (long) value.
|
java.lang.String |
getWhere()
Gets the where property (String) value denoting the method, where
something has gone wrong.
|
boolean |
hasListeners(java.lang.String propertyName)
The hasListeners method was generated to support the propertyChange
field.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
The removePropertyChangeListener method was generated to support the
propertyChange field.
|
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
The removePropertyChangeListener method was generated to support the
propertyChange field.
|
void |
reset()
Resets all statistical counters of this Stock to their default values.
|
boolean |
retrieve(long n)
Method for consumers to make the Stock retrieve a number of n units.
|
void |
setPassByConsumers(boolean newPassBy)
Sets the flag passBy to a new value.
|
void |
setPassByProducers(boolean newPassBy)
Sets the flag passBy to a new value.
|
boolean |
store(long n)
Method for producers to make the Stock store a number of n units.
|
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 Stock(Model owner, java.lang.String name, int prodSortOrder, int prodQCapacity, int consSortOrder, int consQCapacity, long initialUnits, long capacity, boolean showInReport, boolean showInTrace)
Stock
with a certain capacity and a
certain number of initial units of a product in it.
Waiting producer and 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 capacities of the underlying queues for waiting processes
can be chosen, too.owner
- desmoj.Model : The model this Stock is associated to.name
- java.lang.String : The Stock's name, should indicate the kind
of product stored in this Stock.prodSortOrder
- int : determines the sort order of the underlying queue
implementation for the producers. Choose a constant from
QueueBased
like QueueBased.FIFO
or
QueueBased.LIFO
or ...prodQCapacity
- int : The capacity of the producers queue, that is how many
processes can be enqueued. Zero (0) means unlimited capacity.consSortOrder
- int : determines the sort order of the underlying queue
implementation for the consumers. Choose a constant from
QueueBased
like QueueBased.FIFO
or
QueueBased.LIFO
or ...consQCapacity
- int : The capacity of the consumers queue, that is how many
processes can be enqueued. Zero (0) means unlimited capacity.initialUnits
- long : The units of a product the Stock starts with. Must be
positive!capacity
- long : The maximum capacity of products this Stock can hold.showInReport
- boolean : Flag, if this Stock should produce a report or not.showInTrace
- boolean : Flag for trace to produce trace messages.public Stock(Model owner, java.lang.String name, long initialUnits, long capacity, boolean showInReport, boolean showInTrace)
Stock
with a certain capacity and a
certain number of initial units of a product in it.
Waiting producer and consumer processes are sorted (and thus activated)
according to their queueing priorities (highest first) and (if equal)
by FIFO. The capacities of the underlying queues for waiting processes
are unlimited.owner
- desmoj.Model : The model this Stock is associated to.name
- java.lang.String : The Stock's name, should indicate the kind
of product stored in this Stock.initialUnits
- long : The units of a product the Stock starts with. Must be
positive!capacity
- long : The maximum capacity of products this Stock can hold.showInReport
- boolean : Flag, if this Stock should produce a report or not.showInTrace
- boolean : Flag for trace to produce trace messages.public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
public double avgAvail()
public Reporter createDefaultReporter()
public void firePropertyChange(java.beans.PropertyChangeEvent evt)
public void firePropertyChange(java.lang.String propertyName, int oldValue, int newValue)
public void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
public void firePropertyChange(java.lang.String propertyName, boolean oldValue, boolean newValue)
public long getAvail()
public long getCapacity()
public java.lang.String getConsQueueStrategy()
public long getConsRefused()
public long getConsumers()
public long getInitial()
public long getMaximum()
public long getMinimum()
public boolean getPassByConsumers()
public boolean getPassByProducers()
public java.lang.String getProdQueueStrategy()
public long getProdRefused()
public ProcessQueue<SimProcess> getProducerQueue()
public long getProducers()
public long getRefused()
public java.lang.String getWhere()
public boolean hasListeners(java.lang.String propertyName)
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
public void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
public void reset()
reset
in class QueueBased
public boolean retrieve(long n) throws SuspendExecution
n
- long : The number of units the Stock is retrieving for the
consumer; must be positive.true
if the specified number of units
can been retrieved successfully, false
otherwise
(i.e. capacity limit of the queue is reached).SuspendExecution
public void setPassByConsumers(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 setPassByProducers(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 boolean store(long n) throws SuspendExecution
n
- long : The number of units the Stock is receiving from the
producer to store. n must be positive.true
if the specified number of units
can been stored successfully, false
otherwise (i.e.
capacity limit of the queue is reached).SuspendExecution