Przeglądaj źródła

[Improve][AW-CCS][main.c]
2022-05-27 / EASON YANG
Action
1. Improve : Logic for output current print out log.
2. Improve : Logic for power consumption print out log.
3. Improve : Logic for Input voltage print out log.
4. Improve : Decreser print out log.

File
1. Module_InternalComm.c
Action 1
Actino 2
Action 3
Action 4

FIRMWARE VERSION: B0.62.XX.XXXX.PX

8009 2 lat temu
rodzic
commit
015df00fab
1 zmienionych plików z 36 dodań i 15 usunięć
  1. 36 15
      EVSE/Projects/AW-CCS/Apps/Module_InternalComm.c

+ 36 - 15
EVSE/Projects/AW-CCS/Apps/Module_InternalComm.c

@@ -58,7 +58,6 @@ int mystrcmp(char *p1,char *p2);
 void substr(char *dest, const char* src, unsigned int start, unsigned int cnt);
 void split(char **arr, char *str, const char *del);
 
-
 int StoreLogMsg(const char *fmt, ...)
 {
 	char Buf[4096+256];
@@ -1960,11 +1959,33 @@ int main(void)
 					DEBUG_INFO("*******************************************\n");
 					DEBUG_INFO("***** High priority polling : Case 2 ******\n");
 					DEBUG_INFO("*******************************************\n");
-					DEBUG_INFO("MCU-%d set relay request : %d\n", gun_index, ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest);
+					DEBUG_INFO("MCU-%d set PWN request : %d\n", gun_index, ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest);
 
 					previousCharger.gun_info[gun_index].legacyRequest.isLegacyRequest = ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest;
 				}
 
+				//==================================================
+				// Case 2: Config primary Relay
+				//==================================================
+				if((previousCharger.gun_info[gun_index].primaryMcuState.relayState.relay_status[0][0] != ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][0]) ||
+				   (previousCharger.gun_info[gun_index].primaryMcuState.relayState.relay_status[0][1] != ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][1]) ||
+				   (previousCharger.gun_info[gun_index].primaryMcuState.relayState.relay_status[0][2] != ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][2]) ||
+				   (previousCharger.gun_info[gun_index].primaryMcuState.relayState.relay_status[0][3] != ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][3]))
+				{
+					DEBUG_INFO("*******************************************\n");
+					DEBUG_INFO("**** High priority polling : Case 2-X *****\n");
+					DEBUG_INFO("*******************************************\n");
+					DEBUG_INFO("MCU-%d set relay status [0][0] : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][0]);
+					DEBUG_INFO("MCU-%d set relay status [0][1] : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][1]);
+					DEBUG_INFO("MCU-%d set relay status [0][2] : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][2]);
+					DEBUG_INFO("MCU-%d set relay status [0][3] : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][3]);
+
+					previousCharger.gun_info[gun_index].primaryMcuState.relayState.relay_status[0][0] = ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][0];
+					previousCharger.gun_info[gun_index].primaryMcuState.relayState.relay_status[0][1] = ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][1];
+					previousCharger.gun_info[gun_index].primaryMcuState.relayState.relay_status[0][2] = ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][2];
+					previousCharger.gun_info[gun_index].primaryMcuState.relayState.relay_status[0][3] = ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][3];
+				}
+
 				//==================================================
 				// Case 3: Query primary MCU status
 				//==================================================
