浏览代码

2021-03-03 / Wendell

Actions
1. modify ac contactor control logic
2. send internet connection status(connection icon) through misc command
3. send alarm code to backend
4. add auto select gun function and compatible with audi version
5. auto retry when self test fail(warning level 2)
6. fix two dispenser connection bug
7. fix psu receive task lost issue(group number over range)

Files
1. As follow commit history

Image version : D0.10.XX.XXXX.XX
Wendell 4 年之前
父节点
当前提交
1a2fb28cb7

+ 56 - 25
EVSE/Projects/DO360/Apps/Config.h

@@ -45,6 +45,8 @@ typedef unsigned char			byte;
 #define BOOTTING			0
 #define BOOT_COMPLETE		1
 
+#define SM_ChargerInfoKey           3000
+
 enum _SYSTEM_STATUS
 {
 	S_BOOTING = 						0,
@@ -95,21 +97,6 @@ enum _GUN_TYPE
 	_Type_Unknown = 0xFF
 };
 
-//enum _LCM_INDEX
-//{
-//	_LCM_INIT = 			0x00,
-//	_LCM_IDLE = 			0x01,
-//	_LCM_AUTHORIZING = 		0x04,
-//	_LCM_AUTHORIZ_COMP = 	0x05,
-//	_LCM_AUTHORIZ_FAIL = 	0x06,
-//	_LCM_WAIT_FOR_PLUG = 	0x07,
-//	_LCM_PRE_CHARGE = 		0x08,
-//	_LCM_CHARGING = 		0x09,
-//	_LCM_COMPLETE = 		0x0A,
-//	_LCM_FIX = 				0x0B,
-//	_LCM_NONE = 			0xFF,
-//};
-
 enum _LCM_INDEX
 {
 	_LCM_INIT = 			0x00,
@@ -130,19 +117,22 @@ enum _DispenserAuthorizeStatus
     _AuthorizeStatus_Idle   = 0x00,
     _AuthorizeStatus_Wait   = 0x01,
     _AuthorizeStatus_Busy   = 0x02,
-    _AuthorizeStatus_Pass   = 0x03,
-    _AuthorizeStatus_Fail   = 0x04,
+    _AuthorizeStatus_Done   = 0x03,
+    _AuthorizeStatus_End    = 0x04,
 };
 
-#define AUTHORIZE_SRC_NONE_DEV      "None  Src"
-#define AUTHORIZE_SRC_LOCAL_DEV     "Connector"
-#define AUTHORIZE_SRC_REMOTE_DEV    "Connector"
+enum _ConnectorAuthorizeResult
+{
+    _AuthResult_None    = 0x00,
+    _AuthResult_Valid   = 0x01,
+    _AuthResult_Invalid = 0x02,
+};
 
-enum _AuthorizeSource
+enum _AuthorizedType
 {
-    _AuthorizeSrc_None      = 0x00,
-    _AuthorizeSrc_Local     = 0x01,
-    _AuthorizeSrc_Remote    = 0x02,
+    _AuthType_None          = 0x00,
+    _AuthType_RFID          = 0x01,
+    _AuthType_RemoteStart   = 0x02,
 };
 
 enum _SELF_TEST_SEQ
@@ -203,7 +193,8 @@ enum _EXTRA_ERR_PROCESS
 {
 	_EXTRA_ERR_PROCESS_NONE = 0,
 	_EXTRA_ERR_PROCESS_INUVP = 1,
-	_EXTRA_ERR_PROCESS_INOVP = 2
+	_EXTRA_ERR_PROCESS_INOVP = 2,
+	_EXTRA_ERR_PROCESS_PRIMARY = 3,
 };
 
 enum _CHARGER_TYPE
@@ -241,4 +232,44 @@ enum _ETHERNET_USAGE
 	_ETHERNET_USAGE_3G_4g
 };
 
+enum _CONN_STATUS
+{
+    _Connnection_Disable = 0,
+    _Connnection_Connected = 1,
+    _Connnection_Disconnected = 2,
+};
+
+typedef union
+{
+    unsigned int CtrlValue;
+    struct
+    {
+        unsigned int AcContactor:1;                 // 0: ac contactor off,         1: ac contactor on
+        unsigned int AcContactorForceOff:1;         // 0: no effect,                1: ac contactor off
+        unsigned int StandbyCountdown:1;            // 0: charger is using,         1: start countdown
+        unsigned int res:29;
+    }bits;
+}RelayControl;
+
+typedef union
+{
+    unsigned int CtrlValue;
+    struct
+    {
+        unsigned int FailureResume:1;               // 0: no error,                 1: psu failure, need resume
+        unsigned int res:31;
+    }bits;
+}PsuControl;
+
+typedef struct
+{
+    RelayControl    RelayCtrl;
+    PsuControl      PsuCtrl;
+}SysControl;
+
+typedef struct
+{
+    SysControl Control;
+}ChargerInfoData;
+
 #endif /* CONFIG_H_ */

+ 142 - 50
EVSE/Projects/DO360/Apps/Module_EvComm.c

@@ -934,9 +934,10 @@ void ConnectorIDResponse(int socket, struct PACKET_STRUCTURE *packet, unsigned c
 	send(socket, &sendBuffer, sendBuffer.Header.len + 4, 0);
 }
 
-void PowerCabinetStatusResponse(int socket, struct PACKET_STRUCTURE *packet)
+void PowerCabinetStatusResponse(int socket, struct PACKET_STRUCTURE *packet, unsigned char dispenserIndex)
 {
 	struct PACKET_STRUCTURE sendBuffer;
+	unsigned char MiscEventCode[7];
 
 	memset(&sendBuffer, 0x00, sizeof(sendBuffer));
 	sendBuffer.Header.se = packet->Header.se;
@@ -959,6 +960,14 @@ void PowerCabinetStatusResponse(int socket, struct PACKET_STRUCTURE *packet)
 		}
 	}
 
+    if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].Setting.bits.MiscNeedAnnouncement)
+    {
+        sendBuffer.Header.len += 6;
+        memset(MiscEventCode, 0, sizeof(MiscEventCode));
+        memcpy(MiscEventCode, "B40001", sizeof(MiscEventCode) - 1);
+        memcpy(&sendBuffer.Payload.data[1 + (ShmSysConfigAndInfo->SysWarningInfo.WarningCount * 6)], &MiscEventCode[0], 6);
+    }
+
 	send(socket, &sendBuffer, sendBuffer.Header.len + 4, 0);
 }
 
@@ -1290,6 +1299,46 @@ void MiscControlResponse(int socket, struct PACKET_STRUCTURE *packet, unsigned c
                 AddMiscCommand(&sendBuffer, &misc);
             }
 
