当前位置:网站首页>C alarm design

C alarm design

2022-07-05 12:27:00 yang881221

1                      Alarm log module design

 

 

1.1    function analysis

The function of this module is to output the generated alarm to the serial port or log file

 

1.2    The basic principle

      The alarm level output to the serial port defaults to info Level ; The alarm level output to the file defaults to alert Level , take alert And higher level information saved to file .

       When other modules have alarms , call sysLogMsg(MODULEIDmodule, LEVELID level,const char * format, ...) Function to send an alarm message to the module , The incoming parameters have alarm module 、 Alarm level and message body . The module outputs the message to the serial port or saves it to a file according to the alarm module and alarm level .

       If the message queue is full or the message length is greater than 256 byte , The message is discarded . For messages to be output to the serial port , direct printf Printout ; For messages to be saved to a file , For a while Buf in , And put the sign at 1, Each time will be Buf Before writing to the file , Use tick Count the interval between the last save time , When the interval is greater than the specified value , And the sign bit is 1 when , hold Buf Content in write to file .


 

 

 

1.3    Data structure design

typedef struct tagSysLogGlobalConfig {

   int iCurrLofServer;

   int iSendRate;

   LOGHOST plServerList[SYSLOG_MAX_HOST];

 

   LIST *plMsgBufList;

   int iBufListSize;

   BUFLISTELEMENT *ptBufInsertPos;

   BUFLISTELEMENT *ptBufShowFirstPos;

 

   int iConsoleSwitch;

   int iConsoleServity;

   ulong_t ulConsolMessages;

 

   int  iMonitorSwitch;

   int  iMonitorServity;

   ulong_t ulMonitorMessages;

 

   int  iFileSwitch;

   int  iFileServity;

   char * logFileName;

 

   MSG_Q_ID logMsgQ;

   int iLogSocket;

   int iAppendTime;

 

   int iGlobalSwitch;

   ulong_t ulDropMessage;

 

   SEM_ID semMemCpy;

} SYSLOGCONF;

 

typedef struct tagLogHost{

   ulong_t ulIpAddr;       /* Log host's IP Address */

   ulong_t ulLevel;        /* The output level of the log host */

   ulong_t ulFacility;     /*Unix System defined equipment number ,local0~local7(16~23);*/

   ulong_t ulSwitch;       /* Indicates whether the switch of the current log host is on ,0 To open */

   ulong_t ulMsgSent;      /* The number of discarded logs sent to this host */

   ulong_t ulMsgdrop;      /* Number of dropped messages */

   ulong_t ulPort;

} LOGHOST;

 

typedef struct tagBufListElement{

   NODE link;

   ulong_t ulGetTick;

   ulong_t ulSec;

   char* buf;

   ulong_t ulInUse;

   int iModule;    /*module */

   int iLevel;   /*message level*/

}BUFLISTELEMENT;

 

typedef struct tSYSLOGMODULE{

   char *pcModuleName;     /* Module name */

   char *pcFacility;       /**/

   int iModuleDebugSwitch;

} SYSLOGMODULE;


原网站

版权声明
本文为[yang881221]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140529242286.html