|
@@ -21,7 +21,7 @@
|
|
|
#define TMR_IDX_LOGPPRINTOUT 2
|
|
|
#define TMR_IDX_PROFILE_PREPARE 3
|
|
|
#define TMR_IDX_PWN_CHANGE 4
|
|
|
-#define TMR_IDX_CHECK_TASK 5
|
|
|
+#define TMR_IDX_CHECK_TASK 5
|
|
|
#define TMR_IDX_6 6
|
|
|
#define TMR_IDX_7 7
|
|
|
#define TMR_IDX_8 8
|
|
@@ -34,8 +34,8 @@
|
|
|
#define TIMEOUT_SPEC_PROFILE_PREPARE 5000
|
|
|
#define TIMEOUT_SPEC_PWN_CHANGE 5000
|
|
|
|
|
|
-#define SPEC_TEMPERATURE_WARN 75
|
|
|
-#define SPEC_TEMPERATURE_RECOVER 65
|
|
|
+#define SPEC_TEMPERATURE_WARN 71
|
|
|
+#define SPEC_TEMPERATURE_RECOVER 63
|
|
|
|
|
|
#define MtdBlockSize 0x300000
|
|
|
|
|
@@ -211,6 +211,128 @@ long long DiffTimeb(struct timeb ST, struct timeb ET)
|
|
|
return ((StopTime-StartTime)*1000) + (ET.millitm-ST.millitm);
|
|
|
}
|
|
|
|
|
|
+int DiffTimebWithNowSec(struct timeb ST)
|
|
|
+{
|
|
|
+ //return milli-second
|
|
|
+ struct timeb ET;
|
|
|
+ unsigned int StartTime,StopTime;
|
|
|
+
|
|
|
+ ftime(&ET);
|
|
|
+ StartTime=(unsigned int)ST.time;
|
|
|
+ StopTime=(unsigned int)ET.time;
|
|
|
+ return (StopTime-StartTime);
|
|
|
+}
|
|
|
+
|
|
|
+int isOvertNow(uint8_t *start)
|
|
|
+{
|
|
|
+ int result = YES;
|
|
|
+ struct ParsingResult
|
|
|
+ {
|
|
|
+ int result;
|
|
|
+ int scanedElement;
|
|
|
+ int year;
|
|
|
+ int month;
|
|
|
+ int mday;
|
|
|
+ int hour;
|
|
|
+ int min;
|
|
|
+ int sec;
|
|
|
+ int tz_hour;
|
|
|
+ int tz_min;
|
|
|
+ float minSec;
|
|
|
+ }parsingResult;
|
|
|
+
|
|
|
+ struct tm tmStart;
|
|
|
+ struct timeb tbStart;
|
|
|
+
|
|
|
+ memset(&parsingResult, 0x00, sizeof(struct ParsingResult));
|
|
|
+
|
|
|
+ if(strstr((char*)start, ".") != NULL)
|
|
|
+ {
|
|
|
+ // Original data with mini second
|
|
|
+ if(strstr((char*)start, "Z") != NULL)
|
|
|
+ {
|
|
|
+ // Original data with Z
|
|
|
+ parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%fZ",
|
|
|
+ &parsingResult.year,
|
|
|
+ &parsingResult.month,
|
|
|
+ &parsingResult.mday,
|
|
|
+ &parsingResult.hour,
|
|
|
+ &parsingResult.min,
|
|
|
+ &parsingResult.sec,
|
|
|
+ &parsingResult.minSec);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // Original data without Z
|
|
|
+ parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%f%d:%d",
|
|
|
+ &parsingResult.year,
|
|
|
+ &parsingResult.month,
|
|
|
+ &parsingResult.mday,
|
|
|
+ &parsingResult.hour,
|
|
|
+ &parsingResult.min,
|
|
|
+ &parsingResult.sec,
|
|
|
+ &parsingResult.minSec,
|
|
|
+ &parsingResult.tz_hour,
|
|
|
+ &parsingResult.tz_min);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // Original data without mini second
|
|
|
+ if(strstr((char*)start, "Z") != NULL)
|
|
|
+ {
|
|
|
+ // Original data with Z
|
|
|
+ parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%dZ",
|
|
|
+ &parsingResult.year,
|
|
|
+ &parsingResult.month,
|
|
|
+ &parsingResult.mday,
|
|
|
+ &parsingResult.hour,
|
|
|
+ &parsingResult.min,
|
|
|
+ &parsingResult.sec);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // Original data without Z
|
|
|
+ parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d%d:%d",
|
|
|
+ &parsingResult.year,
|
|
|
+ &parsingResult.month,
|
|
|
+ &parsingResult.mday,
|
|
|
+ &parsingResult.hour,
|
|
|
+ &parsingResult.min,
|
|
|
+ &parsingResult.sec,
|
|
|
+ &parsingResult.tz_hour,
|
|
|
+ &parsingResult.tz_min);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(parsingResult.scanedElement >= 6)
|
|
|
+ {
|
|
|
+ tmStart.tm_year = parsingResult.year - 1900;
|
|
|
+ tmStart.tm_mon = parsingResult.month - 1;
|
|
|
+ tmStart.tm_mday = parsingResult.mday;
|
|
|
+ tmStart.tm_hour = parsingResult.hour;
|
|
|
+ tmStart.tm_min = parsingResult.min;
|
|
|
+ tmStart.tm_sec = parsingResult.sec;
|
|
|
+ tmStart.tm_gmtoff = 0;
|
|
|
+ tbStart.time = mktime(&tmStart);
|
|
|
+ tbStart.timezone = 0;
|
|
|
+ tbStart.millitm = 0;
|
|
|
+
|
|
|
+ tbStart.time -= (parsingResult.tz_hour*3600) + (parsingResult.tz_min*60*(parsingResult.tz_hour>=0?1:-1));
|
|
|
+
|
|
|
+ if(DiffTimebWithNowSec(tbStart) <= 0)
|
|
|
+ result = NO;
|
|
|
+ else
|
|
|
+ result = YES;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_WARN("Start date parsing error.\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
void getDateTimeString(char* result)
|
|
|
{
|
|
|
time_t CurrentTime;
|
|
@@ -1635,7 +1757,7 @@ int LoadSysConfigAndInfo(struct SysConfigData *ptr)
|
|
|
free(buf);
|
|
|
|
|
|
system("rm -f /mnt/EvseConfig.bin");
|
|
|
-
|
|
|
+
|
|
|
// SysConfig in flash is empty (0xffffffff)
|
|
|
if((strlen((char*)ShmSysConfigAndInfo->SysConfig.ModelName) > ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.ModelName)) ||
|
|
|
(strlen((char*)ShmSysConfigAndInfo->SysConfig.SerialNumber) > ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.SerialNumber)) ||
|
|
@@ -2545,16 +2667,16 @@ void setLedMotion(unsigned char gun_index,unsigned char led_mode)
|
|
|
}
|
|
|
|
|
|
//===============================================
|
|
|
-// Relay on/off request set
|
|
|
+// Request on/off set (PWM)
|
|
|
//===============================================
|
|
|
-void setRelay(unsigned char gun_index,unsigned char isOn)
|
|
|
+void setRequest(unsigned char gun_index,unsigned char isOn)
|
|
|
{
|
|
|
if(isOn == ON)
|
|
|
{
|
|
|
if(ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest == OFF)
|
|
|
{
|
|
|
ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest = ON;
|
|
|
- DEBUG_INFO("Gun-%d Output relay sts: ON \n",gun_index);
|
|
|
+ DEBUG_INFO("Gun-%d permission request: ON \n",gun_index);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -2562,19 +2684,56 @@ void setRelay(unsigned char gun_index,unsigned char isOn)
|
|
|
if(ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest == ON)
|
|
|
{
|
|
|
ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest = OFF;
|
|
|
- DEBUG_INFO("Gun-%d Output relay sts: OFF \n",gun_index);
|
|
|
+ DEBUG_INFO("Gun-%d permission request: OFF \n",gun_index);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//===============================================
|
|
|
-// Relay on/off request get
|
|
|
+// Request on/off get (PWM)
|
|
|
//===============================================
|
|
|
-int getRelay(unsigned char gun_index)
|
|
|
+int getRequest(unsigned char gun_index)
|
|
|
{
|
|
|
return ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest;
|
|
|
}
|
|
|
|
|
|
+//===============================================
|
|
|
+// Relay on/off set (Relay)
|
|
|
+//===============================================
|
|
|
+void setRelay(unsigned char gun_index,unsigned char isOn)
|
|
|
+{
|
|
|
+ if(isOn == ON)
|
|
|
+ {
|
|
|
+ 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 status: ON. \n",gun_index);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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 status: OFF. \n",gun_index);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//===============================================
|
|
|
+// Relay on/off get (Relay)
|
|
|
+//===============================================
|
|
|
+int getRelay(unsigned char gun_index)
|
|
|
+{
|
|
|
+ return ShmCharger->gun_info[gun_index].legacyRequest.isRelayOn;
|
|
|
+}
|
|
|
+
|
|
|
//===============================================
|
|
|
// Set speaker on/off request
|
|
|
//===============================================
|
|
@@ -2738,48 +2897,16 @@ int isRouteFail()
|
|
|
int isReservationExpired(unsigned char gun_index)
|
|
|
{
|
|
|
int result = NO;
|
|
|
- struct tm expiredDate;
|
|
|
- struct timeb expiredTime;
|
|
|
-
|
|
|
+
|
|
|
if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
|
|
|
{
|
|
|
- if(sscanf((char*)ShmOCPP16Data->ReserveNow[gun_index].ExpiryDate, "%4d-%2d-%2dT%2d:%2d:%2d", &expiredDate.tm_year, &expiredDate.tm_mon, &expiredDate.tm_mday, &expiredDate.tm_hour, &expiredDate.tm_min, &expiredDate.tm_sec) == 6)
|
|
|
- {
|
|
|
- expiredDate.tm_year -= 1900;
|
|
|
- expiredDate.tm_mon -= 1;
|
|
|
- expiredTime.time = mktime(&expiredDate);
|
|
|
-
|
|
|
- if(DiffTimebWithNow(expiredTime)>=0)
|
|
|
- {
|
|
|
- result = YES;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- DEBUG_WARN("Expired date parsing error.\n");
|
|
|
- DEBUG_INFO("Date expired.\n");
|
|
|
+ if(isOvertNow(ShmOCPP16Data->ReserveNow[gun_index].ExpiryDate))
|
|
|
result = YES;
|
|
|
- }
|
|
|
}
|
|
|
else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
|
|
|
{
|
|
|
- if(sscanf((char*)ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime, "%4d-%2d-%2dT%2d:%2d:%2d", &expiredDate.tm_year, &expiredDate.tm_mon, &expiredDate.tm_mday, &expiredDate.tm_hour, &expiredDate.tm_min, &expiredDate.tm_sec) == 6)
|
|
|
- {
|
|
|
- expiredDate.tm_year -= 1900;
|
|
|
- expiredDate.tm_mon -= 1;
|
|
|
- expiredTime.time = mktime(&expiredDate);
|
|
|
-
|
|
|
- if(DiffTimebWithNow(expiredTime)>=0)
|
|
|
- {
|
|
|
- result = YES;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- DEBUG_WARN("Expired date parsing error.\n");
|
|
|
- DEBUG_INFO("Date expired.\n");
|
|
|
+ if(isOvertNow(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime))
|
|
|
result = YES;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
return result;
|
|
@@ -3631,7 +3758,7 @@ int main(void)
|
|
|
{
|
|
|
setLedMotion(gun_index,LED_ACTION_INIT);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
sleep(5);
|
|
|
system("cd /root;./Module_FactoryConfig -m");
|
|
|
system("rm -f /Storage/OCPP/OCPPConfiguration");
|
|
@@ -3808,6 +3935,7 @@ int main(void)
|
|
|
{
|
|
|
setLedMotion(gun_index,LED_ACTION_IDLE);
|
|
|
setRelay(gun_index,OFF);
|
|
|
+ setRequest(gun_index,OFF);
|
|
|
ShmCharger->gun_info[gun_index].isGunPlugged = NO;
|
|
|
ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
|
ShmCharger->gun_info[gun_index].bleConfigData.isRequestStart = OFF;
|
|
@@ -4066,13 +4194,13 @@ int main(void)
|
|
|
if(isModeChange(gun_index))
|
|
|
{
|
|
|
ftime(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
|
|
|
- setRelay(gun_index, ON);
|
|
|
setLedMotion(gun_index,LED_ACTION_CONNECTED);
|
|
|
}
|
|
|
|
|
|
// If control pilot detect Bx, skip watch dog time out.
|
|
|
- if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B)
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C))
|
|
|
{
|
|
|
+ setRequest(gun_index,ON);
|
|
|
ftime(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
|
|
|
ShmCharger->gun_info[gun_index].isGunPlugged = YES;
|
|
|
}
|
|
@@ -4106,18 +4234,23 @@ int main(void)
|
|
|
setChargerMode(gun_index, SYS_MODE_IDLE);
|
|
|
}
|
|
|
}
|
|
|
- else if((ShmCharger->gun_info[gun_index].primaryMcuState.relay_state == ON))
|
|
|
+ else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C))
|
|
|
{
|
|
|
- ocpp_set_unlocker_req(gun_index, OFF);
|
|
|
- ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = 0;
|
|
|
- getDateTimeString((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartDateTime);
|
|
|
- ShmCharger->gun_info[gun_index].powerConsumption.power_consumption_at_start = ShmCharger->gun_info[gun_index].powerConsumption.power_consumption;
|
|
|
- ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100.0);
|
|
|
- memcpy((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ShmSysConfigAndInfo->SysConfig.UserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
|
|
|
- ocpp_copy_userid_to_starttransaction(gun_index);
|
|
|
- ocpp_set_starttransaction_req(gun_index, ON);
|
|
|
+ // Set relay on when the system is state C
|
|
|
+ setRelay(gun_index,ON);
|
|
|
+ if((ShmCharger->gun_info[gun_index].primaryMcuState.relay_state == ON))
|
|
|
+ {
|
|
|
+ ocpp_set_unlocker_req(gun_index, OFF);
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = 0;
|
|
|
+ getDateTimeString((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartDateTime);
|
|
|
+ ShmCharger->gun_info[gun_index].powerConsumption.power_consumption_at_start = ShmCharger->gun_info[gun_index].powerConsumption.power_consumption;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption = (ShmCharger->gun_info[gun_index].powerConsumption.power_consumption/100.0);
|
|
|
+ memcpy((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ShmSysConfigAndInfo->SysConfig.UserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
|
|
|
+ ocpp_copy_userid_to_starttransaction(gun_index);
|
|
|
+ ocpp_set_starttransaction_req(gun_index, ON);
|
|
|
|
|
|
- setChargerMode(gun_index, SYS_MODE_CHARGING);
|
|
|
+ setChargerMode(gun_index, SYS_MODE_CHARGING);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
break;
|
|
@@ -4325,7 +4458,19 @@ int main(void)
|
|
|
{
|
|
|
if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_PWN_CHANGE]) > TIMEOUT_SPEC_PWN_CHANGE)
|
|
|
{
|
|
|
- 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);
|
|
|
+ if((6 <= 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 if((1 <= ShmCharger->gun_info[gun_index].targetCurrent) && (ShmCharger->gun_info[gun_index].targetCurrent < 6))
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = 6;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = 100;
|
|
|
+ }
|
|
|
+
|
|
|
ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
|
|
|
ftime(&startTime[gun_index][TMR_IDX_PWN_CHANGE]);
|
|
|
}
|
|
@@ -4340,7 +4485,19 @@ int main(void)
|
|
|
{
|
|
|
if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_PWN_CHANGE]) > TIMEOUT_SPEC_PWN_CHANGE)
|
|
|
{
|
|
|
- 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);
|
|
|
+ if((6 <= 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);
|
|
|
+ }
|
|
|
+ else if((1 <= ShmCharger->gun_info[gun_index].targetCurrent) && (ShmCharger->gun_info[gun_index].targetCurrent < 6))
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = 6;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = 100;
|
|
|
+ }
|
|
|
+
|
|
|
ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
|
|
|
ftime(&startTime[gun_index][TMR_IDX_PWN_CHANGE]);
|
|
|
}
|
|
@@ -4439,6 +4596,7 @@ int main(void)
|
|
|
case SYS_MODE_TERMINATING:
|
|
|
if(isModeChange(gun_index))
|
|
|
{
|
|
|
+ setLedMotion(gun_index, LED_ACTION_STOP);
|
|
|
if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration != 0)
|
|
|
{
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration = DiffTimeb(startChargingTime[gun_index], endChargingTime[gun_index])/1000;
|
|
@@ -4461,7 +4619,7 @@ int main(void)
|
|
|
ocpp_get_unlocker_req(gun_index) ||
|
|
|
(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].schedule.isTriggerStop == ON))
|
|
|
{
|
|
|
- if((ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest == ON) || (ShmCharger->gun_info[gun_index].isChargerStopByCondition == YES))
|
|
|
+ if(((ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest == ON) || (ShmCharger->gun_info[gun_index].isChargerStopByCondition == YES)) && (ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current != 100))
|
|
|
{
|
|
|
if(((ShmCharger->gun_info[gun_index].rfidReq == ON) && isMatchStartUser(gun_index)) ||
|
|
|
(ShmCharger->gun_info[gun_index].isAuthPassEnd))
|
|
@@ -4475,15 +4633,21 @@ int main(void)
|
|
|
else
|
|
|
{}
|
|
|
|
|
|
- setRelay(gun_index, OFF);
|
|
|
+ ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = 100;
|
|
|
+ ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
|
|
|
setLedMotion(gun_index, LED_ACTION_STOP);
|
|
|
+ checkStopReason(gun_index);
|
|
|
+ sleep(6);
|
|
|
+ setChargerMode(gun_index, SYS_MODE_COMPLETE);
|
|
|
|
|
|
+ /*
|
|
|
// If relay is off, the system should change to complete mode
|
|
|
if(!ShmCharger->gun_info[gun_index].primaryMcuState.relay_state)
|
|
|
{
|
|
|
checkStopReason(gun_index);
|
|
|
setChargerMode(gun_index, SYS_MODE_COMPLETE);
|
|
|
}
|
|
|
+ */
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -4637,9 +4801,61 @@ int main(void)
|
|
|
|
|
|
// Check target current if charging profile limit > 0
|
|
|
checkChargingProfileLimit(gun_index);
|
|
|
- if(ShmCharger->gun_info[gun_index].targetCurrent > 0)
|
|
|
+
|
|
|
+ // Determine max charging current to MCU
|
|
|
+ if(ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent == 0)
|
|
|
{
|
|
|
- setRelay(gun_index, ON);
|
|
|
+ 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);
|
|
|
+ if(ShmCharger->gun_info[gun_index].targetCurrent != ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current)
|
|
|
+ {
|
|
|
+ if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_PWN_CHANGE]) > TIMEOUT_SPEC_PWN_CHANGE)
|
|
|
+ {
|
|
|
+ if((6 <= 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 if((1 <= ShmCharger->gun_info[gun_index].targetCurrent) && (ShmCharger->gun_info[gun_index].targetCurrent < 6))
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = 6;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = 100;
|
|
|
+ }
|
|
|
+
|
|
|
+ ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
|
|
|
+ ftime(&startTime[gun_index][TMR_IDX_PWN_CHANGE]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ if(ShmCharger->gun_info[gun_index].targetCurrent != ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current)
|
|
|
+ {
|
|
|
+ if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_PWN_CHANGE]) > TIMEOUT_SPEC_PWN_CHANGE)
|
|
|
+ {
|
|
|
+ if((6 <= 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);
|
|
|
+ }
|
|
|
+ else if((1 <= ShmCharger->gun_info[gun_index].targetCurrent) && (ShmCharger->gun_info[gun_index].targetCurrent < 6))
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = 6;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = 100;
|
|
|
+ }
|
|
|
+
|
|
|
+ ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
|
|
|
+ ftime(&startTime[gun_index][TMR_IDX_PWN_CHANGE]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {}
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// Debug information
|
|
@@ -4673,6 +4889,8 @@ int main(void)
|
|
|
if(isModeChange(gun_index))
|
|
|
{
|
|
|
setLedMotion(gun_index, LED_ACTION_STOP);
|
|
|
+ setRequest(gun_index, OFF);
|
|
|
+ setRelay(gun_index, OFF);
|
|
|
sleep(3);
|
|
|
}
|
|
|
|
|
@@ -4688,16 +4906,7 @@ int main(void)
|
|
|
break;
|
|
|
case SYS_MODE_ALARM:
|
|
|
setLedMotion(gun_index,LED_ACTION_ALARM);
|
|
|
-
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus == SYS_MODE_CHARGING) ||
|
|
|
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus == SYS_MODE_TERMINATING))
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- setRelay(gun_index, OFF);
|
|
|
- }
|
|
|
+ setRelay(gun_index, OFF);
|
|
|
|
|
|
if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode == 0))
|
|
|
{
|