+            if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].Setting.bits.BackendStatusRequest)
+            {
+                ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].Setting.bits.BackendStatusRequest = false;
+                misc.Command = _MiscCmd_BackendStatus;
+                misc.Value = ShmSysConfigAndInfo->SysInfo.CabinetMicsStatus.BackendStatus;
+
+                PRINTF_FUNC("Announce Connector %d BackendStatus: %d", packet->Header.id, (misc.Value));
+                AddMiscCommand(&sendBuffer, &misc);
+            }
+
+            if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].Setting.bits.EthernetStatusRequest)
+            {
+                ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].Setting.bits.EthernetStatusRequest = false;
+                misc.Command = _MiscCmd_EthernetStatus;
+                misc.Value = ShmSysConfigAndInfo->SysInfo.CabinetMicsStatus.EthernetStatus;
+
+                PRINTF_FUNC("Announce Connector %d EthernetStatus: %d", packet->Header.id, (misc.Value));
+                AddMiscCommand(&sendBuffer, &misc);
+            }
+
+            if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].Setting.bits.WiFiStatusRequest)
+            {
+                ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].Setting.bits.WiFiStatusRequest = false;
+                misc.Command = _MiscCmd_WiFiStatus;
+                misc.Value = ShmSysConfigAndInfo->SysInfo.CabinetMicsStatus.WiFiStatus;
+
+                PRINTF_FUNC("Announce Connector %d WiFiStatus: %d", packet->Header.id, (misc.Value));
+                AddMiscCommand(&sendBuffer, &misc);
+            }
+
+            if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].Setting.bits.TelcomModemStatusRequest)
+            {
+                ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].Setting.bits.TelcomModemStatusRequest = false;
+                misc.Command = _MiscCmd_4GStatus;
+                misc.Value = ShmSysConfigAndInfo->SysInfo.CabinetMicsStatus.TelcomModemStatus;
+
+                PRINTF_FUNC("Announce Connector %d TelcomModemStatus: %d", packet->Header.id, (misc.Value));
+                AddMiscCommand(&sendBuffer, &misc);
+            }
+
             if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].Setting.bits.HardwareRebootRequest)
             {
                 ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].Setting.bits.HardwareRebootRequest = false;
@@ -1486,27 +1535,20 @@ void ConnectorTypeBindingHandler(unsigned char dispenserIndex, unsigned char *ty
 
 BOOL IsAvailableDispenserIndexSequence(unsigned char index)
 {
-	if((ShmSysConfigAndInfo->SysInfo.DispenserInfo.CheckInLog.Status & (1 << index)) > 0)
-	{
-		// dispenser ever checkin
-		return true;
-	}
-	else
-	{
-		for(int i = 0; i < GENERAL_GUN_QUANTITY; i++)
-		{
-			if(i == index)
-			{
-				return true;
-			}
+    for(int i = 0; i < GENERAL_GUN_QUANTITY; i++)
+    {
+        if(i == index)
+        {
+            return true;
+        }
+
+        if((ShmSysConfigAndInfo->SysInfo.DispenserInfo.CheckInLog.Status & (1 << i)) == 0)
+        {
+            // i is not check in yet before index
+            return false;
+        }
+    }
 
-			if((ShmSysConfigAndInfo->SysInfo.DispenserInfo.CheckInLog.Status & (1 << index)) == 0)
-			{
-				// i is not check in yet before index
-				return false;
-			}
-		}
-	}
 	return false;
 }
 
@@ -1830,21 +1872,54 @@ BOOL ConnectorPlugInHandler(struct PACKET_STRUCTURE *packet, unsigned char dispe
 BOOL ConnectorStateHandler(struct PACKET_STRUCTURE *packet, unsigned char dispenserIndex)
 {
 	BOOL find = FindConnectorID(dispenserIndex, packet->Header.id);
+	unsigned char ConnectionState;
+	unsigned char *AlarmCode;
 
-	if(find)
+	if(find && packet->Header.len <= 8)
 	{
-		if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemoteStatus != packet->Payload.data[0])
+	    ConnectionState = packet->Payload.data[0];
+	    AlarmCode = &packet->Payload.data[1];
+
+		if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemoteStatus != ConnectionState)
 		{
-			PRINTF_FUNC("Connector %d Remote Status: %d", packet->Header.id, packet->Payload.data[0]);
+			PRINTF_FUNC("Connector %d Remote Status: %d", packet->Header.id, ConnectionState);
 
-			if((packet->Payload.data[0] == _CRS_Idle && ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemoteStatus != _CRS_Terminating) ||
-				packet->Payload.data[0] == _CRS_Terminating)
+			switch(ConnectionState)
 			{
-			    PRINTF_FUNC("*********** Connector id %d Set Stop Flag ***********\n", packet->Header.id);
-				ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].GeneralChargingData.ChargingStopFlag.bits.NormalStop = true;
+                case _CRS_Idle:
+                case _CRS_Terminating:
+                    if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemoteStatus == _CRS_Preparing ||
+                        ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemoteStatus == _CRS_Charging)
+                    {
+                        PRINTF_FUNC("*********** Connector id %d Set Normal Stop Flag ***********\n", packet->Header.id);
+                        ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].Parameter.bits.NormalStopRequest = true;
+                    }
+                    break;
+
+                case _CRS_Alarm:
+                    memcpy(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemotenAlarmCode, AlarmCode, 6);
+
+                    if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemoteStatus == _CRS_Idle)
+                    {
+                        PRINTF_FUNC("*********** Connector id %d Set Fault Status [%s] ***********", packet->Header.id,
+                            ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemotenAlarmCode);
+                        ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].Parameter.bits.FaultStatusRequest = true;
+                    }
+                    else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemoteStatus == _CRS_Preparing ||
+                        ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemoteStatus == _CRS_Charging)
+                    {
+
+                        PRINTF_FUNC("*********** Connector id %d Set Alarm Stop Flag [%s] ***********", packet->Header.id,
+                            ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemotenAlarmCode);
+                        ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].Parameter.bits.AlarmStopRequest = true;
+                    }
+                    break;
+
+                default:
+                    break;
 			}
 		}
-		ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemoteStatus = packet->Payload.data[0];
+		ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemoteStatus = ConnectionState;
 	}
 	else
 	{
@@ -1858,33 +1933,45 @@ unsigned char UserIDHandler(struct PACKET_STRUCTURE *packet, unsigned char dispe
 {
     BOOL find = FindConnectorID(dispenserIndex, packet->Header.id);
 	DispenserAck_Status authorize = _DAS_Wait;
+	unsigned char CardNumber[32];
+	unsigned char *result;
+	int length = 0;
 
-	if(find)
+	if(find || packet->Header.id == 0xFF)
 	{
-	    if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].AuthorizeStatus == _AuthorizeStatus_Idle)
+	    length = packet->Header.len - 1;
+	    memset(CardNumber, 0x00, sizeof(CardNumber));
+	    memcpy(CardNumber, packet->Payload.data, length);
+
+	    if(packet->Header.id != 0xFF)
 	    {
-	        if(!ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].Parameter.bits.AuthorizeRequest &&
-                ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].AuthorizeStatus == _AuthorizeStatus_Idle)
-	        {
-                memset(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].UserId, 0x00, 32);
-                memcpy(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].UserId, packet->Payload.data, packet->Header.len - 1);
-
-                PRINTF_FUNC("Dispenser %d connector %d user id %s need authorize", dispenserIndex + 1, packet->Header.id, ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].UserId);
-	            ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].Parameter.bits.AuthorizeRequest = true;
-	            ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].Setting.bits.AuthorizeTargetID = packet->Header.id;
-	        }
-	        authorize = _DAS_Wait;
+	        result = &ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].AuthorizingResult;
 	    }
