Browse Source

2021-07-27 / Eason Yang
Action:
1. Improve: Chargin session initial target current get logic.
2. Improve: Power saving logic.
3. Improve: The user is not allowe to use RFID when the system change into the soecified state.
4. Bugfix: Wake up button GPIO1_31 => H:OFF L:ON

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

Image version: D0.55.XX.XXXX.XX
Image checksum: XXXXXXXX

Hardware PWB P/N: XXXXXXXX
Hardware version: XXXXXXXX

8009 3 years ago
parent
commit
b15ba1f336
1 changed files with 60 additions and 10 deletions
  1. 60 10
      EVSE/Projects/AW-CCS/Apps/main.c

+ 60 - 10
EVSE/Projects/AW-CCS/Apps/main.c

@@ -1854,7 +1854,7 @@ void InitGPIO()
 	system("echo \"out\" > /sys/class/gpio/gpio62/direction");
 	system("echo 0 > /sys/class/gpio/gpio62/value");
 
-	/*Wake up button GPIO1_31 => H:ON; L:OFF*/
+	/*Wake up button GPIO1_31 => H:OFF; L:ON*/
 	system("echo 63 > /sys/class/gpio/export");
 	system("echo \"in\" > /sys/class/gpio/gpio64/direction");
 
@@ -2991,6 +2991,11 @@ int isMatchStartUser(unsigned char gun_index)
 		}
 	}
 
+	DEBUG_INFO("==== isMatchStartUser ==== \n");
+	DEBUG_INFO("tmpUser : %s \n", tmpUser);
+	DEBUG_INFO("StartUserId : %s \n", ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId);
+	DEBUG_INFO("========================== \n");
+
 	return ((strcmp((char*)tmpUser, (char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId)==0)?YES:NO);
 }
 
@@ -3039,6 +3044,11 @@ int isMatchPresentUser()
 		}
 	}
 
+	DEBUG_INFO("==== isMatchPresentUser ==== \n");
+	DEBUG_INFO("tmpUser : %s \n", tmpUser);
+	DEBUG_INFO("UserId : %s \n", ShmSysConfigAndInfo->SysConfig.UserId);
+	DEBUG_INFO("============================ \n");
+
 	return ((strcmp((char*)tmpUser, (char*)ShmSysConfigAndInfo->SysConfig.UserId)==0)?YES:NO);
 }
 
@@ -3950,6 +3960,7 @@ void checkChargingProfileLimit(uint8_t gun_index)
 			// Debug information
 			if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_LOGPPRINTOUT]) > TIMEOUT_SPEC_LOGPPRINTOUT)
 			{
+				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);
@@ -3999,6 +4010,7 @@ void checkChargingProfileLimit(uint8_t gun_index)
 			// Debug information
 			if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_LOGPPRINTOUT]) > TIMEOUT_SPEC_LOGPPRINTOUT)
 			{
+				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);
@@ -4301,7 +4313,8 @@ void checkRfidAuthrize()
 						break;
 				}
 			}
-			DEBUG_INFO("Authorize request User Id : %s\n", ShmSysConfigAndInfo->SysConfig.UserId);
+			DEBUG_INFO("Authorize request User Id : %s\n", bufferRFID);
+			//DEBUG_INFO("Authorize request User Id : %s\n", ShmSysConfigAndInfo->SysConfig.UserId);
 
 			for(int gun_index = 0;gun_index<AC_QUANTITY;gun_index++)
 				ShmCharger->gun_info[gun_index].resultAuthorization = UNKNOW_RFID;
@@ -4374,7 +4387,7 @@ void checkRfidAuthrize()
 						ftime(&startTime[0][TMR_IDX_GUN_DETECT]);
 						ShmCharger->isGetAuthResult = TRUE;
 						isCheckdResult = TRUE;
