瀏覽代碼

2021-05-26 / Eason Yang
Action :
1.Improve : Improved setRelay() function for socket e type.
2.Added : Added logic for socket e type into checkRfidAuthrize() function.
3.Added : Added logic for socket e type into SYS_MODE_TERMINATING.

File :
1. main.c
Action 1
Action 2
Action 3

Version :D0.53.XX.XXXX.XX

8009 3 年之前
父節點
當前提交
ed8cdd3e00
共有 1 個文件被更改,包括 62 次插入11 次删除
  1. 62 11
      EVSE/Projects/AW-CCS/Apps/main.c

+ 62 - 11
EVSE/Projects/AW-CCS/Apps/main.c

@@ -3034,22 +3034,69 @@ void setRelay(unsigned char gun_index,unsigned char isOn)
 	{
 		if(ShmCharger->gun_info[gun_index].legacyRequest.isRelayOn == OFF)
 		{
-			ShmCharger->gun_info[gun_index].legacyRequest.isRelayOn = ON;
-			ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][0] = 0x01;
-			ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][1] = 0x01;
-			ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][2] = 0x01;
-			DEBUG_INFO("Gun-%d Output relay sts: ON \n",gun_index);
+			switch(ShmCharger->gun_info[gun_index].chargingMode)
+			{
+				case CHARGING_MODE_BS:
+				case CHARGING_MODE_HLC:
+					ShmCharger->gun_info[gun_index].legacyRequest.isRelayOn = ON;
+					ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][0] = 0x01;
+					ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][1] = 0x01;
+					ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][2] = 0x01;
+
+					if(ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_BS)
+						DEBUG_INFO("Gun-%d Output relay status: ON. [CHARGING_MODE_BS] \n",gun_index);
+					else if(ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_HLC)
+						DEBUG_INFO("Gun-%d Output relay status: ON. [CHARGING_MODE_HLC] \n",gun_index);
+
+					break;
+				case CHARGING_MODE_SOCKETE:
+					ShmCharger->gun_info[gun_index].legacyRequest.isRelayOn = ON;
+					ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][3] = 0x01;
+					DEBUG_INFO("Gun-%d Output relay status: ON. [CHARGING_MODE_SOCKETE] \n",gun_index);
+					break;
+				default:
+					ShmCharger->gun_info[gun_index].legacyRequest.isRelayOn = ON;
+					ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][0] = 0x01;
+					ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][1] = 0x01;
+					ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][2] = 0x01;
+					DEBUG_INFO("Gun-%d Output relay status: ON. [DEFFAULT] \n",gun_index);
+					break;
+			}
 		}
 	}
 	else
 	{
 		if(ShmCharger->gun_info[gun_index].legacyRequest.isRelayOn == ON)
 		{
-			ShmCharger->gun_info[gun_index].legacyRequest.isRelayOn = OFF;
-			ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][0] = 0;
-			ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][1] = 0;
-			ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][2] = 0;
-			DEBUG_INFO("Gun-%d Output relay sts: OFF \n",gun_index);
+			switch(ShmCharger->gun_info[gun_index].chargingMode)
+			{
+				case CHARGING_MODE_BS:
+				case CHARGING_MODE_HLC:
+					ShmCharger->gun_info[gun_index].legacyRequest.isRelayOn = OFF;
+					ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][0] = 0;
+					ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][1] = 0;
+					ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][2] = 0;
+
+					if(ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_BS)
+						DEBUG_INFO("Gun-%d Output relay status: OFF. [CHARGING_MODE_BS] \n",gun_index);
+					else if(ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_HLC)
+						DEBUG_INFO("Gun-%d Output relay status: OFF. [CHARGING_MODE_HLC] \n",gun_index);
+
+					DEBUG_INFO("Gun-%d Output relay status: OFF. \n",gun_index);
+					break;
+				case CHARGING_MODE_SOCKETE:
+					ShmCharger->gun_info[gun_index].legacyRequest.isRelayOn = OFF;
+					ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][3] = 0;
+					DEBUG_INFO("Gun-%d Output relay status: OFF. [CHARGING_MODE_SOCKETE] \n",gun_index);
+					break;
+				default:
+					ShmCharger->gun_info[gun_index].legacyRequest.isRelayOn = OFF;
+					ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][0] = 0;
+					ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][1] = 0;
+					ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][2] = 0;
+					DEBUG_INFO("Gun-%d Output relay status: OFF. [DEFFAULT] \n",gun_index);
+					break;
+			}
 		}
 	}
 }
@@ -4199,7 +4246,7 @@ void checkRfidAuthrize()
 							else
 								setLedMotion(gun_index,LED_ACTION_AUTHED);
 
-							if((((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_IDLE) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_RESERVATION)) && ((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C))) ||
+							if((((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_IDLE) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_RESERVATION)) && (((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C)) || (ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn == ON))) ||
 							   (((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_TERMINATING)) && (ShmCharger->gun_selectd == gun_index))
 							   )
 							{
@@ -5406,6 +5453,10 @@ int main(void)
 							setRelay(gun_index,OFF);
 							ShmCharger->gun_info[gun_index].isCCSWaitChangeDuty = ON;
 						}
+						else
+						{
+							setChargerMode(gun_index, SYS_MODE_COMPLETE);
+						}
 					}
 					else
 					{