-	    else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].AuthorizeStatus == _AuthorizeStatus_Fail)
+	    else
 	    {
-            PRINTF_FUNC("Dispenser %d connector %d user id %s authorizing fail", dispenserIndex + 1, packet->Header.id, ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].UserId);
-            authorize = _DAS_NotAllowed;
+	        result = &ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].AuthResult;
 	    }
-	    else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].AuthorizeStatus == _AuthorizeStatus_Pass)
+
+	    if(*result == _AuthResult_Valid)
 	    {
-            PRINTF_FUNC("Dispenser %d connector %d user id %s authorizing ok", dispenserIndex + 1, packet->Header.id, ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].UserId);
+            PRINTF_FUNC("Dispenser %d Target %d user id %s authorizing ok", dispenserIndex + 1, packet->Header.id, CardNumber);
             authorize = _DAS_Allowed;
 	    }
+	    else if(*result == _AuthResult_Invalid)
+	    {
+            PRINTF_FUNC("Dispenser %d Target %d user id %s authorizing fail", dispenserIndex + 1, packet->Header.id, CardNumber);
+            authorize = _DAS_NotAllowed;
+	    }
+	    else if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].AuthStatus == _AuthorizeStatus_Idle &&
+            ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].Setting.bits.AuthorizeRequest == false)
+	    {
+	        memcpy(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].UserId, CardNumber, sizeof(CardNumber));
+	        ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].AuthTarget = packet->Header.id;
+	        ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].Setting.bits.AuthorizeRequest = true;
+
+	        PRINTF_FUNC("Dispenser %d connector %d user id %s need authorize", dispenserIndex + 1, packet->Header.id, CardNumber);
+	        authorize = _DAS_Wait;
+	    }
 	    else
 	    {
 	        authorize = _DAS_Wait;
@@ -2247,7 +2334,7 @@ void DispenserSocketProcess(int socketFd, struct sockaddr_in clientInfo, unsigne
 			if(rxLen == (receiveBuffer.Header.len + PACKET_HEADER_LENGTH))
 			{
 				ackResult = _R_NG;
-				//ShowSocketData(&receiveBuffer);
+                //ShowSocketData(&receiveBuffer);
 
 				if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[index].Status == _CNS_WaitModelName)
 				{
@@ -2326,6 +2413,10 @@ void DispenserSocketProcess(int socketFd, struct sockaddr_in clientInfo, unsigne
                                 ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].Setting.bits.ConnectorTimeoutConfigRequest = 1;
                                 ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].Setting.bits.DefaultPriceConfigRequest = 1;
                                 ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].Setting.bits.CurrencyConfigRequest = 1;
+                                ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].Setting.bits.BackendStatusRequest = 1;
+                                ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].Setting.bits.EthernetStatusRequest = 1;
+                                ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].Setting.bits.WiFiStatusRequest = 1;
+                                ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].Setting.bits.TelcomModemStatusRequest = 1;
                             }
 						}
 					}
@@ -2333,7 +2424,7 @@ void DispenserSocketProcess(int socketFd, struct sockaddr_in clientInfo, unsigne
 					// Reg: 0x03, Power cabinet status
 					if(receiveBuffer.Header.op == _Header_Read && receiveBuffer.Payload.reg == _Reg_Power_Cabinet_Status)
 					{
-						PowerCabinetStatusResponse(socketFd, &receiveBuffer);
+						PowerCabinetStatusResponse(socketFd, &receiveBuffer, dispenserIndex);
 					}
 
 					// Reg: 0x04, Dispenser status
@@ -2569,7 +2660,8 @@ void InitDispenserInfo(void)
 	    ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].ReadyToCharge = 0;
 	    ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].ParentDispensetIndex = 0;
 	    ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].Parameter.Value = 0;
-	    ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].AuthorizeStatus = 0;
+	    ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].AuthorizingType = 0;
+	    ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].AuthorizingResult = 0;
 	    memset(&ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].WarningInfo, 0x00, sizeof(struct WARNING_CODE_INFO));
 
 	    //memset(&LastWarningInfo[i], 0x00, sizeof(struct WARNING_CODE_INFO));

+ 8 - 0
EVSE/Projects/DO360/Apps/Module_EvComm.h

@@ -29,6 +29,7 @@
 #define CCS_MAX_PHYSICAL_VOLTAGE        9500
 #define CCS_NATURAL_MAX_CURRENT         2000
 #define CCS_LIQUID_MAX_CURRENT          5000
+#define CCS_NATURAL_REMA_MAX_CURRENT    3000
 
 #define CHA_MAX_PHYSICAL_VOLTAGE        5000
 #define CHA_NATURAL_MAX_CURRENT         2000
@@ -36,6 +37,8 @@
 #define GBT_MAX_PHYSICAL_VOLTAGE        7500
 #define GBT_NATURAL_MAX_CURRENT         2500
 
+#define AUTO_GUN_SELECTION              0xFF
+
 struct Message
 {
 	int				size;
@@ -94,6 +97,7 @@ enum Connector_Remote_Status
 	_CRS_Preparing		= 0x01,
 	_CRS_Charging		= 0x02,
 	_CRS_Terminating	= 0x03,
+	_CRS_Alarm          = 0x04,
 };
 
 typedef enum
@@ -166,6 +170,10 @@ enum MiscCommand
     _MiscCmd_DefaultPrice       = 0x0003,
     _MiscCmd_Currency           = 0x0004,
     _MiscCmd_AccountBalance     = 0x0005,
+    _MiscCmd_BackendStatus      = 0x0006,
+    _MiscCmd_EthernetStatus     = 0x0007,
+    _MiscCmd_WiFiStatus         = 0x0008,
+    _MiscCmd_4GStatus           = 0x0009,
     _MiscCmd_HardwareReboot     = 0x0101,
     _MiscCmd_SoftwareRestart    = 0x0102,
     _MiscCmd_RemoteStart        = 0x0103,

+ 19 - 41
EVSE/Projects/DO360/Apps/Module_EventLogging.c

@@ -209,9 +209,6 @@ void RemoveFaultCodeToBuf(unsigned char *Code)
 	}
 }
 
-unsigned char MiscRequirement = 0;
-unsigned char VersionInfoRequirement = 0;
-
 int main(void)
 {
 	int ByteCount,BitCount;
@@ -231,6 +228,8 @@ int main(void)
 	}
 
 	memset((char *)&StatusCodeDisableMask, 0x00, sizeof(struct StatusCodeData));
