|
@@ -1635,7 +1635,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 +2545,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 +2562,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
|
|
|
//===============================================
|
|
@@ -3631,7 +3668,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 +3845,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 +4104,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 +4144,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 +4368,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 +4395,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 +4506,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 +4529,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 +4543,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(8);
|
|
|
+ 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 +4711,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 +4799,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 +4816,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))
|
|
|
{
|