jcontrol.comm.eia709
Class Eia709NetworkVariable

java.lang.Object
  extended by jcontrol.comm.eia709.Eia709NetworkVariable
All Implemented Interfaces:
NetworkVariable

public class Eia709NetworkVariable
extends Object
implements NetworkVariable

The Eia709NetworkVariable class is the main communication interface for running EIA-709 controllets. The methods provided allow to read and modify the current value of a network variable, to propagate the value over the network and to poll network variables for updates.

A NetworkVariableListener can be attached to the network variable to keep updated on value changes and remote write accesses.

In EIA-709, a network variable features a number of properties or modifiers. The term modifier derives from the manner in which network variables are declared in Neuron C. Like in ANSI C, in neuron C modifiers are added to a variable by just writing them in their declaration. The absence of a modifier will cause default behaviour in the functional group.

The folowing table shows the different functional groups, the possible values and default values:

valuesdefault
directionMOD_DIR_OUTGOING, MOD_DIR_INCOMINGMOD_DIR_OUTGOING
propagationMOD_SYNC, MOD_POLLEDMOD_SYNC
constMOD_CONST---
storageMOD_RAM, MOD_EEPROM*MOD_RAM
serviceMOD_SERVICE_UNACKD, MOD_SERVICE_UNACKD_RPT, MOD_SERVICE_ACKDMOD_SERVICE_UNACKD
service configMOD_SERVICE_CONFIG*, MOD_SERVICE_NONCONFIGMOD_SERVICE_NONCONFIG
priorityMOD_PRIORITY, MOD_NONPRIORITYMOD_NONPRIORITY
priority configMOD_PRIORITY_CONFIG*, MOD_PRIORITY_NONCONFIGMOD_PRIORITY_NONCONFIG
authenticationMOD_AUTH*, MOD_NONAUTHMOD_NONAUTH
authentication configMOD_AUTH_CONFIG*, MOD_AUTH_NONCONFIGMOD_AUTH_NONCONFIG
* not supported in this version

See Also:
NetworkVariableListener, NetworkVariableEvent

Field Summary
static int MASK_MOD_DIR
          Masks out the direction information from a modifer value.
static int MASK_MOD_SERVICE
          Masks out the service bits from a modifier value.
static int MOD_AUTH
          Modifier 'autheticated': network variables with this modifier use authenticated datagrams
Note: not supported in this version
static int MOD_AUTH_CONFIG
          Modifier '(config)' for authentication modifiers: network variable authentication can be changed at runtime (default)
Note: not supported in this version
static int MOD_AUTH_NONCONFIG
          Modifier '(nonconfig)' for authentication modifiers: network variable authentication can not be changed at runtime (default)
Note: not supported in this version
static int MOD_CHANGEABLE_TYPE
          Modifier 'changeable_typ': the data type of network variables with this modifier can be changed at runtime
Note: not supported in this version
static int MOD_CONST
          Modifier 'const': network variables with this modifier cannot be changed locally
static int MOD_DIR_INCOMING
          Modifier 'out': network variables with this modifer act as outgoing variables.
static int MOD_DIR_OUTGOING
          Modifier 'in': network variables with this modifer act as incoming variables.
static int MOD_EEPROM
          Modifier 'eeprom': values of network variables with this modifier are stored in persistant memory Note: not supported in this version
static int MOD_NONAUTH
          Modifier 'nonautheticated': network variables with this modifier use non-authenticated datagrams (default)
Note: not supported in this version
static int MOD_NONPRIORITY
          Modifier 'nonpriority': network variables with this modifier use non-priority datagrams for value transmission (default)
static int MOD_POLLED
          Modifier 'polled': network variables with this modifier have to propagated
static int MOD_PRIORITY
          Modifier 'priority': network variables with this modifier use priority datagrams for value transmission
static int MOD_PRIORITY_CONFIG
          Modifier '(nonconfig)' for priority modifiers: network variable priority can be changed at runtime
Note: not supported in this version
static int MOD_PRIORITY_NONCONFIG
          Modifier '(nonconfig)' for priority modifiers: network variable priority can not be changed at runtime (default)
Note: not supported in this version
static int MOD_RAM
          Modifier 'eeprom': values of network variables with this modifier are stored in persistant memory Note: not supported in this version
static int MOD_SERVICE_ACKD
          Modifier 'ackd': network variables with this modifier use the ACKD transmission service