+
+	// AlarmCode disable mask
 	StatusCodeDisableMask.AlarmCode.AlarmEvents.bits.PsuFuseBurnOut = YES;
 	StatusCodeDisableMask.AlarmCode.AlarmEvents.bits.PsuPfcAndDcdcCommFault = YES;
 	StatusCodeDisableMask.AlarmCode.AlarmEvents.bits.PsuBusVoltageUnbalance = YES;
@@ -256,44 +255,17 @@ int main(void)
 	StatusCodeDisableMask.AlarmCode.AlarmEvents.bits.PsuCriticalPointOTP = YES;
 	StatusCodeDisableMask.AlarmCode.AlarmEvents.bits.PsuDcdcOverVoltage = YES;
 
+	// InfoEvents disable mask
+	StatusCodeDisableMask.InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet = YES;
+	StatusCodeDisableMask.InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi = YES;
+	StatusCodeDisableMask.InfoCode.InfoEvents.bits.InternetDisconnectVia4Gi = YES;
+    StatusCodeDisableMask.InfoCode.InfoEvents.bits.WiFiDisable = YES;
+    StatusCodeDisableMask.InfoCode.InfoEvents.bits.Telocom4GModuleDisable = YES;
+	StatusCodeDisableMask.InfoCode.InfoEvents.bits.BackendDisconnectedViaEthernet = YES;
+	StatusCodeDisableMask.InfoCode.InfoEvents.bits.BackendDisconnectedViaEthernet = YES;
+
 	for(;;)
 	{
-	    if(MiscRequirement != ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.MiscNeedAnnouncement)
-	    {
-	        memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
-            memcpy(EventCodeTmp, "B40001", sizeof(EventCodeTmp) - 1);
-
-	        if(ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.MiscNeedAnnouncement)
-	        {
-	            DEBUG_INFO("********** Misc Command Need Announcement **********\n");
-	            AddFaultCodeToBuf(EventCodeTmp);
-	        }
-	        else
-	        {
-	            DEBUG_INFO("********** Misc Command Announced **********\n");
-	            RemoveFaultCodeToBuf(EventCodeTmp);
-	        }
-	        MiscRequirement = ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.MiscNeedAnnouncement;
-	    }
-
-	    if(VersionInfoRequirement != ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.NeedDispenserVerInfo)
-	    {
-            memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
-            memcpy(EventCodeTmp, "B40999", sizeof(EventCodeTmp) - 1);
-
-	        if(ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.NeedDispenserVerInfo)
-	        {
-                DEBUG_INFO("********** Need Update Dispenser Version Info **********\n");
-                AddFaultCodeToBuf(EventCodeTmp);
-	        }
-	        else
-	        {
-	            DEBUG_INFO("********** Dispenser Version Info Updated **********\n");
-	            RemoveFaultCodeToBuf(EventCodeTmp);
-	        }
-	        VersionInfoRequirement = ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.NeedDispenserVerInfo;
-	    }
-
 		//check Fault Status
 		for(ByteCount=0;ByteCount<4;ByteCount++)
 		{
@@ -377,13 +349,19 @@ int main(void)
 							//EventCodeTmp[0]=1;
 							DEBUG_INFO("Recovery Info Code = %s\n", EventCodeTmp);
 							ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount] &= ~(1<<BitCount);
-							RemoveFaultCodeToBuf(EventCodeTmp);
+							if(!(StatusCodeDisableMask.InfoCode.InfoEvents.InfoVal[ByteCount] & (1<<BitCount)))
+							{
+							    RemoveFaultCodeToBuf(EventCodeTmp);
+							}
 						}
 						else
 						{
 							DEBUG_INFO("Info Code = %s\n", EventCodeTmp);
 							ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount] |= (1<<BitCount);
-							AddFaultCodeToBuf(EventCodeTmp);
+							if(!(StatusCodeDisableMask.InfoCode.InfoEvents.InfoVal[ByteCount] & (1<<BitCount)))
+							{
+							    AddFaultCodeToBuf(EventCodeTmp);
+							}
 						}
 					}
 				}

+ 21 - 75
EVSE/Projects/DO360/Apps/Module_InternalComm.c

@@ -30,6 +30,7 @@
 #include	"../../define.h"
 #include	"internalComm.h"
 #include 	<stdbool.h>
+#include    "Config.h"
 
 #define ARRAY_SIZE(A)		(sizeof(A) / sizeof(A[0]))
 #define PASS				1
@@ -58,6 +59,7 @@ struct RelayModuleData			*ShmRelayModuleData[2];
 struct LedModuleData			*ShmLedModuleData;
 struct PsuData 					*ShmPsuData;
 struct OCPP16Data				*ShmOCPP16Data;
+ChargerInfoData                 *ShmChargerInfo;
 
 #define VIN_MAX_VOLTAGE_IEC         285	// 大於該值 : OVP
 #define VIN_MAX_REV_VOLTAGE_IEC     275 // 小於賦歸 OVP
@@ -126,7 +128,6 @@ int Uart5Fd;
 char *relayRs485PortName = "/dev/ttyS5";
 unsigned short fanSpeedSmoothValue = 500;
 
-bool isStopChargingCount = false;
 struct timeval _close_ac_contactor;
 
 struct timeval _priority_time;
@@ -1129,54 +1130,6 @@ void SetK1K2RelayStatus(byte index)
 	}
 }
 
-void CheckAcInputOvpStatus(byte index)
-{
-	if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP == YES ||
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == YES ||
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == YES)
-	{
-//		if ((_chargingData[index]->SystemStatus >= S_PREPARNING && _chargingData[index]->SystemStatus <= S_CHARGING) ||
-//				(_chargingData[index]->SystemStatus >= S_CCS_PRECHARGE_ST0 && _chargingData[index]->SystemStatus <= S_CCS_PRECHARGE_ST1))
-//		{
-//			if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_IEC)
-//			{
-//				if (_psuInputVolR > VIN_MAX_VOLTAGE_IEC ||
-//						_psuInputVolS > VIN_MAX_VOLTAGE_IEC ||
-//						_psuInputVolT > VIN_MAX_VOLTAGE_IEC)
-//				{
-//					PRINTF_FUNC("IEC _psuInputVolR = %f, _psuInputVolS = %f, _psuInputVolT = %f \n",
-//							_psuInputVolR, _psuInputVolS, _psuInputVolT);
-//					_chargingData[index]->StopChargeFlag = YES;
-//				}
-//
-//			}
-//			else if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_UL)
-//			{
-//				if (_psuInputVolR > VIN_MAX_VOLTAGE_UL ||
-//						_psuInputVolS > VIN_MAX_VOLTAGE_UL ||
-//						_psuInputVolT > VIN_MAX_VOLTAGE_UL)
-//				{
-//					PRINTF_FUNC("UL _psuInputVolR = %f, _psuInputVolS = %f, _psuInputVolT = %f \n",
-//							_psuInputVolR, _psuInputVolS, _psuInputVolT);
-//					_chargingData[index]->StopChargeFlag = YES;
-//				}
-//			}
-//		}
-//		else
-			_chargingData[index]->StopChargeFlag = YES;
-	}
-}
-
-void CheckPhaseLossStatus(byte index)
-{
-	if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == YES ||
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == YES ||
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == YES)
-	{
-		_chargingData[index]->StopChargeFlag = YES;
-	}
-}
-
 void SetParalleRelayStatus()
 {
 	// 之後雙槍單模機種,橋接都會上
@@ -1586,6 +1539,21 @@ int InitShareMemory()
 		result = FAIL;
 	}
 
