|
@@ -45,9 +45,6 @@ void split(char **arr, char *str, const char *del);
|
|
|
|
|
|
int isReachableInternet();
|
|
|
int InitRfidPort(void);
|
|
|
-int GetAlarmValue(void);
|
|
|
-int GetInfoValue(void);
|
|
|
-int GetFaultValue(void);
|
|
|
int GetCardSerialNumber();
|
|
|
void setLedMotion(unsigned char gun_index,unsigned char led_mode);
|
|
|
void setRelay(unsigned char gun_index,unsigned char isOn);
|
|
@@ -774,6 +771,7 @@ void InitEthernet()
|
|
|
ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthGatewayAddress);
|
|
|
system(tmpbuf);
|
|
|
system("/sbin/ifconfig eth0:1 192.168.201.201 netmask 255.255.255.248 up");
|
|
|
+ system("ifconfig lo up");
|
|
|
}
|
|
|
|
|
|
if(isInterfaceUp("eth1")==PASS)
|
|
@@ -1063,7 +1061,7 @@ void get_firmware_version(unsigned char gun_index)
|
|
|
strcpy((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev, ShmCharger->gun_info[gun_index].ver.Version_FW);
|
|
|
|
|
|
// Get CSU root file system version
|
|
|
- sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "D0.07.60.6007.BT");
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "D0.08.60.6007.BT");
|
|
|
|
|
|
// Get AC connector type from model name
|
|
|
for(uint8_t idx=0;idx<3;idx++)
|
|
@@ -1210,21 +1208,32 @@ int upgrade_check()
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result = FAIL;
|
|
|
+ DEBUG_ERROR("Model name and Firmware type error.\r\n");
|
|
|
+ }
|
|
|
|
|
|
free(ptr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- // File open error
|
|
|
+ result = FAIL;
|
|
|
DEBUG_ERROR("New firmware open error.\r\n");
|
|
|
}
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result = FAIL;
|
|
|
+ DEBUG_ERROR("File name error.\r\n");
|
|
|
+ }
|
|
|
}
|
|
|
closedir (dir);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- DEBUG_ERROR("/mnt does not valid.\r\n");
|
|
|
+ result = FAIL;
|
|
|
+ DEBUG_ERROR("/mnt does not valid.\r\n");
|
|
|
}
|
|
|
|
|
|
return result;
|
|
@@ -1319,59 +1328,6 @@ int GetCardSerialNumber()
|
|
|
return isSuccess;
|
|
|
}
|
|
|
|
|
|
-//===============================================
|
|
|
-// Alarm value check
|
|
|
-//===============================================
|
|
|
-int GetAlarmValue()
|
|
|
-{
|
|
|
- int result = PASS;
|
|
|
-
|
|
|
- if( (ShmStatusCodeData->AlarmCode.AlarmEvents.AlarmVal[0] > 0) || (ShmStatusCodeData->AlarmCode.AlarmEvents.AlarmVal[1] > 0) || (ShmStatusCodeData->AlarmCode.AlarmEvents.AlarmVal[2] > 0) ||
|
|
|
- (ShmStatusCodeData->AlarmCode.AlarmEvents.AlarmVal[3] > 0) || (ShmStatusCodeData->AlarmCode.AlarmEvents.AlarmVal[4] > 0) || (ShmStatusCodeData->AlarmCode.AlarmEvents.AlarmVal[5] > 0) ||
|
|
|
- (ShmStatusCodeData->AlarmCode.AlarmEvents.AlarmVal[6] > 0) || (ShmStatusCodeData->AlarmCode.AlarmEvents.AlarmVal[7] > 0))
|
|
|
- {
|
|
|
- result = FAIL;
|
|
|
- }
|
|
|
-
|
|
|
- return result;
|
|
|
-}
|
|
|
-
|
|
|
-//===============================================
|
|
|
-// Info value check
|
|
|
-//===============================================
|
|
|
-int GetInfoValue()
|
|
|
-{
|
|
|
- int result = PASS;
|
|
|
-
|
|
|
- if( (ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[0] > 0) || (ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[1] > 0) || (ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[2] > 0) ||
|
|
|
- (ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[3] > 0) || (ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[4] > 0) || (ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[5] > 0) ||
|
|
|
- (ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[6] > 0) || (ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[7] > 0) || (ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[8] > 0) ||
|
|
|
- (ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[9] > 0))
|
|
|
- {
|
|
|
- result = FAIL;
|
|
|
- }
|
|
|
-
|
|
|
- return result;
|
|
|
-}
|
|
|
-
|
|
|
-//===============================================
|
|
|
-// Fault value check
|
|
|
-//===============================================
|
|
|
-int GetFaultValue()
|
|
|
-{
|
|
|
- int result = PASS;
|
|
|
-
|
|
|
- if( (ShmStatusCodeData->FaultCode.FaultEvents.FaultVal[0] > 0) ||
|
|
|
- (ShmStatusCodeData->FaultCode.FaultEvents.FaultVal[1] > 0) ||
|
|
|
- (ShmStatusCodeData->FaultCode.FaultEvents.FaultVal[2] > 0) ||
|
|
|
- (ShmStatusCodeData->FaultCode.FaultEvents.FaultVal[3] > 0))
|
|
|
- {
|
|
|
- result = FAIL;
|
|
|
- }
|
|
|
-
|
|
|
- return result;
|
|
|
-}
|
|
|
-
|
|
|
//===============================================
|
|
|
// Set led motion
|
|
|
//===============================================
|
|
@@ -1582,6 +1538,113 @@ int isReservationExpired(unsigned char gun_index)
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+//===============================================
|
|
|
+// Check charging profile related date routine
|
|
|
+//===============================================
|
|
|
+int isProfileValid(uint8_t gun_index)
|
|
|
+{
|
|
|
+ int result = NO;
|
|
|
+ struct tm tmFrom, tmTo;
|
|
|
+ struct timeb tbFrom, tbTo;
|
|
|
+
|
|
|
+ if((sscanf((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ValidFrom, "%4d-%2d-%2dT%2d:%2d:%2d", &tmFrom.tm_year, &tmFrom.tm_mon, &tmFrom.tm_mday, &tmFrom.tm_hour, &tmFrom.tm_min, &tmFrom.tm_sec) == 6) &&
|
|
|
+ (sscanf((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ValidTo, "%4d-%2d-%2dT%2d:%2d:%2d", &tmTo.tm_year, &tmTo.tm_mon, &tmTo.tm_mday, &tmTo.tm_hour, &tmTo.tm_min, &tmTo.tm_sec) == 6))
|
|
|
+ {
|
|
|
+ tmFrom.tm_year -= 1900;
|
|
|
+ tmFrom.tm_mon -= 1;
|
|
|
+ tbFrom.time = mktime(&tmFrom);
|
|
|
+
|
|
|
+ tmTo.tm_year -= 1900;
|
|
|
+ tmTo.tm_mon -= 1;
|
|
|
+ tbTo.time = mktime(&tmTo);
|
|
|
+
|
|
|
+ DEBUG_INFO("Valid from compare Now: %d\r\n", DiffTimebWithNow(tbFrom));
|
|
|
+ DEBUG_INFO("Valid to compare Now: %d\r\n", DiffTimebWithNow(tbTo));
|
|
|
+ if((DiffTimebWithNow(tbFrom)>=0) && (DiffTimebWithNow(tbTo)<=0))
|
|
|
+ {
|
|
|
+ result = YES;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_WARN("ValidFrom or ValidTo date parsing error.\r\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+int getScheduleStart(int gun_index)
|
|
|
+{
|
|
|
+ int result = -1;
|
|
|
+ struct tm tmScheduleStart;;
|
|
|
+ struct timeb tbScheduleStart;
|
|
|
+
|
|
|
+
|
|
|
+ if((sscanf((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.StartSchedule, "%4d-%2d-%2dT%2d:%2d:%2d", &tmScheduleStart.tm_year, &tmScheduleStart.tm_mon, &tmScheduleStart.tm_mday, &tmScheduleStart.tm_hour, &tmScheduleStart.tm_min, &tmScheduleStart.tm_sec) == 6))
|
|
|
+ {
|
|
|
+ tmScheduleStart.tm_year -= 1900;
|
|
|
+ tmScheduleStart.tm_mon -= 1;
|
|
|
+ tbScheduleStart.time = mktime(&tmScheduleStart);
|
|
|
+
|
|
|
+ result = DiffTimebWithNow(tbScheduleStart)/1000;
|
|
|
+
|
|
|
+ DEBUG_INFO("Schedule start compare Now(seconds): %d\r\n", result);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_WARN("Schedule start date parsing error.\r\n");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+int getStartSinceToday()
|
|
|
+{
|
|
|
+ int result = -1;
|
|
|
+ time_t t;
|
|
|
+ struct tm *tmStartToday;
|
|
|
+ struct timeb tbStartToday;
|
|
|
+
|
|
|
+ t=time(NULL);
|
|
|
+ tmStartToday=localtime(&t);
|
|
|
+
|
|
|
+ tmStartToday->tm_hour = 0;
|
|
|
+ tmStartToday->tm_min = 0;
|
|
|
+ tmStartToday->tm_sec = 0;
|
|
|
+
|
|
|
+ tbStartToday.time = mktime(tmStartToday);
|
|
|
+
|
|
|
+ result = DiffTimebWithNow(tbStartToday)/1000;
|
|
|
+ DEBUG_INFO("Start today compare Now(seconds): %d\r\n", result);
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+int getStartSinceWeek()
|
|
|
+{
|
|
|
+ int result = -1;
|
|
|
+ time_t t;
|
|
|
+ struct tm *tmStartWeek;
|
|
|
+ struct timeb tbStartWeek;
|
|
|
+
|
|
|
+ t=time(NULL);
|
|
|
+ tmStartWeek=localtime(&t);
|
|
|
+
|
|
|
+ tmStartWeek->tm_wday = 0;
|
|
|
+ tmStartWeek->tm_hour = 0;
|
|
|
+ tmStartWeek->tm_min = 0;
|
|
|
+ tmStartWeek->tm_sec = 0;
|
|
|
+
|
|
|
+ tbStartWeek.time = mktime(tmStartWeek);
|
|
|
+
|
|
|
+ result = DiffTimebWithNow(tbStartWeek)/1000;
|
|
|
+
|
|
|
+ DEBUG_INFO("Start week compare Now(seconds): %d\r\n", result);
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
//===============================================
|
|
|
// Valid from local white list
|
|
|
//===============================================
|
|
@@ -1729,7 +1792,6 @@ void checkConnectionTimeout()
|
|
|
ShmCharger->timeoutSpec.Present_Timeout_Spec = TIMEOUT_SPEC_HANDSHAKING;
|
|
|
//DEBUG_INFO("Handshaking timeout specification follow by OCPP Configuration : Fail. Table is blank...\r\n.");
|
|
|
}
|
|
|
-
|
|
|
//DEBUG_INFO("Present timeout spec : %d \r\n", ShmCharger->timeoutSpec.Present_Timeout_Spec);
|
|
|
}
|
|
|
}
|
|
@@ -1764,6 +1826,8 @@ int main(void)
|
|
|
ShmCharger->gun_info[gun_index].primaryMcuState.rotatory_switch = 0xff;
|
|
|
ShmCharger->gun_info[gun_index].mcuResetRequest.isMcuResetRequest = ON;
|
|
|
ShmCharger->gun_info[gun_index].isInitialPass = NO;
|
|
|
+ ShmCharger->gun_info[gun_index].isSetBreatheLedTiming = OFF;
|
|
|
+ ShmCharger->gun_info[gun_index].isSetLedBrightness = OFF;
|
|
|
}
|
|
|
|
|
|
// Main loop
|
|
@@ -1936,6 +2000,16 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // Charging profile preparation
|
|
|
+ if(!ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileConf)
|
|
|
+ {
|
|
|
+ ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileReq = ON;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileConf = OFF;
|
|
|
+ }
|
|
|
+
|
|
|
// Connector process
|
|
|
switch(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus)
|
|
|
{
|
|
@@ -2277,11 +2351,92 @@ int main(void)
|
|
|
if(ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionConf == ON)
|
|
|
ShmOCPP16Data->CpMsg.bits[gun_index].StartTransactionConf = OFF;
|
|
|
|
|
|
- /*
|
|
|
- * TODO:
|
|
|
- * 1. Query target current from charging profile
|
|
|
- */
|
|
|
- // Checking charging profile target current
|
|
|
+ // Checking profile id > 0 and current time is between charging profile validFrom & validTo
|
|
|
+ if((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileId>0) &&
|
|
|
+ (((strlen((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ValidFrom)>0) && (strlen((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ValidTo)>0)) ? isProfileValid(gun_index) : ON))
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Profile ID found: %d\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileId);
|
|
|
+ DEBUG_INFO("Valid from: %s\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ValidFrom);
|
|
|
+ DEBUG_INFO("Valid to: %s\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ValidTo);
|
|
|
+ DEBUG_INFO("Start schedule: %s\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.StartSchedule);
|
|
|
+ DEBUG_INFO("Profile kind: %s\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileKind);
|
|
|
+ DEBUG_INFO("RecurrencyKind: %s\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].RecurrencyKind);
|
|
|
+ DEBUG_INFO("Profile purpose: %s\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfilePurpose);
|
|
|
+ DEBUG_INFO("Transaction ID: %d\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].TransactionId);
|
|
|
+ DEBUG_INFO("ChargingRateUnit: %s\r\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit);
|
|
|
+
|
|
|
+ // Checking profile kind
|
|
|
+ if((mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileKind, "Absolute") == PASS))
|
|
|
+ {
|
|
|
+ // Absolute profile
|
|
|
+ if(((mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfilePurpose, "TxProfile") == PASS) && (ShmOCPP16Data->SmartChargingProfile[gun_index].TransactionId == ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId)) ||
|
|
|
+ (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfilePurpose, "TxProfile") == FAIL))
|
|
|
+ {
|
|
|
+ // Checking limitation
|
|
|
+ for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod);idx_period++)
|
|
|
+ {
|
|
|
+ if((getScheduleStart(gun_index) > ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
|
|
|
+ (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod != 0)))
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].targetCurrent = (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit,"W")==PASS?ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit/220:ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit);
|
|
|
+ DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent on period[%d]: %d\r\n", gun_index, idx_period, ShmCharger->gun_info[gun_index].targetCurrent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if((mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileKind, "Relative") == PASS))
|
|
|
+ {
|
|
|
+ // Relative profile
|
|
|
+ if(((mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfilePurpose, "TxProfile") == PASS) && (ShmOCPP16Data->SmartChargingProfile[gun_index].TransactionId == ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId)) ||
|
|
|
+ (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfilePurpose, "TxProfile") == FAIL))
|
|
|
+ {
|
|
|
+ // Checking limitation
|
|
|
+ for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod);idx_period++)
|
|
|
+ {
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration > ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
|
|
|
+ (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod != 0)))
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].targetCurrent = (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit,"W")==PASS?ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit/220:ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit);
|
|
|
+ DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent on period[%d]: %d\r\n", gun_index, idx_period, ShmCharger->gun_info[gun_index].targetCurrent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // Recurring profile
|
|
|
+ if(((mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfilePurpose, "TxProfile") == PASS) && (ShmOCPP16Data->SmartChargingProfile[gun_index].TransactionId == ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId)) ||
|
|
|
+ (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfilePurpose, "TxProfile") == FAIL))
|
|
|
+ {
|
|
|
+ if((mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].RecurrencyKind, "Daily") == PASS))
|
|
|
+ {
|
|
|
+ // Checking limitation
|
|
|
+ for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod);idx_period++)
|
|
|
+ {
|
|
|
+ if((getStartSinceToday() > ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
|
|
|
+ (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod != 0)))
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].targetCurrent = (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit,"W")==PASS?ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit/220:ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit);
|
|
|
+ DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent on period[%d]: %d\r\n", gun_index, idx_period, ShmCharger->gun_info[gun_index].targetCurrent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // Checking limitation
|
|
|
+ for(uint8_t idx_period=0;idx_period<ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod);idx_period++)
|
|
|
+ {
|
|
|
+ if((getStartSinceWeek() > ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod) &&
|
|
|
+ (((ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod == 0) && (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit != 0)) || (ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].StartPeriod != 0)))
|
|
|
+ {
|
|
|
+ ShmCharger->gun_info[gun_index].targetCurrent = (mystrcmp((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingRateUnit,"W")==PASS?ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit/220:ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingSchedule.ChargingSchedulePeriod[idx_period].Limit);
|
|
|
+ DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent on period[%d]: %d\r\n", gun_index, idx_period, ShmCharger->gun_info[gun_index].targetCurrent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// Determine max charging current to MCU
|
|
|
if(ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent == 0)
|
|
@@ -2353,7 +2508,7 @@ int main(void)
|
|
|
else
|
|
|
{
|
|
|
setRelay(gun_index, OFF);
|
|
|
- DEBUG_INFO("Connector-%d can not charging in off line\r\n", gun_index);
|
|
|
+ DEBUG_INFO("Connector-%d can not charging in off line\r\n", gun_index);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2365,8 +2520,7 @@ int main(void)
|
|
|
if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration != 0)
|
|
|
{
|
|
|
ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration = DiffTimeb(startChargingTime[gun_index], endChargingTime[gun_index])/1000;
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
setLedMotion(gun_index, LED_ACTION_STOP);
|
|
|
getDateTimeString((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StopDateTime);
|
|
|
}
|
|
@@ -2470,6 +2624,8 @@ int main(void)
|
|
|
else
|
|
|
{
|
|
|
ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
ShmOCPP16Data->SpMsg.bits.AuthorizeConf = OFF;
|
|
@@ -2485,13 +2641,20 @@ int main(void)
|
|
|
(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A) ||
|
|
|
ShmOCPP16Data->MsMsg.bits.ResetReq)
|
|
|
{
|
|
|
- if(ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest == ON)
|
|
|
- setSpeaker(ON,SPEAKER_SHORT);
|
|
|
+ //if(ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest == ON)
|
|
|
+ //setSpeaker(ON,SPEAKER_SHORT);
|
|
|
|
|
|
setRelay(gun_index, OFF);
|
|
|
+
|
|
|
+
|
|
|
|
|
|
if(!ShmCharger->gun_info[gun_index].primaryMcuState.relay_state)
|
|
|
{
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_RFID)
|
|
|
+ {
|
|
|
+ setLedMotion(gun_index,LED_ACTION_RFID_PASS);
|
|
|
+ sleep(3);
|
|
|
+ }
|
|
|
if(ShmOCPP16Data->MsMsg.bits.ResetReq)
|
|
|
{
|
|
|
if(strcmp((char*)ShmOCPP16Data->Reset.Type, "Hard")==0)
|
|
@@ -2562,13 +2725,7 @@ int main(void)
|
|
|
break;
|
|
|
case SYS_MODE_FAULT:
|
|
|
if(isModeChange(gun_index))
|
|
|
- {
|
|
|
- /*
|
|
|
- * TODO:
|
|
|
- * 1. LED control depend on relay status
|
|
|
- * 2. Alarm latch & release logic
|
|
|
- */
|
|
|
- }
|
|
|
+ {}
|
|
|
|
|
|
break;
|
|
|
case SYS_MODE_MAINTAIN:
|
|
@@ -2683,13 +2840,7 @@ int main(void)
|
|
|
break;
|
|
|
case SYS_MODE_BOOKING:
|
|
|
if(isModeChange(gun_index))
|
|
|
- {
|
|
|
- /*
|
|
|
- * TODO:
|
|
|
- * 1. LED control depend on relay status
|
|
|
- * 2. Check booking start is on time?
|
|
|
- */
|
|
|
- }
|
|
|
+ {}
|
|
|
break;
|
|
|
case SYS_MODE_DEBUG:
|
|
|
if(isModeChange(gun_index))
|