static int MOD_SERVICE_CONFIG
          Modifier '(config)' for service modifiers: network variable transmission service can be changed at runtime
Note: not supported in this version
static int MOD_SERVICE_NONCONFIG
          Modifier '(nonconfig)' for service modifiers: network variable transmission service can not be changed at runtime (default)
Note: not supported in this version
static int MOD_SERVICE_UNACKD
          Modifier 'unackd': network variables with this modifier use the UNACKD transmission service (default)
static int MOD_SERVICE_UNACKD_RPT
          Modifier 'unackd_rpt': network variables with this modifier use the UNACKD_RPT transmission service
static int MOD_SYNC
          Modifier 'synchronized': network variables with this modifier will be automatically propagated
static int TYPE_SNVT_COLOR
          Variable type 'SNVT_color'.
static int TYPE_SNVT_FREQ_F
          Variable type 'SNVT_freq_f'.
static int TYPE_SNVT_FREQ_HZ
          Variable type 'SNVT_freq_hz'.
static int TYPE_SNVT_SWITCH
          Variable type 'SNVT_switch'.
static int TYPE_SNVT_TEMP
          Variable type 'SNVT_temp'.
 
Constructor Summary
Eia709NetworkVariable(Eia709Node node, String identifier, int type, int size, int modifier)
          Creates a new network variable default self description.
Eia709NetworkVariable(Eia709Node node, String identifier, int type, int size, int modifier, String selfDescription)
          Creates a new network variable.
 
Method Summary
 Eia709Address getAddress()
          Returns the address.
 DataInputStream getDataInputStream()
          Returns a DataInputStream for reading from the network variable value.
 DataOutputStream getDataOutputStream()
          Returns a DataOutputStream for writing to the network variable value.
 int getDataType()
          Returns the NVs data type.
 int getDirection()
          Returns the direction
 String getIdString()
          Returns the network variable ID string.
 int getModifier()
          Returns the network variable modifier.
 Eia709Node getNode()
          Returns the node associated with this network variable.
 int getSelector()
          Returns selector.
 String getSelfDescription()
          Returns this network variable's self description.
 byte[] getValue()
          Returns the current value.
 void notifyListeners(NetworkVariableEvent event)
          Notify all connected Listeners about an event.
 void poll()
          Polls the network variable.
 void propagate()
          Propagates the network variable.
 void setAddress(Eia709Address address)
          Sets the NVs peer address.
 void setListener(NetworkVariableListener listener)
          Attaches a listener.
 void setSelector(int selector)
          Sets the NVs selector.
 void setValue(byte[] value)
          Sets the value.
protected  void updateValue()
          Internal method, do not call directly.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, notifyAll, toString, wait
 

Field Detail

MOD_SYNC

public static final int MOD_SYNC
Modifier 'synchronized': network variables with this modifier will be automatically propagated

See Also:
Constant Field Values

MOD_POLLED

public static final int MOD_POLLED
Modifier 'polled': network variables with this modifier have to propagated

See Also:
Constant Field Values

MOD_CHANGEABLE_TYPE

public static final int MOD_CHANGEABLE_TYPE
Modifier 'changeable_typ': the data type of network variables with this modifier can be changed at runtime
Note: not supported in this version

See Also:
Constant Field Values

MOD_CONST

public static final int MOD_CONST
Modifier 'const': network variables with this modifier cannot be changed locally

See Also:
Constant Field Values

MOD_RAM

public static final int MOD_RAM
Modifier 'eeprom': values of network variables with this modifier are stored in persistant memory Note: not supported in this version

See Also:
Constant Field Values

MOD_EEPROM

public static final int MOD_EEPROM
Modifier 'eeprom': values of network variables with this modifier are stored in persistant memory Note: not supported in this version

See Also:
Constant Field Values

MOD_SERVICE_UNACKD

public static final int MOD_SERVICE_UNACKD
Modifier 'unackd': network variables with this modifier use the UNACKD transmission service (default)

See Also:
MOD_SERVICE_UNACKD_RPT, MOD_SERVICE_ACKD, Constant Field Values

MOD_SERVICE_UNACKD_RPT

public static final int MOD_SERVICE_UNACKD_RPT
Modifier 'unackd_rpt': network variables with this modifier use the UNACKD_RPT transmission service

See Also:
MOD_SERVICE_UNACKD, MOD_SERVICE_ACKD, Constant Field Values