+    if ((MeterSMId = shmget(SM_ChargerInfoKey, sizeof(ChargerInfoData), 0777)) < 0)
+    {
+        #ifdef SystemLogMessage
+        DEBUG_ERROR("shmat ChargerInfoData NG \n");
+        #endif
+        result = FAIL;
+    }
+    else if ((ShmChargerInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+    {
+        #ifdef SystemLogMessage
+        DEBUG_ERROR("shmat ChargerInfoData NG \n");
+        #endif
+        result = FAIL;
+    }
+
 	return result;
 }
 
@@ -2497,7 +2465,6 @@ int main(void)
 	{
 	    if(!ShmSysConfigAndInfo->SysInfo.FirmwareUpdate)
 	    {
-            bool isCharging = false;
             // 程序開始之前~ 必須先確定 FW 版本與硬體版本,確認後!!~ 該模組才算是真正的 Initial Comp.
             if (ShmRelayModuleData[0]->SelfTest_Comp == NO)
             {
@@ -2580,11 +2547,6 @@ int main(void)
                     // 依據當前各槍的狀態選擇 搭上/放開 Relay
                     SetK1K2RelayStatus(i);
 
-                    if (ShmSysConfigAndInfo->SysConfig.PhaseLossPolicy == YES)
-                        CheckPhaseLossStatus(i);
-
-                    CheckAcInputOvpStatus(i);
-
                     if (_chargingData[i]->SystemStatus == S_IDLE)
                     {
                         _chargingData[i]->RelayWeldingCheck = NO;
@@ -2598,7 +2560,6 @@ int main(void)
                         (ShmSysConfigAndInfo->SysInfo.PageIndex >= _LCM_AUTHORIZING && ShmSysConfigAndInfo->SysInfo.PageIndex <= _LCM_WAIT_FOR_PLUG))
                     {
                         _chargingData[i]->IsReadyToCharging = YES;
-                        isCharging = true;
 
                         // 限定只有在槍類別為 GBT 的時候才做 relay welding 的判斷
 //                        if (_chargingData[i]->Type == _Type_GB)
@@ -2626,31 +2587,16 @@ int main(void)
                 // 橋接 relay
                 SetParalleRelayStatus();
 
-                if (isCharging ||
-                    (ShmPsuData->Work_Step >= _TEST_MODE && ShmPsuData->Work_Step <= _TEST_MODE))
+                if(ShmChargerInfo->Control.RelayCtrl.bits.AcContactor == YES &&
+                        ShmChargerInfo->Control.RelayCtrl.bits.AcContactorForceOff == NO)
                 {
-                    isStopChargingCount = false;
                     outputRelay[0].relay_event.bits.AC_Contactor = YES;
                     outputRelay[1].relay_event.bits.AC_Contactor = YES;
                 }
                 else
                 {
-                    if (!isStopChargingCount)
-                    {
-                        gettimeofday(&_close_ac_contactor, NULL);
-                        isStopChargingCount = true;
-                    }
-                    else
-                    {
-                        if (((outputRelay[0].relay_event.bits.AC_Contactor == YES || outputRelay[1].relay_event.bits.AC_Contactor == YES)&&
-                                GetTimeoutValue(_close_ac_contactor) / 1000 >= (TEN_MINUTES * 1000)) ||
-                                ShmSysConfigAndInfo->SysInfo.ForceAcContactorOff == YES)
-                        {
-                            outputRelay[0].relay_event.bits.AC_Contactor = NO;
-                            outputRelay[1].relay_event.bits.AC_Contactor = NO;
-                            ShmSysConfigAndInfo->SysInfo.ForceAcContactorOff = NO;
-                        }
-                    }
+                    outputRelay[0].relay_event.bits.AC_Contactor = NO;
+                    outputRelay[1].relay_event.bits.AC_Contactor = NO;
                 }
 
                 if (ShmPsuData->Work_Step >= _TEST_MODE && ShmPsuData->Work_Step <= _TEST_MODE)

+ 18 - 2
EVSE/Projects/DO360/Apps/Module_PrimaryComm.c

@@ -37,6 +37,8 @@
 #define YES					1
 #define NO					0
 
+#define COMM_FAIL_COUNT     10
+
 typedef unsigned char 		byte;
 
 struct SysConfigAndInfo			*ShmSysConfigAndInfo;
@@ -59,6 +61,7 @@ byte _OutputDrv = 0;
 
 byte _acStatus = 0;
 byte _acChkCount = 0;
+int _CommFailCount = 0;
 
 void PRINTF_FUNC(char *string, ...);
 
@@ -259,9 +262,15 @@ void GetFwAndHwVersion()
 		strcpy((char *)ShmPrimaryMcuData->version, ver.Version_FW);
 		strcpy((char *) ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev, ver.Version_FW);
 	}
+	else
+	{
+	    _CommFailCount++;
+	}
 
 	if (Query_HW_Ver(Uart1Fd, Addr.IoExtend, &ver) == PASS)
+	{
 		PRINTF_FUNC("s2 = %s \n", ver.Version_HW);
+	}
 }
 
 void GetInputGpioStatus()
@@ -286,6 +295,7 @@ void GetInputGpioStatus()
 					ShmSysConfigAndInfo->SysInfo.AcContactorStatus = 1;
 					ShmPrimaryMcuData->InputDet.bits.AcContactorDetec = 1;
 				}
+				PRINTF_FUNC("Ac Contactor Status %s", ShmPrimaryMcuData->InputDet.bits.AcContactorDetec > 0 ? "On" : "Off");
 			}
 			else
 				_acChkCount++;
@@ -309,8 +319,8 @@ void GetInputGpioStatus()
 		//PRINTF_FUNC("left = %d \n", ShmPrimaryMcuData->InputDet.bits.Button1);
 		//PRINTF_FUNC("right = %d \n", ShmPrimaryMcuData->InputDet.bits.Button2);
 		//PRINTF_FUNC("ShmSysConfigAndInfo->SysInfo.AcContactorStatus = %d \n", ShmSysConfigAndInfo->SysInfo.AcContactorStatus);
-		if (ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec == YES)
-			DEBUG_ERROR("AC Mainbreaker occur. \n");
+		//if (ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec == YES)
+		//	DEBUG_ERROR("AC Mainbreaker occur. \n");
 	}
 }
 
