|
@@ -74,6 +74,7 @@ bool isDetectPlugin();
|
|
|
void ClearDetectPluginFlag();
|
|
|
int mystrcmp(unsigned char *p1, unsigned char *p2);
|
|
|
|
|
|
+long long DiffTimebWithNow(struct timeb ST);
|
|
|
unsigned char DetectBitValue(unsigned char _byte, unsigned char _bit);
|
|
|
void SetBitValue(unsigned char *_byte, unsigned char _bit, unsigned char value);
|
|
|
void ChargingTerminalProcess(byte gunIndex);
|
|
@@ -342,6 +343,19 @@ void PRINTF_FUNC(char *string, ...)
|
|
|
|
|
|
DEBUG_INFO_MSG("%s \n", buffer);
|
|
|
}
|
|
|
+
|
|
|
+long long DiffTimebWithNow(struct timeb ST)
|
|
|
+{
|
|
|
+
|
|
|
+ struct timeb ET;
|
|
|
+ long long StartTime,StopTime;
|
|
|
+
|
|
|
+ ftime(&ET);
|
|
|
+ StartTime=(long long)ST.time;
|
|
|
+ StopTime=(long long)ET.time;
|
|
|
+ return ((StopTime-StartTime)*1000) + (ET.millitm-ST.millitm);
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -2725,17 +2739,22 @@ void UserScanFunction()
|
|
|
else
|
|
|
{
|
|
|
|
|
|
- if (isAuthorizedComplete() || ShmSysConfigAndInfo->SysConfig.OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING)
|
|
|
+ if (isAuthorizedComplete() ||
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.OcppConnStatus == NO &&
|
|
|
+ ShmSysConfigAndInfo->SysConfig.OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING))
|
|
|
{
|
|
|
|
|
|
- if(canStartCharging() || ShmSysConfigAndInfo->SysConfig.OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING)
|
|
|
+ if(canStartCharging() ||
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.OcppConnStatus == NO &&
|
|
|
+ ShmSysConfigAndInfo->SysConfig.OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING))
|
|
|
{
|
|
|
if (_authorizeIndex != NO_DEFINE)
|
|
|
{
|
|
|
|
|
|
if (_authorizeIndex == DEFAULT_AC_INDEX)
|
|
|
{
|
|
|
- if (strcmp((char *)ac_chargingInfo[0]->StartUserId, (char *)ShmSysConfigAndInfo->SysConfig.UserId) == EQUAL)
|
|
|
+ if (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST &&
|
|
|
+ strcmp((char *)chargingInfo[_authorizeIndex]->StartUserId, "") != EQUAL)
|
|
|
{
|
|
|
AcChargingTerminalProcess();
|
|
|
}
|
|
@@ -3742,7 +3761,6 @@ void CheckOcppStatus()
|
|
|
{
|
|
|
if (ShmOCPP16Data->SpMsg.bits.BootNotificationConf == YES)
|
|
|
{
|
|
|
- ShmSysConfigAndInfo->SysInfo.OcppConnStatus = YES;
|
|
|
ShmOCPP16Data->SpMsg.bits.BootNotificationConf = NO;
|
|
|
}
|
|
|
|
|
@@ -4397,6 +4415,89 @@ void CheckTask()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+int GetStartScheduleTime(unsigned char *time)
|
|
|
+{
|
|
|
+ int result = -1;
|
|
|
+ struct tm tmScheduleStart;
|
|
|
+ struct timeb tbScheduleStart;
|
|
|
+
|
|
|
+ if((sscanf((char *)time, "%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);
|
|
|
+ tbScheduleStart.millitm = 0;
|
|
|
+
|
|
|
+ result = DiffTimebWithNow(tbScheduleStart) / 1000;
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+void CheckSmartChargeProfile(byte _index)
|
|
|
+{
|
|
|
+ if (ShmOCPP16Data->CSUMsg.bits[_index].ChargingProfileConf == NO)
|
|
|
+ {
|
|
|
+ if (ShmOCPP16Data->CSUMsg.bits[_index].ChargingProfileReq == NO)
|
|
|
+ ShmOCPP16Data->CSUMsg.bits[_index].ChargingProfileReq = YES;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ ShmOCPP16Data->CSUMsg.bits[_index].ChargingProfileConf = NO;
|
|
|
+ if (strcmp((char *)ShmOCPP16Data->SmartChargingProfile[_index].ChargingProfileKind, "Absolute") == EQUAL)
|
|
|
+ {
|
|
|
+ int _time = GetStartScheduleTime(ShmOCPP16Data->SmartChargingProfile[_index].ChargingSchedule.StartSchedule);
|
|
|
+ byte _startCount = NO_DEFINE;
|
|
|
+ byte _maxCount = ARRAY_SIZE(ShmOCPP16Data->SmartChargingProfile[_index].ChargingSchedule.ChargingSchedulePeriod);
|
|
|
+
|
|
|
+ for (byte _count = 0; _count < _maxCount; _count++)
|
|
|
+ {
|
|
|
+
|
|
|
+ if (_time >= ShmOCPP16Data->SmartChargingProfile[_index].ChargingSchedule.ChargingSchedulePeriod[_count].StartPeriod &&
|
|
|
+ ShmOCPP16Data->SmartChargingProfile[_index].ChargingSchedule.ChargingSchedulePeriod[_count].Limit > MIN_OUTPUT_CUR)
|
|
|
+ {
|
|
|
+ _startCount = _count;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ PRINTF_FUNC("_startCount = %d \n", _startCount);
|
|
|
+ if (_startCount < _maxCount)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("*********Limit = %f \n", ShmOCPP16Data->SmartChargingProfile[_index].ChargingSchedule.ChargingSchedulePeriod[_startCount].Limit);
|
|
|
+ chargingInfo[_index]->ChargingProfilePower = ShmOCPP16Data->SmartChargingProfile[_index].ChargingSchedule.ChargingSchedulePeriod[_startCount].Limit * AC_OUTPUT_VOL;
|
|
|
+ if ((chargingInfo[_index]->EvBatterytargetVoltage * 10) > 0)
|
|
|
+ {
|
|
|
+ chargingInfo[_index]->ChargingProfileCurrent = chargingInfo[_index]->ChargingProfilePower / (chargingInfo[_index]->EvBatterytargetVoltage * 10);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ chargingInfo[_index]->ChargingProfilePower = 0;
|
|
|
+ chargingInfo[_index]->ChargingProfileCurrent = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ PRINTF_FUNC("ChargingProfilePower = %f \n", chargingInfo[_index]->ChargingProfilePower);
|
|
|
+ PRINTF_FUNC("ChargingProfileCurrent = %f \n", chargingInfo[_index]->ChargingProfileCurrent);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
int main(void)
|
|
|
{
|
|
|
if(CreateShareMemory() == 0)
|
|
@@ -4532,6 +4633,12 @@ int main(void)
|
|
|
if ((GetTimeoutValue(_cmdMainPriority_time) / 1000) > 5000)
|
|
|
{
|
|
|
CheckTask();
|
|
|
+ for (byte _index = 0; _index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; _index++)
|
|
|
+ {
|
|
|
+ if (chargingInfo[_index]->SystemStatus == S_CHARGING)
|
|
|
+ CheckSmartChargeProfile(_index);
|
|
|
+ }
|
|
|
+
|
|
|
gettimeofday(&_cmdMainPriority_time, NULL);
|
|
|
}
|
|
|
|