defs/si_sha/abrgdev.h File Reference

Automation Bridge Device base class. More...

#include <si_std/queuet.h>
#include <si_sha/abrgcmn.h>
#include <si_sha/autodev.h>
#include <unistd.h>

Go to the source code of this file.

Classes

struct  sc_automationBridgeDevice_vtable
 Table of functions that must be supplied by derived class bridges. More...
struct  sc_automationBridgeDevice
 Base automation bridge device class. More...

Typedefs

typedef struct
sc_automationDeviceMgr 
sc_automationDeviceMgr
Derived class function signatures.
typedef sc_status(* sc_automationBridgeDevice_newPacketF )(void *br, sc_automationPacketPtrh *pkt)
typedef sc_status(* sc_automationBridgeDevice_processEventF )(void *br, sc_automationPacket *evt)
typedef sc_status(* sc_automationBridgeDevice_processRequestF )(void *br, sc_automationRequest *req, sc_automationResponse *res)
typedef sc_status(* sc_automationBridgeDevice_discoverF )(void *br)

Functions

 sm_queueDecl (sc_automationPacketPtrh)
sc_status sc_automationBridgeDevice_construct (sc_automationBridgeDevice *pbd, sc_automationDeviceMgr *pdm, const TCHAR *name, const TCHAR *type, const TCHAR *addr, const TCHAR *networkType, const sc_automationBridgeDevice_vtable *vtbl, void *instance)
sc_status sc_automationBridgeDevice_destruct (sc_automationBridgeDevice *pbd)
sc_status sc_automationBridgeDevice_newPacket (sc_automationBridgeDevice *pbd, sc_automationPacketPtrh *pptrh)
sc_status sc_automationBridgeDevice_discover (sc_automationBridgeDevice *pbd)
sc_status sc_automationBridgeDevice_sendMessage (sc_automationBridgeDevice *pbd, sc_automationPacket *msg, sc_automationPacketPtrh *res)


Detailed Description

Automation Bridge Device base class.

This class serves as a base class for bridges on the JavaScript side. The base class is able to handle much of the boiler-plate code of being a device. Derived class bridges need to provide virtual functions for the following:

The base will start the needed threads, and when events from the network or requests from JavaScript arrive, it will forward these to the derived class for processing.


Function Documentation

sc_status sc_automationBridgeDevice_construct ( sc_automationBridgeDevice pbd,
sc_automationDeviceMgr pdm,
const TCHAR *  name,
const TCHAR *  type,
const TCHAR *  addr,
const TCHAR *  networkType,
const sc_automationBridgeDevice_vtable vtbl,
void *  instance 
)

Constructs automation bridge device base class.

This should only be called by derived bridge class constructors.

Parameters:
[in,out] pbd Base Bridge device to construct (pointer to base member).
[in] pdm Reference to device manager.
[in] name Name (identifier) of the bridge device in LASE.
[in] type Aevice type of the bridge device in LASE.
[in] addr Address of bridge device on the network.
[in] networkType Type of network the bridge connects to.
[in] vtbl Derived class v-table.
[in] instance Derived class address (passed to all derived class functions in v-table).

sc_status sc_automationBridgeDevice_destruct ( sc_automationBridgeDevice pbd  ) 

Destructs Bridge Device base class.

Parameters:
[in,out] pbd Pointer to base member to destruct.

sc_status sc_automationBridgeDevice_discover ( sc_automationBridgeDevice pbd  ) 

Syntactic sugar. Calls derived class discover via v-table.

All discovered devices are passed on for creation to the JavaScript context automatically.

Parameters:
[in,out] pbd The bridge of interest.

sc_status sc_automationBridgeDevice_newPacket ( sc_automationBridgeDevice pbd,
sc_automationPacketPtrh *  pptrh 
)

Syntactic sugar. Calls derived class newPacket via v-table.

Returns a new empty packet to use for network messages.

Parameters:
[in,out] pbd The bridge of interest.
[in] pptrh The pointer-handle to which the new packet will be assigned.

sc_status sc_automationBridgeDevice_sendMessage ( sc_automationBridgeDevice pbd,
sc_automationPacket msg,
sc_automationPacketPtrh *  res 
)

Sends the message in msg and returns the response in res.

This internally forwards msg to the service thread, which in turn calls the derived class processRequest function.

Parameters:
[in,out] pbd The bridge to send the message through.
[in] msg The message to send.
[out] res The response is assigned to the this pointer-handle.

sm_queueDecl ( sc_automationPacketPtrh   ) 

Macro declares sc_automationPacketPtrhQueue, a queue of automation packet pointer-handles.


doxygen