@@ -477,6 +487,12 @@ int main(void)
                 {
                     ShmPrimaryMcuData->SelfTest_Comp = YES;
                 }
+
+                if(_CommFailCount >= COMM_FAIL_COUNT)
+                {
+                    PRINTF_FUNC("Primary MCU Communication Fail: %d", _CommFailCount);
+                    _CommFailCount = 0;
+                }
             }
             else
             {

+ 68 - 35
EVSE/Projects/DO360/Apps/Module_PsuComm.c

@@ -1,5 +1,6 @@
 
 #include 	"Module_PsuComm.h"
+#include    "Config.h"
 
 #define ARRAY_SIZE(A)		(sizeof(A) / sizeof(A[0]))
 #define PASS				1
@@ -26,6 +27,7 @@
 struct SysConfigAndInfo			*ShmSysConfigAndInfo;
 struct StatusCodeData 			*ShmStatusCodeData;
 struct PsuData 					*ShmPsuData;
+ChargerInfoData                 *ShmChargerInfo;
 
 bool libInitialize = false;
 byte getAvailableCapOffset = 5;
@@ -487,11 +489,14 @@ void GetModuleCountCallback(byte group, byte count)
 		ShmPsuData->SystemPresentPsuQuantity = count;
 	else
 	{
-		ShmPsuData->PsuGroup[group].GroupPresentPsuQuantity = count;
+	    if(group < GENERAL_GUN_QUANTITY)
+	    {
+	        ShmPsuData->PsuGroup[group].GroupPresentPsuQuantity = count;
+	    }
 	}
 }
 
-void GetMaxPowerAndCur(unsigned char mode, int ratingCur, int *pow, int *cur)
+void GetMaxPowerAndCur(unsigned char mode, byte group, int ratingCur, int *pow, int *cur)
 {
 	if (ShmPsuData->Work_Step < GET_SYS_CAP)
 		return;
@@ -501,8 +506,20 @@ void GetMaxPowerAndCur(unsigned char mode, int ratingCur, int *pow, int *cur)
 
 	if (mode == _MAIN_CHARGING_MODE_AVER)
 	{
-		maxCurrent /= 2;
-		maxPower /= 2;
+		//maxCurrent /= 2;
+		//maxPower /= 2;
+		if(ShmPsuData->SystemPresentPsuQuantity != 0)
+		{
+		    maxCurrent *= ShmPsuData->PsuGroup[group].GroupPresentPsuQuantity;
+		    maxCurrent /= ShmPsuData->SystemPresentPsuQuantity;
+		    maxPower *= ShmPsuData->PsuGroup[group].GroupPresentPsuQuantity;
+		    maxPower /= ShmPsuData->SystemPresentPsuQuantity;
+		}
+		else
+		{
+		    maxCurrent = 0;
+		    maxPower = 0;
+		}
 	}
 
 	if (maxPower != 0 && maxPower <= *pow)
@@ -638,7 +655,7 @@ void GetAvailableCapCallback(byte address, short maxVol, short minVol, short max
 			}
 		}
 
-		GetMaxPowerAndCur(_MAIN_CHARGING_MODE_AVER, ratingCur, &halfPow, &halfCur);
+		GetMaxPowerAndCur(_MAIN_CHARGING_MODE_AVER, group, ratingCur, &halfPow, &halfCur);
 
 //		if ((ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_GET_NEW_CAP &&
 //				 ShmSysConfigAndInfo->SysInfo.ReAssignedFlag <= _REASSIGNED_RELAY_M_TO_A))
@@ -674,7 +691,7 @@ void GetAvailableCapCallback(byte address, short maxVol, short minVol, short max
 	else if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_MAX)
 	{
 		//PRINTF_FUNC("group = %d, Final = %d \n", group, _current);
-		GetMaxPowerAndCur(_MAIN_CHARGING_MODE_MAX, _ratingcurrent, &_power, &_current);
+		GetMaxPowerAndCur(_MAIN_CHARGING_MODE_MAX, group, _ratingcurrent, &_power, &_current);
 
 		if (ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == YES)
 		{
@@ -1285,6 +1302,21 @@ int InitShareMemory()
 		result = FAIL;
 	 }
 
+    if ((MeterSMId = shmget(SM_ChargerInfoKey, sizeof(ChargerInfoData), 0777)) < 0)
+    {
+        #ifdef SystemLogMessage
+        DEBUG_ERROR("shmat ChargerInfoData NG");
+        #endif
+        result = FAIL;
+    }
+    else if ((ShmChargerInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+    {
+        #ifdef SystemLogMessage
+        DEBUG_ERROR("shmat ChargerInfoData NG");
+        #endif
+        result = FAIL;
+    }
+
     return result;
 }
 
@@ -1305,30 +1337,30 @@ void InitialPsuData()
 		ShmPsuData->PsuGroup[_groupCount].GroupErrorFlag.PsuGroupErrorValue = 0;
 	}
 
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuFuseBurnOut = YES;
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuPfcAndDcdcCommFault = YES;
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuBusVoltageUnbalance = YES;
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuBusOverVoltage = YES;
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuBusVoltageAbnormal = YES;
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuInputOVP = YES;
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuDuplicateID = YES;
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuBusUnderVoltage = YES;
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuInputPhaseLoss = YES;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuFuseBurnOut = NO;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuPfcAndDcdcCommFault = NO;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuBusVoltageUnbalance = NO;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuBusOverVoltage = NO;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuBusVoltageAbnormal = NO;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuInputOVP = NO;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuDuplicateID = NO;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuBusUnderVoltage = NO;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuInputPhaseLoss = NO;
     ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuInputUVP = NO;
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuCommunicationFail = YES;
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuSevereUnevenCurrent = YES;
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuFfcSideShutDown = YES;
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuFanFullSpeed = YES;
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuDcSideShutDown = YES;
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuPowerLimitedState = YES;
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuTemperaturePowerLimit = YES;
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuAcPowerLimit = YES;
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuDcdcEepromFault = YES;
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuFanFailureAlarm = YES;
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuOutputShortCircuit = YES;
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuPfcEepromFault = YES;
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuCriticalPointOTP = YES;
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuDcdcOverVoltage = YES;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuCommunicationFail = NO;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuSevereUnevenCurrent = NO;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuFfcSideShutDown = NO;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuFanFullSpeed = NO;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuDcSideShutDown = NO;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuPowerLimitedState = NO;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuTemperaturePowerLimit = NO;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuAcPowerLimit = NO;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuDcdcEepromFault = NO;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuFanFailureAlarm = NO;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuOutputShortCircuit = NO;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuPfcEepromFault = NO;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuCriticalPointOTP = NO;
+    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuDcdcOverVoltage = NO;
 }
 
 void Initialization()
