fr.emn.reactiveinput.devices
Class DAutoRepeat

java.lang.Object
  extended byfr.emn.reactiveinput.AbstractDevice
      extended byfr.emn.reactiveinput.AbstractMutableDevice
          extended byfr.emn.reactiveinput.devices.DAutoRepeat
All Implemented Interfaces:
Device, MutableDevice, Processor

public class DAutoRepeat
extends AbstractMutableDevice


Field Summary
 In in
           
 In on
           
 Out out
           
 
Fields inherited from class fr.emn.reactiveinput.AbstractDevice
currIndex, ins, outs
 
Fields inherited from interface fr.emn.reactiveinput.Device
AUTO_PROPERTIES
 
Constructor Summary
DAutoRepeat()
           
 
Method Summary
 int getDelay()
           
 Slot[] getMutationTriggers()
          Returns the mutation triggers for this mutable device, i.e. all input or output slots that trigger a mutation when it is connected to another type.
 int getPeriod()
           
 boolean hasExternalInput()
          Specifies whether this device has external (implicit) input or not.
 boolean isOpenable()
          USE: Design.
 void mutate()
          Performs a mutation on this device.
 Processor open(OpenContext context)
          Ensures that the device will be ready for processing or producing data, and returns the Processor object that will process data, or null if an error occured.
 void setDelay(int newDelay)
           
 void setPeriod(int newPeriod)
           
protected static long time()
           
 
Methods inherited from class fr.emn.reactiveinput.AbstractMutableDevice
addMutableIn, addMutableIn, addMutableIn, addMutableOut, addMutableOut, remove
 
Methods inherited from class fr.emn.reactiveinput.AbstractDevice
addIn, addIn, addOut, close, copy, doDisable, doEnable, finalize, getError, getIndex, getInfo, getIns, getName, getOuts, getProperties, hasExternalOutput, init, insertAt, insertAtEnd, insertBefore, isCopiable, isEnabled, setEnabled, setInfo, setInfo, setLastError, setName, update
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface fr.emn.reactiveinput.Device
close, copy, getError, getInfo, getIns, getName, getOuts, getProperties, hasExternalOutput, isCopiable, setEnabled
 

Field Detail

in

public final In in

on

public final In on

out

public final Out out
Constructor Detail

DAutoRepeat

public DAutoRepeat()
Method Detail

getDelay

public int getDelay()
Returns:
int

getMutationTriggers

public Slot[] getMutationTriggers()
Description copied from class: AbstractMutableDevice
Returns the mutation triggers for this mutable device, i.e. all input or output slots that trigger a mutation when it is connected to another type.

Specified by:
getMutationTriggers in interface MutableDevice
Specified by:
getMutationTriggers in class AbstractMutableDevice

getPeriod

public int getPeriod()
Returns:
int

hasExternalInput

public boolean hasExternalInput()
Description copied from interface: Device
Specifies whether this device has external (implicit) input or not.

Returns false if the device is deterministic from the data & time points of view, i.e. if its output production only depend on the explicit input history (input slots) and device's initial configuration. This is the case of most of the processing devices.

Return trues if output values do not only depend on the values of input slots, or if output production takes undefined time. Examples of devices with external input are input peripherals and asynchronous devices.

This method is used by the reactive machine to determine if this device is triggered by its input slots, or if it must be triggered continuously (i.e. each tick). This method can also be used by the editor for the device's graphical representation.

Specified by:
hasExternalInput in interface Device
Overrides:
hasExternalInput in class AbstractDevice

isOpenable

public boolean isOpenable()
Description copied from interface: Device
USE: Design.

This method returns false if the device is not openable because it is not properly configured (e.g. important input slots are not connected). Reactive machines ignore devices that are not openable.

Use this method if you want some pre-conditions to be verified before the execution of your device, inside init() and update() methods.

In the default method provided in DeviceUtilities, isOpenable() returns false if one or several obligatory input slots are not valid (see In.isValid()). You may add your own pre-conditions to this method.

Example :

public boolean isOpenable() { if (DeviceUtilities.defaultIsOpenable(this)) { // Verify default pre-conditions if (...) // Put additional pre-conditions here return true; } return false; }

Specified by:
isOpenable in interface Device
Overrides:
isOpenable in class AbstractDevice

mutate

public void mutate()
Performs a mutation on this device. This method is called when a connection is made (or deleted) on a mutation trigger.

Specified by:
mutate in interface MutableDevice
Specified by:
mutate in class AbstractMutableDevice

open

public Processor open(OpenContext context)
Description copied from interface: Device
Ensures that the device will be ready for processing or producing data, and returns the Processor object that will process data, or null if an error occured.

Some devices may need to perform some more or less heavy initialization (such as allocating resources or opening a stream) before being able to process or produce data. This is the case for most input devices, and some I/O and output devices. All these initializations must be done in the open() method.

Because these initializations are subject to fail, open() may return null even if isOpenable() returns true. In all cases, returning a non-null Processor means that the device is now able to process or produce data.

RE-OPENING A DEVICE:

Devices always stay open during reconfiguration, in order to avoid unnecessary deallocation and reallocation of resources. However, some devices will need to be re-open before re-starting the configuration. So open() is always called on all devices before re-starting.

If open() is called on a device that is already open, it may have no effect (and the current Processor is returned), or the device may be re-open if something has changed in its configuration.

Using a Processor as a return value allows the use of different processors, each adapted to a specific device configuration.

Specified by:
open in interface Device
Overrides:
open in class AbstractDevice
See Also:
Processor, Device.open()

setDelay

public void setDelay(int newDelay)
Parameters:
newDelay - int

setPeriod

public void setPeriod(int newPeriod)
Parameters:
newPeriod - int

time

protected static long time()
Returns:
int