/* drvBkhErr.h * This driver class, derived from asynPortDriver, is designed to handle error * messages and error state generated by all instances of the drvBkhAsyn or * drvBkhAMot classes. Object of this class is created via a C configure * function called from the st.cmd file of the IOC and an extern address * pointer is made available to the other class objects. * Started on 1/9/2015, zms *---------------------------------------------------------------------------*/ #ifndef _drvBkhErr_h #define _drvBkhErr_h #include #include #include "asynPortDriver.h" #ifndef MIN #define MIN(a,b) (((a)<(b))?(a):(b)) #endif #ifndef MAX #define MAX(a,b) (((a)>(b))?(a):(b)) #endif typedef unsigned char byte; typedef epicsUInt16 word; typedef unsigned int uint; typedef struct{ ELLNODE node; int eiId,flag; char port[16]; } errItem_t; #define NSLOTS 1 #define WFLEN 100 #define wfMessageStr "WF_MESSAGE" #define siNameStr "SI_NAME" #define biErrorStr "BI_ERROR" #define boTestStr "BO_TEST" class drvBkhErr: public asynPortDriver{ public: drvBkhErr( const char* port); virtual asynStatus readInt32( asynUser* pau,epicsInt32* v); virtual asynStatus writeInt32( asynUser* pau,epicsInt32 v); virtual void report( FILE* fp,int level); void exitHndl(); void initDone( int flg); int registerClient( const char* port); void setErrorFlag( int id,int flag); void errLock(); void errUnlock(); protected: void _message( const char*); void _refresh(); int _wfMessage, _siName, _biError, _boTest; #define FIRST_ITEM _wfMessage #define LAST_ITEM _boTest #define PARMS (&LAST_ITEM - &FIRST_ITEM + 1) enum{ ixWfMessage, ixSiName, ixBiError, ixBoTest}; private: epicsMutexId _mutexId; errItem_t* _find(int id); char* _port; int _firstix; int _initdone; ELLLIST _clist; // list of client data structures int _cid; // client identifier char _msg[WFLEN]; // for error message }; epicsShareExtern drvBkhErr* pbkherr; #endif // _drvBkhErr_h