@@ -1511,7 +1543,7 @@ void PsuReceiveRecoveryCheck(void)
             psuTaskCount++;
         }
 
-        ptrToken = strtok_r(NULL, ";", &ptrSave);
+        ptrToken = strtok_r(NULL, " ", &ptrSave);
     }
     close(fd);
 
@@ -1574,7 +1606,8 @@ int main(void)
 	while (libInitialize)
 	{
 		// 斷電狀態
-		if (ShmSysConfigAndInfo->SysInfo.AcContactorStatus == NO)
+		if (ShmChargerInfo->Control.RelayCtrl.bits.AcContactor == NO ||
+            ShmChargerInfo->Control.RelayCtrl.bits.AcContactorForceOff == YES)
 		{
 			//一但 AC Off PSU 斷電全部的 PSU Group ID 會全部清 0
 			if (!isInitialComp)
@@ -1648,15 +1681,15 @@ int main(void)
 						PRINTF_FUNC("Psu Count = %d", moduleCount);
 						if (ShmSysConfigAndInfo->SysInfo.BootingStatus == BOOTTING || psuReceiveRecovery)
 						{
-							// 電樁在 Booting 的狀態 - 自檢
-							PRINTF_FUNC("== PSU == GET_SYS_CAP");
-							ShmPsuData->Work_Step = GET_SYS_CAP;
+                            // 電樁在 Booting 的狀態 - 自檢
+                            PRINTF_FUNC("== PSU == GET_SYS_CAP");
+                            ShmPsuData->Work_Step = GET_SYS_CAP;
+                            psuReceiveRecovery = false;
 						}
 						else
 						{
 							PRINTF_FUNC("== PSU == _WORK_CHARGING");
 							ShmPsuData->Work_Step = _WORK_CHARGING;
-
 							gettimeofday(&_test_time, NULL);
 						}
 					}

文件差异内容过多而无法显示
+ 592 - 337
EVSE/Projects/DO360/Apps/main.c


二进制
EVSE/Projects/DO360/Images/ramdisk.gz


+ 52 - 26
EVSE/Projects/define.h

@@ -114,7 +114,7 @@ Storage							0x0A200000-0x7FFFFFFF		1886 MB
     #define CCS_QUANTITY            2
     #define GB_QUANTITY             0
     #define AC_QUANTITY             0
-    #define GENERAL_GUN_QUANTITY	0
+    #define GENERAL_GUN_QUANTITY    0
     #define PSU_QUANTITY            2
     #define ONE_CONNECTOR_USE       0
 #elif DO360
@@ -388,8 +388,8 @@ struct Schedule
 
 struct LocalSharingInfo
 {
-	unsigned short		AvailableShargingCurrent;		// 0 ~ rating value amp,  Synchronize from local sharing server
-	unsigned char		isConnectedSharingServer:1;		// 0: Disconnected,	1: Connected
+    unsigned short      AvailableShargingCurrent;       // 0 ~ rating value amp,  Synchronize from local sharing server
+    unsigned char       isConnectedSharingServer:1;     // 0: Disconnected, 1: Connected
 };
 
 typedef union
@@ -462,7 +462,7 @@ struct SysConfigData
 	unsigned int 			Checksum;					//4 bytes checksum
 	struct LED				LedInfo;					// LED configuration info
 	unsigned char			ShowInformation;
-	unsigned char			isReqFirstUpgrade;			//EVSE is request first upgrade from PH server
+	unsigned char           isReqFirstUpgrade;          //EVSE is request first upgrade from PH server
 };
 
 struct ChargingInfoData
@@ -557,6 +557,9 @@ typedef union
     struct
     {
         unsigned int DispenserConfigSync:1;             // 0: not synced,   1: synced
+        unsigned int MiscNeedAnnouncement:1;            // 0: no need,      1: need send misc command
+        unsigned int NeedDispenserVerInfo:1;            // 0: no need,      1: need dispenser to report it's version info
+        unsigned int EnableAutoGunSelection:1;          // 0: disable,      1: enable auto gun selection
         unsigned int AuthorizeRequest:1;                // 0: idle,         1: requesting                           ( dispenser -> cabinet)
         unsigned int ConnectorTimeoutConfigRequest:1;   // 0: no request,   1: connector timeout setting            (    ocpp   -> cabinet -> dispenser)
         unsigned int DefaultPriceConfigRequest:1;       // 0: no request,   1: default price setting                (    ocpp   -> cabinet -> dispenser)
@@ -565,11 +568,14 @@ typedef union
         unsigned int HardwareRebootConfirm:1;           // 0: no effect,    1: dispenser confirmed
         unsigned int SoftwareResetRequest:1;            // 0: no request,   1: software reset request               (    ocpp   -> cabinet -> dispenser)
         unsigned int SoftwareResetConfirm:1;            // 0: no effect,    1: dispenser confirmed
-        unsigned int AuthorizeTargetID:8;               // authorize target connector id
         unsigned int FirmwareUpdateRequest:1;           // firmware update request
         unsigned int FirmwareUpdateConfirm:1;           // firmware update start
         unsigned int FirmwareUpdateCompleted:1;         // firmware update completed
-        unsigned int res:12;
+        unsigned int BackendStatusRequest:1;            // 0: no request,   1: backend connection status has changed            ( cabinet -> dispenser)
+        unsigned int EthernetStatusRequest:1;           // 0: no request,   1: ethernet connection status has changed           ( cabinet -> dispenser)
+        unsigned int WiFiStatusRequest:1;               // 0: no request,   1: wifi connection status has changed               ( cabinet -> dispenser)
+        unsigned int TelcomModemStatusRequest:1;        // 0: no request,   1: 4g connection status has changed                 ( cabinet -> dispenser)
+        unsigned int res:13;
     }bits;
 }DispenserSettingFlag;
 
@@ -607,7 +613,10 @@ struct DispenserModule
     struct   LED    LedInfo;                    // LED configuration info
 
                                                 // 0: Authorize idle, 1: Authorize wait,   2: Authorizing
-    unsigned char           AuthorizeStatus;    // 3: Authorize ok,   4: Authorizing fail
+    unsigned char           AuthStatus;         // 3: Authorize done, 4: Authorize end
+    unsigned char           AuthTarget;         // Authorize Target Connector ID: 1 ~ 4, AutoSelection: 0xFF
+    unsigned char           AuthType;           // 0: _AuthType_None, 1: _AuthType_RFID, 2: _AuthType_RemoteStart
+    unsigned char           AuthResult;         // 0: _AuthResult_None, 1: _AuthResult_Valid,   2: _AuthResult_Invalid
     DispenserSettingFlag    Setting;
     char                    FwFileName[128];
 };
