modhelxs.mocs.sdf
Class SDFMoC

java.lang.Object
  extended by modhelxs.abstractsemantics.NamedEntity
      extended by modhelxs.abstractsemantics.ModelOfComputation<T>
          extended by modhelxs.abstractsemantics.ModelOfComputationImpl<Unit>
              extended by modhelxs.mocs.sdf.SDFMoC
All Implemented Interfaces:
ModelOfComputation, NamedEntity

public class SDFMoC
extends ModelOfComputationImpl<Unit>


Nested Class Summary
private  class SDFMoC.RelationState
           
 
Field Summary
private  Block current_block_
           
static java.lang.String INITTOKENS_PROPERTY
          Name of the property of pin that do not depend instantaneously on the behavior of their block.
private  java.util.List<Pin> model_inputs_
          List of model pins that are connected to block inputs
private  java.util.List<Pin> model_outputs_
          List of block pins that are connected to model outputs
static java.lang.String PINRATE_PROPERTY
           
private  java.util.Iterator<Block> schedule_
           
private  java.util.List<Block> scheduled_blocks_
          Schedule of the blocks (sorted in topological order and appearing as many times as they must be updated).
private  Clock<Unit> sdf_clock_
          The observation clock of SDF.
 
Constructor Summary
SDFMoC(java.lang.String name)
           
 
Method Summary
private static void addRelationStateToPinMap(java.util.HashMap<Pin,java.util.List<SDFMoC.RelationState>> map, Pin p, SDFMoC.RelationState rs)
           
 boolean canGoFurther(BlockStructure s)
          Tell if it is possible to compute more information.
 void emitObservationRequests(BlockStructure s)
          Place ticks on clocks to request to be observed in future snapshots.
 void endOfUpdate(BlockStructure s)
          Called at the end of an update of an inner block (produce partial outputs for the upper model).
private static int gcd(int a, int b)
           
 Clock<Unit> getClock()
          Get the observation clock of this MoC.
 Unit getCurrentTime()
          Get the current time of this MoC.
static int getNumberOfInitialTokens(Pin p)
          Get number of initial tokens on pin p.
static int getPinRate(Pin p)
          Get production/consumption rate for pin p.
static boolean hasInitialTokens(Pin p)
          Tell if pin p has initial tokens.
 void propagate(BlockStructure s)
          Propagate new information produced by the update of a block.
private static void propagateFromPin(Pin p)
           
 void reset(BlockStructure s)
          Reset for a new computation of the current snapshot (called at least once at the beginning of the snapshot).
 void schedule(BlockStructure s)
          Choose a block to be updated.
static void setNumberOfInitialTokens(Pin p, int n)
          Set number of initial tokens on pin p.
static void setPinRate(Pin p, int rate)
          Set production/consumption rate for pin p.
 void setup(BlockStructure s)
          Setup for simulation.
 void startOfUpdate(BlockStructure s)
          Called at the beginning of an update of an inner block (get partial inputs from the upper model).
 void update(BlockStructure s)
          Update a block.
 
Methods inherited from class modhelxs.abstractsemantics.ModelOfComputationImpl
createToken, duplicateToken, endOfSnapshot, getTokenValue, prep, setTokenValue, startOfSnapshot, validate, wrapup
 
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.NamedEntity
getName, getProperties, setName
 

Field Detail

INITTOKENS_PROPERTY

public static final java.lang.String INITTOKENS_PROPERTY
Name of the property of pin that do not depend instantaneously on the behavior of their block.

See Also:
Constant Field Values

PINRATE_PROPERTY

public static final java.lang.String PINRATE_PROPERTY
See Also:
Constant Field Values

sdf_clock_

private Clock<Unit> sdf_clock_
The observation clock of SDF.


scheduled_blocks_

private java.util.List<Block> scheduled_blocks_
Schedule of the blocks (sorted in topological order and appearing as many times as they must be updated).


schedule_

private java.util.Iterator<Block> schedule_

current_block_

private Block current_block_

model_inputs_

private java.util.List<Pin> model_inputs_
List of model pins that are connected to block inputs


model_outputs_

private java.util.List<Pin> model_outputs_
List of block pins that are connected to model outputs

Constructor Detail

SDFMoC

public SDFMoC(java.lang.String name)
Method Detail

getClock

public Clock<Unit> getClock()
Description copied from class: ModelOfComputation
Get the observation clock of this MoC.

Specified by:
getClock in class ModelOfComputation<Unit>

getCurrentTime

public Unit getCurrentTime()
Description copied from class: ModelOfComputation
Get the current time of this MoC.

Specified by:
getCurrentTime in class ModelOfComputation<Unit>

hasInitialTokens

public static boolean hasInitialTokens(Pin p)
Tell if pin p has initial tokens.


getNumberOfInitialTokens

public static int getNumberOfInitialTokens(Pin p)
Get number of initial tokens on pin p.


setNumberOfInitialTokens

public static void setNumberOfInitialTokens(Pin p,
                                            int n)
Set number of initial tokens on pin p.


getPinRate

public static int getPinRate(Pin p)
Get production/consumption rate for pin p.


setPinRate

public static void setPinRate(Pin p,
                              int rate)
Set production/consumption rate for pin p.


addRelationStateToPinMap

private static void addRelationStateToPinMap(java.util.HashMap<Pin,java.util.List<SDFMoC.RelationState>> map,
                                             Pin p,
                                             SDFMoC.RelationState rs)

gcd

private static int gcd(int a,
                       int b)

setup

public void setup(BlockStructure s)
Description copied from class: ModelOfComputation
Setup for simulation. Called after prep, before the first snapshot.

Overrides:
setup in class ModelOfComputationImpl<Unit>
Parameters:
s - the block structure of the model driven by this MoC

reset

public void reset(BlockStructure s)
Description copied from class: ModelOfComputation
Reset for a new computation of the current snapshot (called at least once at the beginning of the snapshot).

Overrides:
reset in class ModelOfComputationImpl<Unit>

schedule

public void schedule(BlockStructure s)
Description copied from class: ModelOfComputation
Choose a block to be updated.

Specified by:
schedule in class ModelOfComputation<Unit>

update

public void update(BlockStructure s)
Description copied from class: ModelOfComputation
Update a block.

Specified by:
update in class ModelOfComputation<Unit>

propagateFromPin

private static void propagateFromPin(Pin p)

propagate

public void propagate(BlockStructure s)
Description copied from class: ModelOfComputation
Propagate new information produced by the update of a block.

Specified by:
propagate in class ModelOfComputation<Unit>

canGoFurther

public boolean canGoFurther(BlockStructure s)
Description copied from class: ModelOfComputation
Tell if it is possible to compute more information.

Specified by:
canGoFurther in class ModelOfComputation<Unit>

emitObservationRequests

public void emitObservationRequests(BlockStructure s)
Description copied from class: ModelOfComputation
Place ticks on clocks to request to be observed in future snapshots.

Overrides:
emitObservationRequests in class ModelOfComputationImpl<Unit>

startOfUpdate

public void startOfUpdate(BlockStructure s)
Description copied from class: ModelOfComputation
Called at the beginning of an update of an inner block (get partial inputs from the upper model).

Specified by:
startOfUpdate in class ModelOfComputation<Unit>

endOfUpdate

public void endOfUpdate(BlockStructure s)
Description copied from class: ModelOfComputation
Called at the end of an update of an inner block (produce partial outputs for the upper model).

Specified by:
endOfUpdate in class ModelOfComputation<Unit>