|
@@ -6,7 +6,8 @@
|
|
|
#define FAIL -1
|
|
|
#define YES 1
|
|
|
#define NO 0
|
|
|
-#define DERATING 30
|
|
|
+#define DERATING_COUNT 30
|
|
|
+#define DERATING_GAP 30
|
|
|
#define ELEMENT_NOT_FIND 255
|
|
|
#define CHK_VOL_RANGE 50
|
|
|
#define CHK_CUR_RANGE 10
|
|
@@ -14,7 +15,9 @@
|
|
|
#define ZERO_CURRENT 10 // 該值須保持最小為 1A
|
|
|
#define ZERO_VOLTAGE 50
|
|
|
#define STOP_CURRENT 30
|
|
|
-#define PSU_MIN_CUR 100
|
|
|
+#define PSU_MIN_CUR 1000
|
|
|
+#define PRE_CHARG_STEP_CUR 30
|
|
|
+#define PRE_CHARG_RANGE 50
|
|
|
#define EQUAL 0
|
|
|
|
|
|
struct SysConfigAndInfo *ShmSysConfigAndInfo;
|
|
@@ -51,19 +54,21 @@ int StoreLogMsg(const char *fmt, ...)
|
|
|
{
|
|
|
char Buf[4096+256];
|
|
|
char buffer[4096];
|
|
|
- time_t CurrentTime;
|
|
|
- struct tm *tm;
|
|
|
va_list args;
|
|
|
+ struct timeb SeqEndTime;
|
|
|
+ struct tm *tm;
|
|
|
|
|
|
va_start(args, fmt);
|
|
|
int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
|
|
|
va_end(args);
|
|
|
|
|
|
memset(Buf,0,sizeof(Buf));
|
|
|
- CurrentTime = time(NULL);
|
|
|
- tm=localtime(&CurrentTime);
|
|
|
- sprintf(Buf,"echo \"%04d-%02d-%02d %02d:%02d:%02d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
|
|
|
- tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
|
|
|
+ ftime(&SeqEndTime);
|
|
|
+ SeqEndTime.time = time(NULL);
|
|
|
+ tm=localtime(&SeqEndTime.time);
|
|
|
+
|
|
|
+ sprintf(Buf,"echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
|
|
|
+ tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,SeqEndTime.millitm,
|
|
|
buffer,
|
|
|
tm->tm_year+1900,tm->tm_mon+1);
|
|
|
system(Buf);
|
|
@@ -333,7 +338,7 @@ void GetAvailableCapCallback(byte address, short maxVol, short minVol, short max
|
|
|
ShmPsuData->PsuGroup[group].PsuModule[address].AvailableCurrent = maxCur;
|
|
|
|
|
|
ShmPsuData->PsuGroup[group].PsuModule[address].AvailablePower = totalPow;
|
|
|
-
|
|
|
+ // 總和該 Group 的可輸出電流
|
|
|
for (byte index = 0; index < ShmPsuData->PsuGroup[group].GroupPresentPsuQuantity; index++)
|
|
|
{
|
|
|
_groupCurrent += ShmPsuData->PsuGroup[group].PsuModule[index].AvailableCurrent;
|
|
@@ -347,13 +352,20 @@ void GetAvailableCapCallback(byte address, short maxVol, short minVol, short max
|
|
|
chargingInfo[group]->MaximumChargingVoltage = maxVol;
|
|
|
|
|
|
int _power = 0, _current = 0, _ratingcurrent = 0;
|
|
|
+ bool isGetAllDeratingCurrent = true;
|
|
|
+
|
|
|
for (byte index = 0; index < ShmPsuData->GroupCount; index++)
|
|
|
{
|
|
|
_power += ShmPsuData->PsuGroup[index].GroupAvailablePower;
|
|
|
_current += ShmPsuData->PsuGroup[index].GroupAvailableCurrent;
|
|
|
_ratingcurrent += chargingInfo[index]->DeratingChargingCurrent;
|
|
|
+ if (chargingInfo[index]->DeratingChargingCurrent == 0)
|
|
|
+ isGetAllDeratingCurrent = false;
|
|
|
}
|
|
|
|
|
|
+ // 如果不是所有群都得到 Derating current,則先不採樣該次的 ratingCurrent
|
|
|
+ if (!isGetAllDeratingCurrent) _ratingcurrent = 0;
|
|
|
+
|
|
|
ShmPsuData->SystemAvailableCurrent = _current;
|
|
|
ShmPsuData->SystemAvailablePower = _power;
|
|
|
|
|
@@ -365,6 +377,18 @@ void GetAvailableCapCallback(byte address, short maxVol, short minVol, short max
|
|
|
int halfCur = ShmPsuData->PsuGroup[group].GroupAvailableCurrent;
|
|
|
int ratingCur = chargingInfo[group]->DeratingChargingCurrent;
|
|
|
|
|
|
+ if ((ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_GET_NEW_CAP &&
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ReAssignedFlag <= _REASSIGNED_RELAY_M_TO_A))
|
|
|
+ {
|
|
|
+ if (chargingInfo[group]->DividChargingCurrent == 0)
|
|
|
+ return;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ halfCur = chargingInfo[group]->DividChargingCurrent;
|
|
|
+ ratingCur = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
GetMaxPowerAndCur(_MAIN_CHARGING_MODE_AVER, ratingCur, &halfPow, &halfCur);
|
|
|
|
|
|
// if ((ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_GET_NEW_CAP &&
|
|
@@ -436,25 +460,43 @@ void GetInputVoltageCallback(byte address, unsigned short vol1, unsigned short v
|
|
|
|
|
|
void GetPresentOutputCallback(byte group, unsigned short outVol, unsigned short outCur)
|
|
|
{
|
|
|
- unsigned short outputVol = outVol;
|
|
|
- unsigned short outputCur = outCur;
|
|
|
+ //if (outCur != ShmPsuData->PsuGroup[group].GroupPresentOutputCurrent)
|
|
|
+ //{
|
|
|
+ // PRINTF_FUNC("Gp_%d, gp output cur = %d \n", group, outCur);
|
|
|
+ //}
|
|
|
|
|
|
// PSU Group - 電壓
|
|
|
- ShmPsuData->PsuGroup[group].GroupPresentOutputVoltage = outputVol;
|
|
|
+ ShmPsuData->PsuGroup[group].GroupPresentOutputVoltage = outVol;
|
|
|
// PSU Group - 電流
|
|
|
- ShmPsuData->PsuGroup[group].GroupPresentOutputCurrent = outputCur;
|
|
|
+ ShmPsuData->PsuGroup[group].GroupPresentOutputCurrent = outCur;
|
|
|
|
|
|
- if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_MAX)
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_MAX ||
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_AVER &&
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_WAITING &&
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ReAssignedFlag <= _REASSIGNED_COMP))
|
|
|
+ )
|
|
|
{
|
|
|
- outputVol = 0;
|
|
|
- outputCur = 0;
|
|
|
+ unsigned short outputVol = 0;
|
|
|
+ unsigned short outputCur = 0;
|
|
|
|
|
|
for (byte index = 0; index < ShmPsuData->GroupCount; index++)
|
|
|
{
|
|
|
+ bool needtoAdd = true;
|
|
|
+
|
|
|
if (ShmPsuData->PsuGroup[index].GroupPresentOutputVoltage > outputVol)
|
|
|
outputVol = ShmPsuData->PsuGroup[index].GroupPresentOutputVoltage;
|
|
|
|
|
|
- outputCur += ShmPsuData->PsuGroup[index].GroupPresentOutputCurrent;
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_ADJUST_M_TO_A &&
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ReAssignedFlag <= _REASSIGNED_RELAY_M_TO_A)
|
|
|
+ {
|
|
|
+// PRINTF_FUNC("Gp_%d, DividChargingCurrent = %d \n", index,
|
|
|
+// chargingInfo[index]->DividChargingCurrent);
|
|
|
+ if (chargingInfo[index]->DividChargingCurrent == 0)
|
|
|
+ needtoAdd = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (needtoAdd)
|
|
|
+ outputCur += ShmPsuData->PsuGroup[index].GroupPresentOutputCurrent;
|
|
|
}
|
|
|
|
|
|
// 黑白機
|
|
@@ -566,7 +608,7 @@ void GetIavailableCallback(byte address, unsigned short Iavail, unsigned short V
|
|
|
{
|
|
|
chargingInfo[group]->SampleChargingCur[count] = totalCur;
|
|
|
isPass = false;
|
|
|
- continue;
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -764,6 +806,8 @@ void CheckSmartChargingStep(bool isWaitingAver, bool isCharging)
|
|
|
if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_AVER)
|
|
|
{
|
|
|
PRINTF_FUNC("=============Smart Charging : _REASSIGNED_ADJUST_A_TO_M============= Step 12 \n");
|
|
|
+ preChargingCur = preChargingTarget = 0;
|
|
|
+ gettimeofday(&_max_time, NULL);
|
|
|
ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_ADJUST_A_TO_M;
|
|
|
}
|
|
|
else
|
|
@@ -965,9 +1009,6 @@ int main(void)
|
|
|
// Pooling Status
|
|
|
GetStatus(index);
|
|
|
|
|
|
- // 取系統總輸出能力
|
|
|
- GetModuleCap(index);
|
|
|
-
|
|
|
// 取得模塊輸入電壓
|
|
|
GetModuleInput(index);
|
|
|
|
|
@@ -1018,6 +1059,9 @@ int main(void)
|
|
|
|
|
|
for (byte groupIndex = 0; groupIndex < _gunCount; groupIndex++)
|
|
|
{
|
|
|
+ // 取系統總輸出能力
|
|
|
+ GetModuleCap(groupIndex);
|
|
|
+ // 取得模塊的當前輸出
|
|
|
GetModuleOutput(groupIndex);
|
|
|
// 針對各槍當前狀態,傳送需要回傳的資料指令
|
|
|
if (((chargingInfo[groupIndex]->SystemStatus >= S_PREPARING_FOR_EVSE && chargingInfo[groupIndex]->SystemStatus <= S_CHARGING) && chargingInfo[groupIndex]->RelayK1K2Status) ||
|
|
@@ -1063,15 +1107,36 @@ int main(void)
|
|
|
// chargingInfo[groupIndex]->SystemStatus, chargingInfo[groupIndex]->EvBatterytargetCurrent,
|
|
|
// (chargingInfo[groupIndex]->PresentChargingCurrent * 10));
|
|
|
// 智能判斷 Start -----------------------------------------------------------
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_GET_NEW_CAP &&
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ReAssignedFlag <= _REASSIGNED_RELAY_M_TO_A)
|
|
|
+ {
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag == _REASSIGNED_GET_NEW_CAP)
|
|
|
+ {
|
|
|
+ //PRINTF_FUNC("group = %d, GroupPresentOutputCurrent = %d \n",
|
|
|
+ // groupIndex, ShmPsuData->PsuGroup[groupIndex].GroupPresentOutputCurrent);
|
|
|
+
|
|
|
+ if (chargingInfo[groupIndex]->DividChargingCurrent == 0)
|
|
|
+ {
|
|
|
+ chargingInfo[groupIndex]->DividChargingCurrent = ShmPsuData->PsuGroup[groupIndex].GroupPresentOutputCurrent;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PRINTF_FUNC("Index = %d, DividChargingCurrent = %f \n", groupIndex, chargingInfo[groupIndex]->DividChargingCurrent);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ chargingInfo[groupIndex]->DividChargingCurrent = 0;
|
|
|
+ }
|
|
|
+
|
|
|
if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag == _REASSIGNED_GET_NEW_CAP)
|
|
|
{
|
|
|
if (ShmPsuData->SystemAvailableCurrent != chargingInfo[groupIndex]->AvailableChargingCurrent)
|
|
|
{
|
|
|
// 車端要求電流為該充電槍的額定輸出電流的範圍內
|
|
|
- if (chargingInfo[groupIndex]->EvBatterytargetCurrent <= chargingInfo[groupIndex]->AvailableChargingCurrent ||
|
|
|
- deratingKeepCount >= DERATING)
|
|
|
+ if (chargingInfo[groupIndex]->EvBatterytargetCurrent <= ShmPsuData->PsuGroup[groupIndex].GroupPresentOutputCurrent + DERATING_GAP ||
|
|
|
+ deratingKeepCount >= DERATING_COUNT)
|
|
|
{
|
|
|
// 車端降載完成
|
|
|
+ PRINTF_FUNC("Index = %d, newEvCurrent = %f \n", groupIndex, chargingInfo[groupIndex]->EvBatterytargetCurrent);
|
|
|
PRINTF_FUNC("=============Smart Charging : _REASSIGNED_ADJUST_M_TO_A============= Step 3 \n");
|
|
|
ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_ADJUST_M_TO_A;
|
|
|
gettimeofday(&_derating_time, NULL);
|
|
@@ -1080,6 +1145,11 @@ int main(void)
|
|
|
else
|
|
|
{
|
|
|
deratingKeepCount++;
|
|
|
+ PRINTF_FUNC("** Step 2 ** : Index = %d, EvBatterytargetCurrent = %f, TargetCurrent = %d, Count = %d \n",
|
|
|
+ groupIndex,
|
|
|
+ chargingInfo[groupIndex]->EvBatterytargetCurrent,
|
|
|
+ (ShmPsuData->PsuGroup[groupIndex].GroupPresentOutputCurrent + DERATING_GAP),
|
|
|
+ deratingKeepCount);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1088,39 +1158,41 @@ int main(void)
|
|
|
{
|
|
|
bool isChanged = false;
|
|
|
|
|
|
- // 需求電流不降低的情況下 -> 依然要切
|
|
|
- if (chargingInfo[groupIndex]->AvailableChargingCurrent < chargingInfo[groupIndex]->EvBatterytargetCurrent)
|
|
|
+ if (chargingInfo[groupIndex]->AvailableChargingCurrent <= chargingInfo[groupIndex]->EvBatterytargetCurrent)
|
|
|
{
|
|
|
- PRINTF_FUNC("** _REASSIGNED_ADJUST_M_TO_A ** Gun_%d, AvailableChargingCurrent = %f, EvBatterytargetCurrent = %f \n", groupIndex,
|
|
|
+ PRINTF_FUNC("** _REASSIGNED_ADJUST_M_TO_A ** Gun_%d, PresentChargingCurrent = %f, AvailableChargingCurrent = %f, EvBatterytargetCurrent = %f \n", groupIndex,
|
|
|
(chargingInfo[groupIndex]->PresentChargingCurrent * 10),
|
|
|
- chargingInfo[groupIndex]->AvailableChargingCurrent);
|
|
|
+ chargingInfo[groupIndex]->AvailableChargingCurrent,
|
|
|
+ chargingInfo[groupIndex]->EvBatterytargetCurrent);
|
|
|
+
|
|
|
for (byte subIndex = 0; subIndex < ShmPsuData->GroupCount; subIndex++)
|
|
|
{
|
|
|
if (chargingInfo[subIndex]->SystemStatus == S_REASSIGN)
|
|
|
{
|
|
|
- if ((chargingInfo[subIndex]->PresentChargingCurrent * 10) <= CHK_CUR_RANGE)
|
|
|
+ // 當 B 模塊輸出電流小於 5A 及退開 relay
|
|
|
+ if ((ShmPsuData->PsuGroup[subIndex].GroupPresentOutputCurrent) <= 50)
|
|
|
isChanged = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- // 這狀況下輸出端的電流載滿載衝的狀況下,並不會降電流
|
|
|
- // 所以只能拉載到該槍端的最大輸出能力
|
|
|
- if ((chargingInfo[groupIndex]->PresentChargingCurrent * 10) >= chargingInfo[groupIndex]->AvailableChargingCurrent - CHK_CUR_RANGE ||
|
|
|
- (chargingInfo[groupIndex]->PresentChargingCurrent * 10) <= CHK_CUR_RANGE)
|
|
|
- {
|
|
|
- isChanged = true;
|
|
|
- }
|
|
|
}
|
|
|
else if (((chargingInfo[groupIndex]->PresentChargingCurrent * 10) >= ShmPsuData->PsuGroup[groupIndex].GroupPresentOutputCurrent - CHK_CUR_RANGE) &&
|
|
|
((chargingInfo[groupIndex]->PresentChargingCurrent * 10) <= ShmPsuData->PsuGroup[groupIndex].GroupPresentOutputCurrent + CHK_CUR_RANGE))
|
|
|
{
|
|
|
- isChanged = true;
|
|
|
+ for (byte subIndex = 0; subIndex < ShmPsuData->GroupCount; subIndex++)
|
|
|
+ {
|
|
|
+ if (chargingInfo[subIndex]->SystemStatus == S_REASSIGN)
|
|
|
+ {
|
|
|
+ if ((ShmPsuData->PsuGroup[subIndex].GroupPresentOutputCurrent) <= CHK_CUR_RANGE)
|
|
|
+ isChanged = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (isChanged)
|
|
|
{
|
|
|
- PRINTF_FUNC("** _REASSIGNED_ADJUST_M_TO_A ** Gun_%d, PresentChargingCurrent = %f, GroupPresentOutputCurrent = %d \n", groupIndex,
|
|
|
+ PRINTF_FUNC("** _REASSIGNED_ADJUST_M_TO_A To 4** Gun_%d, PresentChargingCurrent = %f, GroupPresentOutputCurrent = %d \n", groupIndex,
|
|
|
(chargingInfo[groupIndex]->PresentChargingCurrent * 10),
|
|
|
ShmPsuData->PsuGroup[groupIndex].GroupPresentOutputCurrent);
|
|
|
|
|
@@ -1128,67 +1200,75 @@ int main(void)
|
|
|
PRINTF_FUNC("=============Smart Charging : _REASSIGNED_RELAY_M_TO_A============= Step 4 \n");
|
|
|
ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_RELAY_M_TO_A;
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if ((GetTimeoutValue(_derating_time) / 1000) > 1000)
|
|
|
+ {
|
|
|
+ gettimeofday(&_derating_time, NULL);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if (ShmPsuData->SystemAvailablePower > 0)
|
|
|
+ //if (ShmPsuData->SystemAvailablePower > 0)
|
|
|
{
|
|
|
// 調整輸出電流 : 漸進調整方式
|
|
|
- if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_ADJUST_M_TO_A)
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_GET_NEW_CAP &&
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ReAssignedFlag < _REASSIGNED_RELAY_M_TO_A)
|
|
|
{
|
|
|
- // 當前充電中的目標電壓
|
|
|
- float targetVol = chargingInfo[groupIndex]->EvBatterytargetVoltage;
|
|
|
- // 當前充電中的目標電流
|
|
|
- //float targetCur = 0;
|
|
|
- // 準備切出去的模塊電流
|
|
|
- float deratingCur = 0;
|
|
|
-
|
|
|
- byte reassignIndex = ELEMENT_NOT_FIND;
|
|
|
- // 找到等待分配的槍
|
|
|
- for (byte subIndex = 0; subIndex < ShmPsuData->GroupCount; subIndex++)
|
|
|
- {
|
|
|
- if (chargingInfo[subIndex]->SystemStatus == S_REASSIGN)
|
|
|
- {
|
|
|
- reassignIndex = subIndex;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (reassignIndex != ELEMENT_NOT_FIND)
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_ADJUST_M_TO_A)
|
|
|
{
|
|
|
- //int derating = GetTimeoutValue(_derating_time) / 1000;
|
|
|
+ // 當前充電中的目標電壓
|
|
|
+ float targetVol = chargingInfo[groupIndex]->EvBatterytargetVoltage;
|
|
|
+ byte reassignIndex = ELEMENT_NOT_FIND;
|
|
|
|
|
|
- //if (derating > 1000)
|
|
|
+ // 找到等待分配的槍
|
|
|
+ for (byte subIndex = 0; subIndex < ShmPsuData->GroupCount; subIndex++)
|
|
|
{
|
|
|
- if (ShmPsuData->PsuGroup[reassignIndex].GroupPresentOutputCurrent > 0)
|
|
|
+ if (chargingInfo[subIndex]->SystemStatus == S_REASSIGN)
|
|
|
{
|
|
|
- deratingCur = ShmPsuData->PsuGroup[reassignIndex].GroupPresentOutputCurrent - DERATING_RANGE;
|
|
|
- if (deratingCur <= CHK_CUR_RANGE)
|
|
|
- deratingCur = CHK_CUR_RANGE;
|
|
|
-
|
|
|
- PresentOutputVol(reassignIndex, targetVol, deratingCur);
|
|
|
- gettimeofday(&_derating_time, NULL);
|
|
|
+ reassignIndex = subIndex;
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // ***********直接降低要移除的模塊電流即可*************
|
|
|
- // 因為爬的速度沒有降的速度快,所以採兩倍速度爬升
|
|
|
-// targetCur = ShmPsuData->PsuGroup[groupIndex].GroupPresentOutputCurrent + (DERATING_RANGE * 2);
|
|
|
-// if (targetCur >= chargingInfo[groupIndex]->EvBatterytargetCurrent)
|
|
|
-// targetCur = chargingInfo[groupIndex]->EvBatterytargetCurrent;
|
|
|
-
|
|
|
- if (targetVol == 0)
|
|
|
- {
|
|
|
- SwitchPower(SYSTEM_CMD, PSU_POWER_OFF);
|
|
|
- FlashLed(SYSTEM_CMD, PSU_FLASH_NORMAL);
|
|
|
- }
|
|
|
- else
|
|
|
+ if (reassignIndex != ELEMENT_NOT_FIND)
|
|
|
{
|
|
|
- SwitchPower(SYSTEM_CMD, PSU_POWER_ON);
|
|
|
- FlashLed(SYSTEM_CMD, PSU_FLASH_ON);
|
|
|
+ if ((GetTimeoutValue(_derating_time) / 1000) <= 50)
|
|
|
+ {
|
|
|
+ // A 模塊維持當前電壓電流
|
|
|
+ //PRINTF_FUNC("A : index = %d, cur = %d \n", groupIndex, ShmPsuData->PsuGroup[groupIndex].GroupPresentOutputCurrent);
|
|
|
+ //PresentOutputVol(groupIndex, targetVol, ShmPsuData->PsuGroup[groupIndex].GroupPresentOutputCurrent);
|
|
|
+ //PRINTF_FUNC("set out (%d) value = %f******** 1 \n", groupIndex, chargingInfo[groupIndex]->EvBatterytargetCurrent);
|
|
|
+ PresentOutputVol(groupIndex, targetVol, chargingInfo[groupIndex]->EvBatterytargetCurrent);
|
|
|
+// }
|
|
|
+//
|
|
|
+// if ((GetTimeoutValue(_derating_time) / 1000) <= 50)
|
|
|
+// {
|
|
|
+ // 直接拉掉 B 模塊的電流
|
|
|
+ //PRINTF_FUNC("B : index = %d, cur = %d \n", reassignIndex, CHK_CUR_RANGE);
|
|
|
+ //PRINTF_FUNC("set out (%d) value = %d******** 2 \n", reassignIndex, CHK_CUR_RANGE);
|
|
|
+ PresentOutputVol(reassignIndex, targetVol, CHK_CUR_RANGE);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (chargingInfo[groupIndex]->EvBatterytargetVoltage == 0)
|
|
|
+ {
|
|
|
+ //PRINTF_FUNC("sys ******** 1 \n");
|
|
|
+ SwitchPower(SYSTEM_CMD, PSU_POWER_OFF);
|
|
|
+ FlashLed(SYSTEM_CMD, PSU_FLASH_NORMAL);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_RELAY_M_TO_A)
|
|
|
+ {
|
|
|
+ //PRINTF_FUNC("set out (%d) value = %f******** 3 \n", groupIndex, chargingInfo[groupIndex]->EvBatterytargetCurrent);
|
|
|
+ PresentOutputVol(groupIndex,
|
|
|
+ chargingInfo[groupIndex]->EvBatterytargetVoltage,
|
|
|
+ chargingInfo[groupIndex]->EvBatterytargetCurrent);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ //PRINTF_FUNC("set out (sys) value = %f******** 4 \n", chargingInfo[groupIndex]->EvBatterytargetCurrent);
|
|
|
// 該充電槍的目標電壓與目標電流
|
|
|
PresentOutputVol(SYSTEM_CMD,
|
|
|
chargingInfo[groupIndex]->EvBatterytargetVoltage,
|
|
@@ -1196,6 +1276,7 @@ int main(void)
|
|
|
|
|
|
if (chargingInfo[groupIndex]->EvBatterytargetVoltage == 0)
|
|
|
{
|
|
|
+ //PRINTF_FUNC("sys ******** 2 \n");
|
|
|
SwitchPower(SYSTEM_CMD, PSU_POWER_OFF);
|
|
|
FlashLed(SYSTEM_CMD, PSU_FLASH_NORMAL);
|
|
|
}
|
|
@@ -1238,63 +1319,135 @@ int main(void)
|
|
|
// 閒置端與車端要求電壓接近
|
|
|
PRINTF_FUNC("=============Smart Charging : _REASSIGNED_RELAY_A_TO_M============= Step 13 \n");
|
|
|
ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_RELAY_A_TO_M;
|
|
|
- gettimeofday(&_averageComp_time, NULL);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if ((GetTimeoutValue(_max_time) / 1000) > 500)
|
|
|
+ {
|
|
|
+ gettimeofday(&_max_time, NULL);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else if(ShmSysConfigAndInfo->SysInfo.ReAssignedFlag == _REASSIGNED_WAITING)
|
|
|
{
|
|
|
- int avrTime = GetTimeoutValue(_averageComp_time) / 1000;
|
|
|
+ int idleCurrent = 0;
|
|
|
+ int chargingCurrent = 0;
|
|
|
|
|
|
- if (avrTime > 10000)
|
|
|
+ for (byte subIndex = 0; subIndex < ShmPsuData->GroupCount; subIndex++)
|
|
|
+ {
|
|
|
+ if (chargingInfo[subIndex]->SystemStatus == S_IDLE ||
|
|
|
+ chargingInfo[subIndex]->SystemStatus == S_RESERVATION ||
|
|
|
+ chargingInfo[subIndex]->SystemStatus == S_REASSIGN_CHECK)
|
|
|
+ idleCurrent = ShmPsuData->PsuGroup[subIndex].GroupPresentOutputCurrent;
|
|
|
+ else
|
|
|
+ chargingCurrent = ShmPsuData->PsuGroup[subIndex].GroupPresentOutputCurrent;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (idleCurrent >= chargingCurrent - PRE_CHARG_RANGE)
|
|
|
{
|
|
|
- // 閒置端與車端要求電壓接近
|
|
|
PRINTF_FUNC("=============Smart Charging_0 : _REASSIGNED_COMP============= Step 15 \n");
|
|
|
ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_COMP;
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if ((GetTimeoutValue(_max_time) / 1000) > 500)
|
|
|
+ {
|
|
|
+ gettimeofday(&_max_time, NULL);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (chargingInfo[groupIndex]->AvailableChargingCurrent > 0)
|
|
|
{
|
|
|
- if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag == _REASSIGNED_ADJUST_A_TO_M)
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_ADJUST_A_TO_M)
|
|
|
{
|
|
|
+ byte reassignIndex = ELEMENT_NOT_FIND;
|
|
|
+
|
|
|
for (byte subIndex = 0; subIndex < ShmPsuData->GroupCount; subIndex++)
|
|
|
{
|
|
|
if (chargingInfo[subIndex]->SystemStatus == S_IDLE ||
|
|
|
- chargingInfo[subIndex]->SystemStatus == S_RESERVATION)
|
|
|
+ chargingInfo[subIndex]->SystemStatus == S_RESERVATION ||
|
|
|
+ chargingInfo[subIndex]->SystemStatus == S_REASSIGN_CHECK)
|
|
|
{
|
|
|
- // 閒置模塊升壓
|
|
|
- PresentOutputVol(subIndex,
|
|
|
- chargingInfo[groupIndex]->EvBatterytargetVoltage,
|
|
|
- ZERO_CURRENT);
|
|
|
+ reassignIndex = subIndex;
|
|
|
+// if ((GetTimeoutValue(_max_time) / 1000) <= 50)
|
|
|
+// {
|
|
|
+// // 閒置模塊升壓,另對剛分配近來的模塊,預上升電流值 (preChargingCur)
|
|
|
+// PresentOutputVol(subIndex,
|
|
|
+// chargingInfo[groupIndex]->EvBatterytargetVoltage,
|
|
|
+// ZERO_CURRENT + preChargingTarget);
|
|
|
+// }
|
|
|
+ //PRINTF_FUNC("preChargingCur = %d \n", preChargingCur);
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_WAITING)
|
|
|
+ {
|
|
|
+ preChargingCur = ShmPsuData->PsuGroup[subIndex].GroupPresentOutputCurrent;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ preChargingCur = 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ //PRINTF_FUNC("CurOutputCurrent = %d \n", ShmPsuData->PsuGroup[subIndex].GroupPresentOutputCurrent - preChargingCur);
|
|
|
// 充電中的模塊維持輸出
|
|
|
- PresentOutputVol(subIndex,
|
|
|
- chargingInfo[subIndex]->EvBatterytargetVoltage,
|
|
|
- chargingInfo[subIndex]->EvBatterytargetCurrent);
|
|
|
+// if ((GetTimeoutValue(_max_time) / 1000) <= 50)
|
|
|
+// {
|
|
|
+// PresentOutputVol(subIndex,
|
|
|
+// chargingInfo[subIndex]->EvBatterytargetVoltage,
|
|
|
+// chargingInfo[subIndex]->EvBatterytargetCurrent - preChargingCur);
|
|
|
+// }
|
|
|
+
|
|
|
+ if ((ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_WAITING) &&
|
|
|
+ (preChargingCur >= preChargingTarget - ZERO_CURRENT))
|
|
|
+ preChargingTarget += PRE_CHARG_STEP_CUR;
|
|
|
+
|
|
|
+ if (preChargingTarget >= chargingInfo[subIndex]->EvBatterytargetCurrent / 2)
|
|
|
+ preChargingTarget = chargingInfo[subIndex]->EvBatterytargetCurrent / 2;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if (chargingInfo[groupIndex]->EvBatterytargetVoltage == 0)
|
|
|
- {
|
|
|
- SwitchPower(subIndex, PSU_POWER_OFF);
|
|
|
- FlashLed(subIndex, PSU_FLASH_NORMAL);
|
|
|
- }
|
|
|
- else
|
|
|
+ if (reassignIndex != ELEMENT_NOT_FIND)
|
|
|
+ {
|
|
|
+ if ((GetTimeoutValue(_max_time) / 1000) <= 50)
|
|
|
{
|
|
|
- SwitchPower(subIndex, PSU_POWER_ON);
|
|
|
- FlashLed(subIndex, PSU_FLASH_ON);
|
|
|
+ //PRINTF_FUNC("set out (%d) value = %d******** 5 \n", reassignIndex, ZERO_CURRENT + preChargingTarget);
|
|
|
+ // 閒置模塊升壓,另對剛分配近來的模塊,預上升電流值 (preChargingCur)
|
|
|
+ PresentOutputVol(reassignIndex,
|
|
|
+ chargingInfo[groupIndex]->EvBatterytargetVoltage,
|
|
|
+ ZERO_CURRENT + preChargingTarget);
|
|
|
+
|
|
|
+ byte _ovCahrgingCur = 0;
|
|
|
+ if (preChargingCur > PRE_CHARG_STEP_CUR)
|
|
|
+ _ovCahrgingCur = PRE_CHARG_STEP_CUR;
|
|
|
+
|
|
|
+ //PRINTF_FUNC("set out (%d) value = %f******** 6 \n", groupIndex, chargingInfo[groupIndex]->EvBatterytargetCurrent - preChargingCur - _ovCahrgingCur);
|
|
|
+ PresentOutputVol(groupIndex,
|
|
|
+ chargingInfo[groupIndex]->EvBatterytargetVoltage,
|
|
|
+ chargingInfo[groupIndex]->EvBatterytargetCurrent - preChargingCur - _ovCahrgingCur);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (chargingInfo[groupIndex]->EvBatterytargetVoltage == 0)
|
|
|
+ {
|
|
|
+ //PRINTF_FUNC("sys ******** 3 \n");
|
|
|
+ SwitchPower(SYSTEM_CMD, PSU_POWER_OFF);
|
|
|
+ FlashLed(SYSTEM_CMD, PSU_FLASH_NORMAL);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SwitchPower(SYSTEM_CMD, PSU_POWER_ON);
|
|
|
+ FlashLed(SYSTEM_CMD, PSU_FLASH_ON);
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ //PRINTF_FUNC("set out (%d) value = %f******** 7 \n", groupIndex, chargingInfo[groupIndex]->EvBatterytargetCurrent);
|
|
|
PresentOutputVol(groupIndex,
|
|
|
chargingInfo[groupIndex]->EvBatterytargetVoltage,
|
|
|
chargingInfo[groupIndex]->EvBatterytargetCurrent);
|
|
|
|
|
|
if (chargingInfo[groupIndex]->EvBatterytargetVoltage == 0)
|
|
|
{
|
|
|
+ //PRINTF_FUNC("%d ******** 4 \n", groupIndex);
|
|
|
SwitchPower(groupIndex, PSU_POWER_OFF);
|
|
|
FlashLed(groupIndex, PSU_FLASH_NORMAL);
|
|
|
}
|
|
@@ -1314,6 +1467,7 @@ int main(void)
|
|
|
{
|
|
|
if (!isCharging)
|
|
|
{
|
|
|
+ //PRINTF_FUNC("sys ******** 5 \n");
|
|
|
SwitchPower(SYSTEM_CMD, PSU_POWER_OFF);
|
|
|
FlashLed(SYSTEM_CMD, PSU_FLASH_NORMAL);
|
|
|
|
|
@@ -1350,9 +1504,20 @@ int main(void)
|
|
|
SwitchPower(groupIndex, PSU_POWER_OFF);
|
|
|
FlashLed(groupIndex, PSU_FLASH_NORMAL);
|
|
|
}
|
|
|
- ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_NONE;
|
|
|
+
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_WAITING)
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_COMP;
|
|
|
+ else
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_NONE;
|
|
|
}
|
|
|
}
|
|
|
+ else if ((chargingInfo[groupIndex]->SystemStatus >= S_PREPARNING && chargingInfo[groupIndex]->SystemStatus <= S_PREPARING_FOR_EV) &&
|
|
|
+ ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_AVER)
|
|
|
+ {
|
|
|
+ //PRINTF_FUNC("%d ******** 7 \n", groupIndex);
|
|
|
+ SwitchPower(groupIndex, PSU_POWER_OFF);
|
|
|
+ FlashLed(groupIndex, PSU_FLASH_NORMAL);
|
|
|
+ }
|
|
|
}
|
|
|
break;
|
|
|
}
|