public class Berth extends QueueBased
Ship
can come and take()
the
needed length for his berthing. Each ship has to release the same length of
the berth it once has acquired by calling the release()
method
of the Berth. Berth is used to implement process synchronization between
ships, which are using berth. The berth has a limited ccertain length. A ship
can take the needed for him length to berth. After his unloading and/or
loading the ship must release the taken length to make her available to other
ships. If a ship can not get the needed length (enough free place) for his
berthing, it has to wait in a queue until enough length ( free palce) are
released by other ships. A ship can release its berthing length anytime.
After the berht has release()
the used length the waiting
queue is checked for ships waiting for her. The first sort criteria of the
queue is always highest priorities first, the second queueing discipline of
the underlying queue and the capacity limit can be determined by the user
(default is FIFO and unlimited capacity).QueueBased
QueueBased.QueueAction
FIFO, LIFO, RANDOM, UNDEFINED
Constructor and Description |
---|
Berth(Model owner,
java.lang.String name,
int length,
boolean showInReport,
boolean showInTrace)
Constructor for a Berth with a certain length.
|
Berth(Model owner,
java.lang.String name,
int sortOrder,
int qCapacity,
int length,
boolean showInReport,
boolean showInTrace)
Constructor for a Berth with a certain length.
|
Modifier and Type | Method and Description |
---|---|
double |
avgServTime()
Returns the average berthing time of the ships that have used this Berth.
|
double |
avgUsage()
Returns the average usage of the Berth.
|
void |
changeLength(int l)
Changes the length of the Berth.
|
Reporter |
createDefaultReporter()
Returns a Reporter to produce a report about this Berth.
|
int |
getAvailLength()
Returns the available length of the berth at the moment.
|
int |
getLength()
Returns the length of the Berth.
|
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 ships refused to be enqueued in the queue, because
the capacity limit is reached.
|
long |
getUsers()
Returns the number of users (ships).
|
boolean |
release()
A Ship is using this method to release this berth and to put length it
has used back to the Berth.
|
void |
reset()
Resets the statistics of this Berth.
|
boolean |
take()
Provides the length to ships to use it for its berthing.
|
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 Berth(Model owner, java.lang.String name, int sortOrder, int qCapacity, int length, boolean showInReport, boolean showInTrace)
owner
- Model : The model this Berth is associated to.name
- java.lang.String : The Berth'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
(ships) can be enqueued. Zero (0) means unlimited capacity.length
- int : The length of the Berth. Must be positive and greater
than 0.showInReport
- boolean : Flag, if Berth should produce a report or not.showInTrace
- boolean : Flag for trace to produce trace messages.public Berth(Model owner, java.lang.String name, int length, boolean showInReport, boolean showInTrace)
owner
- Model : The model this Berth is associated to.name
- java.lang.String : The Berth's namelength
- int : The lenght of this Berth Must be positive and greater
than 0.showInReport
- boolean : Flag, if Berth should produce a report or not.showInTrace
- boolean : Flag for trace to produce trace messages.public Reporter createDefaultReporter()
public void changeLength(int l)
l
- int : The new length of the Berth. Must be positive.public int getLength()
public double avgServTime()
public double avgUsage()
public boolean take() throws SuspendExecution
true
if the needed length has been
provided successfully, false
otherwise (i.e.
capacity limit of the queue is reached).SuspendExecution
public boolean release()
public void reset()
QueueBased
is
also reset.reset
in class QueueBased
public int getAvailLength()
public long getUsers()
public java.lang.String getQueueStrategy()
public long getRefused()