⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iec103.h

📁 在Unix平台下完成的电力系统广发使用的IEC103规约的程序
💻 H
字号:
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <memory.h>
#include <malloc.h>
#include <sys/time.h>
#include <sys/timeb.h>
#include <sys/times.h>
#include <time.h>
#include <sys/signal.h>
#include <sys/wait.h>
#include <errno.h>
#include <sys/termio.h>
#include <fcntl.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/msg.h>
#include <unistd.h>
#include <ctype.h>
#include <math.h>

#include "sysdef.h"
#include "dbdef.h"
#include "fbdef.h"
#include "ipclib.h"
#include "msg_info.h"
#include "netman.h"

#define IFLAG               INLCR|ICRNL|IUCLC|BRKINT
#define OFLAG               OPOST
/* #define CFLAG               B19200|CS8|CREAD|CLOCAL|HUPCL  */
#define CFLAG               B19200|CS8|PARENB|CREAD|CLOCAL|HUPCL
#define LFLAG               ICANON|ISIG|ECHO

#define EnqInterval          1          /*  s */
#define ValInterval          600        /*  s */
#define ClkInterval          900        /*  s */
#define FltInterval          5         /*  s */
#define YxInterval           10         /*  s */

#define MaxSendBuf           1024
#define MaxRcvBuf            1024
#define MaxRetry             3
#define MaxGRPNum            10
#define MaxIECNum            255
#define MaxBHNum             255
#define BUFSIZE              256
#define TIME_OUT             5
#define MaxWaitTimes         10

#define MSG_IEC_STATUS_ON    0
#define MSG_IEC_STATUS_OFF   1

#define NODE_ON              0
#define NODE_OFF             1
#define NO                   0
#define YES                  1
#define Master               1
#define Slave                0

#define ACK                  0x06
#define NAK                  0x15
#define SOH                  0x01
#define STX                  0x02
#define EOT                  0x04
#define ENQ                  0x05
#define CAN                  0x0f
#define NUL                  0x00

#define LINK_ADDR              1
#define ASDU_ADDR              1

#define MaxListDsp            20

/*==== IEC870-5-101 Link Protocol Control Information =====*/

#define LPCI_SYN            0x10
#define LPCI_STX            0x68
#define LPCI_ETX            0x16
#define LPCI_FCB            0x20
#define LPCI_FCV            0x10
#define LPCI_ACD            0x20
#define LPCI_SEQ            0x80
#define LPCI_NUL            0xe5

#define LSDU_CYCLE             1
#define LSDU_SPONT             3
#define LSDU_GENIC             5

#define C_RCU_NA               0
#define C_SND_AK               3
#define C_SYN_NK               4
#define C_RFB_NA               7
#define C_RLK_NA               9
#define C_PL1_NA              10
#define C_PL2_NA              11

#define C_SYN_TA               6
#define C_IGI_NA               7

#define M_CON_NA               0
#define M_BSY_NA               1
#define M_NV_NA                9
#define M_LKR_OK              11
#define M_LKR_FT              14
#define M_LKR_HT              15

#define COT_SPN                1
#define COT_CRC                2
#define COT_FCB                3
#define COT_FCV                4
#define COT_SYN                8
#define COT_IGI                9

#define COT_GWD               40
#define COT_GWD_NAK           41
#define COT_GRD               42
#define COT_GRD_NAK           43
#define COT_GWD_OK            44

#define FUN_GEN              254
#define FUN_GLB              255

#define INF_GROUP            241

#define M_TTM_TA              1
#define M_TMR_TA              2
#define M_MEI_NA              3
#define M_TME_TA              4
#define M_IDI_NA              5
#define M_SYN_TA              6
#define C_SYN_TA              6
#define C_IGI_NA              7
#define M_TGI_NA              8
#define M_ME2_NA              9
#define M_GD_NTA             10
#define C_GD_NA              10
#define M_GI_NTA             11
#define C_GRC_TA             20
#define C_GC_NA              21
#define M_LRD_TA             23
#define C_ODT_TA             24
#define C_ADT_NA             25
#define M_RTD_TA             26
#define M_RTC_TA             27
#define M_RTT_TA             28
#define M_TOT_TA             29
#define M_TOV_TA             30
#define M_EOT_TA             31

typedef struct {
  char           file[20];
  char           alias[10];
  char           device[10];
} PORT_DEF;

typedef struct {
  unsigned char  RepCount;
  unsigned char  SendFlag;
  unsigned short SendSize;
  unsigned char  Buf[MaxSendBuf];
} SENDDEF;

typedef struct {
  unsigned int RxC;
  unsigned char  Buf[MaxRcvBuf];
} RCVDEF;

typedef struct {
  int index;
  int audio;
  int dpi;
  char text[100];
} EVTALM;

typedef struct {
  char name[128];
  float val;
} AINVAL;

#define BH_BUF_NUM  32
#define BH_BUF_LEN  1024

typedef struct {
     int                   type;
     int                   len;
     int                   addr;
     unsigned char         buf[BH_BUF_LEN];
}SHM_BH_DATA;

typedef struct {
     int                   display;
     int                   wptr;
     int                   rptr;
     int                   oflag;
     SHM_BH_DATA           data[BH_BUF_NUM*4];
}SHM_BH_DEF;

typedef struct {
     int                   display;
     int                   wptr;
     int                   rptr;
     int                   oflag;
     SHM_BH_DATA           data[BH_BUF_NUM];
}SHM_BH_DEF1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -