public class ModelComponent extends NamedObject
Constructor and Description |
---|
ModelComponent(Model ownerModel,
java.lang.String name)
Constructs a modelcomponent with the given String as name and the given
model as the associated owner of this component.
|
ModelComponent(Model ownerModel,
java.lang.String name,
boolean showInTrace)
Constructs a modelcomponent with the given String as name and the given
model as the associated owner of this component.
|
Modifier and Type | Method and Description |
---|---|
Schedulable |
current()
Returns the currently active Schedulable object that is handled by the
scheduler.
|
Entity |
currentEntity()
Returns the currently active Entity.
|
java.util.List<Entity> |
currentEntityAll()
Returns the currently active entities.
|
EventAbstract |
currentEvent()
Returns the currently active Event that is handled by the scheduler.
|
Model |
currentModel()
Returns the model that the currently active Event or Entity handled by
the scheduler belongs to or the main model connected to the experiment,
if no model can be returned by the scheduler.
|
SimProcess |
currentSimProcess()
Returns the currently active SimProcess that is handled by the scheduler.
|
boolean |
debugIsOn()
Shows if this modelcomponent currently produces debug output.
|
void |
debugOff()
Switches off debug output for this modelcomponent.
|
void |
debugOn()
Switches on debug output for this modelcomponent.
|
Model |
getModel()
Returns the model that owns this component.
|
boolean |
isExperimentCompatible(ModelComponent other)
Tests if the modelcomponent given as parameter is a component of the same
experiment as this modelcomponent.
|
boolean |
isModelCompatible(ModelComponent other)
Tests if the modelcomponent given as parameter is a component of the same
model as this modelcomponent.
|
TimeInstant |
presentTime()
Returns the current simulation time as displayed by the simulation clock
responsible for this modelcomponent.
|
void |
sendDebugNote(java.lang.String description)
Creates and sends a debugnote to the experiment's messagedistributor.
|
void |
sendMessage(Message m)
Sends a message to the messagedistributor handled by the experiment.
|
void |
sendTraceNote(java.lang.String description)
Creates and sends a tracenote to the experiment's messagedistributor.
|
void |
sendWarning(java.lang.String description,
java.lang.String location,
java.lang.String reason,
java.lang.String prevention)
Creates and sends an error message to warn about a erroneous condition in
the DESMO-J framework to the experiment's messagedistributor.
|
void |
skipTraceNote()
Skips the next tracenote.
|
void |
skipTraceNote(int numSkipped)
Skips the next number of tracenotes.
|
boolean |
traceIsOn()
Shows if this modelcomponent currently produces trace output.
|
void |
traceOff()
Switches off trace output for this modelcomponent.
|
void |
traceOn()
Switches on trace output for this modelcomponent.
|
getName, getQuotedName, toString
public ModelComponent(Model ownerModel, java.lang.String name)
false
.name
- java.lang.String : The name of the componentownerModel
- Model : The model this component is associated to.public ModelComponent(Model ownerModel, java.lang.String name, boolean showInTrace)
name
- java.lang.String : The name of the componentownerModel
- Model : The model this component is associated toshowInTrace
- boolean : Flag for showing component in trace-files. Set it to
true
if component should show up in trace. Set it
to false
if component should not be shown in
trace.public Schedulable current()
public Entity currentEntity()
null
if the current
Schedulable happens to be an external event or a SimProcess.
Note that in case the current Event refers to more than one entity
(EventTwoEntitties
, EventThreeEntitties
),
only the first entity is returned; to obtain all such entities,
use getAllCurrentEntities()
instead.null
in case of an external event or a SimProcess
being the currently active Schedulablepublic java.util.List<Entity> currentEntityAll()
public EventAbstract currentEvent()
null
if a process Event is the current active
Schedulable, thus no Event is active.null
if the
current active Schedulable is a processpublic Model currentModel()
public SimProcess currentSimProcess()
public TimeInstant presentTime()
public boolean debugIsOn()
public void debugOff()
public void debugOn()
public Model getModel()
public boolean isExperimentCompatible(ModelComponent other)
other
- ModelComponent : the other modelcomponent to check
compatibility withpublic boolean isModelCompatible(ModelComponent other)
other
- ModelComponent : the other modelcomponent to check
compatibility withtrue
, if this modelcomponent belongs to the
same model as the given modelcomponent, false
otherwisepublic void sendDebugNote(java.lang.String description)
Scheduler
and Queue
both produce debugnotes if set to do so
representing the data stored inside them. The information about the
simulation time is extracted from the experiment and must not be given as
a parameter.description
- java.lang.String : The description of a modelcomponent's
internal state to be passed with this debugnotepublic void sendMessage(Message m)
out
printstream as configured in
the local Java runtime environment of the computer this simulation is
running on. Note that there are shorthands for sending the standard
DESMO-J messages. These methods create and send the appropriate Message
on-the-fly:
sendTraceNote() to send a tracenote
sendDebugNote()
to send the data needed to debug modelssendWarning()
to send an errormessage that does not stop
the experimentm
- Message : The message to be transmittedsendTraceNote(java.lang.String)
,
sendDebugNote(java.lang.String)
,
sendWarning(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
public void sendTraceNote(java.lang.String description)
description
- java.lang.String : The description of the tracenotepublic void sendWarning(java.lang.String description, java.lang.String location, java.lang.String reason, java.lang.String prevention)
description
- java.lang.String : The description of the error that occuredlocation
- java.lang.String : The class and method the error occured inreason
- java.lang.String : The reason most probably responsible for
the error to occurprevention
- java.lang.String : The measures a user should take to prevent
this warning to be issued againpublic void skipTraceNote()
public void skipTraceNote(int numSkipped)
numSkipped
- int : The number of future tracenotes to be skippedpublic boolean traceIsOn()
public void traceOff()
public void traceOn()