-						
+
 						if(strcmp((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") == 0)
 						{
 							ocpp_set_auth_conf(ON);
@@ -4571,7 +4584,24 @@ int main(void)
 		//==============================================
 		// Check RFID authorization
 		//==============================================
-		checkRfidAuthrize();
+		for(int gun_index = 0;gun_index<AC_QUANTITY;gun_index++)
+		{
+			// The user is not allowed to use RFID when the system change to under those modes.
+			if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_ALARM) ||
+			   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_FAULT) ||
+			   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_DEBUG) ||
+			   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_UPDATE) ||
+			   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_BOOTING) ||
+			   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_COMPLETE) ||
+			   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_MAINTAIN))
+			{
+
+			}
+			else
+			{
+				checkRfidAuthrize();
+			}
+		}
 
 		//==============================================
 		// Connector loop
@@ -4590,7 +4620,11 @@ int main(void)
 				ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_STATE_B]);
 			}
 
-			if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_CHARGING) ||
+			if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_ALARM) ||
+			   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_FAULT) ||
+			   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_UPDATE) ||
+			   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_MAINTAIN) ||
+			   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_CHARGING) ||
 			   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_TERMINATING))
 			{
 				ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_LCD]);
@@ -4599,8 +4633,9 @@ int main(void)
 			}
 			else
 			{
-				if((ShmCharger->gun_info[gun_index].GPIO_Input.Button_Mode_Switch == ON) ||
-				   (gpio_get_value(GPIO_IN_WAKEUP) == ON) ||
+				if((gpio_get_value(GPIO_IN_WAKEUP) == OFF) ||
+				   (ShmCharger->gun_info[gun_index].GPIO_Input.Button_Mode_Switch == ON) ||
+				   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus != ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus) ||
 				   (((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_IDLE) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_PREPARING)) &&
 					(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B) &&
 					(DiffTimebWithNow(startTime[gun_index][TMR_IDX_POWERSAVING_STATE_B]) < 10000)))
@@ -4924,6 +4959,22 @@ int main(void)
 						ShmCharger->gun_info[gun_index].isGunPlugged = NO;
 						ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].schedule.isTriggerStart = OFF;
 
+						// Get target current
+						ocpp_set_profile_req(gun_index, ON);
+						sleep(1);
+						checkChargingProfileLimit(gun_index);
+						if(ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent == 0)
+						{
+							ShmCharger->gun_info[gun_index].targetCurrent = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmCharger->gun_info[gun_index].primaryMcuState.rating_current)?ShmCharger->gun_info[gun_index].primaryMcuState.rating_current:ShmCharger->gun_info[gun_index].targetCurrent);
+							ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmCharger->gun_info[gun_index].primaryMcuState.rating_current)?ShmCharger->gun_info[gun_index].primaryMcuState.rating_current:ShmCharger->gun_info[gun_index].targetCurrent);
+						}
+						else
+						{
+							ShmCharger->gun_info[gun_index].targetCurrent = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent)?ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent:ShmCharger->gun_info[gun_index].targetCurrent);
+							ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent)?ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent:ShmCharger->gun_info[gun_index].targetCurrent);
+						}
+						ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
+
 						setChargerMode(gun_index, SYS_MODE_AUTHORIZING);
 					}
 					else
@@ -4934,7 +4985,6 @@ int main(void)
 					if(isModeChange(gun_index))
 					{
 						ftime(&startTime[gun_index][TMR_IDX_AUTH]);
-						ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
 						if(ShmCharger->isCcsEnable)system("/root/Module_CCS &");
 					}
 					setChargerMode(gun_index, SYS_MODE_PREPARING);
@@ -5258,9 +5308,9 @@ int main(void)
 					if((ShmCharger->gun_info[gun_index].rfidReq == ON) && isMatchPresentUser(gun_index))
 					{
 						DEBUG_INFO("Use RFID card to stop handshaking.\n");
-						setSpeaker(ON,SPEAKER_SHORT);
+						//setSpeaker(ON,SPEAKER_SHORT);
 						//setChargerMode(gun_index, SYS_MODE_IDLE);
-						
+
 						//Cancel CCS task negotiating
 						ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = OFF;	
 						ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = NOTIFICATION_STOP;