|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface NetworkVariable
A network variable is a variable that is shared by different nodes in a communication network. A classic example could be a switch that contain a variable reflecting its state. The state can be changed locally (by physically handling the switch) or remotely over the network, for instance from a different switch that serves the same purpose.
Network variables provide a convenient application interface for distributed application. While some protocols (EIA-709) already provide their own network variable interface, any protocol specification can be abstracted to network variables, making distributed applications work almost independently of the communication protocol.
The JControl network variable implementation uses an event/listener system to keep applications updated on network variable changes.
NetworkVariableEvent
,
NetworkVariableListener
Method Summary | |
---|---|
DataInputStream |
getDataInputStream()
Returns a DataInputStream for reading from the network variable value. |
DataOutputStream |
getDataOutputStream()
Returns a DataOutputStream for writing to the network variable value. |
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 |
setListener(NetworkVariableListener listener)
Attaches a listener to this network variable. |
void |
setValue(byte[] value)
Sets the value. |
Method Detail |
---|
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
getDataInputStream()
,
propagate()
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
getDataOutputStream()
byte[] getValue()
void poll() throws IOException
IOException
- in case of I/O errorsvoid propagate() throws IOException
IOException
- in case of I/O errorsvoid setValue(byte[] value) throws IOException
value
- new value
IOException
- in case of I/O errorsvoid setListener(NetworkVariableListener listener)
networkVariableChanged()
method will be invoked whenever the value of a network variable gets updated. As parameter it
receives a NetworkVariableEvent
.
listener
- listenerNetworkVariableEvent
void notifyListeners(NetworkVariableEvent event)
event
- event to pass to listeners
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |