Jelajahi Sumber

Merge remote-tracking branch 'origin/AW-CCS'

FolusWen 3 tahun lalu
induk
melakukan
dcc58f7862
1 mengubah file dengan 46 tambahan dan 24 penghapusan
  1. 46 24
      EVSE/Projects/AW-CCS/Apps/main.c

+ 46 - 24
EVSE/Projects/AW-CCS/Apps/main.c

@@ -98,6 +98,14 @@ sqlite3 *localDb;
 
 struct SysConfigData			SysConfigOrg;
 ParsingRatedCur 				modelnameInfo={0};
+
+struct PreviousData
+{
+	uint16_t targetCurrent;
+	uint16_t current_limit;
+	uint16_t primaryMcuCp_Pwn_Duty;
+}previousData[4];
+
 //=================================
 // Common routine
 //=================================
@@ -3264,6 +3272,7 @@ int upgrade_check()
 int isMatchStartUser(unsigned char gun_index)
 {
 	uint8_t tmpUser[32];
+	uint8_t isPrintLogOut = OFF;
 
 	if(ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian)
 	{
@@ -3305,11 +3314,15 @@ int isMatchStartUser(unsigned char gun_index)
 				break;
 		}
 	}
-
-	DEBUG_INFO("==== isMatchStartUser ==== \n");
-	DEBUG_INFO("tmpUser : %s \n", tmpUser);
-	DEBUG_INFO("StartUserId : %s \n", ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId);
-	DEBUG_INFO("========================== \n");
+	
+	if(isPrintLogOut == OFF)
+	{
+		DEBUG_INFO("==== isMatchStartUser ==== \n");
+		DEBUG_INFO("tmpUser : %s \n", tmpUser);
+		DEBUG_INFO("StartUserId : %s \n", ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId);
+		DEBUG_INFO("========================== \n");
+		isPrintLogOut = ON;
+	}
 
 	return ((strcmp((char*)tmpUser, (char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId)==0)?YES:NO);
 }
@@ -3317,6 +3330,7 @@ int isMatchStartUser(unsigned char gun_index)
 int isMatchPresentUser()
 {
 	uint8_t tmpUser[32];
+	uint8_t isPrintLogOut = OFF;
 
 	if(ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian)
 	{
@@ -3359,10 +3373,14 @@ int isMatchPresentUser()
 		}
 	}
 
-	DEBUG_INFO("==== isMatchPresentUser ==== \n");
-	DEBUG_INFO("tmpUser : %s \n", tmpUser);
-	DEBUG_INFO("UserId : %s \n", ShmSysConfigAndInfo->SysConfig.UserId);
-	DEBUG_INFO("============================ \n");
+	if(isPrintLogOut == OFF)
+	{
+		DEBUG_INFO("==== isMatchPresentUser ==== \n");
+		DEBUG_INFO("tmpUser : %s \n", tmpUser);
+		DEBUG_INFO("UserId : %s \n", ShmSysConfigAndInfo->SysConfig.UserId);
+		DEBUG_INFO("============================ \n");
+		isPrintLogOut = ON;
+	}
 
 	return ((strcmp((char*)tmpUser, (char*)ShmSysConfigAndInfo->SysConfig.UserId)==0)?YES:NO);
 }
