272 lines
9.8 KiB
C
272 lines
9.8 KiB
C
/****************************************************************************
|
|
|
|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
|
|
|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
|
be copied by any method or incorporated into another program without
|
|
the express written consent of Aerospace C.Power. This Information or any portion
|
|
thereof remains the property of Aerospace C.Power. The Information contained herein
|
|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
|
liability for its use in any way and conveys no license or title under
|
|
any patent or copyright and makes no representation or warranty that this
|
|
Information is free from patent or copyright infringement.
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef PROTO_645_BRK_EXT_H
|
|
#define PROTO_645_BRK_EXT_H
|
|
|
|
/* protocol header file */
|
|
#include "proto_645.h"
|
|
|
|
/* pack for the structures in the whole file */
|
|
#pragma pack(push) /* save the pack status */
|
|
#pragma pack(1) /* 1 byte align */
|
|
|
|
/* extended breaker data item of extended 645-2007 frame */
|
|
/* breaker DI define */
|
|
/* DI: the breaker current data */
|
|
#define PROTO_645_EXT_BRK_DI_I_A (0xea020201u)
|
|
#define PROTO_645_EXT_BRK_DI_I_B (0xea020202u)
|
|
#define PROTO_645_EXT_BRK_DI_I_C (0xea020203u)
|
|
#define PROTO_645_EXT_BRK_DI_I_ALL (0xea0202ffu)
|
|
/* switch fw version */
|
|
#define PROTO_645_EXT_BRK_DI_FW_VER (0xea040002u)
|
|
/* leakage protection status word */
|
|
#define PROTO_645_EXT_BRK_DI_LP_WORD (0xea040100u)
|
|
/* breaker curve data start record tm */
|
|
#define PROTO_645_EXT_BRK_CURVE_START_TM (0xea040401u)
|
|
/* breaker curve data record tm interval unit: minu */
|
|
#define PROTO_645_EXT_BRK_CURVE_INTERVAL_TM (0xea040402u)
|
|
/* set breaker 485 mode words */
|
|
#define PROTO_645_EXT_BRK_485_MODE (0xea040601u)
|
|
/* start calibration */
|
|
#define PROTO_645_EXT_BRK_START_CALIBRATE (0xea040603u)
|
|
/* calibration status */
|
|
#define PROTO_645_EXT_BRK_CALIBRATE_STATUS (0xea040604u)
|
|
/* breaker energy measure data */
|
|
#define PROTO_645_EXT_BRK_MEASURE_DATA (0xea040701u)
|
|
/* erase switch fw */
|
|
#define PROTO_645_EXT_BRK_DI_ERASE_FW (0xeaeaea00u)
|
|
/* breaker energy measure data */
|
|
#define PROTO_645_EXT_BRK_DI_MEASURE_DATA2 (0xeafe00ffu)
|
|
/* erase switch value */
|
|
#define PROTO_645_EXT_BRK_DI_ERASE_FW_VALUE (0xaa)
|
|
|
|
/* define 645-2007 extend protocol fn */
|
|
/* FN: brk rpt data */
|
|
#define PROTO_645_2007_EXT_BRK_FN (0x14)
|
|
|
|
/* define brk current data length */
|
|
#define PROTO_645_EXT_BRK_A_LEN (2)
|
|
|
|
/* define phase sequence data length */
|
|
#define PROTO_645_EXT_BRK_PHASE_SN_LEN (2)
|
|
|
|
/* defined max phase number for breaker */
|
|
#define PROTO_645_2007_EXT_BRK_MAX_PHASE_NUM (3)
|
|
|
|
/* breaker phase id */
|
|
#define PROTO_645_2007_EXT_BRK_PHASE_A 0
|
|
#define PROTO_645_2007_EXT_BRK_PHASE_B 1
|
|
#define PROTO_645_2007_EXT_BRK_PHASE_C 2
|
|
#define PROTO_645_2007_EXT_BRK_PHASE_ALL 3
|
|
#define PROTO_645_2007_EXT_BRK_PHASE_CNT 4
|
|
|
|
/* breaker energy measure data */
|
|
typedef struct _proto_645_ext_brk_measure_data {
|
|
/* voltage RMS, uint is 0.1V, bcd: XXX.X */
|
|
uint8_t v[PROTO_645_2007_EXT_BRK_MAX_PHASE_NUM][PROTO_645_V_LEN];
|
|
/* current RMS, uint is 0.1A, bcd: XXX.X */
|
|
uint8_t i[PROTO_645_2007_EXT_BRK_MAX_PHASE_NUM][PROTO_645_EXT_BRK_A_LEN];
|
|
/* three-phase sum active power, uint is 0.001 KW, BCD */
|
|
uint8_t all_p[PROTO_645_07_P_LEN];
|
|
/* active power, uint is 0.001 KW, bcd: XXX.XXX */
|
|
uint8_t p[PROTO_645_2007_EXT_BRK_MAX_PHASE_NUM][PROTO_645_07_P_LEN];
|
|
/* three-phase sum reactive power, uint is 0.001 Kvar, BCD */
|
|
uint8_t all_q[PROTO_645_07_P_LEN];
|
|
/* reactive power, uint is 0.001 Kvar, bcd: XXX.XXX */
|
|
uint8_t q[PROTO_645_2007_EXT_BRK_MAX_PHASE_NUM][PROTO_645_07_P_LEN];
|
|
/* three-phase sum apparent power, uint is 0.001 KVA, BCD */
|
|
uint8_t all_s[PROTO_645_07_P_LEN];
|
|
/* apparent power, uint is 0.001 KVA, bcd: XXX.XXX */
|
|
uint8_t s[PROTO_645_2007_EXT_BRK_MAX_PHASE_NUM][PROTO_645_07_P_LEN];
|
|
/* frequency, uint Hz, bcd: XX.XX */
|
|
uint8_t freq[PROTO_645_07_FREQ_LEN];
|
|
/* phase sequence, BIN: bit0-2 means phaseA/B/C, set "1" to
|
|
* indicate which phase the device belongs to */
|
|
uint8_t phase[PROTO_645_EXT_BRK_PHASE_SN_LEN];
|
|
/* three-phase power factor, uint is 0.01 KVA, BCD */
|
|
uint8_t all_pf[PROTO_645_07_PF_LEN];
|
|
/* power factor, uint is 0.01 bcd: XX.XX */
|
|
uint8_t pf[PROTO_645_2007_EXT_BRK_MAX_PHASE_NUM][PROTO_645_07_PF_LEN];
|
|
/* positive active total energy, uint is 1/ec kwh bcd */
|
|
uint8_t ept_pos[PROTO_645_07_ENERGY_DATA_LEN];
|
|
/* negative active total energy, uint is 1/ec kwh bcd */
|
|
uint8_t ept_neg[PROTO_645_07_ENERGY_DATA_LEN];
|
|
} proto_645_ext_brk_measure_data_t;
|
|
|
|
/* breaker energy measure data */
|
|
typedef struct _proto_645_ext_brk_measure_data2 {
|
|
/* year */
|
|
uint16_t tm_year;
|
|
/* month */
|
|
uint8_t tm_mon;
|
|
/* day */
|
|
uint8_t tm_mday;
|
|
/* hour */
|
|
uint8_t tm_hour;
|
|
/* minute */
|
|
uint8_t tm_min;
|
|
/* second */
|
|
uint8_t tm_sec;
|
|
/* power line frequency, uint is 0.01Hz */
|
|
uint16_t freq;
|
|
/* temperature, uint is 0.1 centigrade */
|
|
int16_t temperature;
|
|
/* voltage angle between phaseA and phaseB. unit: 1degrees */
|
|
int16_t angle_ua_ub;
|
|
/* voltage angle between phaseA and phaseC. unit: 1degrees */
|
|
int16_t angle_ua_uc;
|
|
/* voltage angle between phaseB and phaseC. unit: 1degrees */
|
|
int16_t angle_ub_uc;
|
|
/* power factor. unit: 0.001 */
|
|
int16_t p_factor[PROTO_645_2007_EXT_BRK_PHASE_CNT];
|
|
/* active power. unit: 0.000001KW */
|
|
int32_t p_p[PROTO_645_2007_EXT_BRK_PHASE_CNT];
|
|
/* reactive power. unit: 0.000001Kvar */
|
|
int32_t p_q[PROTO_645_2007_EXT_BRK_PHASE_CNT];
|
|
/* apparent power. unit: 0.000001KVA */
|
|
int32_t p_s[PROTO_645_2007_EXT_BRK_PHASE_CNT];
|
|
/* voltage rms. unit: 0.1V */
|
|
uint16_t u_rms[PROTO_645_2007_EXT_BRK_PHASE_CNT];
|
|
/* power angele(only phaseA/B/C). unit: 0.1degrees */
|
|
int16_t angle_u_i[PROTO_645_2007_EXT_BRK_PHASE_CNT];
|
|
/* current rms. unit: 0.00001A */
|
|
int32_t i_rms[PROTO_645_2007_EXT_BRK_PHASE_CNT];
|
|
/* positive active energy. unit: 0.01 kwh */
|
|
uint32_t e_p_pos[PROTO_645_2007_EXT_BRK_PHASE_CNT];
|
|
/* negative active energy. unit: 0.01 kwh */
|
|
uint32_t e_p_neg[PROTO_645_2007_EXT_BRK_PHASE_CNT];
|
|
/* positive reactive energy. unit: 0.01 kvarh */
|
|
uint32_t e_q_pos[PROTO_645_2007_EXT_BRK_PHASE_CNT];
|
|
/* negative reactive energy. unit: 0.01 kvarh */
|
|
uint32_t e_q_neg[PROTO_645_2007_EXT_BRK_PHASE_CNT];
|
|
/* positive apparent energy. unit: 0.01 kwh */
|
|
uint32_t e_s_pos[PROTO_645_2007_EXT_BRK_PHASE_CNT];
|
|
/* negative apparent energy. unit: 0.01 kwh */
|
|
uint32_t e_s_neg[PROTO_645_2007_EXT_BRK_PHASE_CNT];
|
|
} proto_645_ext_brk_measure_data2_t;
|
|
|
|
/* leakage protection status word switch status */
|
|
/* switch on status */
|
|
#define PROTO_645_EXT_BRK_LPWD_SWITCH_ON (0x00)
|
|
/* rsvd status */
|
|
#define PROTO_645_EXT_BRK_LPWD_RSVD (0x01)
|
|
/* reclosing status */
|
|
#define PROTO_645_EXT_BRK_LPWD_RECLOSING (0x02)
|
|
/* switch trip status */
|
|
#define PROTO_645_EXT_BRK_LPWD_SWITCH_TRIP (0x03)
|
|
|
|
/* switch normal status */
|
|
#define PROTO_645_EXT_BRK_LPWD_NORMAL (0x00)
|
|
|
|
/* breaker leakage protection status words */
|
|
typedef struct _proto_645_ext_brk_leak_protect_wd {
|
|
/* switch trip reason */
|
|
uint8_t warn_reason : 5,
|
|
/* switch status */
|
|
switch_sts : 2,
|
|
/* switch warn flag */
|
|
warn_flag : 1;
|
|
} proto_645_ext_brk_leak_protect_wd_t;
|
|
|
|
/* breaker 485 mode */
|
|
typedef struct _proto_645_ext_brk_485_mode {
|
|
/* 485 mode : 1 - slave mode, 0 - master mode */
|
|
uint8_t slave : 1,
|
|
/* baudrate: 1200bps */
|
|
bps_1200 : 1,
|
|
/* baudrate: 2400bps */
|
|
bps_2400 : 1,
|
|
/* baudrate: 4800bps */
|
|
bps_4800 : 1,
|
|
/* baudrate: 9600bps */
|
|
bps_9600 : 1,
|
|
/* baudrate: 115200bps */
|
|
bps_115200 : 1,
|
|
/* reserved for future */
|
|
rsvd : 2;
|
|
} proto_645_ext_brk_485_mode_t;
|
|
|
|
/* curve record start time structure layout */
|
|
typedef struct _proto_645_ext_brk_curve_rec_start {
|
|
/* min - BCD */
|
|
uint8_t min;
|
|
/* hour - BCD */
|
|
uint8_t hour;
|
|
/* day - BCD */
|
|
uint8_t day;
|
|
/* mon - BCD */
|
|
uint8_t mon;
|
|
} proto_645_ext_brk_curve_rec_start_t;
|
|
|
|
/* switch version information define */
|
|
typedef union _proto_645_ext_brk_switch_ver {
|
|
/* switch version */
|
|
uint16_t version;
|
|
struct {
|
|
/* revision version */
|
|
uint8_t revision;
|
|
/* minor version */
|
|
uint8_t minor: 4,
|
|
/* major version */
|
|
major: 4;
|
|
} sub_version;
|
|
} proto_645_ext_brk_switch_ver_t;
|
|
|
|
/* breaker 645 fw version */
|
|
typedef struct _proto_645_ext_brk_fw_version {
|
|
/* fw version : bcd code */
|
|
proto_645_ext_brk_switch_ver_t switch_ver;
|
|
/* fw version rsvd data */
|
|
uint8_t rsvd[30];
|
|
} proto_645_ext_brk_fw_version_t;
|
|
|
|
/* breaker calibration param */
|
|
typedef struct _proto_645_ext_brk_calibrat {
|
|
/* calibration voltage param unit: 0.1V */
|
|
uint16_t u;
|
|
/* calibration current param unit: 1A */
|
|
uint8_t i;
|
|
/* calibration power factor param value: 1 - 0.5, 2 - 1, 3 - -0.5 */
|
|
uint8_t pf;
|
|
/* rsvd data */
|
|
uint8_t rsvd[28];
|
|
} proto_645_ext_brk_calibrat_t;
|
|
|
|
/* breaker calibration result */
|
|
typedef struct _proto_645_ext_brk_calibrat_sts {
|
|
/* calibration result */
|
|
uint8_t result;
|
|
} proto_645_ext_brk_calibrat_sts_t;
|
|
|
|
/* breaker calibration result */
|
|
typedef struct _proto_645_ext_brk_erase_cmd {
|
|
/* user */
|
|
uint8_t user[4];
|
|
/* passcode */
|
|
uint8_t passcd[4];
|
|
/* data */
|
|
uint8_t data;
|
|
/* app xmodem block num */
|
|
uint16_t app_total_num;
|
|
/* crc16 */
|
|
uint16_t crc16;
|
|
/* rsvd data */
|
|
uint8_t rsvd[10];
|
|
} proto_645_ext_brk_erase_cmd_t;
|
|
|
|
#pragma pack(pop) /* restore the pack status */
|
|
|
|
#endif /* PROTO_645_BRK_EXT_H */ |