@@ -1986,9 +2007,9 @@ int main(void)
 					if(ShmCharger->gun_info[gun_index].primaryMcuState.relay_state == ON)
 					{
 						if(ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn == ON)
-							DEBUG_INFO("Relay on mode : CHARGING_MODE_SOCKETE. \n");
+							DEBUG_INFO("Relay mode : CHARGING_MODE_SOCKETE. \n");
 						else
-							DEBUG_INFO("Relay on mode : CHARGING_MODE_BS / CHARGING_MODE_HLC. \n");
+							DEBUG_INFO("Relay mode : CHARGING_MODE_BS / CHARGING_MODE_HLC. \n");
 					}
 
 					DEBUG_INFO("MCU-%d get Relay State : %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.relay_state);
@@ -2119,10 +2140,10 @@ int main(void)
 				//==================================================
 				// Case 10: Query primary MCU power consumption
 				//==================================================
-				if((previousCharger.gun_info[gun_index].powerConsumptionTotal.power_consumption != ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption) ||
-				   (previousCharger.gun_info[gun_index].powerConsumption[0].power_consumption != ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption) ||
-				   (previousCharger.gun_info[gun_index].powerConsumption[1].power_consumption != ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption) ||
-				   (previousCharger.gun_info[gun_index].powerConsumption[2].power_consumption != ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption))
+				if((abs(ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption - previousCharger.gun_info[gun_index].powerConsumptionTotal.power_consumption) > 200) ||
+				   (abs(ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption - previousCharger.gun_info[gun_index].powerConsumption[0].power_consumption) > 200) ||
+				   (abs(ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption - previousCharger.gun_info[gun_index].powerConsumption[1].power_consumption) > 200) ||
+				   (abs(ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption - previousCharger.gun_info[gun_index].powerConsumption[2].power_consumption) > 200))
 				{
 					DEBUG_INFO("*******************************************\n");
 					DEBUG_INFO("***** High priority polling : Case 10 *****\n");
@@ -2144,9 +2165,9 @@ int main(void)
 				//==================================================
 				// Case 11: Query primary Out put current config
 				//==================================================
-				if(((int)previousCharger.gun_info[gun_index].outputCurrent.L1N_L12[0] != (int)ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0]) ||
-				   ((int)previousCharger.gun_info[gun_index].outputCurrent.L2N_L23[0] != (int)ShmCharger->gun_info[gun_index].outputCurrent.L2N_L23[0]) ||
-				   ((int)previousCharger.gun_info[gun_index].outputCurrent.L3N_L31[0] != (int)ShmCharger->gun_info[gun_index].outputCurrent.L3N_L31[0]))
+				if((abs((int)ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0] - (int)previousCharger.gun_info[gun_index].outputCurrent.L1N_L12[0]) >= 2) ||
+				   (abs((int)ShmCharger->gun_info[gun_index].outputCurrent.L2N_L23[0] - (int)previousCharger.gun_info[gun_index].outputCurrent.L2N_L23[0]) >= 2) ||
+				   (abs((int)ShmCharger->gun_info[gun_index].outputCurrent.L3N_L31[0] - (int)previousCharger.gun_info[gun_index].outputCurrent.L3N_L31[0]) >= 2))
 				{
 					DEBUG_INFO("*******************************************\n");
 					DEBUG_INFO("***** High priority polling : Case 11 *****\n");
@@ -2169,9 +2190,9 @@ int main(void)
 				//==================================================
 				// Case 1: Query primary In put voltage
 				//==================================================
-				if(((int)previousCharger.gun_info[gun_index].inputVoltage.L1N_L12 != (int)ShmCharger->gun_info[gun_index].inputVoltage.L1N_L12) ||
-				   ((int)previousCharger.gun_info[gun_index].inputVoltage.L2N_L23 != (int)ShmCharger->gun_info[gun_index].inputVoltage.L2N_L23) ||
-				   ((int)previousCharger.gun_info[gun_index].inputVoltage.L3N_L31 != (int)ShmCharger->gun_info[gun_index].inputVoltage.L3N_L31))
+				if((abs((int)ShmCharger->gun_info[gun_index].inputVoltage.L1N_L12 - (int)previousCharger.gun_info[gun_index].inputVoltage.L1N_L12) >= 2) ||
+				   (abs((int)ShmCharger->gun_info[gun_index].inputVoltage.L2N_L23 - (int)previousCharger.gun_info[gun_index].inputVoltage.L2N_L23) >= 2) ||
+				   (abs((int)ShmCharger->gun_info[gun_index].inputVoltage.L3N_L31 - (int)previousCharger.gun_info[gun_index].inputVoltage.L3N_L31) >= 2))
 				{
 					DEBUG_INFO("===========================================\n");
 					DEBUG_INFO("==== Normal priority polling : Case 1 =====\n");
@@ -2375,7 +2396,7 @@ int main(void)
 				}
 				else
 				{
-					DEBUG_WARN("MCU-%d set request fail...%d\n", gun_index, failCount[gun_index]);
+					DEBUG_WARN("MCU-%d set PWN request fail...%d\n", gun_index, failCount[gun_index]);
 					if(failCount[gun_index]<USHRT_MAX)
 						failCount[gun_index]++;
 					else