Public Member Functions | |
virtual void | shutdownHook () |
This virtual method is called by RDA prior to the server shutdown. | |
virtual bool | clientConnectionHook (const rdaClientInfo &clientInfo) |
This virtual method is called by RDA when a new client wants to connect to the server. | |
Basic device access methods | |
Each device server must provide an implementation of these four abstract methods. | |
virtual rdaData * | get (const rdaIOPoint &iop, const rdaData &ctx)=0 |
Allows to read a value at the specified I/O point. | |
virtual void | set (const rdaIOPoint &iop, const rdaData &ctx, const rdaData &value)=0 |
Changes a value at the specified I/O point. | |
virtual void | monitorOn (const rdaIOPoint &iop, const rdaData &ctx, rdaValueChangeListener *listener)=0 |
Starts a subscription to value at the specified I/O point. | |
virtual void | monitorOff (const rdaIOPoint &iop, rdaValueChangeListener *listener)=0 |
Cancels a subscription identified by the I/O point and listener. | |
Asynchronous calls | |
Methods of this group are invoked when clients make asynchronous calls to devices that reside at this server. | |
virtual void | get (const rdaIOPoint &iop, const rdaData &ctx, rdaResult *result) |
Allows to read a value at the specified I/O point. | |
virtual void | set (const rdaIOPoint &iop, const rdaData &ctx, const rdaData &value, rdaResult *result) |
Changes a value at the specified I/O point. | |
virtual void | cancel (rdaResult *result) |
Administration calls | |
These methods are called remotely by administration clients. | |
virtual rdaData * | getState () |
This virtual method is called when an administration client calls the getState method of the admin::ServerAdmin interface. | |
virtual ServerStatus | getStatus () |
This method is called when an administration client calls the getStatus method of the admin::ServerAdmin interface. | |
Static Public Member Functions | |
rdaDeviceServerBase * | theServer () |
Returns a pointer to the single instance of the server. | |
void | init (int argc, char **argv) |
Initializes the RDA. | |
void | runServer () |
Makes the server available for clients. | |
void | shutDown () |
Deactivates the server. | |
void | shutDown (int signo) |
Deactivates the server. | |
const rdaClientInfo * | getClientInfo () |
Allows to obtain information about a remote client that made a device call in a device access method (get, set, monitorOn, monitorOff) implementation. | |
const char * | getName () |
Returns the name of this server. | |
rdaLogger * | getGlobalLogger () |
Returns the logger that is used by RDA to trace general activities in the server (initialization, fatal errors, shutdown). | |
rdaLogger * | getClientsLogger () |
Returns the logger that is used by RDA to trace cleint connections. | |
rdaLogger * | getCallsLogger () |
Returns the logger that is used by RDA to trace client calls. | |
rdaLogger * | getSubscriptionsLogger () |
Returns the logger that is used by RDA to trace subscription reports. | |
Protected Member Functions | |
rdaDeviceServerBase (const char *serverName) | |
Constructs a device server with the specified name. |
|
Constructs a device server with the specified name. The constructor prepares all the facilities required to make the server available for clients over the network, but does not activate the communications. Access to the server can be enabled when it is fully constructed (all subclass constructors successfully completed) using the runServer() method of the class.
|
|
This virtual method is called by RDA when a new client wants to connect to the server.
The connection will be accepted if the method returns
|
|
Allows to read a value at the specified I/O point. This method is invoked when a client makes an asynchronous get call to a device that resides at this server. This class provides the default implementation of the method which does the following:
|
|
Allows to read a value at the specified I/O point. This method is invoked when a client executes a get operation on a device that resides at this server.
|
|
Allows to obtain information about a remote client that made a device call in a device access method (get, set, monitorOn, monitorOff) implementation.
If this method is invoked within the context of a device call, it will return a pointer to the object describing the calling client. This method returns |
|
This virtual method is called when an administration client calls the getState method of the admin::ServerAdmin interface. The default implementation of the method in the rdaDeviceServerBase class returns the state of the RDA server in a Data object which contains the following entries.
If you want to add some information to the state data, first get the RDA server state by calling the superclass' method, then add to it your state variables. Here is an example implementation of this function from the Device Server Example.
class DeviceServer : public rdaDeviceServerBase { ... virtual rdaData* getState() { // // Get the RDA server state // rdaData* result = rdaDeviceServerBase::getState(); // // Add our state variable (updateTime) to the state data // result->insert("example.updateTime", updateTime); return result; } ... };
|
|
This method is called when an administration client calls the getStatus method of the admin::ServerAdmin interface. The default implementation of the method in the rdaDeviceServerBase class returns status of the RDA server. It can be overridden in subclasses so that the call will return the overall status of a device server. To do this, first evaluate the status at the subclass level, then compare it with the RDA status and return the higher severity value. Here is an example implementation of this function from the Device Server Example.
class DeviceServer : public rdaDeviceServerBase { ... virtual ServerStatus getStatus() { // // Evaluate status of our server // ServerStatus myStatus; if (updateTime < 10) myStatus = STATUS_GREEN; // OK else if (updateTime < 15) myStatus = STATUS_YELLOW; // heavy load else myStatus = STATUS_RED; // overloaded // // Get the status of the RDA server, compare it with our status, // and return the higher severity value. // ServerStatus result = rdaDeviceServerBase::getStatus(); if (myStatus > result) result = myStatus; return result; } ... };
|
|
Initializes the RDA. Must be called before any other RDA method with arguments to the main() as parameters.
|
|
Cancels a subscription identified by the I/O point and listener. This call must not throw any exceptions. |
|
Starts a subscription to value at the specified I/O point. This method is invoked when a client executes a monitorOn operation on a device that resides at this server.
|
|
Makes the server available for clients. Each device server must call this method when it is ready to accept client requests. The method registers the server with the naming service and enters event loop to receive incoming requests. The method only returns if the shutDown() method is called on the server.
|
|
Changes a value at the specified I/O point. This method is invoked when a client makes an asynchronous set call to a device that resides at this server. This class provides the default implementation of the method which does the following:
|
|
Changes a value at the specified I/O point. This method is invoked when a client executes a set operation on a device that resides at this server.
|
|
Deactivates the server. This method causes runServer() to return. It is intended for calling from within a signal handler to achieve clean server termination on signals like SIGINT, SIGHUP, and SIGTERM.
|
|
Deactivates the server. This method causes runServer() to return. It can be called from a thread other then main (e.g., a poller) in order to achive clean server termination.
|
|
This virtual method is called by RDA prior to the server shutdown. The rdaDeviceServerBase class provides an empty implementation of this method; derived classes can override it if they need to perform any specific pre-shutdown cleanup in the server. This would typically include termination of I/O processes and threads (e.g., pollers) spawned by the server. |