Files
kunlun/app/chargepile/iot_cp_task.h
2024-09-28 14:24:04 +08:00

1745 lines
48 KiB
C
Executable File

/****************************************************************************
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 _IOT_CP_TASK_H_
#define _IOT_CP_TASK_H_
#include "iot_task_api.h"
#ifdef __cplusplus
extern "C" {
#endif
/* hardware related defintion */
#define IOT_CP_GPIO_RELAY1 (18)
#define IOT_CP_GPIO_MOC1 (19)
#define IOT_CP_GPIO_RELAY2 (20)
#define IOT_CP_GPIO_MOC2 (21)
#define IOT_CP_GPIO_RELAY3 (22)
#define IOT_CP_GPIO_MOC3 (23)
#define IOT_CP_GPIO_RELAY4 (24)
#define IOT_CP_GPIO_MOC4 (25)
#define IOT_CP_GPIO_NRESET (26)
#define IOT_CP_GPIO_PKEY (27)
#define IOT_CP_GPIO_LED (43)
#define IOT_CP_GPIO_OUPUT_HI (1)
#define IOT_CP_GPIO_OUPUT_LOW (0)
/* operation delay between relay and moc */
#define IOT_CP_SWITCH_DELAY (100)
/* defineation for replay's ZC control */
#ifndef CP_ZC_ENABLE
#define CP_ZC_ENABLE (0)
#endif
/* defination for enable N11 or not */
#ifndef USE_N11_GPRS
#define USE_N11_GPRS (0)
#endif
#if CP_ZC_ENABLE == 1
/* gpio number for zc in */
#define IOT_CP_GPIO_ZC_IN (38)
/* point-ahead for relay's control, unit: us */
#define IOT_CP_ZC_POINT_AHEAD (500)
/* counter of sample times */
#define IOT_CP_ZC_SAMPLE_CNT (10)
/* invalid GP TIMER id*/
#define IOT_CP_GP_TIMER_INVALID_ID (0xFF)
/* indicate how many data should be discarded */
#define IOT_CP_ZC_DISCARD_DATA_CNT (4)
/* period of zc, unit: us */
#define IOT_CP_ZC_STD_PERIOD (20000)
/* margin of ZC period */
#define IOT_CP_ZC_PERIOD_MARGIN (400)
/* upper limit of ZC period */
#define IOT_CP_ZC_PERIOD_LIMIT_UPPER \
(IOT_CP_ZC_STD_PERIOD + IOT_CP_ZC_PERIOD_MARGIN)
/* lower limit of ZC period */
#define IOT_CP_ZC_PERIOD_LIMIT_LOWER \
(IOT_CP_ZC_STD_PERIOD - IOT_CP_ZC_PERIOD_MARGIN)
#endif
/*CP : charging pile*/
/*po : purchase order*/
#define CP_UART_BAUD_RATE (115200)
/*frame's preamble code */
#define CP_FRM_PREAMBLE_CODE (0x68)
/*frame's preamble reply code */
#define CP_FRM_PREAMBLE_REPLY_CODE (0x69)
/*frame's tail code */
#define CP_FRM_TAIL_CODE (0x16)
/* Fn code's offset in frame */
#define CP_FRM_FN_OFFSET (1)
/*offset of data lenth */
#define CP_FRM_FN_SIZE (1)
/*offset of data lenth */
#define CP_FRM_DATA_LEN_OFFSET (2)
/* size of data lenth */
#define CP_FRM_DATA_LEN_SIZE (1)
/* size of checksum */
#define CP_FRM_CS_LEN_SIZE (1)
/* minimal frame size */
#define CP_FRM_MIN_LEN (5)
/* purchase order number size, unit: byte */
#define CP_PO_NUMBER_SIZE (8)
/* sta maximum node count */
#define IOT_CP_MAX_STA_CNT (32)
/* maximum number of sockets */
#define IOT_CP_MAX_PLUG_CNT (4)
/* maximum value of charging history table */
#define IOT_CP_MAX_HIS_INFO_CNT (1)
/** Message type defination: */
#define IOT_CP_TASK_MT_UART (1) /* message from uart. */
#define IOT_CP_TASK_MT_TIMER (2) /* message from timer. */
#define IOT_CP_TASK_MT_APPDATA (3) /* message from cp-task. */
#define IOT_CP_TASK_MT_METER (4) /* message from meter-task. */
#define IOT_CP_TASK_MT_REPORT (5) /* report infomation */
#define IOT_CP_TASK_MT_CHARG_SWITCH (6) /* start/stop charging */
/* message id for IOT_CP_TASK_MT_TIMER */
#define IOT_CP_TASK_MSG_ID_TMR_TIMEOUT (1)
#define IOT_CP_TASK_MSG_ID_CMD_HANDLE (2)
#define IOT_CP_TASK_MSG_ID_TMR_PERIOD (3) //Periodic timer
/* message id for IOT_CP_TASK_MT_METER */
#define IOT_CP_TASK_MSG_ID_MERTER_DATA (0) /* data message from meter-task. */
/* message id for report*/
#define IOT_CP_TASK_MSG_ID_REPORT_HANDLE (4)
/* message id for IOT_CP_TASK_MT_CHARG_SWITCH */
#define IOT_CP_TASK_MSG_ID_CHARGE_START (0) /* start charging */
#define IOT_CP_TASK_MSG_ID_CHARGE_STOP (1) /* stop charging */
#define IOT_CP_TASK_ID IOT_GREE_APP_MID
/* stack size of task */
#define IOT_CP_TASK_TASK_STACK_SIZE (2048)
#define IOT_CP_TASK_PROTO_TASK_PRIO (6)
/* number of messages pending in queue. */
#define IOT_CP_TASK_TASK_POOL_SIZE (128)
#define IOT_CP_TASK_TIMER_PERIOD (100) /* units:ms */
/* period of updating timer */
#define IOT_CP_TASK_TIMER_UPDATE_PERIOD (100) /* units:ms */
/* check close order timer period */
#define IOT_CP_TASK_TIMER_CLOSE_ORDER_PRD (3000) /* units:ms */
/* counter of quering RTC interval : 100ms * cnt */
#define IOT_CP_TASK_QUERY_RTC_INTVL_CNT (12000)
/* counter of reporting status interval : 100ms * cnt */
#define IOT_CP_TASK_RPT_STATUS_INTVL_CNT (1800)
/* counter of reporting charging status interval : 100ms * cnt */
#define IOT_CP_TASK_REPORT_INTVL_CNT (30)
/* Maximum cnt of retransmit historical info*/
#define IOT_CP_TASK_RPT_RETRY_MAX_CNT (5)
/* Maximum cnt of request RTC */
#define IOT_CP_TASK_RPT_RTC_MAX_CNT (3)
/* rate: minute to second */
#define IOT_MINUTE_TO_SECOND (60)
/* rate: second to microsecond */
#define IOT_SECOND_TO_MICROSECOND (1000)
/* default initialization value. */
/* the rated voltage, 110V or 220v, unit: 1V */
#define CP_DEFAULT_CFG_RATED_VOLT (220)
/* the current value when charge full, unit:1mA (1~1000) */
#define CP_DEFAULT_CFG_CHG_FULL_CURRENT (100)
/* the current value when load is over, unit:0.1A (1~160) */
#define CP_DEFAULT_CFG_OVERLOAD_CURRENT (30)
/* the current value when leak,unit:1 mA (1~255) */
#define CP_DEFAULT_CFG_LEAK_CURRENT (20)
/* the config value is invalid */
#define CP_CFG_INVALID_VALUE (0)
/* open circurt current without load, uint:mA */
#define CP_DEFAULT_OPEN_CIRCUIT_CURRENT (13)
/* define threshold saved eigenvalue */
#define CP_THESHOLD_EIGENVALUE (0x66666666)
/* chargepile check alram */
enum _iot_cp_alarm_check_e{
ALARM_EN_OVERVOLT = 0,
ALARM_EN_UNDERVOLT = 1,
ALARM_EN_OVERCUR = 2,
ALARM_EN_OVERLOAD = 3,
ALARM_EN_OVERTEMP = 4,
ALARM_EN_CONN_FAIL = 5,
ALARM_EN_LEAK_CUR = 6,
ALARM_EN_GND_ERR = 7,
ALARM_EN_CHARGE_TIMEOUT = 8,
/*... */
ALARM_EN_MAX = 16,
};
#define ALARM_EN_VALUE \
((1 << ALARM_EN_OVERVOLT) \
| (1 << ALARM_EN_UNDERVOLT) \
| (1 << ALARM_EN_OVERCUR) \
| (1 << ALARM_EN_OVERLOAD) \
| (1 << ALARM_EN_LEAK_CUR) \
)
/* frame format*/
#define GE_CRC_SIZE (2)
#define CP_CS_SIZE (1)
#define CP_FRAME_HDR_SIZE (3)
#define CP_FRAME_TAIL_SIZE (2)
#define CP_DATA_OFFSET (4)
#define GE_FRAME_CRC_TAIL_SIZE (3)
/* minial GE frame size used in cp_task */
#define CP_GE_DATA_FRM_MIN_SIZE (22)
/* data transimition direction: cp_task<->uart */
#define IOT_CP_TRANS_DIR_UART (1)
/* data transimition direction: cp_task<->ge */
#define IOT_CP_TRANS_DIR_PLC (2)
/*device code : 0x90*/
#define IOT_CP_DEV_CODE_2200W_PLC (0x90)
typedef uint32_t(*cp_task_cb)(iot_pkt_t * pkt);
/** type of function send pkt data to ge. */
typedef uint8_t(*data_send_to_ge)(uint8_t *buf, uint16_t buf_len);
/* function type of command. */
typedef void (*iot_cp_fn_t)(uint8_t *data,uint8_t fn);
typedef struct _iot_cp_handle_t {
/* command code. */
uint32_t cmd;
/* function handle of command code. */
iot_cp_fn_t fn_cmd;
} iot_cp_handle_t;
/*work role*/
typedef enum _cp_work_role_e
{
/* plc role */
CP_PLC_ROLE_CCO = 0x00,
/* plc role */
CP_PLC_ROLE_STA = 0x01,
} cp_work_role_e;
/* CP net state */
typedef enum _cp_net_status_e
{
/* intialized */
CP_NET_STATUS_INITED = 0x01,
/* online */
CP_NET_STATUS_ONLINE = 0x02,
/* offline */
CP_NET_STATUS_OFFLINE = 0x03,
CP_NET_STATUS_INVALID = 0xFF,
} cp_status_e;
/* CP net state */
typedef enum _cp_task_rpt_type_e
{
/* The corresponding offset of the signal */
CP_SIGNAL_REPORT_ERR = 0,
/* The corresponding offset of the signal*/
CP_SIGNAL_REPORT_HISTORY = 1,
/* Maximum cnt of retransmit signal id*/
CP_REPORT_SIGNAL_MAX_CNT = 2,
} cp_task_rpt_type_e;
/* CP net state */
typedef enum _cp_task_rpt_mask_e
{
/*transmit node's error aborting info fn :60H*/
CP_REPORT_ERR_ON = 0x01,
CP_REPORT_ERR_OFF = 0xFE,
/*transmit node's history info fn :63H*/
CP_REPORT_HISTORY_ON = 0x02,
CP_REPORT_HISTORY_OFF = 0xFD,
} cp_task_rpt_mask_e;
/* cp order check value */
enum _cp_order_check_e {
/* order check default value */
IOT_CP_ORDER_CHECK_DEFAULT = 0x0,
/* order checked */
IOT_CP_ORDER_CHECKED = 0x1,
/* order unchecked */
IOT_CP_ORDER_UNCHECK = 0x2,
};
/** cp_task message */
typedef struct _iot_cp_task_msg {
/* iot task message */
iot_task_msg_t task_msg;
/* pointer to message data */
void *data;
/* another data field */
uint32_t data2;
} iot_cp_task_msg_t;
/* config order result */
typedef enum _cp_cfg_po_ret_code_e
{
/* config order successfully */
IOT_CP_CFG_PO_RET_SUCCESS = 0x00,
/* config order failed due to error data received */
IOT_CP_CFG_PO_RET_ERR_DATA = 0x01,
/* config order failed due to busy */
IOT_CP_CFG_PO_RET_BUSY = 0x02,
/* config order failed due to device malfunction */
IOT_CP_CFG_PO_RET_DEV_FAULT = 0x03,
/* config order failed due to plug out */
IOT_CP_CFG_PO_RET_PLUG_OUT = 0x04,
/* config order failed due to po matched */
IOT_CP_CFG_PO_RET_NO_PO = 0x04,
/* config order failed due to in maintain mode */
IOT_CP_CFG_PO_RET_MAINTENANCE = 0x06,
} cp_cfg_po_ret_code_e;
typedef enum _cp_result_rsp_code_e
{
/* config order successfully */
IOT_RESULT_CONFIG_SUCCESS = 0x00,
/* config RTC successfully */
IOT_RESULT_RTC_SUCCESS = 0x00,
/* find free nodes err*/
IOT_RESULT_FIND_FREE_ERR = 0x00,
/* find free nodes successfully*/
IOT_RESULT_FIND_FREE_SUCCESS = 0x01,
/* config order failed due to error data received */
IOT_RESULT_RET_ERR_DATA = 0x01,
} cp_result_rsp_code_e;
/* charging mode */
typedef enum _cp_cmd_charg_mode_e
{
/* charging based on time */
IOT_CP_CHARGE_MODE_TIME = 0x00,
/* charging based on money */
IOT_CP_CHARGE_MODE_MONEY = 0x01,
/* charging based on power consumption */
IOT_CP_CHARGE_MODE_POWER = 0x02,
/* charging until fulled */
IOT_CP_CHARGE_MODE_FULL_CHARG = 0x03,
/* charging based on fix time */
IOT_CP_CHARGE_MODE_FIX_TIME = 0x04,
} cp_cmd_charg_mode_e;
/* config function code */
typedef enum _cp_cmd_set_fn_e
{
/* config node's parameter */
IOT_CP_CMD_SET_PARAMTR = 0x01,
/* config node's time */
IOT_CP_CMD_SET_RTC_TIME = 0x02,
/* config node's working mode */
IOT_CP_CMD_SET_WORK_MODE = 0x03,
/* issue order number */
IOT_CP_CMD_SET_NEW_PO = 0x40,
/* issue order number */
IOT_CP_CMD_SET_END_PO = 0x41,
/* issue order number */
IOT_CP_CMD_SET_FIND_FREE = 0x42,
/* stop charging due to emergency */
IOT_CP_CMD_SET_EMERGENT_STOP = 0x66,
} cp_cmd_set_fn_e;
typedef enum _cp_cmd_query_fn_e
{
/* query node's status and */
IOT_CP_CMD_QUERY_STATUS = 0x20,
/* query data of charging device */
IOT_CP_CMD_QUERY_DEVIC_DATA = 0x21,
/* query node's version info */
IOT_CP_CMD_QUERY_VER_INFO = 0x22,
/* query node's parameter */
IOT_CP_CMD_QUERY_PARAMTR = 0x23,
/* query node's time */
IOT_CP_CMD_QUERY_TIME = 0x24,
/* query node's time */
IOT_CP_CMD_QUERY_CHAG_RECORD = 0x25,
/* concentrator query node's charging data */
IOT_CP_CMD_CONCENT_QUERY_DATA = 0x65,
/* private cmd: query node's meter data */
IOT_CP_CMD_QUERY_METER_DATA = 0x80,
} cp_cmd_query_fn_e;
typedef enum _cp_cmd_rpt_fn_e
{
/* report data to monitor once error aborting happened */
IOT_CP_CMD_RPT_ERR_ABORT = 0x60,
/* report correcting time */
IOT_CP_CMD_RPT_QUERY_RTC = 0x61,
/* report node's history info */
IOT_CP_CMD_RPT_HISTORY_DATA = 0x63,
/* report node's status change */
IOT_CP_CMD_RPT_STATUS_CHANGE = 0x64,
} cp_cmd_rpt_fn_e;
typedef enum _cp_work_Mode_e
{
/*working mode: maintenance mode*/
IOT_CP_MAINTENANCE_MODE = 0x00,
/*working mode: operating mode*/
IOT_CP_NORMAL_MODE = 0x01,
IOT_CP_WORK_MODE_MAX = 0x02,
} cp_work_Mode_e;
typedef enum _cp_work_State_e
{
/* working state: idle */
IOT_CP_WORK_STATE_IDLE = 0x00,
/* working state: occupied, plug in */
IOT_CP_WORK_STATE_OCCUPIED = 0x01,
/* working state: under charging */
IOT_CP_WORK_STATE_CHARGING = 0x02,
/* working state: charge complet */
IOT_CP_WORK_STATE_CHARGED = 0x03,
/* working state: break down due to fault */
IOT_CP_WORK_STATE_FAULT = 0x04,
/* working state: under maintaince */
IOT_CP_WORK_STATE_MAINTAIN = 0x05,
/* concentrator query node's charging data */
IOT_CP_WORK_STATE_NOT_SUPPORT = 0xFF,
} cp_work_State_e;
typedef enum _cp_work_Fault_State_e
{
/* fault status */
/* overvolt */
IOT_CP_WORK_FAULT_OVERVOLT = 0x0001,
/* undervolt */
IOT_CP_WORK_FAULT_UNDERVOLT = 0x0002,
/* overcurrent */
IOT_CP_WORK_FAULT_OVERCUR = 0x0004,
/* overload*/
IOT_CP_WORK_FAULT_OVERLOAD = 0x0008,
/* over temperature */
IOT_CP_WORK_FAULT_OVERTEMP = 0x0010,
/* connection faluare */
IOT_CP_WORK_FAULT_CONN_FAIL = 0x0020,
/* leak-current protection */
IOT_CP_WORK_FAULT_LEAD_CUE_PROTEC = 0x0040,
/* ground fault */
IOT_CP_WORK_FAULT_GND_ERR = 0x0080,
/* charging timeout alarm enable */
IOT_CP_WORK_FAULT_CHARG_TIMEOUT = 0x0100,
/* reserved for future */
} cp_work_Fault_State_e;
typedef enum _cp_charg_end_type_e
{
/* end charge due to fault case */
IOT_CP_END_TPYE_FAULT = 0x01,
/* end charge due to disconnection */
IOT_CP_END_TPYE_DISCONN = 0x02,
/* end charge due to charging complet */
IOT_CP_END_TPYE_CHARGED = 0x03,
/* end charge due to achive the target setting */
IOT_CP_END_TPYE_SETUP = 0x04,
/* end charge due to recevied a emergence stop cmd */
IOT_CP_END_TPYE_EMERG = 0x05,
/* end charge due to recevied a ending po cmd */
IOT_CP_END_TPYE_END_PO = 0x06,
/* unknown type */
IOT_CP_END_TPYE_UNKNOWN = 0xFF,
} cp_charg_end_type_e;
#pragma pack(push) // save the pack status
#pragma pack(1) // 1 byte align
#if CP_ZC_ENABLE == 1
typedef struct _cp_zc_info_t
{
/* gpio number for zc input */
uint8_t zc_gpio;
/* zc sample buffer index */
uint8_t buf_indx;
/* sample data buffer */
uint8_t zc_buf[IOT_CP_ZC_SAMPLE_CNT];
/* calculated zc period, unit: 1us */
uint32_t zc_period;
/* indicate the zc ticks data vaild */
bool_t zc_tick_vaild;
/* indicate the zc period data vaild */
bool_t zc_period_vaild;
/* last time recorded ticks */
uint32_t pre_triger_ticks;
} cp_zc_info_t;
typedef struct _cp_relay_zc_ctrl_t
{
/* request bitmap for relay's control, indicate which relay will be controled */
uint8_t bm_req;
/* bitmap of relay's on/off state, if reques flag is set, relay's state should be reverse */
uint8_t bm_relay_state;
/* zc information */
cp_zc_info_t zc_info;
/* GP timer ID */
uint8_t gp_timer_id;
/* indicate GP timer's running status, true--running, false--not running */
bool_t timer_running;
} cp_relay_zc_ctrl_t;
#endif
typedef struct _cp_frm_hdr_t
{
/* premable code 0x68 */
uint8_t preamble;
/* function code */
uint8_t fn;
/* data length: less than 250 */
uint8_t data_len;
} cp_frm_hdr_t;
typedef struct _cp_frm_tail_t
{
/* checksum: from preamble code to the last byte of data field */
uint8_t cs;
/* tail code: 0x16 */
uint8_t tail;
} cp_frm_tail_t;
typedef struct _cp_sub_date_t
{
/* node time: year */
uint8_t year;
/* node time: month */
uint8_t month;
/* node time: date */
uint8_t date;
/* node time: hour */
uint8_t hour;
/* node time: minute */
uint8_t min;
/* node time: second */
uint8_t sec;
} cp_sub_date_t;
typedef struct _cp_date_t
{
/* node time: week */
uint8_t week;
cp_sub_date_t sub_date_t;
} cp_date_t;
typedef struct _cp_ver_info_t
{
/* node time: year */
uint8_t year;
/* node time: month */
uint8_t month;
/* node time: date */
uint8_t date;
/* version number */
uint8_t ver_num;
} cp_ver_info_t;
typedef struct _cp_fault_t
{
/* error status */
uint16_t overvolt :1,
/* undervolt */
undervolt :1,
/* overcurrent */
overcur :1,
/* overload*/
overload :1,
/* over temperature */
overtemp :1,
/* connection faluare */
conn_fail :1,
/* leak-current protection */
leak_cur_protec :1,
/* ground fault */
gnd_err :1,
/* charging timeout alarm enable */
charg_timeout :1,
/* reserved for future */
resved :7;
} cp_fault_t;
typedef struct _cp_plug_state_t
{
/* socket number */
uint8_t plug_num;
/* pre-working status, see IOT_CP_WORK_STATE_XXX */
uint8_t pre_work_state;
/* current working status, see IOT_CP_WORK_STATE_XXX */
uint8_t work_state;
/* restore working status after fault recover, see IOT_CP_WORK_STATE_XXX */
uint8_t restore_state;
/* plug status: 0--disconnected, 1--connected */
uint16_t plug_in;
/* incumbent volt of plug */
uint16_t incumbent_v;
/* error status */
cp_fault_t fault_t;
/* fault data*/
uint32_t fault_data;
} cp_plug_state_t;
typedef struct _cp_plug_history_info_t{
/* record number */
uint8_t record_sn;
/* ord checked or not: 0x0:default, 0x1:checked, 0x2:uncheck */
uint8_t checked;
/* order number */
uint8_t po_num[CP_PO_NUMBER_SIZE];
/* type of ending charge, see IOT_CP_END_TPYE_XXX */
uint8_t end_type;
/* working status, see IOT_CP_WORK_STATE_XXX */
uint8_t work_state;
/* The current amount of electricity, unit: 0.01kwh */
uint32_t elect_cur;
/* The last charged current amount of electricity, unit: 0.01kwh */
uint32_t elect_last;
/* charged time, unit: min */
uint16_t charg_time;
/* fault status */
cp_fault_t fault_t;
/* fault data*/
uint32_t fault_data;
/*charging start time*/
cp_date_t start_date_t;
/*end of charge time*/
cp_date_t end_date_t;
} cp_plug_history_info_t;
//meter callbark : meter data struct
typedef struct _cp_plugs_state_info_t
{
/* socket number */
uint8_t pulg_num;
/* temperature, unit: 1 Centigrade */
uint8_t tmperature;
/* charging volt, unit: 100mV */
uint16_t volt;
/* charging current, unit: mA */
uint32_t current;
/* power rate, unit: w */
uint32_t power;
/*The current amount of electricity, unit: 0.01kwh */
uint32_t elect_cur;
/*The last charged current amount of electricity, unit: 0.01kwh */
uint32_t elect_last;
/* leak-current, unit: mA */
uint16_t leak_current;
/* voltage frequnce, unit: 0.01HZ */
uint16_t freq;
/* power factor, unit: 0.01 */
uint8_t factor;
/* threshold of open circuit */
uint8_t discon_cur_th;
/* rated volt */
uint16_t rated_volt;
} cp_plugs_state_info_t;
typedef struct _cp_sub_info_t
{
/* threshold of leakage current protection */
uint8_t leak_cur_protc_th;
/* threshold of leakage current protection time */
uint8_t leak_cur_protc_tm_th;
/* threshold of charging timeout time */
uint8_t charg_timeout_th;
/* time of charge started */
uint8_t charg_start_tm;
/* threshold of open circuit */
uint8_t discon_cur_th;
} cp_sub_info_t;
typedef struct _cp_plug_threshold_info_t{
/* threshold of current for full charging */
uint16_t full_chg_cur_th;
/* threshold current timer for full charging */
uint8_t full_chg_cur_tm_th;
/* threshold of overload protection */
uint16_t over_load_th;
/* threshold of overload protection time */
uint16_t over_load_tm_th;
/* threshold of leakage current protection */
uint8_t leak_cur_protc_th;
/* threshold of leakage current protection time */
uint8_t leak_cur_protc_tm_th;
/* threshold of charging timeout time */
uint8_t charg_timeout_th;
/* time of charge started */
uint8_t charg_start_tm;
/* threshold of open circuit */
uint8_t discon_cur_th;
/* rated volt */
uint16_t rated_volt;
/* fault status */
union {
/* overvolt alarm enable */
uint16_t alarm_en_overvolt :1,
/* undervolt alarm enable */
alarm_en_undervolt :1,
/* overcurrent alarm enable */
alarm_en_overcur :1,
/* overload alarm enable */
alarm_en_overload :1,
/* over temperature enable */
alarm_en_overtemp :1,
/* connection failure enable */
alarm_en_conn_fail :1,
/* leak-current protection alarm enable */
alarm_en_leak_cur :1,
/* ground fault alarm enable */
alarm_en_gnd_err :1,
/* charging timeout alarm enable */
alarm_en_charge_timeout :1,
/* reserved for future */
resved :7;
uint16_t alarm_en_data;
}alarm;
} cp_plug_threshold_info_t;
typedef struct _cp_flash_info_t
{
/* threshold saved eigenvalue, CP_THESHOLD_EIGENVALUE */
uint32_t th_eigenvalue;
/* all the threshold information */
cp_plug_threshold_info_t plug_th[IOT_CP_MAX_PLUG_CNT];
/* charging history data */
cp_plug_history_info_t his_info[IOT_CP_MAX_PLUG_CNT];
} cp_flash_info_t;
typedef struct _cp_plug_info_t
{
cp_plug_state_t plug_state;
/* order number */
uint8_t po_num[CP_PO_NUMBER_SIZE];
/* charg mode, see IOT_CP_CHARGE_MODE_XXX */
uint8_t charge_mode;
/* charg data */
uint16_t charge_data;
/* threshold of current for full charging */
uint16_t full_chg_cur_th;
/* threshold current timer for full charging */
uint8_t full_chg_cur_tm_th;
/* threshold of overload protection */
uint16_t over_load_th;
/* threshold of overload protection time */
uint16_t over_load_tm_th;
cp_sub_info_t sub_info;
/* rated volt */
uint16_t rated_volt;
/* device type */
uint8_t dev_type;
/* temperature, unit: 1 Centigrade */
uint8_t tmperature;
/* charging volt, unit: 100mV */
uint16_t volt;
/* charging current, unit: mA */
uint32_t current;
/* power rate, unit: w */
uint32_t power;
/*The total amount of electricity */
uint32_t elect_total;
/*The total amount of electricity before charge, unit: 0.01kwh */
uint32_t elect_init;
/*The current amount of electricity, unit: 0.01kwh */
uint32_t elect_cur;
/*The last charged current amount of electricity, unit: 0.01kwh */
uint32_t elect_last;
/* charged time, unit: min */
uint16_t charg_time;
/* The last charge's electricity, unit: 0.01kwh */
uint32_t early_elect_cur;
/* The last charged current amount of electricity, unit: 0.01kwh */
uint32_t early_elect_last;
/* charged time, unit: min */
uint16_t early_charg_time;
/* leak-current, unit: mA */
uint16_t leak_current;
/* voltage frequnce, unit: 0.01HZ */
uint16_t freq;
/* power factor, unit: 0.01 */
uint8_t factor;
/*date of new po setting*/
cp_sub_date_t date_t;
/*date of charging done */
cp_sub_date_t date_charged;
/* timestamp of new po setting, seconds */
uint32_t new_po_ts;
/* operation cfg */
uint8_t en_on;
/* current record number */
uint8_t record_sn_cur;
/* charging history data */
cp_plug_history_info_t his_info[IOT_CP_MAX_HIS_INFO_CNT];
/* last historical record */
uint8_t his_last;
/* the relay state, plug in or plug out */
bool_t relay_state;
/* count of retry for reporting to platform */
uint8_t rpt_cnt;
/* reporting bitmap: indicate which report cmd should be sending retry */
uint8_t rpt_bitmap;
/* interval counter of transmit to platform*/
uint16_t rpt_cnt_down;
/* data of transmit to platform*/
uint8_t rpt_data;
/* sequnce number for sending cmd*/
uint32_t send_signal_sn[CP_REPORT_SIGNAL_MAX_CNT];
/* sequnce number for received cmd*/
uint32_t recv_signal_sn[CP_REPORT_SIGNAL_MAX_CNT];
} cp_plug_info_t;
//energe meter data infor struct
typedef struct _cp_plugs_em_info_t
{
/* sigle current, unit: mA */
uint16_t current;
/* power rate, unit: w */
uint16_t power;
/* power factor, unit: 0.01 */
uint8_t factor;
/* Incumbent volt, unit: 100mV */
uint16_t incumbent_v;
/* woking state, see IOT_CP_WORK_STATE */
uint8_t work_state;
/* plug state, in/out */
uint8_t plug_state;
/* bitmap of fault tpye */
cp_fault_t fault;
} cp_plugs_em_info_t;
typedef struct _cp_rsp_frame_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* data field */
uint8_t data[0];
} cp_rsp_frame_t;
typedef struct _cp_param_cfg_fn01_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* threshold of current for full charging */
uint16_t full_chg_cur_th;
/* threshold current timer for full charging */
uint8_t full_chg_cur_tm_th;
/* threshold of overload protection */
uint16_t over_load_th;
/* threshold of overload protection time */
uint16_t over_load_tm_th;
cp_sub_info_t sub_info;
/* rated volt */
uint16_t rated_volt;
/* fault status */
uint16_t alarm;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_param_cfg_fn01_t;
typedef struct _cp_rsp_param_cfg_fn01_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* search result, 0--fail, 1--success */
uint8_t result;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_rsp_param_cfg_fn01_t;
typedef struct _cp_except_rsp_param_cfg_fn01_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* search result, 0--fail, 1--success */
uint8_t result;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_except_rsp_param_cfg_fn01_t;
typedef struct _cp_time_cfg_fn02_t
{
/* frame header */
cp_frm_hdr_t hdr;
cp_date_t date_t;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_time_cfg_fn02_t;
typedef struct _cp_rsp_time_cfg_fn02_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* search result, 0--fail, 1--success */
uint8_t result;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_rsp_time_cfg_fn02_t;
typedef struct _cp_except_rsp_time_cfg_fn02_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* search result, 0--fail, 1--success */
uint8_t result;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_except_rsp_time_cfg_fn02_t;
typedef struct _cp_mode_cfg_fn03_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* working mode, 0--maintain, 1--normal */
uint8_t work_mode;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_mode_cfg_fn03_t;
typedef struct _cp_rsp_mode_cfg_fn03_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* search result, 0--fail, 1--success */
uint8_t result;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_rsp_mode_cfg_fn03_t;
typedef struct _cp_except_rsp_mode_cfg_fn03_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* search result, 0--fail, 1--success */
uint8_t result;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_except_rsp_mode_cfg_fn03_t;
typedef struct _cp_query_sta_status_fn20_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_query_sta_status_fn20_t;
typedef struct _cp_rsp_sta_status_fn20_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* working status, see IOT_CP_WORK_STATE_XXX */
uint8_t work_state;
/* plug status: 0--disconnected, 1--connected */
uint16_t plug_in;
/* fault status */
cp_fault_t fault_t;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_rsp_sta_status_fn20_t;
typedef struct _cp_except_rsp_sta_status_fn20_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* working status, see IOT_CP_WORK_STATE_XXX */
uint8_t work_state;
/* search result, 0--fail, 1--success */
uint8_t result;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_except_rsp_sta_status_fn20_t;
typedef struct _cp_query_charg_data_fn21_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_query_charg_data_fn21_t;
typedef struct _cp_rsp_charg_data_fn21_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* socket number */
uint8_t po_num[CP_PO_NUMBER_SIZE];
/* device type */
uint8_t dev_type;
/* temperature, unit: 1 Centigrade */
uint8_t tmperature;
/* charging volt, unit: 100mV */
uint16_t volt;
/* charging current, unit: mA */
uint32_t current;
/* power rate, unit: w */
uint32_t power;
/*The current amount of electricity, unit: 0.01kwh */
uint32_t elect_cur;
/*The last charged current amount of electricity, unit: 0.01kwh */
uint32_t elect_last;
/* charged time, unit: min */
uint16_t charg_time;
/* leak-current, unit: mA */
uint16_t leak_current;
/* voltage frequnce, unit: 0.01HZ */
uint16_t freq;
/* power factor, unit: 0.01 */
uint8_t factor;
cp_sub_date_t sub_date_t;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_rsp_charg_data_fn21_t;
typedef struct _cp_except_rsp_charg_data_fn21_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* search result, 0--fail, 1--success */
uint8_t result;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_except_rsp_charg_data_fn21_t;
typedef struct _cp_query_ver_info_fn22_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_query_ver_info_fn22_t;
typedef struct _cp_rsp_ver_info_fn22_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* software information */
uint32_t sw_info;
/* hardware information */
uint32_t hw_info;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_rsp_ver_info_fn22_t;
typedef struct _cp_except_rsp_ver_info_fn22_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* search result, 0--fail, 1--success */
uint8_t result;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_except_rsp_ver_info_fn22_t;
typedef struct _cp_query_cfg_param_fn23_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_query_cfg_param_fn23_t;
typedef struct _cp_rsp_cfg_param_fn23_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* threshold of current for full charging */
uint16_t full_chg_cur_th;
/* threshold current timer for full charging */
uint8_t full_chg_cur_tm_th;
/* threshold of overload protection */
uint16_t over_load_th;
/* threshold of overload protection time */
uint16_t over_load_tm_th;
cp_sub_info_t sub_info;
/* rated volt */
uint16_t rated_volt;
/* status alarm */
uint16_t alarm;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_rsp_cfg_param_fn23_t;
typedef struct _cp_except_rsp_cfg_param_fn23_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* search result, 0--fail, 1--success */
uint8_t result;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_except_rsp_cfg_param_fn23_t;
typedef struct _cp_query_sta_time_fn24_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_query_sta_time_fn24_t;
typedef struct _cp_rsp_sta_time_fn24_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* sta time*/
cp_date_t date_t;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_rsp_sta_time_fn24_t;
typedef struct _cp_query_charg_record_fn25_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* socket number */
uint8_t plug_num;
/* record number */
uint8_t record_sn;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_query_charg_record_fn25_t;
typedef struct _cp_rsp_charg_record_fn25_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* record number */
uint8_t record_sn;
/* order number */
uint8_t po_num[CP_PO_NUMBER_SIZE];
/* type of ending charge, see IOT_CP_END_TPYE_XXX */
uint8_t end_type;
/* working status, see IOT_CP_WORK_STATE_XXX */
uint8_t work_state;
/* The current amount of electricity, unit: 0.01kwh */
uint32_t elect_cur;
/* The last charged current amount of electricity, unit: 0.01kwh */
uint32_t elect_last;
/* charged time, unit: min */
uint16_t charg_time;
/* fault status */
cp_fault_t fault_t;
/* fault data*/
uint32_t fault_data;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_rsp_charg_record_fn25_t;
typedef struct _cp_except_rsp_charg_record_fn25_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* search result, 0--fail, 1--success */
uint8_t result;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_except_rsp_charg_record_fn25_t;
typedef struct _cp_new_po_cfg_fn40_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* order number */
uint8_t po_num[CP_PO_NUMBER_SIZE];
/* charg mode, see IOT_CP_CHARGE_MODE_XXX */
uint8_t charge_mode;
/* charg data */
uint16_t charge_data;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_new_po_cfg_fn40_t;
typedef struct _cp_rsp_new_po_cfg_fn40_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* order number */
uint8_t po_num[CP_PO_NUMBER_SIZE];
/* cfg result, see IOT_CP_CFG_ORDER_RET_XXX */
uint8_t result;
/* failure data */
uint16_t fault;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_rsp_new_po_cfg_fn40_t;
typedef struct _cp_except_rsp_new_po_cfg_fn40_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* search result, 0--fail, 1--success */
uint8_t result;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_except_rsp_new_po_cfg_fn40_t;
typedef struct _cp_end_po_cfg_fn41_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* order number */
uint8_t po_num[CP_PO_NUMBER_SIZE];
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_end_po_cfg_fn41_t;
typedef struct _cp_rsp_end_po_cfg_fn41_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* order number */
uint8_t po_num[CP_PO_NUMBER_SIZE];
/* cfg result, see IOT_CP_CFG_ORDER_RET_XXX */
uint8_t result;
/* The last charge's electricity, unit: 0.01kwh */
uint32_t early_elect_cur;
/* The last charged current amount of electricity, unit: 0.01kwh */
uint32_t early_elect_last;
/* charged time, unit: min */
uint16_t early_charg_time;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_rsp_end_po_cfg_fn41_t;
typedef struct _cp_except_rsp_end_po_cfg_fn41_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* search result, 0--fail, 1--success */
uint8_t result;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_except_rsp_end_po_cfg_fn41_t;
typedef struct _cp_search_idle_fn42_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* operation cfg */
uint8_t en_on;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_search_idle_fn42_t;
typedef struct _cp_rsp_search_idle_fn42_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* search result, 0--fail, 1--success */
uint8_t result;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_rsp_search_idle_fn42_t;
typedef struct _cp_except_rsp_search_idle_fn42_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* search result, 0--fail, 1--success */
uint8_t result;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_except_rsp_search_idle_fn42_t;
typedef struct _cp_rpt_charg_abort_fn60_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* cmd SN */
uint32_t signal_sn;
/* order number */
uint8_t po_num[CP_PO_NUMBER_SIZE];
/* type of ending charge, see IOT_CP_END_TPYE_XXX */
uint8_t end_type;
/* working status, see IOT_CP_WORK_STATE_XXX */
uint8_t work_state;
/* The current amount of electricity, unit: 0.01kwh */
uint32_t elect_cur;
/* The last charged current amount of electricity, unit: 0.01kwh */
uint32_t elect_last;
/* charged time, unit: min */
uint16_t charg_time;
/* fault status */
cp_fault_t fault_t;
/* fault data*/
uint32_t fault_data;
/* socket number */
uint8_t plug_num;
/* frame tail */
cp_frm_tail_t tail;
} cp_rpt_charg_abort_fn60_t;
typedef struct _cp_ack_charg_abort_fn60_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* search result, 0--fail, 1--success */
uint8_t result;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_ack_charg_abort_fn60_t;
typedef struct _cp_rpt_query_sta_time_fn61_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_rpt_query_sta_time_fn61_t;
typedef struct _cp_ack_query_sta_time_fn61_t
{
/* frame header */
cp_frm_hdr_t hdr;
/*get RTC*/
cp_date_t date_t;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_ack_query_sta_time_fn61_t;
typedef struct _cp_rpt_history_data_fn63_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* cmd SN */
uint32_t signal_sn;
/* order number */
uint8_t po_num[CP_PO_NUMBER_SIZE];
/* type of ending charge, see IOT_CP_END_TPYE_XXX */
uint8_t end_type;
/* charged time, unit: min */
uint16_t charg_time;
/* The current amount of electricity, unit: 0.01kwh */
uint32_t elect_cur;
/* The last charged current amount of electricity, unit: 0.01kwh */
uint32_t elect_last;
cp_sub_date_t date_t;
/* socket number */
uint8_t plug_num;
/* frame tail */
cp_frm_tail_t tail;
} cp_rpt_history_data_fn63_t;
typedef struct _cp_ack_history_data_fn63_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* search result, 0--fail, 1--success */
uint8_t result;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_ack_history_data_fn63_t;
//sta report equipment status and fault information
typedef struct _cp_rpt_status_change_fn64_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* cmd SN */
uint32_t signal_sn;
/* working status, see IOT_CP_WORK_STATE_XXX */
uint8_t work_state;
/* fault status */
cp_fault_t fault_t;
/* socket number */
uint8_t plug_num;
/* order number */
uint8_t po_num[CP_PO_NUMBER_SIZE];
/* frame tail */
cp_frm_tail_t tail;
} cp_rpt_status_change_fn64_t;
typedef struct _cp_ack_status_change_fn64_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* search result, 0--fail, 1--success */
uint8_t result;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_ack_status_change_fn64_t;
//concentrator queries equipment charging data fn : 65H
typedef struct _cp_concentrator_query_data_fn65_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_concentrator_query_data_fn65_t;
//sta reply equipment charging data fn : 65H
typedef struct _cp_rsp_concentrator_query_data_fn65_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* order number */
uint8_t po_num[CP_PO_NUMBER_SIZE];
/* device type */
uint8_t dev_type;
/* temperature, unit: 1 Centigrade */
uint8_t tmperature;
/* charging volt, unit: 100mV */
uint16_t volt;
/* charging current, unit: mA */
uint32_t current;
/* power rate, unit: w */
uint32_t power;
/*The current amount of electricity, unit: 0.01kwh */
uint32_t elect_cur;
/*The last charged current amount of electricity, unit: 0.01kwh */
uint32_t elect_last;
/* charged time, unit: min */
uint16_t charg_time;
/* leak-current, unit: mA */
uint16_t leak_current;
/* voltage frequnce, unit: 0.01HZ */
uint16_t freq;
/* power factor, unit: 0.01 */
uint8_t factor;
/* socket number */
uint8_t plug_num;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
}cp_rsp_concentrator_query_data_fn65_t;
//query meter data fn : 80H
typedef struct _cp_query_meter_data_fn80_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_query_meter_data_fn80_t;
//node reply meter data fn : 80H
typedef struct _cp_rsp_meter_data_fn80_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* cmd SN */
uint32_t signal_sn;
/* power volt, unit: 100mV */
uint16_t volt;
/* leakage current, unit: 0.1mA */
uint16_t leak_i;
/* voltage frequnce, unit: 0.01HZ */
uint16_t freq;
/* information of energe meter */
cp_plugs_em_info_t em_info[IOT_CP_MAX_PLUG_CNT];
/* frame tail */
cp_frm_tail_t tail;
} cp_rsp_meter_data_fn80;
/* reply query charging data exception fn : 65H */
typedef struct _cp_except_rsp_concentrator_query_data_fn65_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* search result, 0--fail, 1--success */
uint8_t result;
/* socket number */
uint8_t plug_num;
/* frame tail */
cp_frm_tail_t tail;
} cp_except_rsp_concentrator_query_data_fn65_t;
/* emergency shutdown fn : 66H */
typedef struct _cp_set_emergency_stop_fn66_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_set_emergency_stop_fn66_t;
typedef struct _cp_rsp_emergency_stop_fn66_t
{
/* frame header */
cp_frm_hdr_t hdr;
/* search result, 1--fail, 0--success */
uint8_t result;
/* cmd SN */
uint32_t signal_sn;
/* frame tail */
cp_frm_tail_t tail;
} cp_rsp_emergency_stop_fn66_t;
#pragma pack(pop)
#ifdef __cplusplus
}
#endif
#endif /* _IOT_CP_TASK_H_ */