Browse Source

[Bug fixed][DM30][DW30][Gun select]: If the charger's hardware is one PSU with two charging connector, and press right button when one connector is charging, the LCM will switch to the other connector's information, it should not be able to change the LCM page since there is only one PSU.

2020.06.17 / TC Hsu

Actions: Merge Alston's application code, when right button pressed, check the IsAlternatvieConf flag to decide is the LCM page can be change or not. Add GetStartChargingByAlterMode() function to decide is the charging process can be started or not for this case. Add CheckReturnToChargingConn() function for this hardware with AC charger.

Image version    : N/A
Image checksum   : N/A

Hardware PWB P/N : N/A
Hardware Version : N/A

Files:

	modified:   EVSE/Projects/DM30/Apps/main.c
	modified:   EVSE/Projects/DW30/Apps/main.c
TC_Hsu 4 years ago
parent
commit
488f66df03
2 changed files with 222 additions and 12 deletions
  1. 111 6
      EVSE/Projects/DM30/Apps/main.c
  2. 111 6
      EVSE/Projects/DW30/Apps/main.c

+ 111 - 6
EVSE/Projects/DM30/Apps/main.c

@@ -2333,7 +2333,8 @@ void ChkPrimaryStatus()
         {
             rightBtnPush = true;
             PRINTF_FUNC("right btn down............................... %d \n", ShmSysConfigAndInfo->SysInfo.CurGunSelected);
-            if (ShmSysConfigAndInfo->SysInfo.CurGunSelected + 1 < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount)
+            if (ShmSysConfigAndInfo->SysInfo.CurGunSelected + 1 < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount &&
+                ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == NO)
             {
                 ShmSysConfigAndInfo->SysInfo.CurGunSelected++;
                 ChangeGunSelectByIndex(ShmSysConfigAndInfo->SysInfo.CurGunSelected);
@@ -2341,6 +2342,23 @@ void ChkPrimaryStatus()
             else if (ShmSysConfigAndInfo->SysConfig.AcConnectorCount > 0 &&
                      ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc == NO_DEFINE)
                 ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = DEFAULT_AC_INDEX;
+            else if (ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == YES)
+            {
+                for (byte _index = 0; _index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; _index++)
+                {
+                    if (chargingInfo[_index]->SystemStatus != S_BOOTING &&
+                            chargingInfo[_index]->SystemStatus != S_IDLE &&
+                            chargingInfo[_index]->SystemStatus != S_RESERVATION)
+                    {
+                        ShmSysConfigAndInfo->SysInfo.CurGunSelected = _index;
+                        ChangeGunSelectByIndex(ShmSysConfigAndInfo->SysInfo.CurGunSelected);
+                        return;
+                    }
+                }
+
+                ShmSysConfigAndInfo->SysInfo.CurGunSelected = 0;
+                ChangeGunSelectByIndex(ShmSysConfigAndInfo->SysInfo.CurGunSelected);
+            }
             else
             {
                 ShmSysConfigAndInfo->SysInfo.CurGunSelected = 0;
@@ -4498,6 +4516,86 @@ void CheckSmartChargeProfile(byte _index)
     }
 }
 
+void CheckReturnToChargingConn()
+{
+    if ((ShmSysConfigAndInfo->SysConfig.TotalConnectorCount + ShmSysConfigAndInfo->SysConfig.AcConnectorCount) > 1 &&
+        ShmSysConfigAndInfo->SysInfo.PageIndex != _LCM_AUTHORIZING &&
+        ShmSysConfigAndInfo->SysInfo.PageIndex != _LCM_AUTHORIZ_FAIL &&
+        ShmSysConfigAndInfo->SysInfo.PageIndex != _LCM_AUTHORIZ_COMP &&
+        ShmSysConfigAndInfo->SysInfo.PageIndex != _LCM_WAIT_FOR_PLUG)
+    {
+        bool isReturnTimeout = false;
+        for (byte count = 0; count < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; count++)
+        {
+            if (count != ShmSysConfigAndInfo->SysInfo.CurGunSelected)
+            {
+                if ((chargingInfo[count]->SystemStatus >= S_REASSIGN_CHECK && chargingInfo[count]->SystemStatus <= S_COMPLETE) ||
+                        (chargingInfo[count]->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingInfo[count]->SystemStatus <= S_CCS_PRECHARGE_ST1))
+                {
+                    isReturnTimeout = true;
+                    StartSystemTimeoutDet(Timeout_ReturnToChargingGunDet);
+                }
+            }
+        }
+
+        // AC 槍
+        if (!isReturnTimeout && ShmSysConfigAndInfo->SysConfig.AcConnectorCount > 0)
+        {
+            // 沒有選中 AC,且 AC 在充電中
+            if (ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc == NO_DEFINE &&
+                    (ac_chargingInfo[0]->SystemStatus >= S_PREPARNING && ac_chargingInfo[0]->SystemStatus <= S_COMPLETE))
+            {
+                // 當前 DC 充電槍在 idle 狀態
+                if (chargingInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus == S_IDLE ||
+                        chargingInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus == S_RESERVATION)
+                {
+                    isReturnTimeout = true;
+                    StartSystemTimeoutDet(Timeout_ReturnToChargingGunDet);
+                }
+            }
+            else if (ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc == DEFAULT_AC_INDEX &&
+                        ((chargingInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus >= S_REASSIGN_CHECK && chargingInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus <= S_COMPLETE) ||
+                        (chargingInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus <= S_CCS_PRECHARGE_ST1)))
+            {
+                // 當前 DC 充電槍在 idle 狀態
+                if (ac_chargingInfo[0]->SystemStatus == S_IDLE ||
+                        ac_chargingInfo[0]->SystemStatus == S_RESERVATION)
+                {
+                    isReturnTimeout = true;
+                    StartSystemTimeoutDet(Timeout_ReturnToChargingGunDet);
+                }
+            }
+        }
+
+        if (!isReturnTimeout)
+            StopSystemTimeoutDet();
+    }
+}
+
+bool GetStartChargingByAlterMode(byte _gun)
+{
+    bool result = true;
+
+    if (ShmSysConfigAndInfo->SysConfig.TotalConnectorCount == 2 &&
+            ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == YES)
+    {
+        for (byte _select = 0; _select < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; _select++)
+        {
+            if (_select != _gun)
+            {
+                if (chargingInfo[_select]->SystemStatus != S_IDLE &&
+                        chargingInfo[_select]->SystemStatus != S_RESERVATION)
+                {
+                    result = false;
+                    break;
+                }
+            }
+        }
+    }
+
+    return result;
+}
+
 int main(void)
 {
     if(CreateShareMemory() == 0)
@@ -4624,6 +4722,8 @@ int main(void)
         ScannerCardProcess();
         // 當 AC 沒有搭上時,清除一些錯誤碼
         ClearAlarmCodeWhenAcOff();
+        // 確認是否要回到充電中的槍畫面邏輯判斷
+        CheckReturnToChargingConn();
 
         if (_acgunIndex > 0 && isDetectPlugin() && !isCardScan)
         {
@@ -4784,11 +4884,16 @@ int main(void)
                                      (chargingInfo[gun_index]->ConnectorPlugIn == YES && chargingInfo[gun_index]->IsAvailable))
                             {
                                 PRINTF_FUNC("-----------------3----------------- \n");
-                                ChangeGunSelectByIndex(gun_index);
-                                AddPlugInTimes(gun_index);
-                                setChargerMode(gun_index, MODE_REASSIGN_CHECK);
-                                ClearDetectPluginFlag();
-                                continue;
+                                bool isCanStartChargingFlag = GetStartChargingByAlterMode(gun_index);
+
+                                if (isCanStartChargingFlag)
+                                {
+                                    ChangeGunSelectByIndex(gun_index);
+                                    AddPlugInTimes(gun_index);
+                                    setChargerMode(gun_index, MODE_REASSIGN_CHECK);
+                                    ClearDetectPluginFlag();
+                                    continue;
+                                }
                             }
                             else
                             {

+ 111 - 6
EVSE/Projects/DW30/Apps/main.c

@@ -2333,7 +2333,8 @@ void ChkPrimaryStatus()
         {
             rightBtnPush = true;
             PRINTF_FUNC("right btn down............................... %d \n", ShmSysConfigAndInfo->SysInfo.CurGunSelected);
-            if (ShmSysConfigAndInfo->SysInfo.CurGunSelected + 1 < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount)
+            if (ShmSysConfigAndInfo->SysInfo.CurGunSelected + 1 < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount &&
+                ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == NO)
             {
                 ShmSysConfigAndInfo->SysInfo.CurGunSelected++;
                 ChangeGunSelectByIndex(ShmSysConfigAndInfo->SysInfo.CurGunSelected);
@@ -2341,6 +2342,23 @@ void ChkPrimaryStatus()
             else if (ShmSysConfigAndInfo->SysConfig.AcConnectorCount > 0 &&
                      ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc == NO_DEFINE)
                 ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = DEFAULT_AC_INDEX;
+            else if (ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == YES)
+            {
+                for (byte _index = 0; _index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; _index++)
+                {
+                    if (chargingInfo[_index]->SystemStatus != S_BOOTING &&
+                            chargingInfo[_index]->SystemStatus != S_IDLE &&
+                            chargingInfo[_index]->SystemStatus != S_RESERVATION)
+                    {
+                        ShmSysConfigAndInfo->SysInfo.CurGunSelected = _index;
+                        ChangeGunSelectByIndex(ShmSysConfigAndInfo->SysInfo.CurGunSelected);
+                        return;
+                    }
+                }
+
+                ShmSysConfigAndInfo->SysInfo.CurGunSelected = 0;
+                ChangeGunSelectByIndex(ShmSysConfigAndInfo->SysInfo.CurGunSelected);
+            }
             else
             {
                 ShmSysConfigAndInfo->SysInfo.CurGunSelected = 0;
@@ -4498,6 +4516,86 @@ void CheckSmartChargeProfile(byte _index)
     }
 }
 
+void CheckReturnToChargingConn()
+{
+    if ((ShmSysConfigAndInfo->SysConfig.TotalConnectorCount + ShmSysConfigAndInfo->SysConfig.AcConnectorCount) > 1 &&
+        ShmSysConfigAndInfo->SysInfo.PageIndex != _LCM_AUTHORIZING &&
+        ShmSysConfigAndInfo->SysInfo.PageIndex != _LCM_AUTHORIZ_FAIL &&
+        ShmSysConfigAndInfo->SysInfo.PageIndex != _LCM_AUTHORIZ_COMP &&
+        ShmSysConfigAndInfo->SysInfo.PageIndex != _LCM_WAIT_FOR_PLUG)
+    {
+        bool isReturnTimeout = false;
+        for (byte count = 0; count < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; count++)
+        {
+            if (count != ShmSysConfigAndInfo->SysInfo.CurGunSelected)
+            {
+                if ((chargingInfo[count]->SystemStatus >= S_REASSIGN_CHECK && chargingInfo[count]->SystemStatus <= S_COMPLETE) ||
+                        (chargingInfo[count]->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingInfo[count]->SystemStatus <= S_CCS_PRECHARGE_ST1))
+                {
+                    isReturnTimeout = true;
+                    StartSystemTimeoutDet(Timeout_ReturnToChargingGunDet);
+                }
+            }
+        }
+
+        // AC 槍
+        if (!isReturnTimeout && ShmSysConfigAndInfo->SysConfig.AcConnectorCount > 0)
+        {
+            // 沒有選中 AC,且 AC 在充電中
+            if (ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc == NO_DEFINE &&
+                    (ac_chargingInfo[0]->SystemStatus >= S_PREPARNING && ac_chargingInfo[0]->SystemStatus <= S_COMPLETE))
+            {
+                // 當前 DC 充電槍在 idle 狀態
+                if (chargingInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus == S_IDLE ||
+                        chargingInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus == S_RESERVATION)
+                {
+                    isReturnTimeout = true;
+                    StartSystemTimeoutDet(Timeout_ReturnToChargingGunDet);
+                }
+            }
+            else if (ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc == DEFAULT_AC_INDEX &&
+                        ((chargingInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus >= S_REASSIGN_CHECK && chargingInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus <= S_COMPLETE) ||
+                        (chargingInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus <= S_CCS_PRECHARGE_ST1)))
+            {
+                // 當前 DC 充電槍在 idle 狀態
+                if (ac_chargingInfo[0]->SystemStatus == S_IDLE ||
+                        ac_chargingInfo[0]->SystemStatus == S_RESERVATION)
+                {
+                    isReturnTimeout = true;
+                    StartSystemTimeoutDet(Timeout_ReturnToChargingGunDet);
+                }
+            }
+        }
+
+        if (!isReturnTimeout)
+            StopSystemTimeoutDet();
+    }
+}
+
+bool GetStartChargingByAlterMode(byte _gun)
+{
+    bool result = true;
+
+    if (ShmSysConfigAndInfo->SysConfig.TotalConnectorCount == 2 &&
+            ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == YES)
+    {
+        for (byte _select = 0; _select < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; _select++)
+        {
+            if (_select != _gun)
+            {
+                if (chargingInfo[_select]->SystemStatus != S_IDLE &&
+                        chargingInfo[_select]->SystemStatus != S_RESERVATION)
+                {
+                    result = false;
+                    break;
+                }
+            }
+        }
+    }
+
+    return result;
+}
+
 int main(void)
 {
     if(CreateShareMemory() == 0)
@@ -4624,6 +4722,8 @@ int main(void)
         ScannerCardProcess();
         // 當 AC 沒有搭上時,清除一些錯誤碼
         ClearAlarmCodeWhenAcOff();
+        // 確認是否要回到充電中的槍畫面邏輯判斷
+        CheckReturnToChargingConn();
 
         if (_acgunIndex > 0 && isDetectPlugin() && !isCardScan)
         {
@@ -4784,11 +4884,16 @@ int main(void)
                                      (chargingInfo[gun_index]->ConnectorPlugIn == YES && chargingInfo[gun_index]->IsAvailable))
                             {
                                 PRINTF_FUNC("-----------------3----------------- \n");
-                                ChangeGunSelectByIndex(gun_index);
-                                AddPlugInTimes(gun_index);
-                                setChargerMode(gun_index, MODE_REASSIGN_CHECK);
-                                ClearDetectPluginFlag();
-                                continue;
+                                bool isCanStartChargingFlag = GetStartChargingByAlterMode(gun_index);
+
+                                if (isCanStartChargingFlag)
+                                {
+                                    ChangeGunSelectByIndex(gun_index);
+                                    AddPlugInTimes(gun_index);
+                                    setChargerMode(gun_index, MODE_REASSIGN_CHECK);
+                                    ClearDetectPluginFlag();
+                                    continue;
+                                }
                             }
                             else
                             {