소스 검색

2021-04-03 / Wendell

Actions
1. fix communication issue with psu when emergency button pressed
2. fix power cabinet connection issue with dispenser
3. modify parallel relay logic
4. add new model name rule
5. add qr code display logic compatible with all model
6. fix final cost bug when alarm occur
7. synchronize output power with dispenser

Files
1. As follow commit history

Image version : D0.12.XX.XXXX.XX
Wendell 4 년 전
부모
커밋
66ebeebd1b

+ 32 - 2
EVSE/Projects/DO360/Apps/Config.h

@@ -60,6 +60,9 @@ typedef unsigned char			    byte;
 // ********** e4you ********** //
 // Model Name: DKYE182000D1E4
 
+// ********** xpeng ********** //
+// Model Name: DOYE362000D2XP
+
 enum _SYSTEM_STATUS
 {
 	S_BOOTING = 						0,
@@ -279,6 +282,13 @@ enum _E4YOU_INDICATION_STATUS
     _E4YOU_LED_Alarm            = 4,
 };
 
+enum _QR_MODE
+{
+    _QR_MODE_Default            = 0,
+    _QR_MODE_Customized         = 1,
+    _QR_MODE_ChargeBoxId        = 2,                // for audi
+};
+
 typedef union
 {
     unsigned int CtrlValue;
@@ -290,13 +300,32 @@ typedef union
         unsigned int FanBoardDisable:1;             // 0: fan board enable,         1: fan board disable
         unsigned int LedBoardDisable:1;             // 0: led board enable,         1: led board disable
         unsigned int SecondRelayBoardEnable:1;      // 0: second relay disable,     1: second relay enable
-        unsigned int EnableAutoStartCharging:1;     // 0: disable,                  1: enable auto charging after plug in
         unsigned int StandardLedIndication:1;       // 0: no led indication,        1: enable standard led indication
         unsigned int E4YOULedIndication:1;          // 0: no led indication,        1: enable e4you led indication
-        unsigned int res:23;
+        unsigned int res:24;
     }bits;
 }SystemControl;
 
+typedef union
+{
+    unsigned int AuthFlag;
+    struct
+    {
+        unsigned int AutoStartEnable:1;             // 0: disable,                  1: enable auto charging after plug in
+        unsigned int APPEnable:1;                   // 0: disable,                  1: app auth enable
+        unsigned int QRCodeEnable:1;                // 0: disable,                  1: qr code auth enable
+        unsigned int RFIDEnable:1;                  // 0: disable,                  1: rfid auth enable
+        unsigned int res:24;
+    }bits;
+}AuthModeInfo;
+
+typedef struct
+{
+    AuthModeInfo  AuthMode;
+    unsigned char QRCodeMode;                        // 0: default, 1: customized, 2: audi type
+    unsigned char res[3];
+}SystemAuthInfoData;
+
 typedef union
 {
     unsigned int CtrlValue;
@@ -422,6 +451,7 @@ typedef struct
 
 typedef struct
 {
+    SystemAuthInfoData AuthInfo;
     SysControl Control;
     PsuPositionInfoData PsuPosition;
     PsuGroupingInfoData PsuGrouping;

+ 62 - 7
EVSE/Projects/DO360/Apps/Module_EvComm.c

@@ -52,6 +52,7 @@
 #define false						0
 
 struct SysConfigAndInfo				*ShmSysConfigAndInfo;
+ChargerInfoData                     *ShmChargerInfo;
 
 //struct WARNING_CODE_INFO            LastWarningInfo[GENERAL_GUN_QUANTITY];
 
@@ -203,6 +204,22 @@ int InitShareMemory()
 	 }
 	memset(ShmPsuData,0,sizeof(struct PsuData));
 	*/
+
+    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;
 }
 
