org.indi.server
Class BasicDevice

java.lang.Object
  extended by org.indi.server.BasicDevice
All Implemented Interfaces:
org.indi.reactor.TimerCallback, Device, ObserverCallback
Direct Known Subclasses:
ExternalDevice

public class BasicDevice
extends java.lang.Object
implements Device

Basic implementation of the device interface. Each device driver usually inherits from this class.

Author:
Dirk Hünniger

Field Summary
protected  java.lang.String name
          the name of this driver
protected  java.util.Set<Observer> observers
          A set registered observers, obsering changes of this device
protected  IndiServer server
          the indiserver instance that this driver interacting with
 
Constructor Summary
BasicDevice(IndiServer server)
          class constructor
 
Method Summary
 void def(org.indi.objects.Vector vector)
          Send a def vector message to all interested clients.
 void def(org.indi.objects.Vector vector, java.lang.String message)
          Shortcut to send a def vector message to all interested clients
 void del(org.indi.objects.Vector vector)
          Send a del vector message to all interested clients.
 void del(org.indi.objects.Vector vector, java.lang.String message)
          Shortcut to send a del vector message to all interested clients
 java.lang.String getName()
           
 void msg(java.lang.String message)
          Shortcut to send a message to all interested clients
 void onGetProperties(org.indi.clientmessages.GetProperties o)
          called by the server when a new GetProperties (request to send all defXXX messages) is received from the a client.
 void onNew(org.indi.objects.BlobVector vector)
          called by the server when a new BLOB is received from the a client.
 void onNew(org.indi.objects.NumberVector vector)
          called by the server when a new NumberVector (request to set the state of a number) is received from the a client.
 void onNew(org.indi.objects.SwitchVector vector)
          called by the server when a new SwitchVector (request to set the state of a switch) is received from the a client.
 void onNew(org.indi.objects.TextVector vector)
          called by the server when a new TestVector (request to set the state of a text) is received from the a client.
 void onObserved(org.indi.objects.Vector vector)
          called by the indiserver when a property for which an for with a observer was install via the subscibe method has changed
 void onTimer()
          called by the reactor when the a timer registered with this callback expires
 void sendToClients(org.indi.objects.Object object, org.indi.objects.TransferType type, java.lang.String message)
          Send to the given object to all interested clients
 void set(org.indi.objects.Vector vector)
          Send a set vector message to all interested clients.
 void set(org.indi.objects.Vector vector, java.lang.String message)
          Shortcut to send a set vector message to all interested clients
 Observer subscribe(java.lang.String device, java.lang.String name, ObserverState state)
          Register a new observer callback with the server.
 void timer(long timeout)
          register a timer such the onTimer will be called after the given timeout
 void unsubscribe(Observer o)
          remove the given observer.
 void unsubscribe(java.lang.String device, java.lang.String name)
          cancel the callback(s) for state or value changes for the property defined by the name of the device and the name of the property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

server

protected IndiServer server
the indiserver instance that this driver interacting with


name

protected java.lang.String name
the name of this driver


observers

protected java.util.Set<Observer> observers
A set registered observers, obsering changes of this device

Constructor Detail

BasicDevice

public BasicDevice(IndiServer server)
class constructor

Parameters:
server - the indiserver to interact with
Method Detail

onNew

public void onNew(org.indi.objects.SwitchVector vector)
called by the server when a new SwitchVector (request to set the state of a switch) is received from the a client.

Specified by:
onNew in interface Device
Parameters:
vector - the vector received from the client

onNew

public void onNew(org.indi.objects.NumberVector vector)
called by the server when a new NumberVector (request to set the state of a number) is received from the a client.

Specified by:
onNew in interface Device
Parameters:
vector - the vector received from the client

onNew

public void onNew(org.indi.objects.BlobVector vector)
called by the server when a new BLOB is received from the a client.

Specified by:
onNew in interface Device
Parameters:
vector - the vector received from the client

onNew

public void onNew(org.indi.objects.TextVector vector)
called by the server when a new TestVector (request to set the state of a text) is received from the a client.

Specified by:
onNew in interface Device
Parameters:
vector - the vector received from the client

onGetProperties

public void onGetProperties(org.indi.clientmessages.GetProperties o)
called by the server when a new GetProperties (request to send all defXXX messages) is received from the a client.

Specified by:
onGetProperties in interface Device
Parameters:
o - the GetProperties message received from the client

onTimer

public void onTimer()
called by the reactor when the a timer registered with this callback expires

Specified by:
onTimer in interface org.indi.reactor.TimerCallback

subscribe

public Observer subscribe(java.lang.String device,
                          java.lang.String name,
                          ObserverState state)
Register a new observer callback with the server. The method onObserved of this class will be called whenever the given property changes.

Parameters:
device - The name of the device to observe
name - The name of the property to observe
state - The observerstate object destribing to listen for state or value changes or both.
Returns:
The newly created obserer object describing that this object is to be called back if the observed property changes

unsubscribe

public void unsubscribe(Observer o)
remove the given observer. Thus cancel the callbacks for state or value changes

Parameters:
o - The obsever object to describing the subscibtrion to be canceled

unsubscribe

public void unsubscribe(java.lang.String device,
                        java.lang.String name)
cancel the callback(s) for state or value changes for the property defined by the name of the device and the name of the property.

Parameters:
device - The name of the device
name - The name of the property

def

public void def(org.indi.objects.Vector vector,
                java.lang.String message)
Shortcut to send a def vector message to all interested clients

Parameters:
vector - The vector to be send
message - The message string to be sent with the vector

set

public void set(org.indi.objects.Vector vector,
                java.lang.String message)
Shortcut to send a set vector message to all interested clients

Parameters:
vector - The vector to be send
message - The message string to be sent with the vector

del

public void del(org.indi.objects.Vector vector,
                java.lang.String message)
Shortcut to send a del vector message to all interested clients

Parameters:
vector - The vector to be send
message - The message string to be sent with the vector

msg

public void msg(java.lang.String message)
Shortcut to send a message to all interested clients

Parameters:
message - The message string to be sent

timer

public void timer(long timeout)
register a timer such the onTimer will be called after the given timeout

Parameters:
timeout - the time to wait before calling onTimer in milliseconds

def

public void def(org.indi.objects.Vector vector)
Send a def vector message to all interested clients.

Parameters:
vector - the vector to be send.

set

public void set(org.indi.objects.Vector vector)
Send a set vector message to all interested clients.

Parameters:
vector - the vector to be send.

del

public void del(org.indi.objects.Vector vector)
Send a del vector message to all interested clients.

Parameters:
vector - the vector to be send.

sendToClients

public void sendToClients(org.indi.objects.Object object,
                          org.indi.objects.TransferType type,
                          java.lang.String message)
Send to the given object to all interested clients

Parameters:
object - the object to be send
type - the way the object shall to be send
message - the to be send with the object

getName

public java.lang.String getName()
Specified by:
getName in interface Device
Returns:
the name of the device

onObserved

public void onObserved(org.indi.objects.Vector vector)
called by the indiserver when a property for which an for with a observer was install via the subscibe method has changed

Specified by:
onObserved in interface ObserverCallback
Parameters:
vector - the vector that changed


Copyright © 2008. All Rights Reserved.