/* * Module_PowerSharing.h * * Created on: 2020/12/07 * Author: foluswen */ #ifndef MODULE_POWERSHARING_H_ #define MODULE_POWERSHARING_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "define.h" #include "main.h" //#define DEBUG #define is_error(ptr) ((unsigned long)ptr > (unsigned long)-4000L) #define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0])) #define PASS 1 #define FAIL -1 #define ON 1 #define OFF 0 #define YES 1 #define NO 0 #define true 1 #define false 0 #define LISTEN_PORT_UDP 8421 #define LISTEN_PORT_TCP 8422 #define CONNECTION_LIMIT 8 #define ShmPowerShargingKey LISTEN_PORT_TCP enum ROTARY_SWITCH_LIMIT { SWITCH_0_DEBUG=0, SWITCH_1_12A, SWITCH_2_16A, SWITCH_3_20A, SWITCH_4_24A, SWITCH_5_28A, SWITCH_6_32A, SWITCH_7_36A, SWITCH_8_40A, SWITCH_9_48A, SWITCH_A_56A, SWITCH_B_64A, SWITCH_C_72A, SWITCH_D_80A, SWITCH_E_RESERVE, SWITCH_F_SLAVE }; enum SHARING_COMMAND { SHARING_CMD_QUERY_SHARING=0x01, SHARING_CMD_SYNC_INFO=0x81, SHARING_CMD_CONNECTION_FULL=0xfd, SHARING_CMD_CHKSUM_ERROR=0xfe, SHARING_CMD_UNKNOWN=0xff }; struct Message { int size; uint8_t buffer[2048]; }; struct CONNECTION_INFO { int socketFd; uint16_t sharingCurrent; uint16_t actualCurrent; time_t lastHeartBeatTime; uint8_t isConnected:1; uint8_t isCharging:1; }; struct POWER_SHARING { uint8_t connectedQty; struct CONNECTION_INFO Connection_Info[CONNECTION_LIMIT]; }; #endif /* MODULE_POWERSHARING_H_ */