@@ -4271,12 +4289,14 @@ void checkAvailability(uint8_t gun_index)
 
 void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
 {
+	/*
 	static struct PreviousData
 	{
 		uint16_t targetCurrent;
 		uint16_t current_limit;
 		uint16_t primaryMcuCp_Pwn_Duty;
 	}previousData[4];
+	*/
 
 	if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 	{
@@ -4287,7 +4307,7 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
 			// Debug information
 			if(getDiffSecNow(startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]) > TIMEOUT_SPEC_LOGPPRINTOUT)
 			{
-				DEBUG_INFO("===============================================================\n");
+				DEBUG_INFO("==================================================\n");
 				DEBUG_INFO("Profile ID found: %d\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileId);
 				DEBUG_INFO("Valid from: %s\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ValidFrom);
 				DEBUG_INFO("Valid to: %s\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ValidTo);
@@ -4297,7 +4317,7 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
 				DEBUG_INFO("Profile purpose: %s\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfilePurpose);
 				DEBUG_INFO("Transaction ID: %d\n", ShmOCPP16Data->SmartChargingProfile[gun_index].TransactionId);
 				DEBUG_INFO("ChargingRateUnit: %s\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit);
-				DEBUG_INFO("===============================================================\n");
+				DEBUG_INFO("==================================================\n");
 				
 				refreshStartTimer(&startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]);
 			}
@@ -4339,7 +4359,7 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
 			// Debug information
 			if(getDiffSecNow(startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]) > TIMEOUT_SPEC_LOGPPRINTOUT)
 			{
-				DEBUG_INFO("===============================================================\n");
+				DEBUG_INFO("==================================================\n");
 				DEBUG_INFO("Profile ID found: %d\n", ShmOCPP20Data->SmartChargingProfile[gun_index].id);
 				DEBUG_INFO("Valid from: %s\n", ShmOCPP20Data->SmartChargingProfile[gun_index].validFrom);
 				DEBUG_INFO("Valid to: %s\n", ShmOCPP20Data->SmartChargingProfile[gun_index].validTo);
@@ -4349,7 +4369,7 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
 				DEBUG_INFO("Profile purpose: %s\n", ShmOCPP20Data->SmartChargingProfile[gun_index].chargingProfilePurpose);
 				DEBUG_INFO("Transaction ID: %d\n", ShmOCPP20Data->SmartChargingProfile[gun_index].transactionId);
 				DEBUG_INFO("ChargingRateUnit: %s\n", ShmOCPP20Data->SmartChargingProfile[gun_index].chargingSchedule[0].chargingRateUnit);
-				DEBUG_INFO("===============================================================\n");
+				DEBUG_INFO("==================================================\n");
 				
 				refreshStartTimer(&startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]);
 			}
@@ -4369,7 +4389,7 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
 						  )
 						{
 							ShmCharger->gun_info[gun_index].targetCurrent = (mystrcmp((char*)ShmOCPP20Data->SmartChargingProfile[gun_index].chargingSchedule[0].chargingRateUnit,"W")==PASS?ShmOCPP20Data->SmartChargingProfile[gun_index].chargingSchedule[0].chargingSchedulePeriod[idx_period].limit/(220*ShmOCPP20Data->SmartChargingProfile[gun_index].chargingSchedule[0].chargingSchedulePeriod[idx_period].numberPhases):ShmOCPP20Data->SmartChargingProfile[gun_index].chargingSchedule[0].chargingSchedulePeriod[idx_period].limit);
-							DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent on period[%d]: %d\n", gun_index, idx_period, ShmCharger->gun_info[gun_index].targetCurrent);
+							//DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent on period[%d]: %d\n", gun_index, idx_period, ShmCharger->gun_info[gun_index].targetCurrent);
 						}
 						else
 							break;
@@ -4488,29 +4508,26 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
 
 			if(previousData[gun_index].primaryMcuCp_Pwn_Duty != ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current)
 			{
-				DEBUG_INFO("====================================================\n");
+				DEBUG_INFO("==================================================\n");
 				DEBUG_INFO("gun-%02d primaryMcuCp_Pwn_Duty: %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current);
-				DEBUG_INFO("====================================================\n");
-
+				DEBUG_INFO("==================================================\n");
 				previousData[gun_index].primaryMcuCp_Pwn_Duty = ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current;
 			}
 
 			if(ShmCharger->gun_info[gun_index].targetCurrent != previousData[gun_index].targetCurrent)
 			{
-				DEBUG_INFO("====================================================\n");
-				DEBUG_INFO("MaxChargingCurrent: %d \n", ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent);
+				DEBUG_INFO("==================================================\n");
 				DEBUG_INFO("gun-%02d targetCurrent: %d\n", gun_index, ShmCharger->gun_info[gun_index].targetCurrent);
-				DEBUG_INFO("====================================================\n");
-
+				DEBUG_INFO("MaxChargingCurrent: %d \n", ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent);
+				DEBUG_INFO("==================================================\n");
 				previousData[gun_index].targetCurrent = ShmCharger->gun_info[gun_index].targetCurrent;
 			}
 
 			if(ShmCharger->gun_info[gun_index].primaryMcuState.current_limit != previousData[gun_index].current_limit)
 			{
-				DEBUG_INFO("====================================================\n");
+				DEBUG_INFO("==================================================\n");
 				DEBUG_INFO("gun-%02d mcu current_limit: %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.current_limit);
-				DEBUG_INFO("====================================================\n");
-
+				DEBUG_INFO("==================================================\n");
 				previousData[gun_index].current_limit = ShmCharger->gun_info[gun_index].primaryMcuState.current_limit;
 			}
 
@@ -5476,6 +5493,11 @@ int main(void)
 						ShmCharger->gun_info[gun_index].resultAuthorization = DEFAULT_RFID;
 						//if(ShmCharger->isCcsEnable)system("pkill Module_CCS");
 						DB_Check_Record_Buf(localDb, gun_index);
+						
+						// Default previousData every time
+						previousData[gun_index].primaryMcuCp_Pwn_Duty = 0;
+						previousData[gun_index].targetCurrent = 0;
+						previousData[gun_index].current_limit = 0;
 					}
 
 					checkHandshakeCountdown(gun_index);