MOD_SERVICE_ACKD

public static final int MOD_SERVICE_ACKD
Modifier 'ackd': network variables with this modifier use the ACKD transmission service

See Also:
MOD_SERVICE_UNACKD, MOD_SERVICE_UNACKD_RPT, Constant Field Values

MASK_MOD_SERVICE

public static final int MASK_MOD_SERVICE
Masks out the service bits from a modifier value.

See Also:
Constant Field Values

MOD_SERVICE_NONCONFIG

public static final int MOD_SERVICE_NONCONFIG
Modifier '(nonconfig)' for service modifiers: network variable transmission service can not be changed at runtime (default)
Note: not supported in this version

See Also:
MOD_SERVICE_CONFIG, Constant Field Values

MOD_SERVICE_CONFIG

public static final int MOD_SERVICE_CONFIG
Modifier '(config)' for service modifiers: network variable transmission service can be changed at runtime
Note: not supported in this version

See Also:
MOD_SERVICE_NONCONFIG, Constant Field Values

MOD_NONPRIORITY

public static final int MOD_NONPRIORITY
Modifier 'nonpriority': network variables with this modifier use non-priority datagrams for value transmission (default)

See Also:
MOD_PRIORITY, Constant Field Values

MOD_PRIORITY

public static final int MOD_PRIORITY
Modifier 'priority': network variables with this modifier use priority datagrams for value transmission

See Also:
MOD_NONPRIORITY, Constant Field Values

MOD_PRIORITY_NONCONFIG

public static final int MOD_PRIORITY_NONCONFIG
Modifier '(nonconfig)' for priority modifiers: network variable priority can not be changed at runtime (default)
Note: not supported in this version

See Also:
MOD_PRIORITY_CONFIG, Constant Field Values

MOD_PRIORITY_CONFIG

public static final int MOD_PRIORITY_CONFIG
Modifier '(nonconfig)' for priority modifiers: network variable priority can be changed at runtime
Note: not supported in this version

See Also:
MOD_PRIORITY_NONCONFIG, Constant Field Values

MOD_NONAUTH

public static final int MOD_NONAUTH
Modifier 'nonautheticated': network variables with this modifier use non-authenticated datagrams (default)
Note: not supported in this version

See Also:
MOD_AUTH, Constant Field Values

MOD_AUTH

public static final int MOD_AUTH
Modifier 'autheticated': network variables with this modifier use authenticated datagrams
Note: not supported in this version

See Also:
MOD_NONAUTH, Constant Field Values

MOD_AUTH_NONCONFIG

public static final int MOD_AUTH_NONCONFIG
Modifier '(nonconfig)' for authentication modifiers: network variable authentication can not be changed at runtime (default)
Note: not supported in this version

See Also:
MOD_AUTH_CONFIG, Constant Field Values

MOD_AUTH_CONFIG

public static final int MOD_AUTH_CONFIG
Modifier '(config)' for authentication modifiers: network variable authentication can be changed at runtime (default)
Note: not supported in this version

See Also:
MOD_AUTH_NONCONFIG, Constant Field Values

MASK_MOD_DIR

public static final int MASK_MOD_DIR
Masks out the direction information from a modifer value.

See Also:
Constant Field Values

MOD_DIR_OUTGOING

public static final int MOD_DIR_OUTGOING
Modifier 'in': network variables with this modifer act as incoming variables.

See Also:
Constant Field Values

MOD_DIR_INCOMING

public static final int MOD_DIR_INCOMING
Modifier 'out': network variables with this modifer act as outgoing variables.

See Also:
Constant Field Values

TYPE_SNVT_TEMP

public static final int TYPE_SNVT_TEMP
Variable type 'SNVT_temp'.

See Also:
Constant Field Values

TYPE_SNVT_COLOR

public static final int TYPE_SNVT_COLOR
Variable type 'SNVT_color'.

See Also:
Constant Field Values

TYPE_SNVT_FREQ_F

public static final int TYPE_SNVT_FREQ_F
Variable type 'SNVT_freq_f'.

See Also:
Constant Field Values

TYPE_SNVT_FREQ_HZ

public static final int TYPE_SNVT_FREQ_HZ
Variable type 'SNVT_freq_hz'.

See Also:
Constant Field Values

TYPE_SNVT_SWITCH

public static final int TYPE_SNVT_SWITCH
Variable type 'SNVT_switch'.

