modhelxs.abstractsemantics
Class Model<T extends java.lang.Comparable<? super T>>

java.lang.Object
  extended by modhelxs.abstractsemantics.NamedEntity
      extended by modhelxs.abstractsemantics.ObservableEntity
          extended by modhelxs.abstractsemantics.Model<T>
All Implemented Interfaces:
Model, NamedEntity, ObservableEntity
Direct Known Subclasses:
WindowController, WindowModel

public class Model<T extends java.lang.Comparable<? super T>>
extends ObservableEntity
implements Model

A Model describes a behavior by the combination of the behavior of the blocks of a structure according to a model of computation.

Author:
boulange

Field Summary
private  Engine engine_
          The execution engine in charge of the execution of this model (cached value).
private  java.util.Set<Pin> inputpins_
           
private  ModelOfComputation<T> moc_
          The model of computation of this model.
private  java.util.Set<Pin> outputpins_
           
private  InterfaceBlock parent_
          The interface block this model belongs to (if any, null otherwise).
private  BlockStructure structure_
          The structure that holds the blocks of this model.
 
Constructor Summary
Model(java.lang.String name, ModelOfComputation<T> moc, BlockStructure s, java.lang.Object... properties)
          Build a new model.
Model(java.lang.String name, ModelOfComputation<T> moc, java.lang.Object... properties)
          Build a model, automatically creating the corresponding block structure.
 
Method Summary
<B extends Block>
B
add(B b)
          Add a block to this model.
 Relation connect(Pin mine, Pin other)
          Connect one of my pins to another pin.
 Relation connectFromInterfaceBlock(InterfaceBlock intfBlock, Pin other, Pin mine)
          Connect pin other of InterfaceBlock intfBlock to my pin mine.
 Relation connectFromModel(Model<?> model, Pin other, Pin mine)
          Connect pin other of Model model to my pin mine.
 Relation connectFromRegularBlock(Block block, Pin other, Pin mine)
          Connect pin other of regular Block block to my pin mine.
 Relation createRelation(Pin source, Pin target)
          Connect two pins in this model.
 void emitObservationRequests()
          Emit observation request for future snapshots by creating ticks on clocks.
 void endOfSnapshot()
          End of the observation round, the observable can update its internal state.
 void endOfUpdate()
          End of a partial update (produce partial outputs to the outer model).
 Engine getEngine()
          Get the execution engine which is in charge of executing this model.
 java.util.Collection<Pin> getInputPins()
          Get the input pins of this entity.
 ModelOfComputation<T> getMoC()
          Return the model of computation in which this entity is observed.
 java.util.Collection<Pin> getOutputPins()
          Get the output ins of this entity.
 InterfaceBlock getParent()
           
 BlockStructure getStructure()
           
 void prep()
          Initialize the entity.
 void reset()
          Reset the computation of the outputs and next state for the current snapshot.
 void sanityCheck()
          Perform sanity check before setup.
 void setEngine(Engine e)
           
 void setParent(InterfaceBlock b)
          Set the interface block that contains this model.
 void setup()
          Prepare for the simulation.
 void startOfSnapshot()
          Start a new snapshot (observation round).
 void startOfUpdate()
          Start a partial update (get partial inputs from the outer model).
 void update()
          Update the interface of the observable: take inputs into account, update outputs.
 boolean validate()
          Validate the computation of the observation.
 void wrapup()
          Cleanup at the end of the simulation.
 
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

moc_

private ModelOfComputation<T extends java.lang.Comparable<? super T>> moc_
The model of computation of this model.


structure_

private BlockStructure structure_
The structure that holds the blocks of this model.


parent_

private InterfaceBlock parent_
The interface block this model belongs to (if any, null otherwise).


engine_

private Engine engine_
The execution engine in charge of the execution of this model (cached value).


inputpins_

private java.util.Set<Pin> inputpins_

outputpins_

private java.util.Set<Pin> outputpins_
Constructor Detail

Model

public Model(java.lang.String name,
             ModelOfComputation<T> moc,
             BlockStructure s,
             java.lang.Object... properties)
Build a new model.

Parameters:
name - name of the model
moc - model of computation of the model
s - block structure of the model

Model

public Model(java.lang.String name,
             ModelOfComputation<T> moc,
             java.lang.Object... properties)
Build a model, automatically creating the corresponding block structure.

Method Detail

add

public <B extends Block> B add(B b)
Add a block to this model.


createRelation

public Relation createRelation(Pin source,
                               Pin target)
Connect two pins in this model.


connect

public Relation connect(Pin mine,
                        Pin other)
Connect one of my pins to another pin.

Specified by:
connect in class ObservableEntity

connectFromModel

public Relation connectFromModel(Model<?> model,
                                 Pin other,
                                 Pin mine)
Connect pin other of Model model to my pin mine.

Specified by:
connectFromModel in class ObservableEntity

connectFromRegularBlock

public Relation connectFromRegularBlock(Block block,
                                        Pin other,
                                        Pin mine)
Connect pin other of regular Block block to my pin mine.

Specified by:
connectFromRegularBlock in class ObservableEntity

connectFromInterfaceBlock

public Relation connectFromInterfaceBlock(InterfaceBlock intfBlock,
                                          Pin other,
                                          Pin mine)
Connect pin other of InterfaceBlock intfBlock to my pin mine.

Specified by:
connectFromInterfaceBlock in class ObservableEntity

setParent

public void setParent(InterfaceBlock b)
Set the interface block that contains this model.


getParent

public InterfaceBlock getParent()
Specified by:
getParent in interface Model

getEngine

public Engine getEngine()
Get the execution engine which is in charge of executing this model.


setEngine

public void setEngine(Engine e)

getMoC

public ModelOfComputation<T> getMoC()
Description copied from class: ObservableEntity
Return the model of computation in which this entity is observed.

Specified by:
getMoC in interface Model
Specified by:
getMoC in class ObservableEntity

getStructure

public BlockStructure getStructure()
Specified by:
getStructure in interface Model

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

sanityCheck

public void sanityCheck()
Description copied from class: ObservableEntity
Perform sanity check before setup.

Specified by:
sanityCheck in class ObservableEntity

setup

public void setup()
Description copied from class: ObservableEntity
Prepare for the simulation. Called after prep, before the first step of the simulation.

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

reset

public void reset()
Description copied from class: ObservableEntity
Reset the computation of the outputs and next state for the current snapshot.

Specified by:
reset in class ObservableEntity

update

public void update()
Description copied from class: ObservableEntity
Update the interface of the observable: take inputs into account, update outputs.

Specified by:
update 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

endOfSnapshot

public void endOfSnapshot()
Description copied from class: ObservableEntity
End of the observation round, the observable can update its internal state.

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

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

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

getInputPins

public java.util.Collection<Pin> getInputPins()
Description copied from class: ObservableEntity
Get the input pins of this entity.

Specified by:
getInputPins in class ObservableEntity

getOutputPins

public java.util.Collection<Pin> getOutputPins()
Description copied from class: ObservableEntity
Get the output ins of this entity.

Specified by:
getOutputPins in class ObservableEntity