modhelxs.state_management
Class ManagedBlock

java.lang.Object
  extended by modhelxs.abstractsemantics.NamedEntity
      extended by modhelxs.abstractsemantics.ObservableEntity
          extended by modhelxs.abstractsemantics.Block
              extended by modhelxs.state_management.ManagedBlock
All Implemented Interfaces:
Block, NamedEntity, ObservableEntity
Direct Known Subclasses:
PlainManagedBlock, TimedManagedBlock

public abstract class ManagedBlock
extends Block

A Block with default management for state changes.


Field Summary
private  State myState_
          The state of the block, managing the revert and commit operations on its state values.
private  TransientValue<java.lang.Boolean> was_updated_
          Transient value telling whether the block was updated during this snapshot.
 
Constructor Summary
ManagedBlock(java.lang.String name, java.lang.Object... properties)
           
 
Method Summary
private  boolean checkNotManagedFields()
          Check for fields that are not final and are not manageable by a State object.
abstract  void doEndOfSnapshot()
          The endOfSnapshot behavior of the block.
abstract  void doPreSetup()
          Some pre-setup behavior necessary for subclasses.
abstract  void doReset()
          The reset behavior of the block.
abstract  void doSetup()
          The setup behavior of the block.
abstract  void doStartOfSnapshot()
          The start of snapshot behavior of the block.
abstract  void doUpdate()
          The update behavior of the block.
 void emitObservationRequests()
          Emit observation request for future snapshots by creating ticks on clocks.
 void endOfSnapshot()
          The endOfSnapshot behavior of the ManagedBlock, which calls doEndOfSnapshot() and manages the state values.
 void endOfUpdate()
          End of a partial update (produce partial outputs to the outer model).
 void initFromProperties(java.lang.String... assignments)
          Initialize the state values and parameters of the block from its properties.
 void prep()
          Initialize the entity.
 void reset()
          The reset behavior of the ManagedBlock, which manages the state values and calls doReset().
 void setup()
          The setup behavior of the ManagedBlock, which manages the state values and calls doSetup().
 void startOfSnapshot()
          Start a new snapshot (observation round).
 void startOfUpdate()
          Start a partial update (get partial inputs from the outer model).
 void update()
          The update behavior of the ManagedBlock, which calls doUpdate() and manages the state values.
 boolean validate()
          Validate the computation of the observation.
 boolean wasUpdated()
          Tell whether the block was updated during this snapshot.
 void wrapup()
          Cleanup at the end of the simulation.
 
Methods inherited from class modhelxs.abstractsemantics.Block
connect, connectFromInterfaceBlock, connectFromModel, connectFromRegularBlock, getEngine, getInputPins, getMoC, getOutputPins, getParent, getSolver, getTimeOfRequest, hasObservationRequest, sanityCheck, setParent
 
Methods inherited from class modhelxs.abstractsemantics.ObservableEntity
addPin, getInterface, getPin
 
Methods inherited from class modhelxs.abstractsemantics.NamedEntity
getName, getProperties, getProperty, hasProperty, removeProperty, setName, setProperties, setProperty, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface modhelxs.ecore.ObservableEntity
getInterface
 
Methods inherited from interface modhelxs.ecore.NamedEntity
getName, getProperties, setName
 

Field Detail

was_updated_

private TransientValue<java.lang.Boolean> was_updated_
Transient value telling whether the block was updated during this snapshot.


myState_

private State myState_
The state of the block, managing the revert and commit operations on its state values.

Constructor Detail

ManagedBlock

public ManagedBlock(java.lang.String name,
                    java.lang.Object... properties)
Method Detail

checkNotManagedFields

private boolean checkNotManagedFields()
Check for fields that are not final and are not manageable by a State object.


wasUpdated

public boolean wasUpdated()
Tell whether the block was updated during this snapshot.


initFromProperties

public void initFromProperties(java.lang.String... assignments)
Initialize the state values and parameters of the block from its properties.


prep

public void prep()
Description copied from class: ObservableEntity
Initialize the entity. Called after loading the model, before the simulation starts.

Specified by:
prep in class ObservableEntity

doStartOfSnapshot

public abstract void doStartOfSnapshot()
The start of snapshot behavior of the block.


doPreSetup

public abstract void doPreSetup()
Some pre-setup behavior necessary for subclasses.


doSetup

public abstract void doSetup()
The setup behavior of the block.


setup

public final void setup()
The setup behavior of the ManagedBlock, which manages the state values and calls doSetup().

Specified by:
setup in class ObservableEntity

startOfSnapshot

public void startOfSnapshot()
Description copied from class: ObservableEntity
Start a new snapshot (observation round).

Specified by:
startOfSnapshot in class ObservableEntity

doReset

public abstract void doReset()
The reset behavior of the block.


reset

public final void reset()
The reset behavior of the ManagedBlock, which manages the state values and calls doReset().

Specified by:
reset in class ObservableEntity

startOfUpdate

public void startOfUpdate()
Description copied from class: ObservableEntity
Start a partial update (get partial inputs from the outer model).

Specified by:
startOfUpdate in class ObservableEntity

doUpdate

public abstract void doUpdate()
The update behavior of the block.


update

public final void update()
The update behavior of the ManagedBlock, which calls doUpdate() and manages the state values.

Specified by:
update in class ObservableEntity

endOfUpdate

public void endOfUpdate()
Description copied from class: ObservableEntity
End of a partial update (produce partial outputs to the outer model).

Specified by:
endOfUpdate in class ObservableEntity

validate

public boolean validate()
Description copied from class: ObservableEntity
Validate the computation of the observation. Answer true if the observable agrees with the observed values.

Specified by:
validate in class ObservableEntity

doEndOfSnapshot

public abstract void doEndOfSnapshot()
The endOfSnapshot behavior of the block.


endOfSnapshot

public final void endOfSnapshot()
The endOfSnapshot behavior of the ManagedBlock, which calls doEndOfSnapshot() and manages the state values.

Specified by:
endOfSnapshot in class ObservableEntity

emitObservationRequests

public void emitObservationRequests()
Description copied from class: ObservableEntity
Emit observation request for future snapshots by creating ticks on clocks.

Specified by:
emitObservationRequests in class ObservableEntity

wrapup

public void wrapup()
Description copied from class: ObservableEntity
Cleanup at the end of the simulation.

Specified by:
wrapup in class ObservableEntity