demos.semantic_adaptation
Class DE_SDF_LinInterpolator

java.lang.Object
  extended by modhelxs.abstractsemantics.NamedEntity
      extended by modhelxs.abstractsemantics.ObservableEntity
          extended by modhelxs.abstractsemantics.Block
              extended by modhelxs.abstractsemantics.InterfaceBlock
                  extended by modhelxs.state_management.ManagedInterfaceBlock
                      extended by modhelxs.state_management.TimedManagedInterfaceBlock<java.lang.Double,java.lang.Double>
                          extended by demos.semantic_adaptation.DE_SDF_LinInterpolator
All Implemented Interfaces:
Block, InterfaceBlock, NamedEntity, ObservableEntity

public class DE_SDF_LinInterpolator
extends TimedManagedInterfaceBlock<java.lang.Double,java.lang.Double>

This is a special interface block (IB) between DE and SDF that can react to threshold crossing on the outputs of its internal SDF model. For each output with a "threshold" property, the IB compares the current and previous values produces by the internal model to the threshold. If the threshold was crossed from below to above, an event with value +1 is produced. If the threshold was crossed from above to below, an event with value -1 is produced. If the output also has a "precision" property, it gives the precision required on the date of the event. So, if the threshold was crossed, and the time elapsed between the linearly estimated crossing time t and the current time is greater than the precision, the snapshot is not validated, and a tick is added to the control clock of the IB to make the next update occur at t. Since the snapshot has not been validated, this next update will occur during the same snapshot. This means that the DE time will change. Since we cannot update the SDF model at any time, the IB computes the current value of the outputs by linear interpolation between the previous and current values, without updating the internal SDF model.

Author:
boulange

Field Summary
private  TransientValue<java.lang.Boolean> backtrack_
          Should we backtrack in time to interpolate an output?
private  MapAttribute<Pin,java.lang.Object> inputPinValue_
          Current value of each input pin.
private  TransientValue<java.lang.Double> interpolation_time_
          Time at which the upper bounds in interpolationTable_ were reached.
private  TransientMap<Pin,java.lang.Object> interpolationTable_
          Upper bound of the value of the output pins of the internal model in an interpolation step.
private  Attribute<java.lang.Double> last_update_time_
          The last update time of this interface block, including interpolation updates.
private  MapAttribute<Pin,java.lang.Object> outputPinValue_
          Current value of each output pin.
private  Parameter<java.lang.Double> update_period_
          The update period of the internal SDF model.
 
Constructor Summary
DE_SDF_LinInterpolator(java.lang.String name, Model<Unit> internalModel, java.lang.Object... properties)
           
 
Method Summary
 void adaptIn()
          Adapt data, time and control from the outer model to the inner one.
 void adaptOut()
          Adapt data, time and control from the inner model to the outer one.
 void doEndOfSnapshot()
          The endOfSnapshot behavior of the interface block.
 void doGhostUpdate()
          The update behavior of the interface block when the internal model is not updated.
 void doPostUpdate()
          The update behavior of the interface block after updating the internal model.
 void doPreUpdate()
          The update behavior of the interface block before updating the internal model.
 void doSetup()
          The setup behavior of the block.
 boolean validate()
          Validate the computation of the observation.
 
Methods inherited from class modhelxs.state_management.TimedManagedInterfaceBlock
advanceNextInternalObservationTime, advanceNextInternalObservationTime, advanceNextObservationTime, advanceNextObservationTime, doPreSetup, doReset, doStartOfSnapshot, emitObservationRequests, getNextInternalObservationTime, getNextObservationTime, getTimeOfRequest, hasObservationRequest, internalObservationClock, nextInternalObsTimeAttribute, nextObsTimeAttribute, observationClock, setNextInternalObservationTime, setNextObservationTime, shouldUpdateModel
 
Methods inherited from class modhelxs.state_management.ManagedInterfaceBlock
endOfSnapshot, endOfUpdate, initFromProperties, internalWasUpdated, reset, setup, startOfSnapshot, startOfUpdate, update, wasUpdated
 
Methods inherited from class modhelxs.abstractsemantics.InterfaceBlock
connect, connectFromModel, createAdaptationRelation, getAdaptation, getInputPins, getInternalModel, getOutputPins, prep, wrapup
 
Methods inherited from class modhelxs.abstractsemantics.Block
connectFromInterfaceBlock, connectFromRegularBlock, getEngine, getMoC, getParent, getSolver, 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.Block
getParent
 
Methods inherited from interface modhelxs.ecore.ObservableEntity
getInterface
 
Methods inherited from interface modhelxs.ecore.NamedEntity
getName, getProperties, setName
 

Field Detail

inputPinValue_

private MapAttribute<Pin,java.lang.Object> inputPinValue_
Current value of each input pin.


outputPinValue_

private MapAttribute<Pin,java.lang.Object> outputPinValue_
Current value of each output pin.


backtrack_

private TransientValue<java.lang.Boolean> backtrack_
Should we backtrack in time to interpolate an output?


interpolationTable_

private TransientMap<Pin,java.lang.Object> interpolationTable_
Upper bound of the value of the output pins of the internal model in an interpolation step.


interpolation_time_

private TransientValue<java.lang.Double> interpolation_time_
Time at which the upper bounds in interpolationTable_ were reached.


update_period_

private Parameter<java.lang.Double> update_period_
The update period of the internal SDF model.


last_update_time_

private Attribute<java.lang.Double> last_update_time_
The last update time of this interface block, including interpolation updates.

Constructor Detail

DE_SDF_LinInterpolator

public DE_SDF_LinInterpolator(java.lang.String name,
                              Model<Unit> internalModel,
                              java.lang.Object... properties)
Method Detail

doSetup

public void doSetup()
Description copied from class: ManagedInterfaceBlock
The setup behavior of the block.

Specified by:
doSetup in class ManagedInterfaceBlock

adaptIn

public void adaptIn()
Description copied from class: InterfaceBlock
Adapt data, time and control from the outer model to the inner one.

Specified by:
adaptIn in class InterfaceBlock

doPreUpdate

public void doPreUpdate()
Description copied from class: ManagedInterfaceBlock
The update behavior of the interface block before updating the internal model.

Specified by:
doPreUpdate in class ManagedInterfaceBlock

doPostUpdate

public void doPostUpdate()
Description copied from class: ManagedInterfaceBlock
The update behavior of the interface block after updating the internal model.

Specified by:
doPostUpdate in class ManagedInterfaceBlock

doGhostUpdate

public void doGhostUpdate()
Description copied from class: ManagedInterfaceBlock
The update behavior of the interface block when the internal model is not updated.

Specified by:
doGhostUpdate in class ManagedInterfaceBlock

adaptOut

public void adaptOut()
Description copied from class: InterfaceBlock
Adapt data, time and control from the inner model to the outer one.

Specified by:
adaptOut in class InterfaceBlock

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.

Overrides:
validate in class InterfaceBlock

doEndOfSnapshot

public void doEndOfSnapshot()
Description copied from class: ManagedInterfaceBlock
The endOfSnapshot behavior of the interface block.

Specified by:
doEndOfSnapshot in class ManagedInterfaceBlock