/* * Config.h * * Created on: 2019年12月25日 * Author: EasonYang */ #ifndef CONFIG_MAIN_H_ #define CONFIG_MAIN_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*標準輸入輸出定義*/ #include /*標準函數庫定義*/ #include /*Unix 標準函數定義*/ #include /*檔控制定義*/ #include /*PPSIX 終端控制定義*/ #include /*錯誤號定義*/ #include #include #include #include #include #include #include #include //========================== // Define system mode constant //========================== #define MODE_BOOTING 0 #define MODE_IDLE 1 #define MODE_AUTHORIZING 2 #define MODE_PREPARING 3 #define MODE_CHARGING 4 #define MODE_TERMINATING 5 #define MODE_ALARM 6 #define MODE_FAULT 7 #define MODE_RESERVATION 8 #define MODE_BOOKING 9 #define MODE_MAINTAIN 10 #define MODE_DEBUG 11 //=================================== // Define CP State constant //=================================== #define CP_STATE_UNKNOWN 0 #define CP_STATE_A 1 #define CP_STATE_B 2 #define CP_STATE_C 3 #define CP_STATE_D 4 #define CP_STATE_E 5 #define CP_STATE_F 6 //=================================== // Define start mode constant //=================================== #define START_METHOD_MANUAL 0 #define START_METHOD_RFID 1 #define START_METHOD_BACKEND 2 #define START_METHOD_BLE 3 //=================================== // Define Speaker type constant //=================================== #define SPEAKER_STOP 0 #define SPEAKER_ALWAYS_ON 1 #define SPEAKER_SHORT 2 #define SPEAKER_LONG 3 #define SPEAKER_INTERVAL_SHORT 4 #define SPEAKER_INTERVAL_LONG 5 #define SPEAKER_INTERVAL_3COUNT 6 //=================================== // Define Alarm code constant //=================================== #define ALARM_OVER_VOLTAGE 0x000001 #define ALARM_UNDER_VOLTAGE 0x000002 #define ALARM_OVER_CURRENT 0x000004 #define ALARM_OVER_TEMPERATURE 0x000008 #define ALARM_GROUND_FAIL 0x000010 #define ALARM_CP_ERROR 0x000020 #define ALARM_CURRENT_LEAK_AC 0x000040 #define ALARM_CURRENT_LEAK_DC 0x000080 #define ALARM_MCU_TESTFAIL 0x000100 #define ALARM_HANDSHAKE_TIMEOUT 0x000200 #define ALARM_EMERGENCY_STOP 0x000400 #define ALARM_RELAY_STATUS 0x000800 #define ALARM_LEAK_MODULE_FAIL 0x001000 #define ALARM_SHUTTER_FAULT 0x002000 #define ALARM_LOCKER_FAULT 0x004000 #define ALARM_POWER_DROP 0x008000 #define ALARM_CIRCUIT_SHORT 0x010000 #define ALARM_ROTATORY_SWITCH_FAULT 0x020000 #define ALARM_RELAY_DRIVE_FAULT 0x040000 //=================================== // Define Led constant //=================================== #define LED_ACTION_INIT 0 #define LED_ACTION_IDLE 1 #define LED_ACTION_AUTHED 2 #define LED_ACTION_CONNECTED 3 #define LED_ACTION_CHARGING 4 #define LED_ACTION_STOP 5 #define LED_ACTION_ALARM 6 #define LED_ACTION_MAINTAIN 7 #define LED_ACTION_RFID_PASS 8 #define LED_ACTION_RFID_FAIL 9 #define LED_ACTION_BLE_CONNECT 10 #define LED_ACTION_BLE_DISABLE 11 #define LED_ACTION_DEBUG 12 #define LED_ACTION_ALL_OFF 13 #define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args) #define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args) #define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args) extern int StoreLogMsg(const char *fmt, ...); //============================================================ // Private shared memory key define //============================================================ #define ShmChargerKey 2001 typedef struct Verion { char Version_FW[32]; char Version_HW[32]; }Ver; typedef struct PRESENTINPUTVOLTAGE { unsigned char inputType; // 0x00: Line to Line 0x01: Line to Neutral double L1N_L12; double L2N_L23; double L3N_L31; }PresentInputVoltage; typedef struct PRESENTOUTPUTVOLTAGE { double behindFuse_Voltage_C1; double behindRelay_Voltage_C1; double behindFuse_Voltage_C2; double behindRelay_Voltage_C2; }PresentOutputVoltage; typedef struct FANSPEED { unsigned short int speed[4]; }FanSpeed; typedef struct TEMPERATURE { unsigned char point[8]; }Temperature; typedef struct AUXPOWER { unsigned char voltage[8]; }AuxPower; typedef struct RELAY { unsigned char relay_status[2][8]; }Relay; typedef struct GFD { unsigned short int adc_value_positive[2]; unsigned short int adc_value_negative[2]; }Gfd; typedef struct GPIO_IN { unsigned char AC_Connector; unsigned char AC_MainBreaker; unsigned char SPD; unsigned char Door_Open; unsigned char GFD[2]; unsigned char Button[2]; unsigned char Button_Emergency; }Gpio_in; typedef struct GPIO_OUT { unsigned char AC_Connector; unsigned char Button_LED[2]; unsigned char System_LED[4]; }Gpio_out; typedef struct ALARM_LOG { unsigned char logArea; unsigned int alarmIndex; unsigned char log[8]; }Alarm_Log; typedef struct BLE_CONFIG_DATA { unsigned char isLogin:1; unsigned char isRequestStart:1; unsigned char isRequestStop:1; }Ble_Config_Data; typedef struct BLE_LONGIN_CENTRAL_ID { unsigned char id[32]; }Ble_Login_Central_Id; typedef struct RTC { unsigned short int year; unsigned char month; unsigned char day; unsigned char hour; unsigned char min; unsigned char sec; }Rtc; typedef struct PRESENTOUTPUTCURRENT { double L1N_L12[2]; double L2N_L23[2]; double L3N_L31[2]; }Presentoutputcurrent; typedef struct AC_PRIMARY_MCU { unsigned char cp_state; unsigned int current_limit; unsigned int cp_voltage_positive; unsigned int cp_voltage_negtive; unsigned char locker_state; unsigned char relay_state; unsigned char shutter_state; unsigned char meter_state; unsigned char pp_state; unsigned char rating_current; }Ac_Primary_Mcu; typedef struct AC_PRIMARY_MCU_ALARM { union { unsigned long InputAlarmCode; struct { unsigned long OVP:1; unsigned long UVP:1; unsigned long OCP:1; unsigned long OTP:1; unsigned long gmi_fault:1; unsigned long cp_fault:1; unsigned long ac_leak:1; unsigned long dc_leak:1; unsigned long mcu_selftest_fail:1; unsigned long handshaking_timeout:1; unsigned long emergency_stop:1; unsigned long relay_welding:1; unsigned long leak_module_fail:1; unsigned long shutter_fault:1; unsigned long locker_fault:1; unsigned long power_drop:1; unsigned long circuit_short:1; unsigned long set_circuit:1; unsigned long relay_drive_fault:1; unsigned long comm_timeout:1; }bits; }; }Ac_Primary_Mcu_Alarm; typedef struct AC_PRIMARY_MCU_LED { unsigned char mode; unsigned long alarm_code; }Ac_Primary_Mcu_Led; typedef struct EVSE_ID { unsigned char model_name[14]; unsigned char serial_number[12]; }Evse_Id; typedef struct AC_PRIMARY_MCU_CP_PWM_DUTY { unsigned int max_current; }Ac_Primary_Mcu_Cp_Pwm_Duty; typedef struct LEGACY_REQUEST { unsigned char isLegacyRequest:1; }Legacy_Request; typedef struct POWER_CONSUMPTION { uint32_t power_consumption; }Power_Consumption; typedef struct MCU_OP_FLAG { unsigned char isSetModePass:1; unsigned char isSetSerialNumberPass:1; unsigned char isSetModelNamePass:1; unsigned char isReadFwVerPass:1; unsigned char isMcuUpgradeReq:1; }Mcu_Op_Flag; typedef struct SYSTEM_ALARM_CODE { unsigned long SystemAlarmCode; }System_Alarm_Code; typedef struct OTHER_ALARM_CODE { unsigned char isMcuSelfTest:1; unsigned char isCurrentShort:1; unsigned char isLeakageModule:1; unsigned char isShutter:1; unsigned char isLocker:1; unsigned char isRotatorySwitchr:1; unsigned char isPowerDrop:1; unsigned char isOverCurrent:1; unsigned char isHandshakingTimeOut:1; unsigned char HandShakingAlarmRequest:1; }Other_Alarm_Code; typedef struct PILOT_VOLTAGE { float PilotVoltagePositive; float PilotVoltageNegative; }Pilot_Voltage; typedef struct FW_UPGRADE_INFO { int fwType; char modelName[17]; char location[384]; }Fw_Upgrade_Info; typedef struct GUN_INFO { Ver ver; PresentInputVoltage inputVoltage; Presentoutputcurrent outputCurrent; Temperature temperature; Ble_Config_Data bleConfigData; Ble_Login_Central_Id bleLoginCentralId; Rtc rtc; Ac_Primary_Mcu primaryMcuState; Ac_Primary_Mcu_Alarm primaryMcuAlarm; Ac_Primary_Mcu_Led primaryMcuLed; Mcu_Op_Flag mcuFlag; Power_Consumption powerConsumption; Legacy_Request legacyRequest; System_Alarm_Code systemAlarmCode; Ac_Primary_Mcu_Cp_Pwm_Duty primaryMcuCp_Pwn_Duty; Other_Alarm_Code otherAlarmCode; Pilot_Voltage PilotVoltage; }Gun_Info; struct Charger { Ver ver; Evse_Id evseId; Gun_Info gun_info[2]; Fw_Upgrade_Info fwUpgradeInfo; unsigned char rfidReq:1; unsigned char speaker_type; unsigned char isSpeakerOn:1; }; #endif /* CONFIG_MAIN_H_ */