public abstract class SimProcess extends Entity
lifeCycle()
), they inherit from Entity and thus can also
be used in conjunction with events. So they can be handled in both ways,
event- and process-oriented. Clients are supposed to implement the
lifeCycle()
method to specify the individual behaviour of a special
SimProcess subclass. Since implementing activity- and transaction-oriented
synchronization mechanisms requires significant changes in this class,
methods that have been implemented by Soenke Claassen have been marked.Constructor and Description |
---|
SimProcess(Model owner,
java.lang.String name,
boolean showInTrace)
Short-cut constructor of a SimProcess whose
lifeCycle() is only
executed once. |
SimProcess(Model owner,
java.lang.String name,
boolean repeating,
boolean showInTrace)
The most general constructor of a SimProcess.
|
Modifier and Type | Method and Description |
---|---|
void |
activate()
Schedules the SimProcess to be activated at the current simulation time.
|
void |
activate(TimeInstant when)
Schedules the SimProcess to be activated at the given point in
simulation time.
|
void |
activate(TimeSpan dt)
Schedules the SimProcess to be activated after a given span of
simulation time.
|
void |
activateAfter(Schedulable after)
Schedules this SimProcess to be activated directly after the given
Schedulable, which itself is already scheduled.
|
void |
activateBefore(Schedulable before)
Schedules this SimProcess to be activated directly before the given
Schedulable, which itself is already scheduled.
|
void |
activatePreempt()
Schedules the SimProcess to be activated immediately at the given point in
simulation time, implicitly stalling the current process until the activated process withdraws
program control, referred to as process preemption.
|
void |
cancelInterruptDelayed()
Clears the currently scheduled delayed interrupt so that it wont be
performed.
|
boolean |
canCooperate()
Returns
true if this process can cooperate with another
SimProcess. |
void |
clearInterruptCode()
Resets the interrupt-status of this SimProcess to not interrupted.
|
void |
cooperate()
The current (master) process is calling this method (within
WaitQueue.cooperate() ) on the slave process to lead him
through the joint cooperation. |
Schedulable |
getActivatedBy()
Returns the last
Schedulable that did cause the last
activation (or interruption) of this SimProcess. |
InterruptCode |
getInterruptCode()
Returns the InterruptCode from this SimProcess.
|
InterruptException |
getInterruptException() |
SimProcess |
getMaster()
Returns the master when two SimProcesses are cooperating.
|
long |
getRealTimeConstraint()
Returns the realTime deadline for this SimProcess (in nanoseconds).
|
int |
getSchedulingPriority()
Returns the process' scheduling priority.
|
ProcessQueue<? extends SimProcess> |
getSlaveWaitQueue()
Returns the waiting-queue in which this SimProcess is waiting as a slave
to cooperate with a master.
|
ComplexSimProcess |
getSupervisor()
Returns the supervising
ComplexSimProcess this SimProcess is
contained in. |
void |
hold(NumericalDist<?> dist)
Passivates a SimProcess for span of time sampled from the distribution
provided to the method.
|
void |
hold(TimeInstant until)
Passivates a SimProcess until the given point in simulation time.
|
void |
hold(TimeSpan dt)
Passivates a SimProcess for the given span of time.
|
void |
interrupt(InterruptCode interruptReason)
Interrupts the SimProcess setting the given InterruptCode as the reason
for the interruption.
|
void |
interrupt(InterruptException interruptReason)
Interrupts the SimProcess by throwing the given InterruptException in
it's lifeCylce() method.
|
ExternalEvent |
interruptDelayed(TimeInstant when)
Schedules this process to be interrupted at the given point in simulation
time.
|
ExternalEvent |
interruptDelayed(TimeSpan delay)
Schedules this process to be interrupted after the given delay.
|
boolean |
isBlocked()
Returns the current block-status of the SimProcess.
|
boolean |
isComponent()
Returns the current component status of this SimProcess.
|
boolean |
isDelayedInterruptScheduled() |
boolean |
isInterrupted()
Returns the current interrupt-status of this SimProcess.
|
boolean |
isRepeating()
Returns the current repeating-status of the SimProcess.
|
boolean |
isTerminated()
Returns the current status of the SimProcess.
|
abstract void |
lifeCycle()
Override this method in a subclass of SimProcess to implement the
specific behaviour of this SimProcess.
|
void |
obtainResources(Resource[] obtainedResources)
Makes the SimProcess obtain an array of resources and store them for
further usage.
|
void |
passivate()
Passivates the SimProcess for an indefinite time.
|
void |
prepareTransport()
The current (master) process is calling this method (within
TransportJunction.cooperate() ) on the slave process to make
him prepare for the transportation. |
void |
reActivate(TimeInstant when)
Re-schedules the activation of this process (which must be exaxctly one)
by setting it to the TimeInstant passed to this method.
|
void |
reActivate(TimeSpan dt)
Re-schedules all SimProcess activation by adding a TimeSpan to the
current activation times.
|
void |
resetMaster()
Gets the InterruptCode from the master and resets the master to
null . |
void |
returnAllResources()
Makes the SimProcess return all resources it holds at the moment to all
the different Res pools it is holding resources from.
|
Resource[] |
returnResources(Res resPool,
int n)
Makes the SimProcess return a certain number of resources of the given
resource pool.
|
void |
setBlocked(boolean blockStatus)
Sets the SimProcess' blocked status to the boolean value given.
|
void |
setRealTimeConstraint(long realTimeConstraint)
Sets the realTime deadline for this SimProcess (in nanoseconds).
|
void |
setRepeating(boolean repeatingStatus)
Sets the SimProcess' repeating status to the boolean value given, permitting
the process' lifeCycle to either start again (
true ) or terminate
(false ) after the current cycle is completed. |
void |
setSchedulingPriority(int newPriority)
Sets the process' scheduling priority to a given integer value.
|
void |
setSlaveWaitQueue(ProcessQueue<? extends SimProcess> slvWaitQueue)
Sets the SimProcess' slaveWaitQueue variable to the ProcessQueue in
which this SimProcess is waiting as a slave to cooperate with a master.
|
getIdentNumber, getQueueingPriority, getQueues, getScheduledEvents, isEqual, isLarger, isLargerOrEqual, isNotEqual, isQueued, isSimProcess, isSmaller, isSmallerOrEqual, schedule, schedule, schedule, schedule, schedule, schedule, schedule, schedule, schedule, scheduleAfter, scheduleAfter, scheduleAfter, scheduleBefore, scheduleBefore, scheduleBefore, schedulePreempt, schedulePreempt, schedulePreempt, setQueueingPriority
assignReporter, cancel, getCorrespondingReportable, isCurrent, isScheduled, rename, reSchedule, reSchedule, reSchedulePreempt, scheduledNext, setCorrespondingReportable
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 SimProcess(Model owner, java.lang.String name, boolean repeating, boolean showInTrace)
name
- String : The name of the SimProcessowner
- Model : The model this SimProcess is associated torepeating
- boolean : Flag to set the SimProcess' repeating behaviour:
If set to true
, the lifeCycle will be executed
again after completion, while false
will
create a process whose lifeCycle is executed only once.showInTrace
- boolean : Flag for showing SimProcess in trace-files. Set it
to true
if SimProcess should show up in trace.
Set it to false
if SimProcess should not be shown
in trace.public SimProcess(Model owner, java.lang.String name, boolean showInTrace)
lifeCycle()
is only
executed once.name
- String : The name of the SimProcessowner
- Model : The model this SimProcess is associated toshowInTrace
- boolean : Flag for showing SimProcess in trace-files. Set it
to true
if SimProcess should show up in trace.
Set it to false
if SimProcess should not be shown
in trace.public void activate()
lifeCycle
method. Schedulable
) has
transferred program control back to the Scheduler, e.g. by calling hold(...)
or passivate()
. If process preemption is desired, please use
method activatePreempt()
.public void activatePreempt() throws SuspendExecution
SuspendExecution
public void activate(TimeInstant when)
lifeCycle
method. presentTime()
, the activated process is resumed
after the current process (or other Schedulable
) has
transferred program control back to the Scheduler, e.g. by calling hold(...)
or passivate()
. If process preemption is desired, please use
method activatePreempt()
.when
- TimeInstant : The point in simulation time this process is to
be activated.public void activate(TimeSpan dt)
lifeCycle
method. TimeSpan(0)
, the activated process is resumed
after the current process (or other Schedulable
) has
transferred program control back to the Scheduler, e.g. by calling hold(...)
or passivate()
. If process preemption is desired, please use
method activatePreempt()
.activate(new TimeSpan(0))
,
the shorm form activate()
exists.dt
- TimeSpan : The offset to the current simulation time this
process is to be activatedpublic void activateAfter(Schedulable after)
lifeCycle()
method directly after the given Schedulable but
the simulation clock will not change. Please make sure that the
Schedulable given as parameter is actually scheduled.after
- Schedulable : The Schedulable this SimProcess should be
scheduled afterpublic void activateBefore(Schedulable before)
lifeCycle()
method directly before the given Schedulable but
the simulation clock will not change. Please make sure that the
Schedulable given as parameter is actually scheduled.before
- Schedulable : The Schedulable this SimProcess should be
scheduled beforepublic void cancelInterruptDelayed()
public boolean isDelayedInterruptScheduled()
public boolean canCooperate()
true
if this process can cooperate with another
SimProcess. If this process is already cooperating with a master
false
is returned.public void clearInterruptCode()
InterruptCode
of this SimProcess
will be reset to null
.public void cooperate()
WaitQueue.cooperate()
) on the slave process to lead him
through the joint cooperation. After the joint cooperation is finished
the master is still active and after him the slave will be activated.public InterruptCode getInterruptCode()
null
.public InterruptException getInterruptException()
public SimProcess getMaster()
null
is
returned.null
if this process is not a slave process.public long getRealTimeConstraint()
public ProcessQueue<? extends SimProcess> getSlaveWaitQueue()
null
is returned.null
if this SimProcess is not
waiting as a slave for cooperation.public ComplexSimProcess getSupervisor()
ComplexSimProcess
this SimProcess is
contained in.ComplexSimProcess
this SimProcess is contained in.
Is null
if this SimProcess is not contained in any
ComplexSimProcess
.public Schedulable getActivatedBy()
Schedulable
that did cause the last
activation (or interruption) of this SimProcess.hold(TimeSpan t)
or an activate(TimeSpan t)
, this method may return
a reference to this process. The method returns null
if
this process has not yet been activated.public void hold(TimeInstant until) throws DelayedInterruptException, InterruptException, SuspendExecution
until
- TimeInstant : The point in simulation time when the
SimProcess' passivation ends.DelayedInterruptException
InterruptException
SuspendExecution
public void hold(TimeSpan dt) throws DelayedInterruptException, InterruptException, SuspendExecution
dt
- TimeSpan : The duration of the SimProcess' passivationDelayedInterruptException
InterruptException
SuspendExecution
public void hold(NumericalDist<?> dist) throws DelayedInterruptException, InterruptException, SuspendExecution
dist
- NumericalDist> : Numerical distribution to sample the
duration of the SimProcess' passivation fromDelayedInterruptException
InterruptException
SuspendExecution
public void interrupt(InterruptCode interruptReason)
interruptReason
- desmoj.InterruptCodepublic void interrupt(InterruptException interruptReason)
interruptReason
- desmoj.InterruptExceptionpublic ExternalEvent interruptDelayed(TimeInstant when)
when
- The Point in time when the interrupt is to be performed.public ExternalEvent interruptDelayed(TimeSpan delay)
delay
- The delay after which the interrupt is to be performed.public boolean isBlocked()
true
if SimProcess is blocked,
false
otherwisepublic boolean isRepeating()
true
if the lifeCycle of the process
will be repeated finishing, while false
indicates
the process will terminate after the lifeCycle is completed.public boolean isComponent()
ComplexSimProcess
it is blocked and
passivated. It exists only within the ComplexSimProcess
;
it's own lifeCycle is stopped and will only be activated again when it is
removed from the ComplexSimProcess
.true
if and only if this SimProcess is a
component (part of) a ComplexSimProcess
;
false
otherwise.public boolean isInterrupted()
clearInterruptCode()
-method.true
if this SimProcess is interrupted,
false
otherwise.public boolean isTerminated()
lifeCycle()
method
and can not further be used as a SimProcess. A terminated SimProcess can
still be used like any other Entity which it is derived from.true
if the SimProcess is terminated,
false
otherwiseEntity
public abstract void lifeCycle() throws SuspendExecution
SuspendExecution
public void obtainResources(Resource[] obtainedResources)
obtainedResources
- Resource[] : The array of resources obtained.public void passivate() throws DelayedInterruptException, InterruptException, SuspendExecution
DelayedInterruptException
InterruptException
SuspendExecution
public void prepareTransport()
TransportJunction.cooperate()
) on the slave process to make
him prepare for the transportation. After the transport is finished the
master is still active and after him the slave will be activated.public void reActivate(TimeSpan dt)
dt
- TimeSpan : The offset to the current activation times
to be added to all activation times.public void reActivate(TimeInstant when)
when
- TimeInstant : The point in simulation time this process is to
be reactivated.public void resetMaster()
null
.public void returnAllResources()
public Resource[] returnResources(Res resPool, int n)
resPool
- Res : The resource pool which resources will be returned.n
- int : The number of resources which will be returned.public void setBlocked(boolean blockStatus)
blockStatus
- boolean : The new value for the blocked statuspublic void setRepeating(boolean repeatingStatus)
true
) or terminate
(false
) after the current cycle is completed. Note that setting
setting this property to true
after the the process has
terinated has no effect.repeatingStatus
- boolean : The new value for the repeating statuspublic void setRealTimeConstraint(long realTimeConstraint)
realTimeConstraint
- the realTimeConstraint in nanoseconds to setpublic void setSlaveWaitQueue(ProcessQueue<? extends SimProcess> slvWaitQueue)
slvWaitQueue
- ProcessQueue : The waiting-queue in which this SimProcess is
waiting as a slave to cooperate with a master.public int getSchedulingPriority()
public void setSchedulingPriority(int newPriority)
integer
data type [-2147483648, +2147483647].
An process' scheduling priority it used to determine which process is
executed first if activated at the same time instant.
Should the priority be the same, order of event execution depends on the
EventList
in use, e.g. activated first is executed
first (EventTreeList
) or random (RandomizingEventTreeList
).newPriority
- int : The new scheduling priority value