See Also:
Constant Field Values
Constructor Detail

Eia709NetworkVariable

public Eia709NetworkVariable(Eia709Node node,
                             String identifier,
                             int type,
                             int size,
                             int modifier)
Creates a new network variable default self description.

Parameters:
node - associated node
identifier - network variable identifier (must not be null)
type - variable type (basic types, SNVTs or UNVTs)
size - value size
modifier - variable modifiers (see the list of valid modifiers in this class)

Eia709NetworkVariable

public Eia709NetworkVariable(Eia709Node node,
                             String identifier,
                             int type,
                             int size,
                             int modifier,
                             String selfDescription)
Creates a new network variable.

Parameters:
node - associated node
identifier - network variable identifier (must not be null)
type - variable type (basic types, SNVTs or UNVTs)
size - value size
modifier - variable modifiers (see the list of valid modifiers in this class)
selfDescription - self description string (may be null)
Method Detail

setValue

public void setValue(byte[] value)
              throws IOException
Description copied from interface: NetworkVariable
Sets the value. If the variable is OUTGOING and possesses the "sync" modifier, the value is automatically propagated to the address.

Specified by:
setValue in interface NetworkVariable
Parameters:
value - new value
Throws:
IOException - in case of I/O errors

getValue

public byte[] getValue()
Returns the current value.

Specified by:
getValue in interface NetworkVariable
Returns:
value

propagate

public void propagate()
               throws IOException
Propagates the network variable.

Specified by:
propagate in interface NetworkVariable
Throws:
IOException

setListener

public void setListener(NetworkVariableListener listener)
Attaches a listener.

Specified by:
setListener in interface NetworkVariable
Parameters:
listener - listener
See Also:
NetworkVariableEvent

notifyListeners

public void notifyListeners(NetworkVariableEvent event)
Notify all connected Listeners about an event.

Specified by:
notifyListeners in interface NetworkVariable
Parameters:
event - event to pass to listeners

setSelector

public void setSelector(int selector)
Sets the NVs selector.

Parameters:
selector - EIA-709 network variable selector
See Also:
Eia709Constants.MIN_NV_SELECTOR, Eia709Constants.MAX_NV_SELECTOR

updateValue

protected void updateValue()
Internal method, do not call directly.


getNode

public Eia709Node getNode()
Returns the node associated with this network variable.

Returns:
node

getSelector

public int getSelector()
Returns selector.

Returns:
selector

setAddress

public void setAddress(Eia709Address address)
Sets the NVs peer address.

Parameters:
address - address

getAddress

public Eia709Address getAddress()
Returns the address.

Returns:
address

getDirection

public int getDirection()
Returns the direction

Returns:
MOD_DIR_OUTGOING or MOD_DIR_INCOMING

getModifier

public int getModifier()
Returns the network variable modifier.

Returns:
network variable modifier

getSelfDescription

public String getSelfDescription()
Returns this network variable's self description.

Returns:
self description

getIdString

public String getIdString()
Returns the network variable ID string.

Returns:
ID string

getDataType

public int getDataType()
Returns the NVs data type.

Returns:
data type

poll

public void poll()
          throws IOException
Polls the network variable.

Specified by:
poll in interface NetworkVariable
Throws:
IOException

getDataOutputStream

public DataOutputStream getDataOutputStream()
Returns a DataOutputStream for writing to the network variable value. The DataOutputStream can be used to write complex data structures to a network variable value. After the modification of the value it can be propagated by calling the propagate() method.
Example:
 DataOutputStream out = nv.getDataOutputStream();
 out.writeInt( 0x123456); // write a 4-byte integer value
 out.writeFloat( 1.2f);   // write a 4-byte floating point value
 nv.propagate();          // propagate value
 

Specified by:
getDataOutputStream in interface NetworkVariable
Returns:
DataOutputStream
See Also:
getDataInputStream(), propagate()

getDataInputStream

public DataInputStream getDataInputStream()
Returns a DataInputStream for reading from the network variable value. The DataInputStream can be used to read complex data structures from a network variable value.
Example:
 DataInputStream in = nv.getDataInputStream();
 int i = in.readInt();       // read a 4-byte integer value
 float f = in.readFloat();   // read a 4-byte floating point value
 

Specified by:
getDataInputStream in interface NetworkVariable
Returns:
DataInputStream
See Also:
getDataOutputStream()