cdev
Class Device

java.lang.Object
  |
  +--cdev.Device
Direct Known Subclasses:
DeviceArray

public class Device
extends java.lang.Object

This class represents the device abstraction in the cdev Java paradigm. Devices have properties which can be set or retrieved via synchronous or asynchronous methods (determined by argument type):

Devices can also be sent messages using any of three methods. Four basic messages are currently implemented for any property. A message may contain a keyword (verb) and one additional word naming the property. No limit is set on the number of words in a message for non-property based I/O. The keywords are the same as the property methods: See the user documentation for more details about use of messages and format.

See Also:
Data, DeviceContext

Field Summary
static Data CONTROL_CTX
           
static Data MONITOR_CTX
           
static Data VALUE_CTX
           
 
Constructor Summary
Device(java.lang.String dname)
           
Device(java.lang.String dname, ControlSystem sys)
           
 
Method Summary
 DeviceError get(java.lang.String property, Data result)
          Initiate synchronous get of property value.
 void get(java.lang.String property, DeviceListener listener)
          Initiate asynchronous get of property value.
 DeviceError getCharacteristic(java.lang.String property, java.lang.String characteristic, Data data)
          Initiate synchronous get value of a property's characteristic .
 void getCharacteristic(java.lang.String property, java.lang.String characteristic, DeviceListener listener)
          Initiate an asynchronous get value of a property's characteristic.
 DeviceContext getContext()
          Return a reference to the context associated with the device.
 ControlSystem getControlSystem()
          Return the reference to the ControlSystem associated with the device.
 DeviceClass getDeviceClass()
          Returns the reference to the deviceClass this device belongs to.
 java.lang.String getName()
          Return the name of the device.
 DeviceError getReference(java.lang.String property, Data result)
          Initiate synchronous get of property reference value.
 void getReference(java.lang.String property, DeviceListener listener)
          Initiate asynchronous get of property reference value.
 java.lang.Object getServiceData()
           
 void monitorOff(java.lang.String property, DeviceListener listener)
          Terminate asynchronous subscription to property value.
 void monitorOn(java.lang.String property, DeviceListener listener)
          Initiate asynchronous subscription to property value.
 boolean needCycleType()
          Returns true if the I/O may require a cycle type.
 boolean needCycleType(java.lang.String propertyName)
          Returns true if the I/O with this property requires a cycle type.
 void send(java.lang.String message, Data data, Callback handler)
          Deprecated. Use send with DeviceListener instead.
 DeviceError send(java.lang.String message, Data data, Data result)
          Initiate a synchronous "send" transaction.
 void send(java.lang.String message, Data data, DeviceListener listener)
          Initiate a transaction that delivers results to a listener when the reply is returned from the server.
 void sendNoBlock(java.lang.String message, Data data, Data result)
          Initiate asynchronous transaction that delivers data to Data object.
 DeviceError set(java.lang.String property, Data data)
          Initiate synchronous set of property value.
 void set(java.lang.String property, Data data, DeviceListener listener)
          Initiate asynchronous set of property value.
 void setContext(Data data)
          (Deprecated; use setContext (DeviceContext ctx) instead) Set the context for the device.
 void setContext(DeviceContext ctx)
          Set the context for the device.
 DeviceError setReference(java.lang.String property, Data data)
          Initiate synchronous set of property reference value.
 void setReference(java.lang.String property, Data data, DeviceListener listener)
          Initiate asynchronous set of property reference value.
 void setServiceData(java.lang.Object sd)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTROL_CTX

public static Data CONTROL_CTX

MONITOR_CTX

public static Data MONITOR_CTX

VALUE_CTX

public static Data VALUE_CTX
Constructor Detail

Device

public Device(java.lang.String dname)
       throws java.io.IOException

Device

public Device(java.lang.String dname,
              ControlSystem sys)
       throws java.io.IOException
Method Detail

get

public void get(java.lang.String property,
                DeviceListener listener)
         throws java.io.IOException
Initiate asynchronous get of property value. If the value is is not received within TIMEOUT seconds, an error is returned.
Parameters:
property - The name of the property
listener - Reference to the device listener to receive value

get

public DeviceError get(java.lang.String property,
                       Data result)
                throws java.io.IOException
Initiate synchronous get of property value. If the value is is not received within TIMEOUT seconds, an error is returned.
Parameters:
property - The name of the property
result - Reference to the data object to receive the result
Returns:
DeviceError reference, or null if no errors

set

public void set(java.lang.String property,
                Data data,
                DeviceListener listener)
         throws java.io.IOException
Initiate asynchronous set of property value. An acknowledgement is delivered to the listener when a response is received. If a response is not received within TIMEOUT seconds, an error is returned.
Parameters:
property - The name of the property
data - Data object containing the value.
listener - The device listener object to receive the response.

set

public DeviceError set(java.lang.String property,
                       Data data)
                throws java.io.IOException
Initiate synchronous set of property value. If a response is not received within TIMEOUT seconds, an error is returned.
Parameters:
property - The name of the property
data - Data object containing the value.
Returns:
DeviceError reference, or null if no errors

monitorOn

