|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object fr.emn.reactiveinput.Configuration
The Configuration class contains all connection & mutation methods for one input configuration.
Using this class is forbidden during execution.
Warning: This class is not thread-safe.
Field Summary | |
protected boolean |
autoMutation
|
static int |
COMPATIBLE_ALWAYS
A type-compatible connection |
static int |
COMPATIBLE_FOR_NOW
A type-compatible connection, but which may become incompatible if one of the slots mutates |
static int |
INCOMPATIBLE_ALWAYS
A type-incompatible connection |
static int |
INCOMPATIBLE_FOR_NOW
A type-incompatible connection, but which may become compatible if one of the slots mutates |
int |
maxIterations
The max. number of iterations when performing mutations. |
protected java.util.Vector |
mutationCache
|
protected java.util.Hashtable |
mutationCounter
|
Constructor Summary | |
Configuration(OpenContext context)
Creates a new empty configuration with default folders. |
|
Configuration(OpenContext context,
DeviceFolder rootFolder)
Creates a new empty configuration with the given root folder. context may be null. |
|
Configuration(OpenContext context,
DeviceFolder rootFolder,
java.io.File icFile)
Creates a configuration from an .ic file. |
|
Configuration(OpenContext context,
DeviceFolder rootFolder,
java.lang.String configurationScript)
Creates a configuration from a String script. |
Method Summary | |
Device |
add(Device d)
Adds a device to this Configuration. |
void |
addListener(ConfigurationListener c)
Listener management |
MissingIn |
addMissingIn(java.lang.String fullInAlias)
Creates and adds a MissingIn instance. |
MissingOut |
addMissingOut(java.lang.String fullOutAlias)
Creates and adds a MissingOut instance. |
boolean |
canConnect(Slot slot1,
Slot slot2)
Returns true if a connection can be made between given slots, disregard the compatibility between them. |
boolean |
canConnect(Slot slot1,
Slot slot2,
Slot disconnect1,
Slot disconnect2)
Returns true if a connection can be made between given slots, after the given link has been disconnected. |
void |
clear()
Clear all except root folder |
void |
close()
Closes all the devices. |
boolean |
connect(Slot slot1,
Slot slot2)
Connects this input slot to an output slot. |
void |
disconnect(Device d)
|
boolean |
disconnect(In in)
Same as connect(in, null). |
boolean |
disconnect(Out out)
Removes all connections from this slot. |
void |
eventDispatched(java.awt.AWTEvent event)
Listen to Ctrl-C events |
protected void |
finalize()
Closes all devices |
Device |
findDevice(DeviceDescriptor descriptor)
Returns the first available device matching the given descriptor in the root folder. |
Device |
findDevice(java.lang.String descriptor)
Returns the first available device matching the given descriptor in the root folder. |
Device[] |
findDeviceMatch(DeviceDescriptor[] descriptors)
Find an array of devices matching the given array of descriptors, with distinct declared slots. |
Device[] |
findDeviceMatch(java.lang.String descriptors)
Find an array of devices matching the given list of descriptors, with distinct declared slots. |
Device[] |
findDevices(DeviceDescriptor descriptor)
Returns all available devices matching the given descriptor in the root folder. |
Device[] |
findDevices(java.lang.String descriptor)
Returns all available devices matching the given descriptor in the root folder. |
protected void |
fireConfigurationStarted()
|
protected void |
fireConfigurationStopped()
|
protected void |
fireDeviceFailed(Device d)
|
protected void |
fireDeviceOpened(Device d)
|
java.lang.String |
getAlias(Device d)
Returns the alias that has been assigned to the device, or null if the device has no alias. |
java.lang.String |
getAlias(Slot s)
Returns the single alias of the slot, or null if the slot has no alias. |
static int |
getCompatibility(Slot slot1,
Slot slot2)
Returns the type of compatibility between those 2 slots. |
java.lang.String |
getConfigurationScript()
Creates the script for this configuration |
Device[] |
getConnectedDevices(Device d)
|
OpenContext |
getContext()
|
java.lang.String |
getCustomDescription(Device obj)
Returns contextual description on object. |
java.lang.String |
getCustomDescription(Slot obj)
Returns contextual description on object. |
java.lang.String |
getCustomHelp(Device obj)
Returns contextual help on object. |
java.lang.String |
getCustomHelp(Slot obj)
Returns contextual help on object. |
DeviceDescriptor |
getCustomSignature(Device d)
|
DeviceDescriptor |
getDefaultSignature(Device d)
Builds a default signature for the device d. |
Device |
getDevice(java.lang.String alias)
Returns the device having the given alias. |
Device[] |
getDevices()
Returns all devices used in this configuration. |
int |
getFrequency()
|
java.lang.String |
getFullAlias(Slot s)
Returns the full slot alias (devAlias.slotAlias). |
ConfigurationInfo |
getInfo()
|
protected MissingIn |
getMissingIn(Device d,
java.lang.String name)
Retreive a missing slot by its parent device & slot name |
MissingIn[] |
getMissingIns(Device d)
|
protected MissingOut |
getMissingOut(Device d,
java.lang.String name)
Retreive a missing slot by its parent device & slot name |
MissingOut[] |
getMissingOuts(Device d)
|
java.lang.String |
getOriginalFileScript()
|
java.lang.String |
getOriginalScript()
Returns the whole script that was used to create this configuration. |
DeviceFolder |
getRootFolder()
Returns the folder containing all devices ready to use in this configuration. |
Slot |
getSlot(java.lang.String fullSlotAlias,
boolean inSlot,
boolean outSlot)
Returns the slot having the given full alias (devAlias.slotAlias). |
java.io.File |
getSourceFile()
Returns the file this configuration is associated to, if this configuration was previously loaded from disk or saved to disk. |
Configuration[] |
getSubConfigurations()
Returns subconfigurations from compound devices |
static boolean |
isConnected(In in,
Out out)
Returns true if slots are connected. |
boolean |
isIndirectSuccessor(Device before,
Device after)
Returns true if "after" is dependent on "before". |
boolean |
isStarted()
|
boolean |
isSuccessor(Device before,
Device after)
Returns true if there exists a direct connection between a "before" output and an "after" input. |
boolean |
load(java.io.File icFile)
Creates a configuration from an .ic file. |
void |
load(java.lang.String configurationScript)
Fills the configuration from a String script. |
void |
mutate(MutableDevice d)
Force a single device to mutate without propagating mutations. |
Device[][] |
open()
Prepares the execution of reactive machine. |
Device[][] |
open(boolean createMachines)
|
MutableDevice[] |
performMutations()
Trigger all cached mutations. |
void |
remove(Device d)
Removes a device from this Configuration. |
void |
removeListener(ConfigurationListener c)
|
boolean |
save(java.io.File icfFile)
Saves this configuration to an .icf file. |
boolean |
save(java.io.File icfFile,
java.lang.String additionalScript)
Saves this configuration to an .icf file. |
void |
setAlias(Device d,
java.lang.String alias)
Sets/replaces a device alias. |
void |
setAlias(Slot s,
java.lang.String alias)
Sets/replaces a slot alias. |
void |
setAutoMutation(boolean auto)
Sets whether mutations must be performed automatically at each change on connections (connect/disconnect). |
void |
setContext(OpenContext context)
|
void |
setCustomDescription(Device obj,
java.lang.String value)
Assigns a custom contextual description to the device. |
void |
setCustomDescription(Slot obj,
java.lang.String value)
Assigns a custom contextual description to the slot. |
void |
setCustomHelp(Device obj,
java.lang.String value)
Assigns a custom contextual help to the device. |
void |
setCustomHelp(Slot obj,
java.lang.String value)
Assigns a custom contextual help to the slot. |
void |
setCustomSignature(Device d,
DeviceDescriptor signature)
Assigns a signature to the device, to override the getDefaultSignature() method. |
void |
setCustomSignature(Device d,
java.lang.String signature)
Assigns a signature to the device, to override the getDefaultSignature() method. |
void |
setFrequency(int freq)
|
void |
setInfo(ConfigurationInfo info)
|
void |
setInfo(java.lang.String description,
java.lang.String help)
|
void |
setRootFolder(DeviceFolder rootFolder)
|
void |
setSourceFile(java.io.File sourceFile)
Sets the sourceFile. |
void |
start()
Starts running the configuration. |
void |
start(boolean withAnalysis)
Starts running the configuration. |
double |
startBenchmark(int loops)
|
void |
stop()
Stops running the configuration. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int INCOMPATIBLE_ALWAYS
public static final int INCOMPATIBLE_FOR_NOW
public static final int COMPATIBLE_FOR_NOW
public static final int COMPATIBLE_ALWAYS
protected final java.util.Vector mutationCache
protected final java.util.Hashtable mutationCounter
public int maxIterations
protected boolean autoMutation
Constructor Detail |
public Configuration(OpenContext context)
The OpenContext argument will be passed to the devices as the open context. This argument may be null, however some devices will really need a OpenContext argument to run.
public Configuration(OpenContext context, DeviceFolder rootFolder)
public Configuration(OpenContext context, DeviceFolder rootFolder, java.io.File icFile)
public Configuration(OpenContext context, DeviceFolder rootFolder, java.lang.String configurationScript)
Method Detail |
public Device add(Device d)
public MissingIn addMissingIn(java.lang.String fullInAlias)
This method is automatically called by load() if slots are missing while performing connections. Call this method if you want to preserve connections even if devices or slots are missing. Missing devices/slots may appear in graphical editors, in order to be replaced by the user.
This method also displays a warning message in standard output.
public MissingOut addMissingOut(java.lang.String fullOutAlias)
This method is automatically called by load() if slots are missing while performing connections. Call this method if you want to preserve connections even if devices or slots are missing. Missing devices/slots may appear in graphical editors, in order to be replaced by the user.
This method also displays a warning message in standard output.
public java.io.File getSourceFile()
public boolean canConnect(Slot slot1, Slot slot2)
This method returns true only if: - One slot is In and the other is Out - We are in design mode (configuration is not started), - These slots belong to existing devices (have not been removed from device) - These devices do not already belong to another configuration, - The connection does not generate a cycle.
out can be equal to null (this means disconnecting a slot).
public boolean canConnect(Slot slot1, Slot slot2, Slot disconnect1, Slot disconnect2)
public void clear()
public boolean connect(Slot slot1, Slot slot2)
Devices are automatically added to this configuration.
Call connect(in, null) to disconnect.
public void disconnect(Device d)
public boolean disconnect(In in)
public boolean disconnect(Out out)
protected void finalize()
public Device findDevice(DeviceDescriptor descriptor)
See Finder.findDevice(DeviceFolder, DeviceDescriptor).
public Device findDevice(java.lang.String descriptor)
See Finder.findDevice(DeviceFolder, DeviceDescriptor).
public Device[] findDeviceMatch(DeviceDescriptor[] descriptors)
See Finder.findDeviceMatch(DeviceFolder, DeviceDescriptor[]) and getDeclared... methods.
public Device[] findDeviceMatch(java.lang.String descriptors)
See Finder.findDeviceMatch(DeviceFolder, DeviceDescriptor[]) and getDeclared... methods.
public Device[] findDevices(DeviceDescriptor descriptor)
See Finder.findDevices(DeviceFolder, DeviceDescriptor).
public Device[] findDevices(java.lang.String descriptor)
See Finder.findDevices(DeviceFolder, DeviceDescriptor).
public java.lang.String getAlias(Device d)
public java.lang.String getAlias(Slot s)
public static int getCompatibility(Slot slot1, Slot slot2)
public java.lang.String getConfigurationScript()
public Device[] getConnectedDevices(Device d)
public OpenContext getContext()
public java.lang.String getCustomDescription(Device obj)
public java.lang.String getCustomDescription(Slot obj)
public java.lang.String getCustomHelp(Device obj)
public java.lang.String getCustomHelp(Slot obj)
public DeviceDescriptor getCustomSignature(Device d)
public DeviceDescriptor getDefaultSignature(Device d)
public Device getDevice(java.lang.String alias)
public Device[] getDevices()
public java.lang.String getFullAlias(Slot s)
The slot name is used if slot has no alias.
public ConfigurationInfo getInfo()
public MissingIn[] getMissingIns(Device d)
protected MissingIn getMissingIn(Device d, java.lang.String name)
public MissingOut[] getMissingOuts(Device d)
protected MissingOut getMissingOut(Device d, java.lang.String name)
public java.lang.String getOriginalScript()
A configuration only uses the 'Devices' and 'Connections' sections of the script. Applications such as graphical configuration editors may need to retreive their own section.
Returns null if this Configuration was not created from a script or a file.
public java.lang.String getOriginalFileScript()
public DeviceFolder getRootFolder()
public Slot getSlot(java.lang.String fullSlotAlias, boolean inSlot, boolean outSlot)
public static boolean isConnected(In in, Out out)
public boolean isIndirectSuccessor(Device before, Device after)
public boolean isStarted()
public boolean isSuccessor(Device before, Device after)
public boolean load(java.io.File icFile)
public void load(java.lang.String configurationScript)
public void mutate(MutableDevice d)
public MutableDevice[] performMutations()
public void remove(Device d)
public boolean save(java.io.File icfFile)
public boolean save(java.io.File icfFile, java.lang.String additionalScript)
public void setAlias(Device d, java.lang.String alias)
Device aliases are used in the 'Connections' part of the configuration script. Each declared device must have a unique alias. If you don't provide alias values, default aliases will be assigned to your devices when a script is generated from your configuration.
This method is automatically called in load() methods.
public void setAlias(Slot s, java.lang.String alias)
Slot aliases are used in the 'Connections' part of the configuration script. Slot aliases are optional in configuration scripts, because slot names are unique inside a device. When no alias is provided, the slot name is used for referencing the slot.
This method is automatically called in load() methods.
public void setAutoMutation(boolean auto)
If auto mutation is set to false, you must call performMutations() each time it is necessary.
Auto mutation is set to true by default.
public void setContext(OpenContext context)
public void setCustomDescription(Device obj, java.lang.String value)
public void setCustomDescription(Slot obj, java.lang.String value)
public void setCustomHelp(Device obj, java.lang.String value)
public void setCustomHelp(Slot obj, java.lang.String value)
public void setCustomSignature(Device d, DeviceDescriptor signature)
public void setCustomSignature(Device d, java.lang.String signature)
public void setInfo(ConfigurationInfo info)
public void setInfo(java.lang.String description, java.lang.String help)
public void setRootFolder(DeviceFolder rootFolder)
public int getFrequency()
public void setFrequency(int freq)
public Configuration[] getSubConfigurations()
public Device[][] open()
Opens all the devices in this configuration, and return successfully opened devices, or null if a cycle was found. Call this method just before start(). PENDING: Change state changing algorithm or reopen all
public Device[][] open(boolean createMachines)
public void close()
public void start()
IMPORTANT: You must call open() method just before calling start().
public void start(boolean withAnalysis)
IMPORTANT: You must call open() method just before calling start().
public double startBenchmark(int loops)
public void stop()
public void eventDispatched(java.awt.AWTEvent event)
eventDispatched
in interface java.awt.event.AWTEventListener
public void setSourceFile(java.io.File sourceFile)
sourceFile
- The sourceFile to setpublic void addListener(ConfigurationListener c)
public void removeListener(ConfigurationListener c)
protected void fireDeviceOpened(Device d)
protected void fireDeviceFailed(Device d)
protected void fireConfigurationStarted()
protected void fireConfigurationStopped()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |