fr.emn.reactiveinput.devices
Class DVirtualUser

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

public class DVirtualUser
extends AbstractMutableDevice
implements RecordCacheListener

Titre :

Description :

Copyright : Copyright (c) 2002

Société :

Version:
1.0
Author:
non attribuable

Field Summary
static RecordCache cache
           
protected  SlotEvent[] currentEvents
           
 In currentTime
           
protected  SlotDefinition[] definitions
           
protected  java.util.LinkedList events
           
protected  java.util.Iterator eventsIterator
           
protected  java.io.File file
           
 int MAX_SLOTS
           
 int MIN_SLOTS
           
protected  int numSlots
           
 Out[] outs
           
 In play
           
protected  long replayStartTime
           
 In reset
           
protected  long startTime
           
 
Fields inherited from class fr.emn.reactiveinput.AbstractDevice
currIndex, ins
 
Fields inherited from interface fr.emn.reactiveinput.Device
AUTO_PROPERTIES
 
Constructor Summary
DVirtualUser()
           
 
Method Summary
 void cacheUpdated(java.lang.Object k)
           
 void close()
          Closes the device.
 java.io.File getFile()
           
 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 getSpeedFactor()
           
 boolean hasExternalInput()
          Specifies whether this device has external (implicit) input or not.
 void init()
          Initializes device's output values.
 boolean isReadyForCache()
           
 void mutate()
          Perform 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.
protected  void resetPlay()
           
 void setFile(java.io.File f)
           
 void setSpeedFactor(int s)
           
 void update()
          Updates device's output values.
 
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, copy, doDisable, doEnable, finalize, getError, getIndex, getInfo, getIns, getName, getOuts, getProperties, hasExternalOutput, insertAt, insertAtEnd, insertBefore, isCopiable, isEnabled, isOpenable, setEnabled, setInfo, setInfo, setLastError, setName
 
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
copy, getError, getInfo, getIns, getName, getOuts, getProperties, hasExternalOutput, isCopiable, isOpenable, setEnabled
 

Field Detail

cache

public static RecordCache cache

MIN_SLOTS

public final int MIN_SLOTS
See Also:
Constant Field Values

MAX_SLOTS

public final int MAX_SLOTS
See Also:
Constant Field Values

currentTime

public final In currentTime

play

public final In play

reset

public final In reset

outs

public Out[] outs

definitions

protected SlotDefinition[] definitions

numSlots

protected int numSlots

currentEvents

protected SlotEvent[] currentEvents

eventsIterator

protected java.util.Iterator eventsIterator

events

protected java.util.LinkedList events

file

protected java.io.File file

startTime

protected long startTime

replayStartTime

protected long replayStartTime
Constructor Detail

DVirtualUser

public DVirtualUser()
Method Detail

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

isReadyForCache

public boolean isReadyForCache()
Specified by:
isReadyForCache in interface RecordCacheListener

cacheUpdated

public void cacheUpdated(java.lang.Object k)
Specified by:
cacheUpdated in interface RecordCacheListener

getSpeedFactor

public int getSpeedFactor()

setSpeedFactor

public void setSpeedFactor(int s)

getFile

public java.io.File getFile()

setFile

public void setFile(java.io.File f)

mutate

public void mutate()
Description copied from class: AbstractMutableDevice
Perform a mutation on this device. This method is called when a connection is made (or deleted) on an entry point.

Add mutation code here.

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

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

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()

close

public void close()
Description copied from interface: Device
Closes the device. Called when the device is not used any more.

Deallocate resources here.

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

resetPlay

protected void resetPlay()

init

public void init()
Description copied from class: AbstractDevice
Initializes device's output values.

Subclass init() and update() methods if you want the device to process the data itself. Otherwise, subclass getProcessor() method to use extern processors. By default, this method calls update(). Subclass this method if you'd like to make a specific initialization routine.

Specified by:
init in interface Processor
Overrides:
init in class AbstractDevice
See Also:
Processor.init()

update

public void update()
Description copied from class: AbstractDevice
Updates device's output values.

Subclass init() and update() methods if you want the device to process the data itself. Otherwise, subclass getProcessor() method to use extern processors.

Specified by:
update in interface Processor
Overrides:
update in class AbstractDevice
See Also:
Processor.update()