public void monitorOn(java.lang.String property,
                      DeviceListener listener)
               throws java.io.IOException
Initiate asynchronous subscription to property value. If a value is is not received within TIMEOUT seconds, an error is returned.
Parameters:
property - The name of the property
listener - Reference to the device listener to receive the results
Returns:
DeviceError reference, or null if no errors

monitorOff

public void monitorOff(java.lang.String property,
                       DeviceListener listener)
                throws java.io.IOException
Terminate asynchronous subscription to property value.
Parameters:
property - The name of the property
listener - Reference to the device listener to receive the results
Returns:
DeviceError reference, or null if no errors

send

public void send(java.lang.String message,
                 Data data,
                 DeviceListener listener)
          throws java.io.IOException
Initiate a transaction that delivers results to a listener when the reply is returned from the server.
Parameters:
message - The message to send to the server.
dataIn - The data to send with the message.
listener - The listener object to receive results.

send

public DeviceError send(java.lang.String message,
                        Data data,
                        Data result)
                 throws java.io.IOException
Initiate a synchronous "send" transaction. This method will return the sooner of receiving a reply or the default time period expires. When returning as a result of timeout, the result will be unchanged from what was passed in.
Parameters:
message - The message to send to the server.
data - The data to send with the message.
result - Reference to data to return from the server.
Returns:
The status from the transaction.

sendNoBlock

public void sendNoBlock(java.lang.String message,
                        Data data,
                        Data result)
                 throws java.io.IOException
Initiate asynchronous transaction that delivers data to Data object.
Parameters:
message - The message to send to the server.
data - The data to send with the message.
result - Reference to data to receive result from the server.

send

public void send(java.lang.String message,
                 Data data,
                 Callback handler)
          throws java.io.IOException
Deprecated. Use send with DeviceListener instead.


getReference

public DeviceError getReference(java.lang.String property,
                                Data result)
                         throws java.io.IOException
Initiate synchronous get of property reference value. If the value is not received within TIMEOUT seconds, an error is returned.
Parameters:
property - The name of the property
result - Reference to the data object to receive the result
Returns:
DeviceError reference, or null if no errors

getReference

public void getReference(java.lang.String property,
                         DeviceListener listener)
                  throws java.io.IOException
Initiate asynchronous get of property reference value. If the value is is not received within TIMEOUT seconds, an error is returned.
Parameters:
property - The name of the property
listener - Reference to the device listener to receive value

setReference

public void setReference(java.lang.String property,
                         Data data,
                         DeviceListener listener)
                  throws java.io.IOException
Initiate asynchronous set of property reference value. An acknowledgement is delivered to the listener when a response is received. If a response is not received within TIMEOUT seconds, an error is returned.
Parameters:
property - The name of the property
data - Data object containing the value.
listener - The device listener object to receive the response.

setReference

public DeviceError setReference(java.lang.String property,
                                Data data)
                         throws java.io.IOException
Initiate synchronous set of property reference value. If a response is not received within TIMEOUT seconds, an error is returned.
Parameters:
property - The name of the property
data - Data object containing the value.
Returns:
DeviceError reference, or null if no errors

getCharacteristic

public DeviceError getCharacteristic(java.lang.String property,
                                     java.lang.String characteristic,
                                     Data data)
                              throws java.io.IOException
Initiate synchronous get value of a property's characteristic . If a response is not received within TIMEOUT seconds, an error is returned.
Parameters:
property - The name of the property
characteristic - The name of the characteristic
data - Data object containing the value returned.
Returns:
DeviceError reference, or null if no errors

getCharacteristic

public void getCharacteristic(java.lang.String property,
                              java.lang.String characteristic,
                              DeviceListener listener)
                       throws java.io.IOException
Initiate an asynchronous get value of a property's characteristic. An acknowledgement is delivered to the listener when a response is received. If a response is not received within TIMEOUT seconds, an error is returned.
Parameters:
property - The name of the property
characteristic - The name of the characteristic
listener - The device listener object to receive the response.

getName

public java.lang.String getName()
Return the name of the device.

getControlSystem

public ControlSystem getControlSystem()
Return the reference to the ControlSystem associated with the device.

getContext

public DeviceContext getContext()
Return a reference to the context associated with the device.

setContext

public void setContext(DeviceContext ctx)
Set the context for the device.
Parameters:
ctx - Data object containing context items

setContext

public void setContext(Data data)
(Deprecated; use setContext (DeviceContext ctx) instead) Set the context for the device.
Parameters:
data - Data object containing context items

getServiceData

public java.lang.Object getServiceData()

setServiceData

public void setServiceData(java.lang.Object sd)

getDeviceClass

public DeviceClass getDeviceClass()
                           throws DataNotFoundException
Returns the reference to the deviceClass this device belongs to.
Throws:
DataNotFoundException - if no directory service, no device data or no device class defined.

needCycleType

public boolean needCycleType()
                      throws DataNotFoundException
Returns true if the I/O may require a cycle type.
Throws:
DataNotFoundException - if no directory service or no device data

needCycleType

public boolean needCycleType(java.lang.String propertyName)
                      throws DataNotFoundException
Returns true if the I/O with this property requires a cycle type.