|
@@ -45,6 +45,8 @@
|
|
|
#define UNPLUG 0
|
|
|
#define UNDEFINED_TEMP 255
|
|
|
#define ALLOW_COUNT_MAX 30
|
|
|
+#define VOUT_MIN_VOLTAGE 150
|
|
|
+#define CURR_MIN_CURRENT 0
|
|
|
|
|
|
struct SysConfigAndInfo *ShmSysConfigAndInfo;
|
|
|
struct StatusCodeData *ShmStatusCodeData;
|
|
@@ -59,6 +61,7 @@ struct DcCommonInformation *ShmDcCommonData;
|
|
|
byte gun_count;
|
|
|
int chargingTime[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
|
|
|
byte rtcChkCount = 0;
|
|
|
+bool printLogRecord;
|
|
|
|
|
|
float LogInfo[2][10];
|
|
|
bool _useOfflineNoCharging = false;
|
|
@@ -91,6 +94,7 @@ struct timespec _chk_chademo_permission_timeout[CHAdeMO_QUANTITY + CCS_QUANTITY
|
|
|
bool chkChademoPermission[2] = { false, false };
|
|
|
bool chkChademoPermissionSend[2] = { false, false };
|
|
|
byte SendErrorCount[2] = { 0, 0};
|
|
|
+struct timespec delayToPrintLogTimeout;
|
|
|
|
|
|
unsigned char mask_table[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
|
|
|
|
|
@@ -2875,6 +2879,13 @@ void CANReceiver()
|
|
|
PRINTF_FUNC("Conn %d, Plug None Check. (%d) \n", targetGun, frame.data[0]);
|
|
|
}
|
|
|
|
|
|
+ // for using ccid to authoriz.
|
|
|
+ if (ShmDcCommonData->_authWithCcidFlag[targetGun] == _CCID_AUTHFAIL &&
|
|
|
+ _chargingData[targetGun]->ConnectorPlugIn == UNPLUG)
|
|
|
+ {
|
|
|
+ ShmDcCommonData->_authWithCcidFlag[targetGun] = _CCID_NONE;
|
|
|
+ }
|
|
|
+
|
|
|
_chargingData[targetGun]->ConnectorPlugIn = frame.data[0];
|
|
|
_chargingData[targetGun]->PilotVoltage = frame.data[1];
|
|
|
|
|
@@ -3157,7 +3168,8 @@ void SetPresentChargingOutputPower(struct ChargingInfoData *chargingData_1, stru
|
|
|
// if (ShmGBTData->ev[chargingData_1->type_index].PresentMsgFlowStatus == 10)
|
|
|
// vol1 = ShmPsuData->PsuGroup[0].GroupTargetOutputVoltage;
|
|
|
// else
|
|
|
- vol1 = chargingData_1->FireChargingVoltage;
|
|
|
+
|
|
|
+ vol1 = chargingData_1->FireChargingVoltage;
|
|
|
|
|
|
cur1 = (chargingData_1->PresentChargingCurrent * 10);
|
|
|
|
|
@@ -3183,24 +3195,33 @@ void SetPresentChargingOutputPower(struct ChargingInfoData *chargingData_1, stru
|
|
|
// if (ShmGBTData->ev[chargingData_2->type_index].PresentMsgFlowStatus == 10)
|
|
|
// vol2 = ShmPsuData->PsuGroup[1].GroupTargetOutputVoltage;
|
|
|
// else
|
|
|
- vol2 = chargingData_2->FireChargingVoltage;
|
|
|
+
|
|
|
+ vol2 = chargingData_2->FireChargingVoltage;
|
|
|
|
|
|
cur2 = (chargingData_2->PresentChargingCurrent * 10);
|
|
|
|
|
|
- if (
|
|
|
- (LogInfo[0][EV_LOG_NOW_OUTPUT_VOL] >= vol1 + CHK_VOL_RANGE) || (LogInfo[0][EV_LOG_NOW_OUTPUT_VOL] <= vol1 - CHK_VOL_RANGE) ||
|
|
|
- (LogInfo[0][EV_LOG_NOW_OUTPUT_CUR] >= cur1 + CHK_CUR_RANGE) || (LogInfo[0][EV_LOG_NOW_OUTPUT_CUR] <= cur1 - CHK_CUR_RANGE) ||
|
|
|
- (LogInfo[1][EV_LOG_NOW_OUTPUT_VOL] >= vol2 + CHK_VOL_RANGE) || (LogInfo[1][EV_LOG_NOW_OUTPUT_VOL] <= vol2 - CHK_VOL_RANGE) ||
|
|
|
- (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] >= cur2 + CHK_CUR_RANGE) || (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] <= cur2 - CHK_CUR_RANGE)
|
|
|
- )
|
|
|
+ if ((chargingData_1->SystemStatus >= SYS_MODE_PREPARING && chargingData_1->SystemStatus <= SYS_MODE_CHARGING) ||
|
|
|
+ (chargingData_1->SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0 && chargingData_1->SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1))
|
|
|
{
|
|
|
- PRINTF_FUNC("G1 -> Output Vol = %.1f, Output Cur = %.1f -- G2 -> Output Vol = %.1f, Output Cur = %.1f \n",
|
|
|
- vol1 / 10, cur1 / 10, vol2 / 10, cur2 / 10);
|
|
|
+ if ((LogInfo[0][EV_LOG_NOW_OUTPUT_VOL] >= vol1 + CHK_VOL_RANGE) || (LogInfo[0][EV_LOG_NOW_OUTPUT_VOL] <= vol1 - CHK_VOL_RANGE) ||
|
|
|
+ (LogInfo[0][EV_LOG_NOW_OUTPUT_CUR] >= cur1 + CHK_CUR_RANGE) || (LogInfo[0][EV_LOG_NOW_OUTPUT_CUR] <= cur1 - CHK_CUR_RANGE))
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("G_0 -> Output Vol = %.1f, Output Cur = %.1f \n", vol1 / 10, cur1 / 10);
|
|
|
+ LogInfo [0] [EV_LOG_NOW_OUTPUT_VOL] = vol1;
|
|
|
+ LogInfo [0] [EV_LOG_NOW_OUTPUT_CUR] = cur1;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- LogInfo[0][EV_LOG_NOW_OUTPUT_VOL] = vol1;
|
|
|
- LogInfo[0][EV_LOG_NOW_OUTPUT_CUR] = cur1;
|
|
|
- LogInfo[1][EV_LOG_NOW_OUTPUT_VOL] = vol2;
|
|
|
- LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] = cur2;
|
|
|
+ if ((chargingData_2->SystemStatus >= SYS_MODE_PREPARING && chargingData_2->SystemStatus <= SYS_MODE_CHARGING) ||
|
|
|
+ (chargingData_2->SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0 && chargingData_2->SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1))
|
|
|
+ {
|
|
|
+ if ((LogInfo[1][EV_LOG_NOW_OUTPUT_VOL] >= vol2 + CHK_VOL_RANGE) || (LogInfo[1][EV_LOG_NOW_OUTPUT_VOL] <= vol2 - CHK_VOL_RANGE) ||
|
|
|
+ (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] >= cur2 + CHK_CUR_RANGE) || (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] <= cur2 - CHK_CUR_RANGE))
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("G_1 -> Output Vol = %.1f, Output Cur = %.1f \n", vol2 / 10, cur2 / 10);
|
|
|
+ LogInfo[1][EV_LOG_NOW_OUTPUT_VOL] = vol2;
|
|
|
+ LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] = cur2;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
targetCur = chargingData_2->EvBatterytargetCurrent * 10;
|
|
@@ -3249,51 +3270,67 @@ void SetPresentChargingOutputCap(struct ChargingInfoData *chargingData_1, struct
|
|
|
|
|
|
pow1 = chargingData_1->AvailableChargingPower;
|
|
|
cur1 = chargingData_1->AvailableChargingCurrent;
|
|
|
-
|
|
|
vol = chargingData_1->MaximumChargingVoltage;
|
|
|
- GetMaxVolAndCurMethod(chargingData_1->Index, &vol, &cur1);
|
|
|
- GetMaxPowerMethod(chargingData_1->Index, &pow1);
|
|
|
- if (pow1 <= 0)
|
|
|
- cur1 = 0;
|
|
|
- else
|
|
|
+
|
|
|
+ if ((chargingData_1->SystemStatus >= SYS_MODE_PREPARING && chargingData_1->SystemStatus <= SYS_MODE_CHARGING) ||
|
|
|
+ (chargingData_1->SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0 && chargingData_1->SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1))
|
|
|
{
|
|
|
- if (chargingData_1->SystemStatus == SYS_MODE_CHARGING &&
|
|
|
- chargingData_1->FireChargingVoltage > 1500)
|
|
|
+ GetMaxVolAndCurMethod(chargingData_1->Index, &vol, &cur1);
|
|
|
+ GetMaxPowerMethod(chargingData_1->Index, &pow1);
|
|
|
+ if (pow1 <= 0)
|
|
|
+ cur1 = 0;
|
|
|
+ else
|
|
|
{
|
|
|
- float maxCur = 0;
|
|
|
- maxCur = (pow1 * 1000) / chargingData_1->FireChargingVoltage;
|
|
|
-
|
|
|
- if (maxCur * 10 <= cur1)
|
|
|
+ if (chargingData_1->SystemStatus == SYS_MODE_CHARGING &&
|
|
|
+ chargingData_1->FireChargingVoltage > 1500)
|
|
|
{
|
|
|
- //PRINTF_FUNC("Gun1 -> MaxCharging Current = %f, Cap Current = %f \n", (maxCur * 10), cur1);
|
|
|
- cur1 = maxCur * 10;
|
|
|
+ float maxCur = 0;
|
|
|
+ maxCur = (pow1 * 1000) / chargingData_1->FireChargingVoltage;
|
|
|
+
|
|
|
+ if (maxCur * 10 <= cur1)
|
|
|
+ {
|
|
|
+ //PRINTF_FUNC("Gun1 -> MaxCharging Current = %f, Cap Current = %f \n", (maxCur * 10), cur1);
|
|
|
+ cur1 = maxCur * 10;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ cur1 = chargingData_1->ConnectorMaxCurrent;
|
|
|
+ }
|
|
|
|
|
|
pow2 = chargingData_2->AvailableChargingPower;
|
|
|
cur2 = chargingData_2->AvailableChargingCurrent;
|
|
|
vol = chargingData_2->MaximumChargingVoltage;
|
|
|
|
|
|
- GetMaxVolAndCurMethod(chargingData_2->Index, &vol, &cur2);
|
|
|
- GetMaxPowerMethod(chargingData_2->Index, &pow2);
|
|
|
- if (pow2 <= 0)
|
|
|
- cur2 = 0;
|
|
|
- else
|
|
|
+ if ((chargingData_2->SystemStatus >= SYS_MODE_PREPARING && chargingData_2->SystemStatus <= SYS_MODE_CHARGING) ||
|
|
|
+ (chargingData_2->SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0 && chargingData_2->SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1))
|
|
|
{
|
|
|
- if (chargingData_2->SystemStatus == SYS_MODE_CHARGING &&
|
|
|
- chargingData_2->FireChargingVoltage > 1500)
|
|
|
+ GetMaxVolAndCurMethod(chargingData_2->Index, &vol, &cur2);
|
|
|
+ GetMaxPowerMethod(chargingData_2->Index, &pow2);
|
|
|
+ if (pow2 <= 0)
|
|
|
+ cur2 = 0;
|
|
|
+ else
|
|
|
{
|
|
|
- float maxCur = 0;
|
|
|
- maxCur = (pow2 * 1000) / chargingData_2->FireChargingVoltage;
|
|
|
-
|
|
|
- if (maxCur * 10 <= cur2)
|
|
|
+ if (chargingData_2->SystemStatus == SYS_MODE_CHARGING &&
|
|
|
+ chargingData_2->FireChargingVoltage > 1500)
|
|
|
{
|
|
|
- //PRINTF_FUNC("Gun2 -> MaxCharging Current = %f, Cap Current = %f \n", (maxCur * 10), cur2);
|
|
|
- cur2 = maxCur * 10;
|
|
|
+ float maxCur = 0;
|
|
|
+ maxCur = (pow2 * 1000) / chargingData_2->FireChargingVoltage;
|
|
|
+
|
|
|
+ if (maxCur * 10 <= cur2)
|
|
|
+ {
|
|
|
+ //PRINTF_FUNC("Gun2 -> MaxCharging Current = %f, Cap Current = %f \n", (maxCur * 10), cur2);
|
|
|
+ cur2 = maxCur * 10;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ cur2 = chargingData_2->ConnectorMaxCurrent;
|
|
|
+ }
|
|
|
|
|
|
if ((LogInfo[0][EV_LOG_OUTPUT_CAP_POW] <= pow1 - 5 || LogInfo[0][EV_LOG_OUTPUT_CAP_POW] >= pow1 + 5) ||
|
|
|
(LogInfo[0][EV_LOG_OUTPUT_CAP_CUR] <= cur1 - 5 || LogInfo[0][EV_LOG_OUTPUT_CAP_CUR] >= cur1 + 5) ||
|
|
@@ -3339,10 +3376,20 @@ void Initialization()
|
|
|
}
|
|
|
sleep(1);
|
|
|
}
|
|
|
+
|
|
|
+ GetTimespecFunc(&delayToPrintLogTimeout);
|
|
|
}
|
|
|
|
|
|
void GetMaxVolAndCurMethod(byte index, float *vol, float *cur)
|
|
|
{
|
|
|
+// unsigned short configCurrent = ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent * 10;
|
|
|
+//
|
|
|
+// if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_AVER)
|
|
|
+// configCurrent /= 2;
|
|
|
+//
|
|
|
+// if (configCurrent != 0 && configCurrent < *cur)
|
|
|
+// *cur = configCurrent;
|
|
|
+
|
|
|
if (_chargingData[index]->ConnectorMaxVoltage != 0 &&
|
|
|
_chargingData[index]->ConnectorMaxVoltage <= *vol)
|
|
|
*vol = _chargingData[index]->ConnectorMaxVoltage;
|
|
@@ -3365,12 +3412,16 @@ void GetMaxPowerMethod(byte index, float *pow)
|
|
|
if (maxChargingPow != 0 && maxChargingPow <= *pow)
|
|
|
*pow = maxChargingPow;
|
|
|
|
|
|
+ if (_chargingData[index]->RealRatingPower * 10 != 0 && _chargingData[index]->RealRatingPower * 10 <= *pow)
|
|
|
+ *pow = _chargingData[index]->RealRatingPower * 10;
|
|
|
+
|
|
|
+ // 100 = (/ 1000 * 10)
|
|
|
if (((_chargingData[index]->SystemStatus >= SYS_MODE_PREPARE_FOR_EVSE && _chargingData[index]->SystemStatus <= SYS_MODE_CHARGING) ||
|
|
|
(_chargingData[index]->SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0 && _chargingData[index]->SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1)) &&
|
|
|
- (_chargingData[index]->ChargingProfilePower / 1000) >= 0 &&
|
|
|
- (_chargingData[index]->ChargingProfilePower / 1000) <= *pow)
|
|
|
+ (_chargingData[index]->ChargingProfilePower / 100) >= 0 &&
|
|
|
+ (_chargingData[index]->ChargingProfilePower / 100) <= *pow)
|
|
|
{
|
|
|
- *pow = (float)(_chargingData[index]->ChargingProfilePower / 1000) * 10;
|
|
|
+ *pow = (float)(_chargingData[index]->ChargingProfilePower / 100);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -3411,6 +3462,17 @@ byte GetStopChargingReasonByEvse(byte gunIndex, byte *reason)
|
|
|
*(reason + 5) = '1';
|
|
|
result = YES;
|
|
|
}
|
|
|
+ else if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DoorOpen == 0x01)
|
|
|
+ {
|
|
|
+ // 012251
|
|
|
+ *(reason + 0) = '0';
|
|
|
+ *(reason + 1) = '1';
|
|
|
+ *(reason + 2) = '2';
|
|
|
+ *(reason + 3) = '2';
|
|
|
+ *(reason + 4) = '5';
|
|
|
+ *(reason + 5) = '2';
|
|
|
+ result = YES;
|
|
|
+ }
|
|
|
|
|
|
if (_chargingData[gunIndex]->Type == _Type_Chademo)
|
|
|
{
|
|
@@ -3447,6 +3509,20 @@ byte GetStopChargingReasonByEvse(byte gunIndex, byte *reason)
|
|
|
*(reason + 5) = '4';
|
|
|
result = YES;
|
|
|
}
|
|
|
+ else if (ShmSysConfigAndInfo->SysConfig.PhaseLossPolicy == YES &&
|
|
|
+ (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == YES ||
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == YES ||
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == YES))
|
|
|
+ {
|
|
|
+ // 012203-012204-012205
|
|
|
+ * (reason + 0) = '0';
|
|
|
+ * (reason + 1) = '1';
|
|
|
+ * (reason + 2) = '2';
|
|
|
+ * (reason + 3) = '2';
|
|
|
+ * (reason + 4) = '0';
|
|
|
+ * (reason + 5) = '3';
|
|
|
+ result = YES;
|
|
|
+ }
|
|
|
}
|
|
|
else if (_chargingData[gunIndex]->Type == _Type_GB)
|
|
|
{
|
|
@@ -3622,7 +3698,10 @@ void FormatVoltageAndCurrent()
|
|
|
{
|
|
|
if (_chargingData[_index]->Type == _Type_Chademo)
|
|
|
{
|
|
|
- _chargingData[_index]->ConnectorMaxCurrent = 600;
|
|
|
+ if (_chargingData[_index]->ModelType == 'L')
|
|
|
+ _chargingData[_index]->ConnectorMaxCurrent = 800;
|
|
|
+ else
|
|
|
+ _chargingData[_index]->ConnectorMaxCurrent = 600;
|
|
|
}
|
|
|
else if (_chargingData[_index]->Type == _Type_CCS)
|
|
|
{
|
|
@@ -3645,7 +3724,11 @@ void FormatVoltageAndCurrent()
|
|
|
}
|
|
|
else if (_chargingData[_index]->Type == _Type_CCS)
|
|
|
{
|
|
|
- _chargingData[_index]->ConnectorMaxCurrent = 1200;
|
|
|
+ if (_chargingData [_index]->ModelType == 'Y' ||
|
|
|
+ _chargingData [_index]->ModelType == 'Z')
|
|
|
+ _chargingData [_index]->ConnectorMaxCurrent = 1500;
|
|
|
+ else
|
|
|
+ _chargingData [_index]->ConnectorMaxCurrent = 1200;
|
|
|
}
|
|
|
else if (_chargingData[_index]->Type == _Type_GB)
|
|
|
{
|
|
@@ -3656,11 +3739,23 @@ void FormatVoltageAndCurrent()
|
|
|
{
|
|
|
if (_chargingData[_index]->Type == _Type_Chademo)
|
|
|
{
|
|
|
- _chargingData[_index]->ConnectorMaxCurrent = 1200;
|
|
|
+ if (_chargingData[_index]->ModelType == 'K')
|
|
|
+ _chargingData[_index]->ConnectorMaxCurrent = 2000;
|
|
|
+ else
|
|
|
+ _chargingData[_index]->ConnectorMaxCurrent = 1200;
|
|
|
}
|
|
|
else if (_chargingData[_index]->Type == _Type_CCS)
|
|
|
{
|
|
|
- _chargingData[_index]->ConnectorMaxCurrent = 2000;
|
|
|
+ if (_chargingData [_index]->ModelType == 'V' ||
|
|
|
+ _chargingData [_index]->ModelType == 'F')
|
|
|
+ _chargingData [_index]->ConnectorMaxCurrent = 5000;
|
|
|
+ if (_chargingData [_index]->ModelType == 'T' ||
|
|
|
+ _chargingData [_index]->ModelType == 'D')
|
|
|
+ _chargingData [_index]->ConnectorMaxCurrent = 3000;
|
|
|
+ else if (_chargingData [_index]->ModelType == 'R')
|
|
|
+ _chargingData [_index]->ConnectorMaxCurrent = 2500;
|
|
|
+ else
|
|
|
+ _chargingData [_index]->ConnectorMaxCurrent = 2000;
|
|
|
}
|
|
|
else if (_chargingData[_index]->Type == _Type_GB)
|
|
|
{
|
|
@@ -3797,37 +3892,123 @@ void ConnectorOTP(byte _index)
|
|
|
|
|
|
void OfferCurrentAndPowerRecord(byte _index)
|
|
|
{
|
|
|
+ // 網頁設定值
|
|
|
unsigned short maxCurBuf = ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent * 10;
|
|
|
unsigned short maxPowBuf = ShmSysConfigAndInfo->SysConfig.MaxChargingPower * 10;
|
|
|
|
|
|
+ //_chargingData[_index]->CurrentOffered = 1200;
|
|
|
+ //_chargingData [_index]->PowerOffered = 300;
|
|
|
+ //{"value":"120","context":"Sample.Periodic","format":"Raw","measurand":"Current.Offered","location":"Outlet","unit":"A"}
|
|
|
+ //{"value":"30000","context":"Sample.Periodic","format":"Raw","measurand":"Power.Offered","location":"Outlet","unit":"W"}
|
|
|
if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_AVER)
|
|
|
{
|
|
|
maxCurBuf /= 2; maxPowBuf /= 2;
|
|
|
}
|
|
|
|
|
|
- if (_chargingData[_index]->ConnectorMaxCurrent > 0)
|
|
|
+ if (_index == 1 && ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf)
|
|
|
{
|
|
|
- if (maxCurBuf == 0)
|
|
|
- _chargingData[_index]->CurrentOffered = _chargingData[_index]->ConnectorMaxCurrent;
|
|
|
- else
|
|
|
- _chargingData[_index]->ConnectorMaxCurrent >= maxCurBuf ?
|
|
|
- (_chargingData[_index]->CurrentOffered = maxCurBuf) :
|
|
|
- (_chargingData[_index]->CurrentOffered = _chargingData[_index]->ConnectorMaxCurrent);
|
|
|
+ _chargingData [1]->PowerOffered = _chargingData [0]->PowerOffered;
|
|
|
+ _chargingData [1]->CurrentOffered = _chargingData [0]->CurrentOffered;
|
|
|
}
|
|
|
else
|
|
|
- _chargingData[_index]->CurrentOffered = 0;
|
|
|
+ {
|
|
|
+ if (_chargingData[_index]->ConnectorMaxCurrent > 0)
|
|
|
+ {
|
|
|
+ if (maxCurBuf == 0)
|
|
|
+ _chargingData[_index]->CurrentOffered = _chargingData[_index]->ConnectorMaxCurrent;
|
|
|
+ else
|
|
|
+ _chargingData[_index]->ConnectorMaxCurrent >= maxCurBuf ?
|
|
|
+ (_chargingData[_index]->CurrentOffered = maxCurBuf) :
|
|
|
+ (_chargingData[_index]->CurrentOffered = _chargingData[_index]->ConnectorMaxCurrent);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ _chargingData[_index]->CurrentOffered = 0;
|
|
|
|
|
|
- if (ShmPsuData->PsuGroup[_index].GroupAvailablePower > 0)
|
|
|
+ if (ShmPsuData->PsuGroup [_index].GroupAvailablePower > 0)
|
|
|
{
|
|
|
if (maxPowBuf == 0)
|
|
|
- _chargingData[_index]->PowerOffered = ShmPsuData->PsuGroup[_index].GroupAvailablePower;
|
|
|
+ {
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_AVER)
|
|
|
+ _chargingData [_index]->PowerOffered = ShmPsuData->PsuGroup [_index].GroupAvailablePower;
|
|
|
+ else
|
|
|
+ _chargingData [_index]->PowerOffered = ShmPsuData->SystemAvailablePower;
|
|
|
+ }
|
|
|
else
|
|
|
- _chargingData[_index]->ConnectorMaxCurrent >= maxPowBuf ?
|
|
|
- (_chargingData[_index]->PowerOffered = maxPowBuf) :
|
|
|
- (_chargingData[_index]->PowerOffered = ShmPsuData->PsuGroup[_index].GroupAvailablePower);
|
|
|
+ {
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_AVER)
|
|
|
+ {
|
|
|
+ ShmPsuData->PsuGroup[_index].GroupAvailablePower >= maxPowBuf ?
|
|
|
+ (_chargingData [_index]->PowerOffered = maxPowBuf) :
|
|
|
+ (_chargingData [_index]->PowerOffered = ShmPsuData->PsuGroup [_index].GroupAvailablePower);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ShmPsuData->SystemAvailablePower >= maxPowBuf ?
|
|
|
+ (_chargingData [_index]->PowerOffered = maxPowBuf) :
|
|
|
+ (_chargingData [_index]->PowerOffered = ShmPsuData->SystemAvailablePower);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ _chargingData [_index]->PowerOffered = 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+bool IsTimeToPrintLog()
|
|
|
+{
|
|
|
+ bool result = false;
|
|
|
+
|
|
|
+ int _timebuf = GetTimeoutValue(&delayToPrintLogTimeout);
|
|
|
+
|
|
|
+ if (_timebuf < 0)
|
|
|
+ GetTimespecFunc (&delayToPrintLogTimeout);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (_timebuf >= 5)
|
|
|
+ result = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+void InitTimeToPrintLog()
|
|
|
+{
|
|
|
+ GetTimespecFunc (&delayToPrintLogTimeout);
|
|
|
+}
|
|
|
+
|
|
|
+void AuthorizeByCcid(byte _index)
|
|
|
+{
|
|
|
+ if (_chargingData[_index]->Type == _Type_CCS &&
|
|
|
+ _chargingData [_index]->IsAvailable &&
|
|
|
+ ShmDcCommonData->enObtainAuthorizbyCCID &&
|
|
|
+ strcmp ( (char *) _chargingData[_index]->StartUserId, "") == EQUAL)
|
|
|
+ {
|
|
|
+ if (_chargingData [_index]->ConnectorPlugIn)
|
|
|
+ {
|
|
|
+ if (ShmDcCommonData->_authWithCcidFlag [_index] == _CCID_NONE)
|
|
|
+ {
|
|
|
+ if (printLogRecord)
|
|
|
+ PRINTF_FUNC ( "index = %d, Wait for CCID. \n", _index );
|
|
|
+
|
|
|
+ if (strcmp ( (char *) _chargingData [_index]->EVCCID, "" ) == EQUAL)
|
|
|
+ {
|
|
|
+ SendCommunicationOnly ( _index );
|
|
|
+ GetEvccIdReq ( _index, _chargingData [_index]->Evboard_id );
|
|
|
+ }
|
|
|
+ else
|
|
|
+ ShmDcCommonData->_authWithCcidFlag [_index] = _CCID_GET;
|
|
|
+ }
|
|
|
+ else if (ShmDcCommonData->_authWithCcidFlag [_index] == _CCID_AUTHFAIL)
|
|
|
+ {
|
|
|
+ SendStopOnly ( _index );
|
|
|
+ strcpy ( (char *) _chargingData [_index]->EVCCID, "" );
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
- _chargingData[_index]->PowerOffered = 0;
|
|
|
+ {
|
|
|
+ SendStopOnly ( _index );
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
@@ -3884,6 +4065,8 @@ int main(int argc, char *argv[])
|
|
|
|
|
|
while(CanFd)
|
|
|
{
|
|
|
+ printLogRecord = IsTimeToPrintLog();
|
|
|
+
|
|
|
for(byte _index = 0; _index < gun_count; _index++)
|
|
|
{
|
|
|
byte targetID = _chargingData[_index]->Evboard_id;
|
|
@@ -4019,7 +4202,7 @@ int main(int argc, char *argv[])
|
|
|
_chargingData[_index]->StopChargeFlag = NO;
|
|
|
}
|
|
|
|
|
|
- if (priorityLow == 1)
|
|
|
+ if (priorityLow == 1 || printLogRecord)
|
|
|
{
|
|
|
_chargingData[_index]->PresentChargedEnergy = 0;
|
|
|
_chargingData[_index]->PresentChargingPower = 0;
|
|
@@ -4092,9 +4275,14 @@ int main(int argc, char *argv[])
|
|
|
break;
|
|
|
case SYS_MODE_PREPARE_FOR_EV:
|
|
|
{
|
|
|
+ AuthorizeByCcid(_index);
|
|
|
+
|
|
|
if (ShmDcCommonData->startTransactionFlag[_index] == START_TRANSATION_STATUS_WAIT)
|
|
|
continue;
|
|
|
|
|
|
+ if (_chargingData[_index]->Type == _Type_CCS)
|
|
|
+ GetEvccIdReq(_index, _chargingData[_index]->Evboard_id);
|
|
|
+
|
|
|
// 開始確認車端是否同意開始充電 : 1.SOC, 2.Target Vol, 3.Target Cur, 4.Charging remaining time
|
|
|
GetOutputReq(_index, targetID);
|
|
|
|
|
@@ -4124,15 +4312,9 @@ int main(int argc, char *argv[])
|
|
|
}
|
|
|
|
|
|
_chargingData[_index]->RealMaxVoltage = maxVol;
|
|
|
-
|
|
|
- SetChargingPermission(_index, START,
|
|
|
- _chargingData[_index]->AvailableChargingPower,
|
|
|
- maxCur,
|
|
|
- maxVol,
|
|
|
- targetID);
|
|
|
-
|
|
|
- if (_chargingData[_index]->Type == _Type_CCS)
|
|
|
- GetEvccIdReq(_index, _chargingData[_index]->Evboard_id);
|
|
|
+ SetChargingPermission ( _index, START,
|
|
|
+ _chargingData [_index]->AvailableChargingPower,
|
|
|
+ maxCur, maxVol, targetID );
|
|
|
|
|
|
// 取得車端電池資訊 : 1.AC or DC ? 2.Total battery cap, 3.Max battery vol, 4.Max battery cur
|
|
|
GetEvBatteryInfo(_index, targetID);
|
|
@@ -4308,17 +4490,17 @@ int main(int argc, char *argv[])
|
|
|
// 設定當前輸出
|
|
|
if (gun_count == 1)
|
|
|
{
|
|
|
- if (_chargingData[0]->FireChargingVoltage <= 500)
|
|
|
- _chargingData[0]->PresentChargingCurrent = 0;
|
|
|
+ if (_chargingData[0]->FireChargingVoltage <= VOUT_MIN_VOLTAGE)
|
|
|
+ _chargingData[0]->PresentChargingCurrent = CURR_MIN_CURRENT;
|
|
|
|
|
|
SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
|
|
|
}
|
|
|
else if (gun_count == 2)
|
|
|
{
|
|
|
- if (_chargingData[0]->FireChargingVoltage <= 500)
|
|
|
- _chargingData[0]->PresentChargingCurrent = 0;
|
|
|
- if (_chargingData[1]->FireChargingVoltage <= 500)
|
|
|
- _chargingData[1]->PresentChargingCurrent = 0;
|
|
|
+ if (_chargingData[0]->FireChargingVoltage <= VOUT_MIN_VOLTAGE)
|
|
|
+ _chargingData[0]->PresentChargingCurrent = CURR_MIN_CURRENT;
|
|
|
+ if (_chargingData[1]->FireChargingVoltage <= VOUT_MIN_VOLTAGE)
|
|
|
+ _chargingData[1]->PresentChargingCurrent = CURR_MIN_CURRENT;
|
|
|
|
|
|
SetPresentChargingOutputPower(_chargingData[0], _chargingData[1]);
|
|
|
}
|
|
@@ -4401,6 +4583,10 @@ int main(int argc, char *argv[])
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (printLogRecord)
|
|
|
+ InitTimeToPrintLog();
|
|
|
+
|
|
|
priorityLow >= 20 ? priorityLow = 1 : priorityLow++;
|
|
|
usleep(45000); //EV 小板通訊 (50 ms)
|
|
|
}
|