00001 #ifndef __si_sha_autobrg_h__83e6f8a1_6266_40d6_931e_b98bbf61c3d7
00002 #define __si_sha_autobrg_h__83e6f8a1_6266_40d6_931e_b98bbf61c3d7
00003
00013 #include <si_sha/abrgcmn.h>
00014 #include <unistd.h>
00015 #include <pthread.h>
00016
00017
00018 typedef struct sc_automationBridgeBase sc_automationBridgeBase;
00019
00020
00023 typedef struct sc_automationBridgeConnection
00024 {
00025 sc_rep _rep;
00027 int fd_;
00028 int dieW_;
00029 int dieR_;
00030 pthread_t thread_;
00031 s_bool open_;
00033 sc_automationBridgeBase* brg_;
00034 } sc_automationBridgeConnection;
00035
00039 sm_ptrhDecl(sc_automationBridgeConnection);
00040
00044 sm_listDecl(sc_automationBridgeConnectionPtrh);
00045
00046 sc_status sc_automationBridgeConnection_new(sc_automationBridgeBase* pb, int fd,
00047 sc_automationBridgeConnectionPtrh* conn);
00056 sc_status sc_automationBridgeConnection_open(sc_automationBridgeConnection* pc);
00062 sc_status sc_automationBridgeConnection_close(
00063 sc_automationBridgeConnection* pc);
00073 typedef sc_status (*sc_automationBridge_serviceDeviceF) (void* br,
00074 sc_automationPacket* pkt);
00075
00077 typedef sc_status (*sc_automationBridge_processRequestF)(void* br,
00078 sc_automationBridgeConnection* pc,
00079 sc_automationRequest* req,
00080 sc_automationResponse* res);
00081
00083 typedef struct sc_automationBridge_vtable {
00084 sc_automationBridge_serviceDeviceF serviceDevice;
00085 sc_automationBridge_processRequestF processRequest;
00086 } sc_automationBridge_vtable;
00087
00095 struct sc_automationBridgeBase {
00096
00097 const TCHAR* name_;
00098 const TCHAR* basePath_;
00100 const sc_automationBridge_vtable* vtbl_;
00101 void* instance_;
00103 se_bridgeState state_;
00105 pthread_mutex_t mux_;
00108 pthread_t svcThread_;
00111 int fdSvc_;
00112 int fdDev_;
00113 int fdCtlW_;
00114 int fdCtlR_;
00116 sc_automationPacketPool pool_;
00118 sc_automationPacketPtrhList ooo_;
00120 sc_automationBridgeConnectionPtrhList connections_;
00121 };
00122
00123
00124 sc_status sc_automationBridgeBase_construct(
00125 sc_automationBridgeBase* pb,
00126 const TCHAR* name,
00127 const TCHAR* basePath,
00128 s_uint32 pktSize, s_uint32 pktPoolSize,
00129 const sc_automationBridge_vtable* vtbl,
00130 void* instance);
00146 sc_status sc_automationBridgeBase_start(sc_automationBridgeBase* pb);
00152 sc_status sc_automationBridgeBase_stop (sc_automationBridgeBase* pb);
00158 sc_status sc_automationBridgeBase_destruct(sc_automationBridgeBase* pb);
00164 #endif