@@ -662,7 +671,6 @@ typedef union
     unsigned int Value;
     struct
     {
-        unsigned int  AuthorizeRequestType:4;           // 0: not authorize, 1: local authorized, 2: remote start authorized
         unsigned int  PermissionRequest:1;              // 0: no request,    1: dispenser request to charging                   ( dispenser -> cabinet)
         unsigned int  RemoteStartRequest:1;             // 0: no request,    1: remote start                                    (    ocpp   -> cabinet -> dispenser)
         unsigned int  RemoteStartConfirm:1;
@@ -677,26 +685,30 @@ typedef union
         unsigned int  AnnounceBalance:1;                //
         unsigned int  StartWaitPlug:1;                  //
         unsigned int  NeedCleanAuthorizeInfo:1;         //
-        unsigned int  AuthorizeRequest:1;               // 0: idle,         1: requesting                                       ( dispenser -> cabinet)
         unsigned int  SwipeRfidConfirm:1;
         unsigned int  OutputLimitEnable:1;              // 0: disable,      1: enable
         unsigned int  ChargingPermission:2;             // 0: not allowed,  1: allowed,         2: wait
-        unsigned int  res:9;
+        unsigned int  NormalStopRequest:1;              // 0: no effect,    1: connector normal stop request                    ( dispenser -> cabinet)
+        unsigned int  AlarmStopRequest:1;               // 0: no effect,    1: connector alarm stop request                     ( dispenser -> cabinet)
+        unsigned int  FaultStatusRequest:1;
+        unsigned int  res:11;
     }bits;
 }ConnectorParameter;
 
 struct ConnectorInfoData
 {
-    unsigned char RemoteStatus;                         // 0: Idle, 1: Preparing, 2: Charging, 3: Terminating
+    unsigned char RemoteStatus;                         // 0: Idle, 1: Preparing, 2: Charging, 3: Terminating, 4: Alarm
     unsigned char Enable;                               // 0: Disable, 1: Enable
     unsigned char ReadyToCharge;                        // 0: Not Ready, 1: Ready to Charge (no use)
     unsigned char ParentDispensetIndex;                 // Parent Dispenser Index: 0 ~ 3
     ConnectorParameter       Parameter;
-                                                        // 0: Authorize idle, 1: Authorize wait,   2: Authorizing
-    unsigned char            AuthorizeStatus;           // 3: Authorize ok,   4: Authorizing fail
+
+    unsigned char            AuthorizingType;
+    unsigned char            AuthorizingResult;         // 0: _AuthResult_None, 1: _AuthResult_Valid,   2: _AuthResult_Invalid
     struct ChargingInfoData  GeneralChargingData;
     struct WARNING_CODE_INFO WarningInfo;
 
+    unsigned char           RemotenAlarmCode[7];
     unsigned short          RemoteChargingVoltage;          // charging voltage from connector, unit: 0.1V
     unsigned short          RemoteChargingCurrent;          // charging current from connector, unit: 0.1A
     unsigned int            RemoteRemainChargingDuration;   // remain charging duration from connector, unit: 1s
@@ -726,16 +738,25 @@ typedef union
     {
         unsigned int StartAuthorize:1;          // 0: idle,    1: authorizing
         unsigned int AuthorizingCompleted:1;    // 0: not yet, 1: authorizing completed
-        unsigned int AuthorizeTargetIndex:4;    // dispenser or connector index from 0 ~ 3
-        unsigned int AuthorizeSrc:4;            // 0: not authorize, 1: local authorize, 2: remote authorize
-        unsigned int MiscNeedAnnouncement:1;    // 0: no requirement, 1: need to announce something to dispenser
-        unsigned int NeedDispenserVerInfo:1;    // 0: no requirement, 1: need dispenser to report it's version info
         unsigned int DispenserDisconnection:1;  // 0: no connection,  1: dispenser connected
         unsigned int BackendAuthorized:1;       // 0: local authorized, 1: backend authorized
-        unsigned int res:18;
+        unsigned int res:28;
     }bits;
 }CabinetSettingFlag;
 
+typedef struct
+{
+    unsigned int ConnectionTimeout;             // unit: 1s
+    unsigned int DefaultPrice;                  // unit: 0.01dollar
+    unsigned int Currency;                      // currency index
+    unsigned int BackendStatus;                 // 0: disable, 1: connected, 2: disconnected
+    unsigned int EthernetStatus;                // 0: disable, 1: connected, 2: disconnected
+    unsigned int WiFiStatus;                    // 0: disable, 1: connected, 2: disconnected
+    unsigned int TelcomModemStatus;             // 0: disable, 1: connected, 2: disconnected
+    unsigned int HardwareReboot;                // 1: HardwareReboot, Other value: no effect
+    unsigned int SoftwareRestart;               // 1: SoftwareRestart, Other value: no effect
+}CabinetMiscCommand;
+
 struct SysInfoData
 {
 	/**************System***************/
@@ -819,9 +840,14 @@ struct SysInfoData
     unsigned char Relay2ModuleFwRev[32];	//Relay control  module firmware version
     struct DispenserInfoData DispenserInfo;
     struct ConnectorInfoData ConnectorInfo[GENERAL_GUN_QUANTITY];
-    CabinetSettingFlag       CabinetSetting;
-    unsigned char       ForceAcContactorOff;            // 0: no effect,    1: ac contactor off
-    struct LocalSharingInfo localSharingInfo;			// Local power sharing info structure
+
+    unsigned char           AuthorizedDispenser;        // record authorized dispenser index
+    unsigned char           AuthorizedTarget;           // record authorized target: 1 ~ 4, 0xFF
+    unsigned char           AuthorizedType;             // record authorized type
+    unsigned char           AuthorizedStatus;           // cabinet authorized status
+    CabinetSettingFlag      CabinetSetting;
+    CabinetMiscCommand      CabinetMicsStatus;
+    struct LocalSharingInfo localSharingInfo;           // Local power sharing info structure
 };
 
 struct SysConfigAndInfo
@@ -5634,11 +5660,11 @@ struct OCPP20Data
 			//CSUMsgValue[0]
 			unsigned char ChargingProfileReq:1;	//bit 0,
 			unsigned char ChargingProfileConf:1;	//bit 0,
-			unsigned char ClearedChargingLimitReq :1;
-			unsigned char ClearedChargingLimitConf :1;
-			unsigned char NotifyEVChargingNeedsReq :1;
-			unsigned char NotifyEVChargingNeedsConf :1;
-			unsigned char :2;	//bit 1,2,3,4,5,6,7 , reserved
+            unsigned char ClearedChargingLimitReq :1;
+            unsigned char ClearedChargingLimitConf :1;
+            unsigned char NotifyEVChargingNeedsReq :1;
+            unsigned char NotifyEVChargingNeedsConf :1;
+            unsigned char :2;   //bit 1,2,3,4,5,6,7 , reserved
 		} bits[CONNECTOR_QUANTITY];
 	}CSUMsg;
 

二进制
EVSE/rootfs/root/OcppBackend20


部分文件因为文件数量过多而无法显示