Files
microser/include/IEC60870DEF.h
2025-01-16 16:17:01 +08:00

1812 lines
49 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @file: $RCSfile: IEC60870DEF.h,v $
* @brief: $60870Ïà¹Ø¶¨Òå
*
* @version: $Revision: 1.1 $
* @date: $Date: 2018/11/24 06:54:49 $
* @author: $Author: lizhongming $
* @state: $State: Exp $
*
* @latest: $Id: IEC60870DEF.h,v 1.1 2018/11/24 06:54:49 lizhongming Exp $
*/
/******************************************************************************
*
* Module: $ IEC60870-5-101 Library.
* Filename: $ IEC60870DEF.h
* Copyright: $ Copyright(C) 2004 SNAC Ltd. All rights reserved.
* Author: $ DGY,YXF
* Release: $
* Create: $ 2004/08/07
* Modify: $ ver 0.1 - 2004/09/07
* $
* $
* Language: $ C
* Environment: $ VC6/VC7 - WIN32 - I386 (support)
* $ GCC - LINUX - I386 (support)
* Description: $ Base data type of the IEC60870-5-101 protocol.
*
******************************************************************************/
#ifndef _INC_IEC60870_5_101_TYPE_H
#define _INC_IEC60870_5_101_TYPE_H
/**
* @defgroup S_IEC60870_5_PROTOCOL IEC60870-5 serial protocols type identification
* @{
*/
#define INVALID_0 0 /**< Invalid data type */
/* Process information in monitor direction (station-specific parameter) */
#define M_SP_NA_1 1 /**< Single-point information */
#define M_SP_TA_1 2 /**< Single-point information with time tag */
#define M_DP_NA_1 3 /**< Double-point information */
#define M_DP_TA_1 4 /**< Double-point information with time tag */
#define M_ST_NA_1 5 /**< Step position information */
#define M_ST_TA_1 6 /**< Step position information with time tag */
#define M_BO_NA_1 7 /**< Bitstring of 32 bit */
#define M_BO_TA_1 8 /**< Bitstring of 32 bit with time tag */
#define M_ME_NA_1 9 /**< Measured value, normalised value */
#define M_ME_TA_1 10 /**< Measured value, normalised value with time tag */
#define M_ME_NB_1 11 /**< Measured value, scaled value */
#define M_ME_TB_1 12 /**< Measured value, scaled value with time tag */
#define M_ME_NC_1 13 /**< Measured value, short floating point value */
#define M_ME_TC_1 14 /**< Measured value, short floating point value with time tag */
#define M_IT_NA_1 15 /**< Integrated totals */
#define M_IT_TA_1 16 /**< Integrated totals with time tag */
#define M_EP_TA_1 17 /**< Event of protection equipment with time tag */
#define M_EP_TB_1 18 /**< Packed start events of protection equipment with time tag */
#define M_EP_TC_1 19 /**< Packed output circuit information of protection equipment with time tag */
#define M_PS_NA_1 20 /**< Packed single point information with time tag */
#define M_ME_ND_1 21 /**< Measured value, normalised value without quality descriptor */
#define M_SP_TB_1 30 /**< Single point information with time tag CP56Time2a */
#define M_DP_TB_1 31 /**< Double point information with time tag CP56Time2a */
#define M_ST_TB_1 32 /**< Step position information with time tag CP56Time2a */
#define M_BO_TB_1 33 /**< Bitstring of 32 bit with time tag CP56Time2a */
#define M_ME_TD_1 34 /**< Measured value, normalised value with time tag CP56Time2a */
#define M_ME_TE_1 35 /**< Measured value, scaled value with time tag CP56Time2a */
#define M_ME_TF_1 36 /**< Measured value, short floating point value with time tag CP56Time2a */
#define M_IT_TB_1 37 /**< Integrated totals with time tag CP56Time2a */
#define M_EP_TD_1 38 /**< Event of protection equipment with time tag CP56Time2a */
#define M_EP_TE_1 39 /**< Packed start events of protection equipment with time tag CP56Time2a */
#define M_EP_TF_1 40 /**< Packed tripping events of protection equipment with time tag CP56Time2a */
/* Process information in control direction (station-specific parameter) */
#define C_SC_NA_1 45 /**< Single command */
#define C_DC_NA_1 46 /**< Double command */
#define C_RC_NA_1 47 /**< Regulating step command */
#define C_SE_NA_1 48 /**< Set point command, normalised value */
#define C_SE_NB_1 49 /**< Set point command, scaled value */
#define C_SE_NC_1 50 /**< Set point command, short floating point value */
#define C_BO_NA_1 51 /**< Bitstring of 32 bit */
#define C_SC_TA_1 58 /**< Single command with time tag CP56Time2a */
#define C_DC_TA_1 59 /**< Double command with time tag CP56Time2a */
#define C_RC_TA_1 60 /**< Regulating step command with time tag CP56Time2a */
#define C_SE_TA_1 61 /**< Set point command, normalised value with time tag CP56Time2a */
#define C_SE_TB_1 62 /**< Set point command, scaled value with time tag CP56Time2a */
#define C_SE_TC_1 63 /**< Set point command, short floating point value with time tag CP56Time2a */
#define C_BO_TA_1 64 /**< Bitstring of 32 bit with time tag CP56Time2a */
/* System information in monitor direction (station-specific parameter) */
#define M_EI_NA_1 70 /**< End of initialisation */
/* System information in control direction (station-specific parameter) */
#define C_IC_NA_1 100 /**< Interrogation command ¶¨ÖµÕÙ»½ */
#define C_CI_NA_1 101 /**< Counter interrogation command */
#define C_RD_NA_1 102 /**< Read command */
#define C_CS_NA_1 103 /**< Clock synchronisation command */
#define C_TS_NA_1 104 /**< Test command */
#define C_RP_NA_1 105 /**< Reset process command */
#define C_CD_NA_1 106 /**< Delay acquisition command */
#define C_TS_TA_1 107 /**< Test command with time tag CP56Time2a */
/* Parameter in control direction (station-specific parameter) */
#define P_ME_NA_1 110 /**< Parameter of measured value, normalised value */
#define P_ME_NB_1 111 /**< Parameter of measured value, scaled value */
#define P_ME_NC_1 112 /**< Parameter of measured value, short floating point value */
#define P_AC_NA_1 113 /**< Active parameter */
/* File Transfer (station-specific parameter) */
#define F_FR_NA_1 120 /**< File ready */
#define F_SR_NA_1 121 /**< Section ready */
#define F_SC_NA_1 122 /**< Call directory, select file, call file, call section */
#define F_LS_NA_1 123 /**< Last section, last segment */
#define F_AF_NA_1 124 /**< Ack file, ack section */
#define F_SG_NA_1 125 /**< Segment */
#define F_DR_TA_1 126 /**< Directory */
/* Special type for AGC */
#define C_SE_ND_1 136 /**< Set multi-point command, normalised value */
/* EYE-LINUXϵͳ˳¿ØÌØÊⶨÒå */
#define M_ES_NA_1 41 /**< ˳¿ØÖ´ÐÐÐÅÏ¢ÉÏË͵ÄÊý¾ÝÀàÐÍ */
#define C_GS_NA_1 114 /**< */
#define C_SS_NA_1 115 /**< */
/* EYE-LINUXÏµÍ³ÌØÊⶨÒå */
#define C_MT_ND_1 152 /**< Multi-point transmit command, normalised value (ÓÃÓÚ϶¨Öµ) */
#define M_EX_TA_1 153 /**< ´øSOE²ÎÊýµÄÀ©Õ¹Ìá³ö±¨ÎÄ */
#define C_SE_EX_1 154 /**< Set Point Command,ÉèµãÃüÁÎÞÑ¡Ôñ¹ý³Ì£¬Ö±½ÓÖ´ÐÐ */
#define M_GD_NA_1 160 /**< IEC60870-5-103 GDD type monitor direction data [×Ö·û´®] */
#define C_GD_NA_1 168 /**< IEC60870-5-103 GDD type control direction data */
/* EYE-LINUXÏµÍ³ÌØÊⶨÒå */
#define D_RE_DT_1 180 /**< Õм²¨ÁбíÃüÁî */
#define D_FA_SE_1 181 /**< Õм²¨ÃüÁî */
#define D_ACC_ACK_1 182 /**< ¼²¨¹æÔ¼ÏìÓ¦ */
#define M_IT_S1_1 185 /** Signed int 1 */
#define M_IT_U1_1 186 /** Unsigned int 1 */
#define M_IT_S2_1 187 /** Signed int 2 */
#define M_IT_U2_1 188 /** Unsigned int 2 */
#define M_IT_S4_1 189 /** Signed int 4 */
#define M_IT_U4_1 190 /** Unsigned int 4 */
#define M_IT_F4_1 191 /** float 4 */
#define M_IT_F8_1 192 /** float 8 */
/* ------------------------------------------------------------------------------------
* IEC60870-5-101 cause of transmission possibilities for each ASDU
* Cause := UI6[1..6] <0..63>
* <14..19> := reserved for further compatible definitions
* <42..47> := reserved for further compatible definitions
*/
#define COT0_NOTUSED_1 0 /**< not used */
#define COT1_PERCYC_1 1 /**< periodic, cyclic */
#define COT2_BACK_1 2 /**< background scan */
#define COT3_SPONT_1 3 /**< spontaneous */
#define COT4_INIT_1 4 /**< initialised */
#define COT5_REQ_1 5 /**< request or requested */
#define COT6_ACT_1 6 /**< activation */
#define COT7_ACTCON_1 7 /**< activation confirmation */
#define COT8_DEACT_1 8 /**< deactivation */
#define COT9_DEACTCON_1 9 /**< deactivation confirmation */
#define COT10_ACTTERM_1 10 /**< activation termination */
#define COT11_RETREM_1 11 /**< return information caused by a remote command */
#define COT12_RETLOC_1 12 /**< return information caused by a local command */
#define COT13_FILE_1 13 /**< file transfer */
#define COT20_INROGEN_1 20 /**< interrogated by general interrogation */
#define COT21_INRO1_1 21 /**< interrogated by group 1 interrogation */
#define COT22_INRO2_1 22 /**< interrogated by group 2 interrogation */
#define COT23_INRO3_1 23 /**< interrogated by group 3 interrogation */
#define COT24_INRO4_1 24 /**< interrogated by group 4 interrogation */
#define COT25_INRO5_1 25 /**< interrogated by group 5 interrogation */
#define COT26_INRO6_1 26 /**< interrogated by group 6 interrogation */
#define COT27_INRO7_1 27 /**< interrogated by group 7 interrogation */
#define COT28_INRO8_1 28 /**< interrogated by group 8 interrogation */
#define COT29_INRO9_1 29 /**< interrogated by group 9 interrogation */
#define COT30_INRO10_1 30 /**< interrogated by group 10 interrogation */
#define COT31_INRO11_1 31 /**< interrogated by group 11 interrogation */
#define COT32_INRO12_1 32 /**< interrogated by group 12 interrogation */
#define COT33_INRO13_1 33 /**< interrogated by group 13 interrogation */
#define COT34_INRO14_1 34 /**< interrogated by group 14 interrogation */
#define COT35_INRO15_1 35 /**< interrogated by group 15 interrogation */
#define COT36_INRO16_1 36 /**< interrogated by group 16 interrogation */
#define COT37_REQCOGEN_1 37 /**< reques ted by general counter request */
#define COT38_REQCO1_1 38 /**< reques ted by group 1 counter request */
#define COT39_REQCO1_1 39 /**< reques ted by group 2 counter request */
#define COT40_REQCO1_1 40 /**< reques ted by group 3 counter request */
#define COT41_REQCO1_1 41 /**< reques ted by group 4 counter request */
/**< ¶¯×÷²ÎÊý */
#ifdef _OS_WIN32_
#pragma pack(push,1)
#endif
typedef struct I_STRUCT I_STRUCT;
/** I_STRUCT */
struct I_STRUCT {
uint32_t flag:1; /**< I format flag = 0 */
uint32_t SNO:15; /**< Send number */
uint32_t RES:1; /**< Reserved = 0 */
uint32_t RNO:15; /**< Recieve number */
}ALIGNPACKED; /**< I format */
typedef struct S_STRUCT S_STRUCT;
/** S_STRUCT */
struct S_STRUCT {
uint32_t flag:2; /**< S format flag = 01 */
uint32_t RES:15; /**< Reserved = 0 */
uint32_t RNO:15; /**< Recieve number */
}ALIGNPACKED; /**< S format */
typedef struct U_STRUCT U_STRUCT;
/** U_STRUCT */
struct U_STRUCT {
uint32_t flag:2; /**< U format flag = 11 */
uint32_t STARTDT:2; /**< STARTDT */
uint32_t STOPDT:2; /**< STOPDT */
uint32_t TESTFR:2; /**< TESTFR */
uint32_t RES:24; /**< Reserved = 0 */
}ALIGNPACKED; /**< U format */
typedef union ctrlarea_t ctrlarea_t;
/** Control field */
union ctrlarea_t {
byte_t byte[4];
I_STRUCT I;
S_STRUCT S;
U_STRUCT U;
}ALIGNPACKED;
typedef struct apci_t apci_t;
/** apci_t */
struct apci_t { /* IEC60870-5-104 special */
byte_t startC1; /* Start character = 68H */
byte_t length1; /* length */
ctrlarea_t ctrl_field; /* Control field */
}ALIGNPACKED;
/* FRAME_TYPE()/IS_I_FRAME()/IS_S_FRAME()/IS_U_FRAME()*/
typedef struct asdustd_t asdustd_t;
struct asdustd_t {
byte_t typid; /* Type identification */
byte_t vsq; /* Variable structure qualifier */
uint16_t cot; /* Cause of transmission */
uint16_t addr; /* Common address of ASDUs */
byte_t data[256]; /* Variable structure qualifier */
}ALIGNPACKED;
// ===============================================================================
/** Æ·ÖÊÃèÊö×ֵĺ¬Òå
* BL=·âËø/δ±»·âËø
* ÐÅÏ¢ÌåµÄÖµ±»±ÕËøºó£¬ÎªÁË´«ÊäÐèÒª£¬´«Êä±»·âËøÇ°µÄÖµ£¬·âËøºÍ½âËø¿ÉÒÔÓɵ±µØÁªËø
* »ú¹¹»òµ±µØÆäËûÔ­ÒòÀ´Æô¶¯¡£
* SB=È¡´ú/δ±»È¡´ú
* ÐÅÏ¢ÌåµÄÖµ±»Öµ°àÔ±µÄÊäÈëÖµ»òÓÉÒ»¸ö×Ô¶¯×°ÖõÄÊäÈëËùÈ¡´ú¡£
* NT=µ±Ç°Öµ/·Çµ±Ç°Öµ
* Èô×î½üµÄˢгɹ¦ÔòÖµ¾Í³ÆÎªµ±Ç°Öµ¡£ÈôÔÚÒ»¸öÖ¸¶¨µÄʱ¼ä¼ä¸ôÄÚˢв»³É¹¦»òÕßÖµ²»
* ¿ÉÓþͳÆÎª·Çµ±Ç°Öµ¡£
* IV=ÓÐЧ/ÎÞЧ
* ÈôÖµ±»ÕýÈ·²É¼¯¾ÍÊÇÓÐЧ£¬Ôڲɼ¯¹¦ÄÜÈ·ÈÏÐÅÏ¢Ô´µÄ·´³£×´Ì¬(ɥʧ»ò·Ç¹¤×÷Ë¢ÐÂ)ÔòÖµ
* ¾ÍÊÇÎÞЧ£¬ÐÅÏ¢ÌåÖµÔÚÕâЩÌõ¼þÏÂûÓб»¶¨Òå¡£±êÉÏÎÞЧÓÃÒÔÌáÐÑʹÓÃÕߣ¬´ËÖµ²»ÕýÈ·
* ¶ø²»Äܱ»Ê¹Óá£
* OV=Òç³ö/δÒç³ö
* EI=ʼþ״̬
* Èô¶¯×÷ʱ¼äÖµ±»ÕýÈ·²É¼¯¾ÍΪÓÐЧ£¬Ôڲɼ¯¹¦ÄÜÈ·ÈÏËüΪ·´³£×´Ì¬Ê±£¬Ôò¶¯×÷ʱ¼äֵΪ
* ÎÞЧ£¬ÐÅÏ¢Ì嶯×÷ʱ¼äÖµÔÚÕâЩÌõ¼þÏÂδ±»¶¨Òå¡£±êÉÏÎÞЧÓÃÒÔÌáÐÑʹÓÃÕߣ¬´ËÖµ²»Õý
* È·¶ø²»Äܱ»Ê¹Óá£
*/
typedef struct siq_t siq_t;
/** ´øÆ·ÖÊÃèÊöµÄµ¥µãÐÅÏ¢
* SPI¡Ã=BS1£Û£±£Ý£¼0¡«1£¾
* £¼0£¾¡Ã=OFF ¿ª
* £¼1£¾¡Ã=ON ºÏ
*/
#ifdef PPC_LINUX
struct siq_t {
byte_t IV:1;
byte_t NT:1;
byte_t SB:1;
byte_t BL:1;
byte_t RES:3;
byte_t SPI:1;
}ALIGNPACKED;
#else
struct siq_t {
byte_t SPI:1;
byte_t RES:3;
byte_t BL:1;
byte_t SB:1;
byte_t NT:1;
byte_t IV:1;
}ALIGNPACKED;
#endif
typedef union SIQ SIQ;
union SIQ {
byte_t bits;
siq_t parts;
}ALIGNPACKED;
typedef struct diq_t diq_t;
/** ´øÆ·ÖÊÃèÊöµÄË«µãÐÅÏ¢
* DPI¡Ã=UI2£Û1¡«2£Ý£¼0¡«3£¾
* £¼0£¾¡Ã=Öмä״̬»ò²»È·¶¨
* £¼1£¾¡Ã=È·¶¨×´Ì¬¿ª(OFF)
* £¼2£¾¡Ã=È·¶¨×´Ì¬ºÏ(ON)
* £¼3£¾¡Ã=Öмä״̬»ò²»È·¶¨
*/
#ifdef PPC_LINUX
struct diq_t {
byte_t IV:1;
byte_t NT:1;
byte_t SB:1;
byte_t BL:1;
byte_t RES:2;
byte_t DPI:2;
}ALIGNPACKED;
#else
struct diq_t {
byte_t DPI:2;
byte_t RES:2;
byte_t BL:1;
byte_t SB:1;
byte_t NT:1;
byte_t IV:1;
}ALIGNPACKED;
#endif
typedef union DIQ DIQ;
union DIQ {
byte_t bits;
diq_t parts;
}ALIGNPACKED;
typedef struct qdp_t qdp_t;
/** ¼Ìµç±£»¤×°ÖÃʼþµÄÆ·ÖÊÃèÊö´Ê */
#ifdef PPC_LINUX
struct qdp_t {
byte_t IV:1;
byte_t NT:1;
byte_t SB:1;
byte_t BL:1;
byte_t EI:1;
byte_t RES:3;
}ALIGNPACKED;
#else
struct qdp_t {
byte_t RES:3;
byte_t EI:1;
byte_t BL:1;
byte_t SB:1;
byte_t NT:1;
byte_t IV:1;
}ALIGNPACKED;
#endif
typedef union QDP QDP;
union QDP {
byte_t bits;
qdp_t parts;
}ALIGNPACKED;
typedef struct qds_t qds_t;
/** Æ·ÖÊÃèÊö´Ê */
#ifdef PPC_LINUX
struct qds_t {
byte_t IV:1;
byte_t NT:1;
byte_t SB:1;
byte_t BL:1;
byte_t RES:3;
byte_t OV:1;
}ALIGNPACKED;
#else
struct qds_t {
byte_t OV:1;
byte_t RES:3;
byte_t BL:1;
byte_t SB:1;
byte_t NT:1;
byte_t IV:1;
}ALIGNPACKED;
#endif
typedef union QDS QDS;
union QDS {
byte_t bits;
qds_t parts;
}ALIGNPACKED;
typedef struct vti_t vti_t;
/** ´øË²±ä״ָ̬ʾµÄÖµ */
#ifdef PPC_LINUX
struct vti_t {
byte_t transient:1;
byte_t value:7;
}ALIGNPACKED;
#else
struct vti_t {
byte_t value:7;
byte_t transient:1;
}ALIGNPACKED;
#endif
typedef union VTI VTI;
union VTI {
byte_t bits;
vti_t parts;
}ALIGNPACKED;
typedef struct NVA NVA;
/** ²âÁ¿Á¿£¬¹éÒ»»¯Öµ */
struct NVA {
int16_t value;
}ALIGNPACKED;
typedef union VA VA;
union VA {
uint16_t ui;
int16_t i;
}ALIGNPACKED;
typedef struct sva_t sva_t;
/** ²âÁ¿Á¿£¬±ê¶È»¯Öµ */
#ifdef PPC_LINUX
struct sva_t {
uint16_t sign:1;
uint16_t value:15;
}ALIGNPACKED;
#else
struct sva_t {
uint16_t value:15;
uint16_t sign:1;
}ALIGNPACKED;
#endif
typedef union SVA SVA;
union SVA {
int16_t bits;
sva_t parts;
}ALIGNPACKED;
typedef struct ieee754dp_t ieee754dp_t;
/** ²âÁ¿Á¿£¬IEEE STD754 R64.52¸¡µãÊý */
#ifdef PPC_LINUX
struct ieee754dp_t {
uint64_t sign:1;
uint64_t bexp:11;
uint64_t mant:52;
}ALIGNPACKED;
#else
struct ieee754dp_t {
uint64_t mant:52;
uint64_t bexp:11;
uint64_t sign:1;
}ALIGNPACKED;
#endif
typedef union IEEE754DP IEEE754DP;
union IEEE754DP {
uint64_t bits;
ieee754dp_t parts;
double d;
}ALIGNPACKED;
typedef struct ieee754sp_t ieee754sp_t;
/** ²âÁ¿Á¿£¬IEEE STD754 R32.23¶Ì¸¡µãÊý */
#ifdef PPC_LINUX
struct ieee754sp_t {
uint32_t sign:1;
uint32_t bexp:8;
uint32_t mant:23;
}ALIGNPACKED;
#else
struct ieee754sp_t {
uint32_t mant:23;
uint32_t bexp:8;
uint32_t sign:1;
}ALIGNPACKED;
#endif
typedef union IEEE754SP IEEE754SP;
union IEEE754SP {
uint32_t bits;
ieee754sp_t parts;
float f;
}ALIGNPACKED;
typedef struct scd_t scd_t;
/** ״̬ºÍ״̬±ä»¯¼ì³ö */
struct scd_t {
uint16_t ST;
uint16_t CD;
}ALIGNPACKED;
typedef union SCD SCD;
union SCD {
uint32_t bits;
scd_t parts;
}ALIGNPACKED;
typedef struct bcr_t bcr_t;
/** ¶þ½øÖƼÆÊýÆ÷¶ÁÊý */
#ifdef PPC_LINUX
struct bcr_t {
uint32_t counter;
byte_t IV:1;
byte_t CA:1;
byte_t CY:1;
byte_t SQ:5;
}ALIGNPACKED;
#else
struct bcr_t {
uint32_t counter;
byte_t SQ:5;
byte_t CY:1;
byte_t CA:1;
byte_t IV:1;
}ALIGNPACKED;
#endif
typedef union BCR BCR;
union BCR {
byte_t bits[5];
bcr_t parts;
}ALIGNPACKED;
typedef struct sep_t sep_t;
/** ¼Ìµç±£»¤×°Öõĵ¥¸öʼþ */
#ifdef PPC_LINUX
struct sep_t {
byte_t IV:1;
byte_t NT:1;
byte_t SB:1;
byte_t BL:1;
byte_t EI:1;
byte_t RES:1;
byte_t ES:2;
}ALIGNPACKED;
#else
struct sep_t {
byte_t ES:2;
byte_t RES:1;
byte_t EI:1;
byte_t BL:1;
byte_t SB:1;
byte_t NT:1;
byte_t IV:1;
}ALIGNPACKED;
#endif
typedef union SEP SEP;
union SEP {
byte_t bits;
sep_t parts;
}ALIGNPACKED;
typedef struct spe_t spe_t;
/** ¼Ìµç±£»¤×°ÖÃÆô¶¯Ê¼þ */
#ifdef PPC_LINUX
struct spe_t {
byte_t RES:2;
byte_t SRD:1;
byte_t SIE:1;
byte_t SL3:1;
byte_t SL2:1;
byte_t SL1:1;
byte_t GS:1;
}ALIGNPACKED;
#else
struct spe_t {
byte_t GS:1;
byte_t SL1:1;
byte_t SL2:1;
byte_t SL3:1;
byte_t SIE:1;
byte_t SRD:1;
byte_t RES:2;
}ALIGNPACKED;
#endif
typedef union SPE SPE;
union SPE {
byte_t bits;
spe_t parts;
}ALIGNPACKED;
typedef struct oci_t oci_t;
/** ±£»¤×°ÖÃÊä³öµç·ÐÅÏ¢ */
#ifdef PPC_LINUX
struct oci_t {
byte_t RES:4;
byte_t CL3:1;
byte_t CL2:1;
byte_t CL1:1;
byte_t GC:1;
}ALIGNPACKED;
#else
struct oci_t {
byte_t GC:1;
byte_t CL1:1;
byte_t CL2:1;
byte_t CL3:1;
byte_t RES:4;
}ALIGNPACKED;
#endif
typedef union OCI OCI;
union OCI {
byte_t bits;
oci_t parts;
}ALIGNPACKED;
typedef union BSI BSI;
/** ¶þ½ø×´Ì¬ÐÅÏ¢ */
union BSI {
uint32_t bits;
byte_t parts[4];
}ALIGNPACKED;
typedef struct sco_t sco_t;
/** µ¥ÃüÁî */
#ifdef PPC_LINUX
struct sco_t {
byte_t SE:1;
byte_t QU:5;
byte_t RES:1;
byte_t SCS:1;
}ALIGNPACKED;
#else
struct sco_t {
byte_t SCS:1;
byte_t RES:1;
byte_t QU:5;
byte_t SE:1;
}ALIGNPACKED;
#endif
typedef union SCO SCO;
union SCO {
byte_t bits;
sco_t parts;
}ALIGNPACKED;
typedef struct dco_t dco_t;
/** Ë«ÃüÁî */
#ifdef PPC_LINUX
struct dco_t {
byte_t SE:1;
byte_t QU:5;
byte_t DCS:2;
}ALIGNPACKED;
#else
struct dco_t {
byte_t DCS:2;
byte_t QU:5;
byte_t SE:1;
}ALIGNPACKED;
#endif
typedef union DCO DCO;
union DCO {
byte_t bits;
dco_t parts;
}ALIGNPACKED;
typedef struct rco_t rco_t;
/** ²½µ÷½ÚÃüÁî */
#ifdef PPC_LINUX
struct rco_t {
byte_t SE:1;
byte_t QU:5;
byte_t RCS:2;
}ALIGNPACKED;
#else
struct rco_t {
byte_t RCS:2;
byte_t QU:5;
byte_t SE:1;
}ALIGNPACKED;
#endif
typedef union RCO RCO;
union RCO {
byte_t bits;
rco_t parts;
}ALIGNPACKED;
typedef struct qos_t qos_t;
/** ÉèµãÃüÁîÏÞ¶¨´Ê */
#ifdef PPC_LINUX
struct qos_t {
byte_t SE:1;
byte_t QL:7;
}ALIGNPACKED;
#else
struct qos_t {
byte_t QL:7;
byte_t SE:1;
}ALIGNPACKED;
#endif
typedef union QOSP QOSP;
union QOSP {
byte_t bits;
qos_t parts;
}ALIGNPACKED;
typedef struct coi_t coi_t;
/** ³õʼ»¯Ô­Òò */
#ifdef PPC_LINUX
struct coi_t {
byte_t state:1;
byte_t cause:7;
}ALIGNPACKED;
#else
struct coi_t {
byte_t cause:7;
byte_t state:1;
}ALIGNPACKED;
#endif
typedef union COI COI;
union COI {
byte_t bits;
coi_t parts;
}ALIGNPACKED;
typedef struct QOI QOI;
/** ÕÙ»½ÃüÁîµÄÏÞ¶¨´Ê */
struct QOI {
byte_t qoi;
}ALIGNPACKED;
typedef struct qcc_t qcc_t;
/** µçÄܼÆÊýÁ¿ÕÙ»½ÃüÁîµÄÏÞ¶¨´Ê */
#ifdef PPC_LINUX
struct qcc_t {
byte_t FRZ:2;
byte_t RQT:6;
}ALIGNPACKED;
#else
struct qcc_t {
byte_t RQT:6;
byte_t FRZ:2;
}ALIGNPACKED;
#endif
typedef union QCC QCC;
union QCC {
byte_t bits;
qcc_t parts;
}ALIGNPACKED;
typedef struct FBP FBP;
/** ¹Ì¶¨²âÊÔ×Ö */
struct FBP {
uint16_t HEX;
}ALIGNPACKED;
//#define FBP (uint16_t)(0x55aa)
typedef struct QRP QRP;
/** ¸´Î»½ø³ÌÃüÁîµÄÏÞ¶¨´Ê */
struct QRP {
byte_t qrp;
}ALIGNPACKED;
typedef struct qpm_t qpm_t;
/** ²âÁ¿Öµ²ÎÊýÏÞ¶¨´Ê */
#ifdef PPC_LINUX
struct qpm_t {
byte_t POP:1;
byte_t LPC:1;
byte_t KPA:6;
}ALIGNPACKED;
#else
struct qpm_t {
byte_t KPA:6;
byte_t LPC:1;
byte_t POP:1;
}ALIGNPACKED;
#endif
typedef union QPM QPM;
union QPM {
byte_t bits;
qpm_t parts;
}ALIGNPACKED;
#define QPM_NOTUSED 0 /** not used */
#define QPM_THRESHOLD 1 /** threshold value */
#define QPM_SMOOTHING 2 /** smoothing factor (filter time constant) */
#define QPM_LOWLIMIT 3 /** high limits */
#define QPM_HIGHLIMIT 4 /** low limits */
typedef struct QPA QPA;
/** ²ÎÊý¼¤»îÏÞ¶¨´Ê */
struct QPA {
byte_t qpa;
}ALIGNPACKED;
/* File Transfer (station-specific parameter) */
/* ÎļþÃû¶¨Ò壬ÆäÖÐÎļþÃûµÚ2¸ö8λ×éΪ½«À´Ó¦Óñ£Áô */
#define FILE_TRANSPARENT (1) /**< ͸Ã÷Îļþ */
#define FILE_EQUIP (2) /**< ¼Ìµç±£»¤É豸µÄÈŶ¯Êý¾Ý */
#define FILE_EVENT_SEQ (3) /**< ʼþÐòÁÐ */
#define FILE_ANALOG_SEQ (4) /**< ±»¼Ç¼µÄÄ£ÄâÁ¿ÏµÁÐ */
/* ´«ÊäÔ­Òò */
#define FILE_TRAN_DEFAULT (0) /**< ȱʡ */
#define FILE_TRAN_SEL (1) /**< Ñ¡ÔñÎļþ */
#define FILE_TRAN_REQ (2) /**< ÇëÇóÎļþ */
#define FILE_TRAN_INACTIVE (3) /**< Í£Ö¹¼¤»îÎļþ */
#define FILE_TRAN_DELETE (4) /**< ɾ³ýÎļþ */
//....
#define FILE_ERR_MEM (0) /**< ÎÞËùÇëÇóµÄ¿Õ¼ä */
#define FILE_ERR_CHKSUM (1) /**< УÑéºÍ´í */
//....
#define FILE_ERR_FILENAME (4) /**< ·ÇËùÆÚÍûÎļþÃû³Æ */
/** Name Of File */
typedef uint16_t NOF;
/** Name Of Session */
typedef byte_t NOS;
typedef struct LOF LOF;
/** Length Of File */
struct LOF {
byte_t lof[3];
}ALIGNPACKED;
/** Length Of Session */
typedef byte_t LOS;
/** CHeckSum */
typedef byte_t CHS;
typedef struct sof_t sof_t;
/** State Of File */
#ifdef PPC_LINUX
struct sof_t {
byte_t FA:1;
byte_t FOR:1;
byte_t LFD:1;
byte_t STATUS:5;
}ALIGNPACKED;
#else
struct sof_t {
byte_t STATUS:5;
byte_t LFD:1;
byte_t FOR:1;
byte_t FA:1;
}ALIGNPACKED;
#endif
typedef union SOF SOF;
/** State Of File */
union SOF {
byte_t bits;
sof_t parts;
}ALIGNPACKED;
typedef struct frq_t frq_t;
/** File Ready Qualifier */
#ifdef PPC_LINUX
struct frq_t {
byte_t ACK:1; /**< =0 ack; =1 deny */
byte_t FILES:7;
}ALIGNPACKED;
#else
struct frq_t {
byte_t FILES:7;
byte_t ACK:1; /**< =0 ack; =1 deny */
}ALIGNPACKED;
#endif
typedef union FRQ FRQ;
/** File Ready Qualifier */
union FRQ {
byte_t bits;
frq_t parts;
}ALIGNPACKED;
typedef struct srq_t srq_t;
/** Session Ready Qualifier */
#ifdef PPC_LINUX
struct srq_t {
byte_t READY:1;
byte_t SESSION:7;
}ALIGNPACKED;
#else
struct srq_t {
byte_t SESSION:7;
byte_t READY:1;
}ALIGNPACKED;
#endif
typedef union SRQ SRQ;
/** Session Ready Qualifier */
union SRQ {
byte_t bits;
srq_t parts;
}ALIGNPACKED;
typedef struct scq_t scq_t;
/** Select/Call Qualifier */
#ifdef PPC_LINUX
struct scq_t {
byte_t RESPONSE:4;
byte_t REQUEST:4;
}ALIGNPACKED;
#else
struct scq_t {
byte_t REQUEST:4;
byte_t RESPONSE:4;
}ALIGNPACKED;
#endif
typedef union SCQ SCQ;
/** Select/Call Qualifier */
union SCQ {
byte_t bits;
scq_t parts;
}ALIGNPACKED;
/** Lasted Session Qualifier */
typedef byte_t LSQ;
typedef struct afq_t afq_t;
/** Ack File/Session Qualifier */
#ifdef PPC_LINUX
struct afq_t {
byte_t STATUS:4;
byte_t ACK:4;
}ALIGNPACKED;
#else
struct afq_t {
byte_t ACK:4;
byte_t STATUS:4;
}ALIGNPACKED;
#endif
typedef union AFQ AFQ;
/** Ack File/Session Qualifier */
union AFQ {
byte_t bits;
afq_t parts;
}ALIGNPACKED;
/** ===========================ÐÅÏ¢¶ÔÏó½á¹¹¶¨ÒåÇø================================= */
/** Process information in monitor direction (station-specific parameter) */
typedef struct M_SP_NA_1_t M_SP_NA_1_t;
/** Single-point information */
struct M_SP_NA_1_t {
SIQ siq;
}ALIGNPACKED;
typedef struct M_SP_TA_1_t M_SP_TA_1_t;
/** Single-point information with time tag */
struct M_SP_TA_1_t {
SIQ siq;
CP24Time2a tm;
}ALIGNPACKED;
typedef struct M_DP_NA_1_t M_DP_NA_1_t;
/** Double-point information */
struct M_DP_NA_1_t {
DIQ diq;
}ALIGNPACKED;
typedef struct M_DP_TA_1_t M_DP_TA_1_t;
/** Double-point information with time tag */
struct M_DP_TA_1_t {
DIQ diq;
CP24Time2a tm;
}ALIGNPACKED;
typedef struct M_ST_NA_1_t M_ST_NA_1_t;
/** Step position information */
struct M_ST_NA_1_t {
VTI vti;
QDS qds;
}ALIGNPACKED;
typedef struct M_ST_TA_1_t M_ST_TA_1_t;
/** Step position information with time tag */
struct M_ST_TA_1_t {
VTI vti;
QDS qds;
CP24Time2a tm;
}ALIGNPACKED;
typedef struct M_BO_NA_1_t M_BO_NA_1_t;
/** Bitstring of 32 bit */
struct M_BO_NA_1_t {
BSI bsi;
QDS qds;
}ALIGNPACKED;
typedef struct M_SA_NA_1_t M_SA_NA_1_t;
/** String of ASCII */
struct M_SA_NA_1_t {
byte_t length;
char str[1];
}ALIGNPACKED;
typedef struct M_BO_TA_1_t M_BO_TA_1_t;
/** Bitstring of 32 bit with time tag */
struct M_BO_TA_1_t {
BSI bsi;
QDS qds;
CP24Time2a tm;
}ALIGNPACKED;
typedef struct M_ME_NA_1_t M_ME_NA_1_t;
/** Measured value, normalised value */
struct M_ME_NA_1_t {
NVA nva;
QDS qds;
}ALIGNPACKED;
typedef struct M_ME_TA_1_t M_ME_TA_1_t;
/** Measured value, normalised value with time tag */
struct M_ME_TA_1_t {
NVA nva;
QDS qds;
CP24Time2a tm;
}ALIGNPACKED;
typedef struct M_ME_NB_1_t M_ME_NB_1_t;
/** Measured value, scaled value */
struct M_ME_NB_1_t {
SVA sva;
QDS qds;
}ALIGNPACKED;
typedef struct M_ME_TB_1_t M_ME_TB_1_t;
/** Measured value, scaled value with time tag */
struct M_ME_TB_1_t {
SVA sva;
QDS qds;
CP24Time2a tm;
}ALIGNPACKED;
typedef struct M_ME_NC_1_t M_ME_NC_1_t;
/** Measured value, short floating point value */
struct M_ME_NC_1_t {
IEEE754SP std;
QDS qds;
}ALIGNPACKED;
typedef struct M_ME_TC_1_t M_ME_TC_1_t;
/** Measured value, short floating point value with time tag */
struct M_ME_TC_1_t {
IEEE754SP std;
QDS qds;
CP24Time2a tm;
}ALIGNPACKED;
typedef struct M_IT_NA_1_t M_IT_NA_1_t;
/** Integrated totals */
struct M_IT_NA_1_t {
BCR bcr;
}ALIGNPACKED;
typedef struct M_IT_TA_1_t M_IT_TA_1_t;
/** Integrated totals with time tag */
struct M_IT_TA_1_t {
BCR bcr;
CP24Time2a tm;
}ALIGNPACKED;
typedef struct M_EP_TA_1_t M_EP_TA_1_t;
/** Event of protection equipment with time tag */
struct M_EP_TA_1_t {
SEP sep;
CP16Time2a tm16;
CP24Time2a tm24;
}ALIGNPACKED;
typedef struct M_EP_TB_1_t M_EP_TB_1_t;
/** Packed start events of protection equipment with time tag */
struct M_EP_TB_1_t {
SPE spe;
QDP qdp;
CP16Time2a tm16;
CP24Time2a tm24;
}ALIGNPACKED;
typedef struct M_EP_TC_1_t M_EP_TC_1_t;
/** Packed output circuit information of protection equipment with time tag */
struct M_EP_TC_1_t {
OCI oci;
QDP qdp;
CP16Time2a tm16;
CP24Time2a tm24;
}ALIGNPACKED;
typedef struct M_PS_NA_1_t M_PS_NA_1_t;
/** Packed single point information with time tag */
struct M_PS_NA_1_t {
SCD scd;
QDS qds;
}ALIGNPACKED;
typedef struct M_ME_ND_1_t M_ME_ND_1_t;
/** Measured value, normalised value without quality descriptor */
struct M_ME_ND_1_t {
NVA nva;
}ALIGNPACKED;
typedef struct M_SP_TB_1_t M_SP_TB_1_t;
/** Single point information with time tag CP56Time2a */
struct M_SP_TB_1_t {
SIQ siq;
CP56Time2a tm;
}ALIGNPACKED;
typedef struct M_DP_TB_1_t M_DP_TB_1_t;
/** Double point information with time tag CP56Time2a */
struct M_DP_TB_1_t {
DIQ diq;
CP56Time2a tm;
}ALIGNPACKED;
typedef struct M_ST_TB_1_t M_ST_TB_1_t;
/** Step position information with time tag CP56Time2a */
struct M_ST_TB_1_t {
VTI vti;
QDS qds;
CP56Time2a tm;
}ALIGNPACKED;
typedef struct M_BO_TB_1_t M_BO_TB_1_t;
/** Bitstring of 32 bit with time tag CP56Time2a */
struct M_BO_TB_1_t {
BSI bsi;
CP56Time2a tm;
}ALIGNPACKED;
typedef struct M_ME_TD_1_t M_ME_TD_1_t;
/** Measured value, normalised value with time tag CP56Time2a */
struct M_ME_TD_1_t {
NVA nva;
QDS qds;
CP56Time2a tm;
}ALIGNPACKED;
typedef struct M_ME_TE_1_t M_ME_TE_1_t;
/** Measured value, scaled value with time tag CP56Time2a */
struct M_ME_TE_1_t {
SVA sva;
QDS qds;
CP56Time2a tm;
}ALIGNPACKED;
typedef struct M_ME_TF_1_t M_ME_TF_1_t;
/** Measured value, short floating point value with time tag CP56Time2a */
struct M_ME_TF_1_t {
IEEE754SP std;
QDS qds;
CP56Time2a tm;
}ALIGNPACKED;
typedef struct M_IT_TB_1_t M_IT_TB_1_t;
/** Integrated totals with time tag CP56Time2a */
struct M_IT_TB_1_t {
BCR bcr;
CP56Time2a tm;
}ALIGNPACKED;
typedef struct M_EP_TD_1_t M_EP_TD_1_t;
/** Event of protection equipment with time tag CP56Time2a */
struct M_EP_TD_1_t {
SEP sep;
CP16Time2a tm16;
CP56Time2a tm56;
}ALIGNPACKED;
typedef struct M_EP_TE_1_t M_EP_TE_1_t;
/** Packed start events of protection equipment with time tag CP56Time2a */
struct M_EP_TE_1_t {
SPE spe;
QDP qdp;
CP16Time2a tm16;
CP56Time2a tm56;
}ALIGNPACKED;
typedef struct M_EP_TF_1_t M_EP_TF_1_t;
/** Packed tripping events of protection equipment with time tag CP56Time2a */
struct M_EP_TF_1_t {
OCI oci;
QDP qdp;
CP16Time2a tm16;
CP56Time2a tm56;
}ALIGNPACKED;
/** ˳¿ØÖ´ÐÐÐÅÏ¢ÉÏË͵ÄÊý¾ÝÀàÐͽṹ */
typedef struct es_nva_t es_nva_t;
struct es_nva_t {
byte_t step;
byte_t flag;
byte_t no;
byte_t pause_time;
byte_t rsv2;
byte_t rsv3;
byte_t rsv4;
byte_t rsv5;
byte_t rsv6;
byte_t rsv7;
byte_t rsv8;
}ALIGNPACKED;
typedef struct es_str_t es_str_t;
struct es_str_t {
byte_t strlen;
byte_t string[255];
}ALIGNPACKED;
typedef struct M_ES_NA_1_t M_ES_NA_1_t;
struct M_ES_NA_1_t {
es_nva_t esn;
es_str_t ess;
}ALIGNPACKED;
/** Process information in control direction (station-specific parameter) */
typedef struct C_SC_NA_1_t C_SC_NA_1_t;
/** Single command */
struct C_SC_NA_1_t {
SCO sco;
}ALIGNPACKED;
typedef struct C_DC_NA_1_t C_DC_NA_1_t;
/** Double command */
struct C_DC_NA_1_t {
DCO dco;
}ALIGNPACKED;
typedef struct C_RC_NA_1_t C_RC_NA_1_t;
/** Regulating step command */
struct C_RC_NA_1_t {
RCO rco;
}ALIGNPACKED;
typedef struct C_SE_NA_1_t C_SE_NA_1_t;
/** Set point command, normalised value */
struct C_SE_NA_1_t {
NVA nva;
QOSP qos;
}ALIGNPACKED;
typedef struct C_SE_EX_1_t C_SE_EX_1_t;
/** Set point command, normalised value ,Ö±½ÓÖ´ÐУ¬ÎÞÐ跴У
S/E λÎÞЧ£¬ÖÃΪ 0
*/
struct C_SE_EX_1_t {
NVA nva;
QOSP qos;
}ALIGNPACKED;
typedef struct C_SE_NB_1_t C_SE_NB_1_t;
/** Set point command, scaled value */
struct C_SE_NB_1_t {
SVA sva;
QOSP qos;
}ALIGNPACKED;
typedef struct C_SE_NC_1_t C_SE_NC_1_t;
/** Set point command, short floating point value */
struct C_SE_NC_1_t {
IEEE754SP std;
QOSP qos;
}ALIGNPACKED;
typedef struct C_BO_NA_1_t C_BO_NA_1_t;
/** Bitstring of 32 bit */
struct C_BO_NA_1_t {
BSI bsi;
}ALIGNPACKED;
typedef struct C_SC_TA_1_t C_SC_TA_1_t;
/** Single command with time tag CP56Time2a */
struct C_SC_TA_1_t {
SCO sco;
CP56Time2a tm;
}ALIGNPACKED;
typedef struct C_DC_TA_1_t C_DC_TA_1_t;
/** Double command with time tag CP56Time2a */
struct C_DC_TA_1_t {
DCO dco;
CP56Time2a tm;
}ALIGNPACKED;
typedef struct C_RC_TA_1_t C_RC_TA_1_t;
/** Regulating step command with time tag CP56Time2a */
struct C_RC_TA_1_t {
RCO rco;
CP56Time2a tm;
}ALIGNPACKED;
typedef struct C_SE_TA_1_t C_SE_TA_1_t;
/** Set point command, normalised value with time tag CP56Time2a */
struct C_SE_TA_1_t {
NVA nva;
QOSP qos;
CP56Time2a tm;
}ALIGNPACKED;
typedef struct C_SE_TB_1_t C_SE_TB_1_t;
/** Set point command, scaled value with time tag CP56Time2a */
struct C_SE_TB_1_t {
SVA sva;
QOSP qos;
CP56Time2a tm;
}ALIGNPACKED;
typedef struct C_SE_TC_1_t C_SE_TC_1_t;
/** Set point command, short floating point value with time tag CP56Time2a */
struct C_SE_TC_1_t {
IEEE754SP std;
QOSP qos;
CP56Time2a tm;
}ALIGNPACKED;
typedef struct C_BO_TA_1_t C_BO_TA_1_t;
/** Bitstring of 32 bit with time tag CP56Time2a */
struct C_BO_TA_1_t {
BSI bsi;
CP56Time2a tm;
}ALIGNPACKED;
/** System information in monitor direction (station-specific parameter) */
typedef struct M_EI_NA_1_t M_EI_NA_1_t;
/** End of initialisation */
struct M_EI_NA_1_t {
COI coi;
}ALIGNPACKED;
/** System information in control direction (station-specific parameter) */
typedef struct C_IC_NA_1_t C_IC_NA_1_t;
/** Interrogation command */
struct C_IC_NA_1_t {
QOI qoi;
}ALIGNPACKED;
typedef struct C_CI_NA_1_t C_CI_NA_1_t;
/** Counter interrogation command */
struct C_CI_NA_1_t {
QCC qcc;
}ALIGNPACKED;
/* Read command = C_RD_NA_1 no structure body */
typedef struct C_CS_NA_1_t C_CS_NA_1_t;
/** Clock synchronisation command */
struct C_CS_NA_1_t {
CP56Time2a tm;
}ALIGNPACKED;
typedef struct C_TS_NA_1_t C_TS_NA_1_t;
/** Test command */
struct C_TS_NA_1_t {
FBP fbp;
}ALIGNPACKED;
typedef struct C_RP_NA_1_t C_RP_NA_1_t;
/** Reset process command */
struct C_RP_NA_1_t {
QRP qrp;
}ALIGNPACKED;
typedef struct C_CD_NA_1_t C_CD_NA_1_t;
/** Delay acquisition command */
struct C_CD_NA_1_t {
CP16Time2a tm;
}ALIGNPACKED;
typedef struct C_TS_TA_1_t C_TS_TA_1_t;
/** Test command with time tag CP56Time2a */
struct C_TS_TA_1_t {
FBP fbp;
CP56Time2a tm;
}ALIGNPACKED;
/** Parameter in control direction (station-specific parameter) */
typedef struct P_ME_NA_1_t P_ME_NA_1_t;
/** Parameter of measured value, normalised value */
struct P_ME_NA_1_t {
NVA nva;
QPM qpm;
}ALIGNPACKED;
typedef struct P_ME_NB_1_t P_ME_NB_1_t;
/** Parameter of measured value, scaled value */
struct P_ME_NB_1_t {
SVA sva;
QPM qpm;
}ALIGNPACKED;
typedef struct P_ME_NC_1_t P_ME_NC_1_t;
/** Parameter of measured value, short floating point value */
struct P_ME_NC_1_t {
IEEE754SP std;
QPM qpm;
}ALIGNPACKED;
typedef struct P_AC_NA_1_t P_AC_NA_1_t;
/** Active parameter */
struct P_AC_NA_1_t {
QPA qpa;
}ALIGNPACKED;
typedef struct F_FR_NA_1_t F_FR_NA_1_t;
/** File Transfer (station-specific parameter) */
struct F_FR_NA_1_t {
NOF nof;
LOF lof;
FRQ frq;
}ALIGNPACKED;
typedef struct F_SR_NA_1_t F_SR_NA_1_t;
/** Section ready */
struct F_SR_NA_1_t {
NOF nof;
NOS nos;
LOF lof;
}ALIGNPACKED;
typedef struct F_SC_NA_1_t F_SC_NA_1_t;
/** Call directory, select file, call file, call section */
struct F_SC_NA_1_t {
NOF nof;
NOS nos;
SCQ scq;
}ALIGNPACKED;
typedef struct F_LS_NA_1_t F_LS_NA_1_t;
/** Last section, last segment */
struct F_LS_NA_1_t {
NOF nof;
NOS nos;
LSQ lsq;
CHS chs;
}ALIGNPACKED;
typedef struct F_AF_NA_1_t F_AF_NA_1_t;
/** Ack file, ack section */
struct F_AF_NA_1_t {
NOF nof;
NOS nos;
AFQ afq;
}ALIGNPACKED;
typedef struct F_SG_NA_1_t F_SG_NA_1_t;
/** Segment */
struct F_SG_NA_1_t {
NOF nof;
NOS nos;
LOS los;
byte_t seg[1];
}ALIGNPACKED;
typedef struct F_DR_TA_1_t F_DR_TA_1_t;
/** Directory */
struct F_DR_TA_1_t {
NOF nof;
LOF lof;
SOF nos;
CP56Time2a tm;
}ALIGNPACKED;
/** Special type for AGC */
typedef struct C_SE_ND_1_t C_SE_ND_1_t;
/** Set multi-point command, normalised value */
struct C_SE_ND_1_t {
uint16_t num; /** É趨ֵÊýÄ¿ */
}ALIGNPACKED;
/** ===========================¹ÊÕÏÐÅÏ¢½á¹¹¶¨Òå================================= */
typedef struct ACC_PARAM_RELTIME_t ACC_PARAM_RELTIME_t;
struct ACC_PARAM_RELTIME_t{
uint16_t relativetime;
}ALIGNPACKED;
typedef struct ACC_PARAM_FAN_t ACC_PARAM_FAN_t;
struct ACC_PARAM_FAN_t{
uint16_t fan;
}ALIGNPACKED;
typedef struct ACC_PARAM_NOF_t ACC_PARAM_NOF_t;
struct ACC_PARAM_NOF_t{
uint16_t nof;
}ALIGNPACKED;
#ifdef PPC_LINUX
struct PHASE_t{
byte_t phaseA :1; //AÏà¹ÊÕÏ
byte_t phaseB :1; //BÏà¹ÊÕÏ
byte_t phaseC :1; //CÏà¹ÊÕÏ
byte_t phaseI :1; //½ÓµØ¹ÊÕÏ
byte_t phaseO :1; //ÇøÍâ¹ÊÕÏ
byte_t res :2; //±¸ÓÃ
byte_t valid :1; //ÓÐЧλ
}ALIGNPACKED;
#else
struct PHASE_t{
byte_t phaseA :1; //AÏà¹ÊÕÏ
byte_t phaseB :1; //BÏà¹ÊÕÏ
byte_t phaseC :1; //CÏà¹ÊÕÏ
byte_t phaseI :1; //½ÓµØ¹ÊÕÏ
byte_t phaseO :1; //ÇøÍâ¹ÊÕÏ
byte_t res :2; //±¸ÓÃ
byte_t valid :1; //ÓÐЧλ
}ALIGNPACKED;
#endif
typedef union ACC_PARAM_PHASE_t ACC_PARAM_PHASE_t;
union ACC_PARAM_PHASE_t{
byte_t bit;
struct PHASE_t phase;
}ALIGNPACKED;
typedef struct ACC_PARAM_DISTANCE_t ACC_PARAM_DISTANCE_t;
struct ACC_PARAM_DISTANCE_t{
float distance;
}ALIGNPACKED;
typedef struct ACC_PARAM_MAXI_t ACC_PARAM_MAXI_t;
struct ACC_PARAM_MAXI_t{
float max_i;
}ALIGNPACKED;
typedef struct ACC_PARAM_MINI_t ACC_PARAM_MINI_t;
struct ACC_PARAM_MINI_t{
float min_i;
}ALIGNPACKED;
/** ===========================EYE-LINUXÏµÍ³ÌØÊâ½á¹¹================================= */
typedef struct C_MT_ND_1_t C_MT_ND_1_t;
/** Multi-point transmit command, normalised value */
struct C_MT_ND_1_t {
uint16_t num; /** É趨ֵÊýÄ¿ */
dco_t dco; /** Ñ¡Ôñ/Ö´ÐÐ */
byte_t desc; /** ¶¨ÖµÃèÊö */
uint16_t start; /** ¶¨ÖµÆðʼµãºÅ */
uint16_t end; /** ¶¨Öµ½áÊøµãºÅ */
}ALIGNPACKED;
typedef struct gd_t gd_t;
struct gd_t {
byte_t size; //Ê××Ö½Ú±íʾºóÐø×Ö·û´®µÄ³¤¶È £¬c×Ö·û´®µÄÐè°üº¬ ½áβ \0ËùÕ¼µÄ³¤¶È
byte_t gid[255];
}ALIGNPACKED;
/** ×Ö·û´®ÀàÐͶ¨Òå */
/* ×Ö·û´®ÀàÐÍʹÓÃʾÀý
byte_t value[256];
value_t val;
val.data = &value;
val.typid = M_GD_NA_1;
value[0] = strlen(str)+1 ; //val.data²¿·Ö£¬Ê××Ö½Ú±íʾºóÐø×Ö·û´®µÄ³¤¶È £¬¼ÓÉÏ1 ÊÇc×Ö·û´®µÄ½áβ \0ËùÕ¼µÄ³¤¶È
val.size = value[0] +1; //value_tµÄsize Ó¦¸ÃÊÇ£º ×Ö·û±¾Éí³¤¶È + ³¤¶ÈÓòÒ»×Ö½Ú
strcpy(value+1,str);
*/
/** Special type for eye-linux */
typedef union M_GD_NA_1_t M_GD_NA_1_t;
/** IEC60870-5-103 GDD structure, eye-linux special */
union M_GD_NA_1_t {
byte_t bits[256];
gd_t parts;
};
typedef union C_GD_NA_1_t C_GD_NA_1_t;
/** IEC60870-5-103 GDD structure, eye-linux special */
union C_GD_NA_1_t {
byte_t bits[256];
gd_t parts;
}ALIGNPACKED;
typedef struct value_t value_t;
/** ÃèÊö´æ´¢Ìض¨ÀàÐÍÊý¾ÝµÄ»º³åÇø½á¹¹ */
struct value_t {
byte_t typid; /**< Êý¾ÝÀàÐÍ£¬Ê¹ÓÃIEC60870-5-101µÄASDU TYP¶¨Òå */
uint16_t size; /**< = sizeof(typidÀàÐ͵ÄÊý¾Ý) */
void* data; /**< Ö¸Ïòsize´óСµÄÄڴ滺³åÇø(´æ´¢×ÅtypidÀàÐ͵ÄÊý¾Ý) */
}ALIGNPACKED;
#define REQ_TD_2 2 //Ñ¡Ôñ¼²¨
#define STA_TD_4 4 //Æô¶¯Â¼²¨
#define ACC_ACK_OK 1 //Õм²¨(Áбí)ÃüÁîÏ·¢³É¹¦
#define ACC_ACK_FALUT 2 //Õм²¨(Áбí)ÃüÁîÏ·¢Ê§°Ü
#define ACC_ACK_BUZY 3 //×°ÖÃæ£¬ÃüÁîδÏ·¢
#define ACC_ACK_NOSUPPORT 4 //×°Öò»Ö§³ÖÕм²¨(ÊÖ¶¯Â¼²¨£©
typedef struct dist_record_t dist_record_t;
/** Disurbance record */
struct dist_record_t {
uint16_t fan;
byte_t sof;
CP56Time2a glb_tm;
}ALIGNPACKED;
typedef struct dist_table_t dist_table_t;
/** Recorded disturbance table */
struct dist_table_t {
uint32_t ied;
uint16_t cpu;
byte_t nor; /**< Number of disturbance recorded */
dist_record_t *rec;
};
typedef struct sfa_t sfa_t;
/** Status of Fault */
#ifdef PPC_LINUX
struct sfa_t {
byte_t RES:4;
byte_t OTEV:1; /**< Other event (disturbance data recording initiated by) */
byte_t TEST:1; /**< Type of disturbance values */
byte_t TM:1; /**< Transmit (disturbance data) */
byte_t TP:1; /**< Trip (Recorded fault) */
}ALIGNPACKED;
#else
struct sfa_t {
byte_t TP:1; /**< Trip (Recorded fault) */
byte_t TM:1; /**< Transmit (disturbance data) */
byte_t TEST:1; /**< Type of disturbance values */
byte_t OTEV:1; /**< Other event (disturbance data recording initiated by) */
byte_t RES:4;
}ALIGNPACKED;
#endif
typedef union SFA SFA;
/** Status of Fault */
union SFA {
byte_t bits;
sfa_t parts;
}ALIGNPACKED;
typedef struct accs_t accs_t;
/** Actual channel data */
struct accs_t {
byte_t tov; /**< Type of disturbance values */
byte_t acc; /**< Actual channel */
char name[32]; /**< channel name */
char szPhase[8]; /**< channel Phase */
char szUnit[8]; /**< Unit */
IEEE754SP rpv; /**< Rated primary value */
IEEE754SP rsv; /**< Rated secondary value */
IEEE754SP rfa; /**< Reference factor */
byte_t maxframe; /**< max frame number */
uint16_t *ndv; /**< Number of disturbance value */
uint16_t *nfe; /**< The order of firsr disturbance value*/
int16_t **sdv; /**< Single disturbance value buffer */
}ALIGNPACKED;
typedef struct tap_t tap_t;
/** Tag postion */
struct tap_t {
uint16_t tap; /**< Tag postion */
DIQ dpi; /**< Double point information */
}ALIGNPACKED;
typedef struct tags_t tags_t;
/** Tag postion data */
struct tags_t {
byte_t fun; /**< Function type */
byte_t inf; /**< Information number */
byte_t noe; /**< number of tag */
char name[32]; /**< tag Name */
tap_t *tag;/**< Tag postion buffer */
}ALIGNPACKED;
typedef struct timespan_t timespan_t;
struct timespan_t {
int flag; // (0=ÕٷǹÊÕϼ²¨ºÍ¹ÊÕϼ²¨) £¨1=Ö»ÕÙ¹ÊÕϼ²¨£©
CP56Time2a lowbound; //low bound of acc time
CP56Time2a highbound; //high bound of acc time
}ALIGNPACKED;
typedef struct M_EX_TA_1_t M_EX_TA_1_t;
#define EXT_SOE_PARAMETER (100) /**< SOE²ÎÊýÀ©Õ¹ */
struct M_EX_TA_1_t {
byte_t typid; /**< ÆÕͨSOE±¨ÎÄÀàÐÍ */
byte_t res_flag1; /**< ±¸ÓñêÖ¾£¬Ä¿Ç°Ìî0 */
byte_t data_1[16]; /**< ÌîдÈëÆÕͨSOE±¨ÎÄ (Cp56+FLOAT+QOS=7+4+1=13 16 should enough) */
byte_t ext_typid; /**< À©Õ¹±¨ÎÄÀàÐÍ */
uint16_t len; /**< À©Õ¹²¿·Ö±¨Îij¤¶È */
byte_t res_flag2; /**< ±¸Óà */
char data_2[256]; /**< À©Õ¹²¿·ÖÄÚÈÝ */
}ALIGNPACKED;
typedef struct EXT_SOE_PARAMETER_HEADER_t EXT_SOE_PARAMETER_HEADER_t;
struct EXT_SOE_PARAMETER_HEADER_t {
byte_t param_id; /**< ²ÎÊýIDºÅ */
byte_t param_type; /**< ²ÎÊýTYPE */
byte_t param_len; /**< ²ÎÊý³¤¶È */
/*...²ÎÊýÄÚÈÝ */
}ALIGNPACKED;
//ÕÐÖ¸¶¨×°Öü²¨Áбí
typedef struct D_RE_DT_1_t D_RE_DT_1_t;
struct D_RE_DT_1_t {
timespan_t timespan;
}ALIGNPACKED;
//¸ù¾ÝÁбíÕм²¨
typedef struct D_FA_SE_1_t D_FA_SE_1_t;
struct D_FA_SE_1_t {
dist_record_t dist_record;
}ALIGNPACKED;
typedef struct D_ACC_ACK_1_t D_ACC_ACK_1_t;
struct D_ACC_ACK_1_t{
byte_t response; //¹æÔ¼ÏìÓ¦(ACC_ACK_OKµÈ)
}ALIGNPACKED;
typedef struct M_IT_S1_1_t M_IT_S1_1_t;
struct M_IT_S1_1_t {
int8_t s_int1;
QDS qds;
}ALIGNPACKED;
typedef struct M_IT_U1_1_t M_IT_U1_1_t;
struct M_IT_U1_1_t {
byte_t u_int1;
QDS qds;
}ALIGNPACKED;
typedef struct M_IT_S2_1_t M_IT_S2_1_t;
struct M_IT_S2_1_t {
int16_t s_int2;
QDS qds;
}ALIGNPACKED;
typedef struct M_IT_U2_1_t M_IT_U2_1_t;
struct M_IT_U2_1_t {
uint16_t u_int2;
QDS qds;
}ALIGNPACKED;
typedef struct M_IT_S4_1_t M_IT_S4_1_t;
struct M_IT_S4_1_t {
int32_t s_int4;
QDS qds;
}ALIGNPACKED;
typedef struct M_IT_U4_1_t M_IT_U4_1_t;
struct M_IT_U4_1_t {
uint32_t u_int4;
QDS qds;
}ALIGNPACKED;
typedef struct M_IT_F4_1_t M_IT_F4_1_t;
struct M_IT_F4_1_t {
float32_t f_4;
QDS qds;
}ALIGNPACKED;
typedef struct M_IT_F8_1_t M_IT_F8_1_t;
struct M_IT_F8_1_t {
float64_t f_8;
QDS qds;
}ALIGNPACKED;
#ifdef _OS_WIN32_
#pragma pack(pop)
#endif
/** @} */
#ifdef __cplusplus
extern "C" {
#endif
/** ¸´ÖÆ»ùÓÚIEC60870±ê×¼¶¨ÒåµÄvlaue_t½á¹¹µÄÖµ£¬º¬¸ñʽת»» */
APR_DECLARE(int) copy_iec_data(value_t *dstval,value_t *srcval,uint32_t flags);
/** Çó³öijһ¾ßÌåIEC60870-5-101±ê×¼ÐÅÏ¢¶ÔÏó½á¹¹µÄ×Ö½Ú³¤¶È */
APR_DECLARE(size_t) sizeof_typid_data(byte_t typid);
/** Çó³öijһ¾ßÌåIEC60870-5-101±ê×¼ÐÅÏ¢¶ÔÏ󻺳åÇøµÄ×Ö½Ú³¤¶È */
APR_DECLARE(size_t) sizeof_typid_buf(byte_t typid, byte_t *buf);
/** ½«value_t±íʾµÄֵת»»³É±íʾ¸Ãֵʵ¼ÊÒâÒåµÄ×Ö·û´® */
APR_DECLARE(int) data_value2string(value_t *val,char *szvalue);
APR_DECLARE(int) data_actual_val(value_t *val,void *actval);
/** µÃµ½EX_TA_1 µÄʵ¼ÊÀ©Õ¹²¿·Ö³¤¶È×Ö½ÚµÄÆ«ÒÆÁ¿ */
APR_DECLARE(size_t) RDB_Get_EX_TA_Len_offset(byte_t *buf);
/** ´óС¶Ëת»»»ùÓÚIEC60870±ê×¼¶¨ÒåµÄvlaue_t½á¹¹µÄÖµ */
APR_DECLARE(int) htolval_iec_data(value_t *dstval,value_t *srcval);
#ifdef __cplusplus
}
#endif
#endif /*_INC_IEC60870_5_101_TYPE_H */