@@ -865,10 +882,10 @@ void tcpSocketClientStart(void)
 
 BOOL IsAvalibleGunType(char name, unsigned char *type)
 {
-	char modelList[6] = {'J', 'U', 'E', 'G', 'V', 'F'};
-	unsigned char typeList[6] = {0, 1, 1, 2, 1, 1};		// 0 : Chademo, 1: CCS, 2: GB
+	char         modelList[11] = {'J', 'U', 'V', 'E', 'F', 'G', 'T', 'D', 'K', 'P', 'R'};
+	unsigned char typeList[11] = {  0,   1,   1,   1,   1,   2,   1,   1,   0,   1,   1}; // 0 : Chademo, 1: CCS, 2: GB
 
-	for(int i = 0; i < 6; i++)
+	for(int i = 0; i < 11; i++)
 	{
 		if(name == modelList[i])
 		{
@@ -1411,9 +1428,38 @@ void WriteChargingInfoResponse(int socket, struct PACKET_STRUCTURE *packet, unsi
     send(socket, &sendBuffer, sendBuffer.Header.len + 4, 0);
 }
 
+int GetChargerSystemId(char *id)
+{
+    int len = 0;
+
+    strcpy((char *)id, "");
+
+    switch(ShmChargerInfo->AuthInfo.QRCodeMode)
+    {
+        case _QR_MODE_Customized:
+            strcpy((char *)id, (char *)ShmSysConfigAndInfo->SysConfig.QRCodeContent);
+            break;
+
+        case _QR_MODE_ChargeBoxId:
+            strcpy((char *)id, (char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
+            break;
+
+        case _QR_MODE_Default:
+        default:
+            strcat((char *)id, (char *)ShmSysConfigAndInfo->SysConfig.ModelName);
+            strcat((char *)id, (char *)ShmSysConfigAndInfo->SysConfig.SerialNumber);
+            break;
+    }
+
+    len = strlen((char *)id);
+
+    return len;
+}
+
 void ChargerSystemIdResponse(int socket, struct PACKET_STRUCTURE *packet, unsigned char dispenserIndex, unsigned char result)
 {
     struct PACKET_STRUCTURE sendBuffer;
+    char system_id[128];
 
     memset(&sendBuffer, 0x00, sizeof(sendBuffer));
     sendBuffer.Header.se = packet->Header.se;
@@ -1425,8 +1471,8 @@ void ChargerSystemIdResponse(int socket, struct PACKET_STRUCTURE *packet, unsign
     if(result == _R_OK)
     {
         int strLen = 0;
-        strLen = strlen((char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
-        memcpy(&sendBuffer.Payload.data[sendBuffer.Header.len - 1], (char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId, strLen);
+        strLen = GetChargerSystemId(system_id);
+        memcpy(&sendBuffer.Payload.data[sendBuffer.Header.len - 1], (char *)system_id, strLen);
         sendBuffer.Header.len += strLen + 1;
 
         char TimeSync[32];
@@ -1480,12 +1526,13 @@ BOOL FindConnectorID(unsigned char dispenserIndex, unsigned char id)
 
 void ConnectorPhysicalLimitBindingHandler(unsigned char connectorIndex, unsigned char physical)
 {
-    //char modelList[6] = {'J', 'U', 'E', 'G', 'V', 'F'};
-    //unsigned char typeList[6] = {0, 1, 1, 2, 1, 1};     // 0 : Chademo, 1: CCS, 2: GB
+    //char         modelList[11] = {'J', 'U', 'V', 'E', 'F', 'G', 'T', 'D', 'K', 'P', 'R'};
+    //unsigned char typeList[11] = {  0,   1,   1,   1,   1,   2,   1,   1,   0,   1,   1}; // 0 : Chademo, 1: CCS, 2: GB
 
     switch(physical)
     {
         case 'J':
+        case 'K':
             ShmSysConfigAndInfo->SysInfo.ConnectorInfo[connectorIndex].RemoteMaxPhysicalVoltage = CHA_MAX_PHYSICAL_VOLTAGE;
             ShmSysConfigAndInfo->SysInfo.ConnectorInfo[connectorIndex].RemoteMaxPhysicalCurrent = CHA_NATURAL_MAX_CURRENT;
             break;
@@ -1503,10 +1550,18 @@ void ConnectorPhysicalLimitBindingHandler(unsigned char connectorIndex, unsigned
 
         case 'V':
         case 'F':
+        case 'P':
+        case 'R':
             ShmSysConfigAndInfo->SysInfo.ConnectorInfo[connectorIndex].RemoteMaxPhysicalVoltage = CCS_MAX_PHYSICAL_VOLTAGE;
             ShmSysConfigAndInfo->SysInfo.ConnectorInfo[connectorIndex].RemoteMaxPhysicalCurrent = CCS_LIQUID_MAX_CURRENT;
             break;
 
+        case 'T':
+        case 'D':
+            ShmSysConfigAndInfo->SysInfo.ConnectorInfo[connectorIndex].RemoteMaxPhysicalVoltage = CCS_MAX_PHYSICAL_VOLTAGE;
+            ShmSysConfigAndInfo->SysInfo.ConnectorInfo[connectorIndex].RemoteMaxPhysicalCurrent = CCS_NATURAL_REMA_MAX_CURRENT;
+            break;
+
         default:
             ShmSysConfigAndInfo->SysInfo.ConnectorInfo[connectorIndex].RemoteMaxPhysicalVoltage = 0;
             ShmSysConfigAndInfo->SysInfo.ConnectorInfo[connectorIndex].RemoteMaxPhysicalCurrent = 0;

+ 39 - 2
EVSE/Projects/DO360/Apps/main.c

@@ -1759,6 +1759,34 @@ void InitialPsuGroupingAndLocation(void)
     }
 }
 
+void InitialAuthMode(void)
+{
+    if(ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D' && ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')
+    {
+        ShmChargerInfo->AuthInfo.AuthMode.bits.AutoStartEnable = true;
+    }
+}
+
+void InitialQRCodeMode(void)
+{
+    if(ShmSysConfigAndInfo->SysConfig.ModelName[12] == 'A' && ShmSysConfigAndInfo->SysConfig.ModelName[13] == 'D')
+    {
+        ShmChargerInfo->AuthInfo.QRCodeMode = _QR_MODE_ChargeBoxId;
+    }
+    else
+    {
+        // customized
+        if(ShmSysConfigAndInfo->SysConfig.QRCodeMadeMode)
+        {
+            ShmChargerInfo->AuthInfo.QRCodeMode = _QR_MODE_Customized;
+        }
+        else
+        {
+            ShmChargerInfo->AuthInfo.QRCodeMode = _QR_MODE_Default;
+        }
+    }
+}
+
 void InitialChargerSetting(void)
 {
     if(ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D' && ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O')
@@ -1777,6 +1805,9 @@ void InitialChargerSetting(void)
 
         ShmChargerInfo->Control.SysCtrl.bits.E4YOULedIndication = true;
     }
+
+    InitialAuthMode();
+    InitialQRCodeMode();
 }
 
 bool InitialSystemDefaultConfig()
@@ -4909,7 +4940,7 @@ void RunningFinalCostHandler(void)
     for(int i = 0; i < CONNECTOR_QUANTITY; i++)
     {
         if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].GeneralChargingData.SystemStatus >= S_REASSIGN_CHECK &&
-            ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].GeneralChargingData.SystemStatus <= S_COMPLETE)
+            ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].GeneralChargingData.SystemStatus <= S_ALARM)
         {
             if(strlen((char *)ShmOCPP16Data->Cost.RunningCost[i].description) > 0)
             {
@@ -6561,6 +6592,11 @@ int main(void)
                             ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.AlarmStopRequest = false;
                             ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.FaultStatusRequest = false;
                             memset(chargingInfo[gun_index]->ConnectorAlarmCode, 0x00, sizeof(chargingInfo[gun_index]->ConnectorAlarmCode));
+
+                            memset(&ShmOCPP16Data->Cost.RunningCost[gun_index], 0x00, sizeof(struct StrcutRunningFinalCost));
+                            memset(&ShmOCPP16Data->Cost.FinalCost[gun_index], 0x00, sizeof(struct StrcutRunningFinalCost));
+                            chargingInfo[gun_index]->PresentChargedEnergy = 0;
+                            chargingInfo[gun_index]->PresentChargingPower = 0;
                         }
                         else if (chargingInfo[gun_index]->SystemStatus == S_RESERVATION)
                         {
@@ -7047,7 +7083,8 @@ int main(void)
 					chargingInfo[gun_index]->PresentChargedDuration = DiffTimeb(startChargingTime[gun_index], endChargingTime[gun_index]);
 
                     // 計算 Power
-                    chargingInfo[gun_index]->PresentChargingPower = ((float)((chargingInfo[gun_index]->PresentChargingVoltage) * (chargingInfo[gun_index]->PresentChargingCurrent)) / 1000);
+                    //chargingInfo[gun_index]->PresentChargingPower = ((float)((chargingInfo[gun_index]->PresentChargingVoltage) * (chargingInfo[gun_index]->PresentChargingCurrent)) / 1000);
+                    chargingInfo[gun_index]->PresentChargingPower = (((float)((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].RemoteChargingVoltage) * (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].RemoteChargingCurrent))) / 1000 / 100);
 
                     if (chargingTime[gun_index] == 0 || chargingTime[gun_index] > chargingInfo[gun_index]->PresentChargedDuration)
                     {

BIN
EVSE/Projects/DO360/Images/ramdisk.gz


BIN
EVSE/rootfs/root/OcppBackend20