|
@@ -40,19 +40,26 @@
|
|
|
#define ENV_TEMP_MIN 45
|
|
|
#define ENV_TEMP_MAX 50
|
|
|
#define DEFAULT_AC_INDEX 2
|
|
|
+#define EQUAL 0
|
|
|
+#define COLOR_MAX_LV 100
|
|
|
+#define COLOR_MIN_LV 0
|
|
|
+
|
|
|
+#define AC_DEFAULT_VOL 220
|
|
|
+
|
|
|
+#define NO_DEFINE 255
|
|
|
+#define NDEFAULT_AC_INDEX 2
|
|
|
|
|
|
struct SysConfigAndInfo *ShmSysConfigAndInfo;
|
|
|
struct StatusCodeData *ShmStatusCodeData;
|
|
|
struct FanModuleData *ShmFanModuleData;
|
|
|
struct RelayModuleData *ShmRelayModuleData;
|
|
|
-struct CHAdeMOData *ShmCHAdeMOData;
|
|
|
-struct CcsData *ShmCcsData;
|
|
|
+struct LedModuleData *ShmLedModuleData;
|
|
|
struct PsuData *ShmPsuData;
|
|
|
|
|
|
-#define VIN_MAX_VOLTAGE_IEC 296 // 大於該值 : OVP
|
|
|
-#define VIN_MIN_VOLTAGE_IEC 166 // 小於該值 : UVP
|
|
|
-#define VIN_MAX_VOLTAGE_UL 305 // 大於該值 : OVP
|
|
|
-#define VIN_MIN_VOLTAGE_UL 215 // 小於該值 : UVP
|
|
|
+#define VIN_MAX_VOLTAGE_IEC 285 // 大於該值 : OVP
|
|
|
+#define VIN_MIN_VOLTAGE_IEC 160 // 小於該值 : UVP
|
|
|
+#define VIN_MAX_VOLTAGE_UL 315 // 大於該值 : OVP
|
|
|
+#define VIN_MIN_VOLTAGE_UL 210 // 小於該值 : UVP
|
|
|
|
|
|
#define VIN_DROP_VOLTAGE 150 // 小於該值 : ac drop
|
|
|
|
|
@@ -102,6 +109,7 @@ bool isStopChargingCount = false;
|
|
|
struct timeval _close_ac_contactor;
|
|
|
|
|
|
struct timeval _priority_time;
|
|
|
+struct timeval _led_priority_time;
|
|
|
|
|
|
struct timeval _ac_charging_comp;
|
|
|
struct timeval _ac_preparing;
|
|
@@ -109,6 +117,11 @@ struct timeb _ac_startChargingTime;
|
|
|
struct timeb _ac_endChargingTime;
|
|
|
|
|
|
unsigned short _setFanSpeed = 0;
|
|
|
+float _beforeChargingTotalEnergy = 0.0;
|
|
|
+byte _checkLedChanged = 3;
|
|
|
+double _psuInputVolR = 0;
|
|
|
+double _psuInputVolS = 0;
|
|
|
+double _psuInputVolT = 0;
|
|
|
|
|
|
Ver ver;
|
|
|
PresentInputVoltage inputVoltage;
|
|
@@ -123,6 +136,8 @@ Gpio_out gpio_out;
|
|
|
Relay outputRelay;
|
|
|
Relay regRelay;
|
|
|
Rtc rtc;
|
|
|
+Led_Color cur_led_color;
|
|
|
+Led_Color led_color;
|
|
|
|
|
|
Ac_Status acStatus;
|
|
|
Ac_Led_Status ledStatus;
|
|
@@ -176,22 +191,33 @@ 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);
|
|
|
+
|
|
|
+ if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES)
|
|
|
+ {
|
|
|
+ sprintf(Buf,"%02d:%02d:%02d:%03d - %s",
|
|
|
+ tm->tm_hour,tm->tm_min,tm->tm_sec,SeqEndTime.millitm, buffer);
|
|
|
+ printf("%s \n", Buf);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ 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);
|
|
|
+ system(Buf);
|
|
|
+ }
|
|
|
|
|
|
return rc;
|
|
|
}
|
|
@@ -220,10 +246,7 @@ void PRINTF_FUNC(char *string, ...)
|
|
|
vsnprintf(buffer, sizeof(buffer), string, args);
|
|
|
va_end(args);
|
|
|
|
|
|
- if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES)
|
|
|
- printf("%s \n", buffer);
|
|
|
- else
|
|
|
- DEBUG_INFO("%s \n", buffer);
|
|
|
+ DEBUG_INFO("%s \n", buffer);
|
|
|
}
|
|
|
|
|
|
//==========================================
|
|
@@ -252,7 +275,7 @@ void GetFwAndHwVersion_Relay()
|
|
|
{
|
|
|
if (Query_FW_Ver(Uart5Fd, Addr.Relay, &ver) == PASS)
|
|
|
{
|
|
|
- // FanModuleData
|
|
|
+ // RelayModuleData
|
|
|
strcpy((char *) ShmRelayModuleData->version, ver.Version_FW);
|
|
|
// SystemInfo
|
|
|
strcpy((char *) ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev, ver.Version_FW);
|
|
@@ -267,6 +290,30 @@ void GetFwAndHwVersion_Relay()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void GetFwAndHwVersion_Led()
|
|
|
+{
|
|
|
+ if (Query_FW_Ver(Uart5Fd, Addr.Led, &ver) == PASS)
|
|
|
+ {
|
|
|
+ // LedModuleData
|
|
|
+ strcpy((char *) ShmLedModuleData->version, ver.Version_FW);
|
|
|
+ // SystemInfo
|
|
|
+ strcpy((char *) ShmSysConfigAndInfo->SysInfo.LedModuleFwRev, ver.Version_FW);
|
|
|
+ PRINTF_FUNC("GetFwAndHwVersion_Led s1 = %s \n", ver.Version_FW);
|
|
|
+ ShmLedModuleData->SelfTest_Comp = YES;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //PRINTF_FUNC("GetFwAndHwVersion_Led fail \n");
|
|
|
+ }
|
|
|
+
|
|
|
+// if (Query_HW_Ver(Uart5Fd, Addr.Led, &ver) == PASS)
|
|
|
+// {
|
|
|
+// // SystemInfo
|
|
|
+// strcpy((char *) ShmSysConfigAndInfo->SysInfo.RelayModuleHwRev, ver.Version_FW);
|
|
|
+// //PRINTF_FUNC("GetFwAndHwVersion_Relay s2 = %s \n", ver.Version_HW);
|
|
|
+// }
|
|
|
+}
|
|
|
+
|
|
|
void GetFwVersion_AC()
|
|
|
{
|
|
|
if (Query_FW_Ver(Uart5Fd, Addr.AcPlug, &ver) == PASS)
|
|
@@ -276,6 +323,15 @@ void GetFwVersion_AC()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void GetAcModelName()
|
|
|
+{
|
|
|
+ memset(ShmSysConfigAndInfo->SysConfig.AcModelName, 0x00, sizeof(ShmSysConfigAndInfo->SysConfig.AcModelName));
|
|
|
+ if (Query_Model_Name(Uart5Fd, Addr.AcPlug, ShmSysConfigAndInfo->SysConfig.AcModelName) == PASS)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("ac model name = %s \n", ShmSysConfigAndInfo->SysConfig.AcModelName);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void SetRtcData_Relay()
|
|
|
{
|
|
|
struct timeb csuTime;
|
|
@@ -373,34 +429,52 @@ void GetPresentInputVol()
|
|
|
if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_IEC)
|
|
|
{
|
|
|
if (inputVoltage.L1N_L12 < VIN_MIN_VOLTAGE_IEC)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("In Uvp L1N_L12 = %f \n", inputVoltage.L1N_L12);
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = YES;
|
|
|
+ }
|
|
|
else
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = NO;
|
|
|
|
|
|
if (inputVoltage.L2N_L23 < VIN_MIN_VOLTAGE_IEC)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("In Uvp L2N_L23 = %f \n", inputVoltage.L2N_L23);
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = YES;
|
|
|
+ }
|
|
|
else
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = NO;
|
|
|
|
|
|
if (inputVoltage.L3N_L31 < VIN_MIN_VOLTAGE_IEC)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("In Uvp L3N_L31 = %f \n", inputVoltage.L3N_L31);
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = YES;
|
|
|
+ }
|
|
|
else
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = NO;
|
|
|
}
|
|
|
else if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_UL)
|
|
|
{
|
|
|
if (inputVoltage.L1N_L12 < VIN_MIN_VOLTAGE_UL)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("In Uvp L1N_L12 = %f \n", inputVoltage.L1N_L12);
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = YES;
|
|
|
+ }
|
|
|
else
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = NO;
|
|
|
|
|
|
if (inputVoltage.L2N_L23 < VIN_MIN_VOLTAGE_UL)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("In Uvp L2N_L23 = %f \n", inputVoltage.L2N_L23);
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = YES;
|
|
|
+ }
|
|
|
else
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = NO;
|
|
|
|
|
|
if (inputVoltage.L3N_L31 < VIN_MIN_VOLTAGE_UL)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("In Uvp L3N_L31 = %f \n", inputVoltage.L3N_L31);
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = YES;
|
|
|
+ }
|
|
|
else
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = NO;
|
|
|
}
|
|
@@ -409,34 +483,52 @@ void GetPresentInputVol()
|
|
|
if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_IEC)
|
|
|
{
|
|
|
if (inputVoltage.L1N_L12 > VIN_MAX_VOLTAGE_IEC)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("In Ovp L1N_L12 = %f \n", inputVoltage.L1N_L12);
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = YES;
|
|
|
+ }
|
|
|
else
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = NO;
|
|
|
|
|
|
if (inputVoltage.L2N_L23 > VIN_MAX_VOLTAGE_IEC)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("In Ovp L2N_L23 = %f \n", inputVoltage.L2N_L23);
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = YES;
|
|
|
+ }
|
|
|
else
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = NO;
|
|
|
|
|
|
if (inputVoltage.L3N_L31 > VIN_MAX_VOLTAGE_IEC)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("In Ovp L3N_L31 = %f \n", inputVoltage.L3N_L31);
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = YES;
|
|
|
+ }
|
|
|
else
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = NO;
|
|
|
}
|
|
|
else if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_UL)
|
|
|
{
|
|
|
if (inputVoltage.L1N_L12 > VIN_MAX_VOLTAGE_UL)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("In Ovp L1N_L12 = %f \n", inputVoltage.L1N_L12);
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = YES;
|
|
|
+ }
|
|
|
else
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = NO;
|
|
|
|
|
|
if (inputVoltage.L2N_L23 > VIN_MAX_VOLTAGE_UL)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("In Ovp L2N_L23 = %f \n", inputVoltage.L2N_L23);
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = YES;
|
|
|
+ }
|
|
|
else
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = NO;
|
|
|
|
|
|
if (inputVoltage.L3N_L31 > VIN_MAX_VOLTAGE_UL)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("In Ovp L3N_L31 = %f \n", inputVoltage.L3N_L31);
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = YES;
|
|
|
+ }
|
|
|
else
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = NO;
|
|
|
}
|
|
@@ -617,6 +709,8 @@ void GetGfdAdc()
|
|
|
if (i == 0)
|
|
|
{
|
|
|
_chargingData[i]->GroundFaultStatus = gfd_adc.result_conn1;
|
|
|
+// PRINTF_FUNC("GFD ******** Result = %d, Step = %d, R = %d, Vol = %d \n",
|
|
|
+// _chargingData[i]->GroundFaultStatus, gfd_adc.rb_step_1, gfd_adc.Resister_conn1, gfd_adc.voltage_conn1);
|
|
|
if (_chargingData[i]->GroundFaultStatus == GFD_FAIL)
|
|
|
{
|
|
|
PRINTF_FUNC("GFD Fail. index = %d, Step = %d, R = %d, Vol = %d \n",
|
|
@@ -625,8 +719,11 @@ void GetGfdAdc()
|
|
|
else if (_chargingData[i]->GroundFaultStatus == GFD_PASS ||
|
|
|
_chargingData[i]->GroundFaultStatus == GFD_WARNING)
|
|
|
{
|
|
|
-// PRINTF_FUNC("GFD Result. index = %d, Result = %d, R = %d, Vol = %d \n",
|
|
|
-// i, _chargingData[i]->GroundFaultStatus, gfd_adc.Resister_conn1, gfd_adc.voltage_conn1);
|
|
|
+ if (_chargingData[i]->GroundFaultStatus == GFD_WARNING)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("GFD Warning. index = %d, Result = %d, R = %d, Vol = %d \n",
|
|
|
+ i, _chargingData[i]->GroundFaultStatus, gfd_adc.Resister_conn1, gfd_adc.voltage_conn1);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else if (i == 1)
|
|
@@ -640,8 +737,11 @@ void GetGfdAdc()
|
|
|
else if (_chargingData[i]->GroundFaultStatus == GFD_PASS ||
|
|
|
_chargingData[i]->GroundFaultStatus == GFD_WARNING)
|
|
|
{
|
|
|
-// PRINTF_FUNC("GFD Result. index = %d, Result = %d, R = %d, Vol = %d \n",
|
|
|
-// i, _chargingData[i]->GroundFaultStatus, gfd_adc.Resister_conn2, gfd_adc.voltage_conn2);
|
|
|
+ if (_chargingData[i]->GroundFaultStatus == GFD_WARNING)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("GFD Warning. index = %d, Result = %d, R = %d, Vol = %d \n",
|
|
|
+ i, _chargingData[i]->GroundFaultStatus, gfd_adc.Resister_conn1, gfd_adc.voltage_conn1);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -793,6 +893,15 @@ void SetFanModuleSpeed()
|
|
|
//==========================================
|
|
|
void SetK1K2RelayStatus(byte index)
|
|
|
{
|
|
|
+ if (ShmPsuData->Work_Step >= _TEST_MODE && ShmPsuData->Work_Step <= _TEST_MODE)
|
|
|
+ {
|
|
|
+ if(regRelay.relay_event.bits.Gun1_N == NO)
|
|
|
+ outputRelay.relay_event.bits.Gun1_N = YES;
|
|
|
+ else if (regRelay.relay_event.bits.Gun1_P == NO)
|
|
|
+ outputRelay.relay_event.bits.Gun1_P = YES;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if (_chargingData[index]->SystemStatus < S_PREPARING_FOR_EVSE)
|
|
|
{
|
|
|
if (_chargingData[index]->Evboard_id == 0x01)
|
|
@@ -924,7 +1033,35 @@ void CheckAcInputOvpStatus(byte index)
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == YES ||
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == YES)
|
|
|
{
|
|
|
- _chargingData[index]->StopChargeFlag = YES;
|
|
|
+// if ((_chargingData[index]->SystemStatus >= S_PREPARNING && _chargingData[index]->SystemStatus <= S_CHARGING) ||
|
|
|
+// (_chargingData[index]->SystemStatus >= S_CCS_PRECHARGE_ST0 && _chargingData[index]->SystemStatus <= S_CCS_PRECHARGE_ST1))
|
|
|
+// {
|
|
|
+// if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_IEC)
|
|
|
+// {
|
|
|
+// if (_psuInputVolR > VIN_MAX_VOLTAGE_IEC ||
|
|
|
+// _psuInputVolS > VIN_MAX_VOLTAGE_IEC ||
|
|
|
+// _psuInputVolT > VIN_MAX_VOLTAGE_IEC)
|
|
|
+// {
|
|
|
+// PRINTF_FUNC("IEC _psuInputVolR = %f, _psuInputVolS = %f, _psuInputVolT = %f \n",
|
|
|
+// _psuInputVolR, _psuInputVolS, _psuInputVolT);
|
|
|
+// _chargingData[index]->StopChargeFlag = YES;
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+// else if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_UL)
|
|
|
+// {
|
|
|
+// if (_psuInputVolR > VIN_MAX_VOLTAGE_UL ||
|
|
|
+// _psuInputVolS > VIN_MAX_VOLTAGE_UL ||
|
|
|
+// _psuInputVolT > VIN_MAX_VOLTAGE_UL)
|
|
|
+// {
|
|
|
+// PRINTF_FUNC("UL _psuInputVolR = %f, _psuInputVolS = %f, _psuInputVolT = %f \n",
|
|
|
+// _psuInputVolR, _psuInputVolS, _psuInputVolT);
|
|
|
+// _chargingData[index]->StopChargeFlag = YES;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// else
|
|
|
+ _chargingData[index]->StopChargeFlag = YES;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -940,7 +1077,8 @@ void CheckPhaseLossStatus(byte index)
|
|
|
|
|
|
void SetParalleRelayStatus()
|
|
|
{
|
|
|
- if (gunCount >= 2 && ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == NO)
|
|
|
+ // 之後雙槍單模機種,橋接都會上
|
|
|
+ if (gunCount >= 2)
|
|
|
{
|
|
|
if (_chargingData[0]->SystemStatus == S_BOOTING || _chargingData[1]->SystemStatus == S_BOOTING ||
|
|
|
(_chargingData[0]->SystemStatus == S_IDLE && _chargingData[1]->SystemStatus == S_IDLE))
|
|
@@ -1020,7 +1158,7 @@ void CheckAlarmOccur()
|
|
|
case AC_DC_LEAKAGE: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip = YES; break;
|
|
|
case AC_SYSTEM_SELFTEST_FAULT: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.McuSelftestFail = YES; break;
|
|
|
case AC_HANDSHAKE_TIMEOUT: break;
|
|
|
- case AC_EMC_STOP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip = YES; break;
|
|
|
+ //case AC_EMC_STOP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip = YES; break;
|
|
|
case AC_RELAY_WELDING: ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayWelding = YES; break;
|
|
|
case AC_GF_MODULE_FAULT: ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail = YES; break;
|
|
|
case AC_SHUTTER_FAULT: break;
|
|
@@ -1045,7 +1183,7 @@ void CheckAlarmOccur()
|
|
|
case AC_DC_LEAKAGE: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip = NO; break;
|
|
|
case AC_SYSTEM_SELFTEST_FAULT: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.McuSelftestFail = NO; break;
|
|
|
case AC_HANDSHAKE_TIMEOUT: break;
|
|
|
- case AC_EMC_STOP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip = NO; break;
|
|
|
+ //case AC_EMC_STOP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip = NO; break;
|
|
|
case AC_RELAY_WELDING: ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayWelding = NO; break;
|
|
|
case AC_GF_MODULE_FAULT: ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail = NO; break;
|
|
|
case AC_SHUTTER_FAULT: break;
|
|
@@ -1061,6 +1199,109 @@ void CheckAlarmOccur()
|
|
|
ac_chargingInfo[0]->IsErrorOccur = isErr;
|
|
|
}
|
|
|
|
|
|
+bool IsNoneMatchLedColor()
|
|
|
+{
|
|
|
+ bool result = false;
|
|
|
+
|
|
|
+ if (cur_led_color.Connect_1_Red != led_color.Connect_1_Red ||
|
|
|
+ cur_led_color.Connect_1_Green != led_color.Connect_1_Green ||
|
|
|
+ cur_led_color.Connect_1_Blue != led_color.Connect_1_Blue ||
|
|
|
+ cur_led_color.Connect_2_Red != led_color.Connect_2_Red ||
|
|
|
+ cur_led_color.Connect_2_Green != led_color.Connect_2_Green ||
|
|
|
+ cur_led_color.Connect_2_Blue != led_color.Connect_2_Blue)
|
|
|
+ {
|
|
|
+ result = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+void SetLedColor(struct ChargingInfoData *chargingData_1, struct ChargingInfoData *chargingData_2)
|
|
|
+{
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf)
|
|
|
+ {
|
|
|
+ if ((chargingData_1->SystemStatus == S_BOOTING || chargingData_1->SystemStatus == S_IDLE || chargingData_1->SystemStatus == S_RESERVATION) &&
|
|
|
+ (chargingData_2->SystemStatus == S_BOOTING || chargingData_2->SystemStatus == S_IDLE || chargingData_2->SystemStatus == S_RESERVATION))
|
|
|
+ {
|
|
|
+ led_color.Connect_1_Green = COLOR_MAX_LV;
|
|
|
+ led_color.Connect_1_Blue = COLOR_MIN_LV;
|
|
|
+ led_color.Connect_1_Red = COLOR_MIN_LV;
|
|
|
+ led_color.Connect_2_Green = COLOR_MAX_LV;
|
|
|
+ led_color.Connect_2_Blue = COLOR_MIN_LV;
|
|
|
+ led_color.Connect_2_Red = COLOR_MIN_LV;
|
|
|
+ }
|
|
|
+ else if ((chargingData_1->SystemStatus >= S_AUTHORIZING && chargingData_1->SystemStatus <= S_COMPLETE) ||
|
|
|
+ (chargingData_1->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingData_1->SystemStatus <= S_CCS_PRECHARGE_ST1) ||
|
|
|
+ (chargingData_2->SystemStatus >= S_AUTHORIZING && chargingData_2->SystemStatus <= S_COMPLETE) ||
|
|
|
+ (chargingData_2->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingData_2->SystemStatus <= S_CCS_PRECHARGE_ST1))
|
|
|
+ {
|
|
|
+ led_color.Connect_1_Green = COLOR_MIN_LV;
|
|
|
+ led_color.Connect_1_Blue = COLOR_MAX_LV;
|
|
|
+ led_color.Connect_1_Red = COLOR_MIN_LV;
|
|
|
+ led_color.Connect_2_Green = COLOR_MIN_LV;
|
|
|
+ led_color.Connect_2_Blue = COLOR_MAX_LV;
|
|
|
+ led_color.Connect_2_Red = COLOR_MIN_LV;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (chargingData_1->SystemStatus == S_BOOTING || chargingData_1->SystemStatus == S_IDLE || chargingData_1->SystemStatus == S_RESERVATION)
|
|
|
+ {
|
|
|
+ led_color.Connect_1_Green = COLOR_MAX_LV;
|
|
|
+ led_color.Connect_1_Blue = COLOR_MIN_LV;
|
|
|
+ led_color.Connect_1_Red = COLOR_MIN_LV;
|
|
|
+ }
|
|
|
+ else if ((chargingData_1->SystemStatus >= S_AUTHORIZING && chargingData_1->SystemStatus <= S_COMPLETE) ||
|
|
|
+ (chargingData_1->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingData_1->SystemStatus <= S_CCS_PRECHARGE_ST1))
|
|
|
+ {
|
|
|
+ led_color.Connect_1_Green = COLOR_MIN_LV;
|
|
|
+ led_color.Connect_1_Blue = COLOR_MAX_LV;
|
|
|
+ led_color.Connect_1_Red = COLOR_MIN_LV;
|
|
|
+ }
|
|
|
+
|
|
|
+ // --------------------------------------------------------------------------
|
|
|
+ if (chargingData_2->SystemStatus == S_BOOTING || chargingData_2->SystemStatus == S_IDLE || chargingData_2->SystemStatus == S_RESERVATION)
|
|
|
+ {
|
|
|
+ led_color.Connect_2_Green = COLOR_MAX_LV;
|
|
|
+ led_color.Connect_2_Blue = COLOR_MIN_LV;
|
|
|
+ led_color.Connect_2_Red = COLOR_MIN_LV;
|
|
|
+ }
|
|
|
+ else if ((chargingData_2->SystemStatus >= S_AUTHORIZING && chargingData_2->SystemStatus <= S_COMPLETE) ||
|
|
|
+ (chargingData_2->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingData_2->SystemStatus <= S_CCS_PRECHARGE_ST1))
|
|
|
+ {
|
|
|
+ led_color.Connect_2_Green = COLOR_MIN_LV;
|
|
|
+ led_color.Connect_2_Blue = COLOR_MAX_LV;
|
|
|
+ led_color.Connect_2_Red = COLOR_MIN_LV;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2)
|
|
|
+ {
|
|
|
+ led_color.Connect_1_Green = COLOR_MIN_LV;
|
|
|
+ led_color.Connect_1_Blue = COLOR_MIN_LV;
|
|
|
+ led_color.Connect_1_Red = COLOR_MAX_LV;
|
|
|
+ led_color.Connect_2_Green = COLOR_MIN_LV;
|
|
|
+ led_color.Connect_2_Blue = COLOR_MIN_LV;
|
|
|
+ led_color.Connect_2_Red = COLOR_MAX_LV;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_checkLedChanged > 0)
|
|
|
+ {
|
|
|
+ if (Config_Led_Color(Uart5Fd, Addr.Led, &led_color) == PASS)
|
|
|
+ {
|
|
|
+ _checkLedChanged--;
|
|
|
+
|
|
|
+ cur_led_color.Connect_1_Red = led_color.Connect_1_Red;
|
|
|
+ cur_led_color.Connect_1_Green = led_color.Connect_1_Green;
|
|
|
+ cur_led_color.Connect_1_Blue = led_color.Connect_1_Blue;
|
|
|
+ cur_led_color.Connect_2_Red = led_color.Connect_2_Red;
|
|
|
+ cur_led_color.Connect_2_Green = led_color.Connect_2_Green;
|
|
|
+ cur_led_color.Connect_2_Blue = led_color.Connect_2_Blue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (IsNoneMatchLedColor())
|
|
|
+ _checkLedChanged = 3;
|
|
|
+}
|
|
|
//==========================================
|
|
|
// Init all share memory
|
|
|
//==========================================
|
|
@@ -1083,8 +1324,8 @@ int InitShareMemory()
|
|
|
DEBUG_ERROR("[shmat ShmSysConfigAndInfo NG\n");
|
|
|
#endif
|
|
|
result = FAIL;
|
|
|
- }
|
|
|
- //creat ShmStatusCodeData
|
|
|
+ }
|
|
|
+ //creat ShmStatusCodeData
|
|
|
if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
|
|
|
{
|
|
|
#ifdef SystemLogMessage
|
|
@@ -1114,9 +1355,10 @@ int InitShareMemory()
|
|
|
DEBUG_ERROR("shmat ShmFanModuleData NG\n");
|
|
|
#endif
|
|
|
result = FAIL;
|
|
|
- }
|
|
|
- memset(ShmFanModuleData,0,sizeof(struct FanModuleData));
|
|
|
- //creat ShmRelayModuleData
|
|
|
+ }
|
|
|
+ memset(ShmFanModuleData,0,sizeof(struct FanModuleData));
|
|
|
+
|
|
|
+ //creat ShmRelayModuleData
|
|
|
if ((MeterSMId = shmget(ShmRelayBdKey, sizeof(struct RelayModuleData), 0777)) < 0)
|
|
|
{
|
|
|
#ifdef SystemLogMessage
|
|
@@ -1131,60 +1373,41 @@ int InitShareMemory()
|
|
|
#endif
|
|
|
result = FAIL;
|
|
|
}
|
|
|
+ memset(ShmRelayModuleData,0,sizeof(struct RelayModuleData));
|
|
|
|
|
|
- //creat ShmPsuData
|
|
|
- if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
|
|
|
+ //creat ShmLedModuleData
|
|
|
+ if ((MeterSMId = shmget(ShmLedBdKey, sizeof(struct LedModuleData), 0777)) < 0)
|
|
|
{
|
|
|
#ifdef SystemLogMessage
|
|
|
- DEBUG_ERROR("shmget ShmPsuData NG \n");
|
|
|
+ DEBUG_ERROR("shmget ShmLedModuleData NG\n");
|
|
|
#endif
|
|
|
result = FAIL;
|
|
|
}
|
|
|
- else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
|
|
|
+ else if ((ShmLedModuleData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
|
|
|
{
|
|
|
#ifdef SystemLogMessage
|
|
|
- DEBUG_ERROR("shmat ShmPsuData NG \n");
|
|
|
+ DEBUG_ERROR("shmat ShmLedModuleData NG\n");
|
|
|
#endif
|
|
|
result = FAIL;
|
|
|
}
|
|
|
- memset(ShmPsuData,0,sizeof(struct PsuData));
|
|
|
+ memset(ShmLedModuleData,0,sizeof(struct LedModuleData));
|
|
|
|
|
|
- if(CHAdeMO_QUANTITY > 0)
|
|
|
+ //creat ShmPsuData
|
|
|
+ if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
|
|
|
{
|
|
|
- if ((MeterSMId = shmget(ShmCHAdeMOCommKey, sizeof(struct CHAdeMOData), IPC_CREAT | 0777)) < 0)
|
|
|
- {
|
|
|
- #ifdef SystemLogMessage
|
|
|
- DEBUG_ERROR("[shmget ShmCHAdeMOData NG \n");
|
|
|
- #endif
|
|
|
- return FAIL;
|
|
|
- }
|
|
|
- else if ((ShmCHAdeMOData = shmat(MeterSMId, NULL, 0)) == (void *) -1) {
|
|
|
- #ifdef SystemLogMessage
|
|
|
- DEBUG_ERROR("shmat ShmCHAdeMOData NG \n");
|
|
|
- #endif
|
|
|
- return FAIL;
|
|
|
- }
|
|
|
+ #ifdef SystemLogMessage
|
|
|
+ DEBUG_ERROR("shmget ShmPsuData NG \n");
|
|
|
+ #endif
|
|
|
+ result = FAIL;
|
|
|
}
|
|
|
-
|
|
|
- if(CCS_QUANTITY > 0)
|
|
|
+ else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
|
|
|
{
|
|
|
- if ((MeterSMId = shmget(ShmCcsCommKey, sizeof(struct CcsData), IPC_CREAT | 0777)) < 0)
|
|
|
- {
|
|
|
- #ifdef SystemLogMessage
|
|
|
- DEBUG_ERROR("shmget ShmCcsData NG \n");
|
|
|
- #endif
|
|
|
- return FAIL;
|
|
|
- }
|
|
|
- else if ((ShmCcsData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
|
|
|
- {
|
|
|
- #ifdef SystemLogMessage
|
|
|
- DEBUG_ERROR("shmat ShmCcsData NG \n");
|
|
|
- #endif
|
|
|
- return FAIL;
|
|
|
- }
|
|
|
+ #ifdef SystemLogMessage
|
|
|
+ DEBUG_ERROR("shmat ShmPsuData NG \n");
|
|
|
+ #endif
|
|
|
+ result = FAIL;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -1282,11 +1505,13 @@ void Initialization()
|
|
|
{
|
|
|
if (!FindChargingInfoData(_index, &_chargingData[0]))
|
|
|
{
|
|
|
- DEBUG_ERROR("EvComm : FindChargingInfoData false \n");
|
|
|
+ DEBUG_ERROR("InternalComm : FindChargingInfoData false \n");
|
|
|
isPass = false;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ sleep(1);
|
|
|
}
|
|
|
|
|
|
isPass = false;
|
|
@@ -1305,6 +1530,8 @@ void Initialization()
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ sleep(1);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1421,7 +1648,7 @@ void CableCheckDetected(byte index)
|
|
|
}
|
|
|
else if (_chargingData[index]->SystemStatus <= S_CHARGING)
|
|
|
{
|
|
|
- if (_chargingData[index]->Type == _Type_GB)
|
|
|
+ if (_chargingData[index]->Type == _Type_GB || _chargingData[index]->Type == _Type_Chademo)
|
|
|
SetGfdConfig(index, GFD_IDLE);
|
|
|
else
|
|
|
SetGfdConfig(index, GFD_CHARGING);
|
|
@@ -1438,9 +1665,9 @@ void CableCheckDetected(byte index)
|
|
|
void CheckOutputPowerOverCarReq(byte index)
|
|
|
{
|
|
|
float fireV = _chargingData[index]->FireChargingVoltage;
|
|
|
- float carV = _chargingData[index]->EvBatterytargetVoltage;
|
|
|
+ float carV = _chargingData[index]->EvBatterytargetVoltage * 10;
|
|
|
|
|
|
- if (_chargingData[index]->EvBatterytargetVoltage > 1500 &&
|
|
|
+ if ((_chargingData[index]->EvBatterytargetVoltage * 10) > 1500 &&
|
|
|
(_chargingData[index]->Type == _Type_Chademo ||
|
|
|
_chargingData[index]->Type == _Type_CCS_2 ||
|
|
|
_chargingData[index]->Type == _Type_GB))
|
|
@@ -1448,9 +1675,9 @@ void CheckOutputPowerOverCarReq(byte index)
|
|
|
if (fireV >= (carV + (carV * 0.1)))
|
|
|
{
|
|
|
PRINTF_FUNC("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f \n",
|
|
|
- _chargingData[index]->FireChargingVoltage, _chargingData[index]->EvBatterytargetVoltage);
|
|
|
+ _chargingData[index]->FireChargingVoltage, (_chargingData[index]->EvBatterytargetVoltage * 10));
|
|
|
DEBUG_ERROR("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f \n",
|
|
|
- _chargingData[index]->FireChargingVoltage, _chargingData[index]->EvBatterytargetVoltage);
|
|
|
+ _chargingData[index]->FireChargingVoltage, (_chargingData[index]->EvBatterytargetVoltage * 10));
|
|
|
_chargingData[index]->StopChargeFlag = YES;
|
|
|
}
|
|
|
}
|
|
@@ -1458,7 +1685,7 @@ void CheckOutputPowerOverCarReq(byte index)
|
|
|
|
|
|
void CheckOutputVolNoneMatchFire(byte index)
|
|
|
{
|
|
|
- if (_chargingData[index]->EvBatterytargetVoltage > 1500 &&
|
|
|
+ if ((_chargingData[index]->EvBatterytargetVoltage * 10) > 1500 &&
|
|
|
(_chargingData[index]->Type == _Type_Chademo ||
|
|
|
_chargingData[index]->Type == _Type_CCS_2 ||
|
|
|
_chargingData[index]->Type == _Type_GB))
|
|
@@ -1524,15 +1751,28 @@ void CheckRelayWeldingStatus(byte index)
|
|
|
void GetPsuTempForFanSpeed()
|
|
|
{
|
|
|
char temp = 0;
|
|
|
+ //double volR = 0, volS = 0, volT = 0;
|
|
|
for (byte index = 0; index < ShmPsuData->GroupCount; index++)
|
|
|
{
|
|
|
for (byte count = 0; count < ShmPsuData->PsuGroup[index].GroupPresentPsuQuantity; count++)
|
|
|
{
|
|
|
if (temp < ShmPsuData->PsuGroup[index].PsuModule[count].ExletTemp)
|
|
|
temp = ShmPsuData->PsuGroup[index].PsuModule[count].ExletTemp;
|
|
|
+
|
|
|
+// if (volR < (ShmPsuData->PsuGroup[index].PsuModule[count].InputVoltageL1 / 10) / 1.732)
|
|
|
+// volR = (ShmPsuData->PsuGroup[index].PsuModule[count].InputVoltageL1 / 10) / 1.732;
|
|
|
+//
|
|
|
+// if (volS < (ShmPsuData->PsuGroup[index].PsuModule[count].InputVoltageL2 / 10) / 1.732)
|
|
|
+// volS = (ShmPsuData->PsuGroup[index].PsuModule[count].InputVoltageL2 / 10) / 1.732;
|
|
|
+//
|
|
|
+// if (volT < (ShmPsuData->PsuGroup[index].PsuModule[count].InputVoltageL3 / 10) / 1.732)
|
|
|
+// volT = (ShmPsuData->PsuGroup[index].PsuModule[count].InputVoltageL3 / 10) / 1.732;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //_psuInputVolR = volR; _psuInputVolS = volS; _psuInputVolT = volT;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.SystemAmbientTemp = temp;
|
|
|
+
|
|
|
if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == NO)
|
|
|
{
|
|
|
if (ShmFanModuleData->TestFanSpeed == NORMAL_FAN_SPEED)
|
|
@@ -1559,7 +1799,8 @@ void GetAcStatus()
|
|
|
if(ShmSysConfigAndInfo->SysConfig.AcMaxChargingCurrent == 0)
|
|
|
ShmSysConfigAndInfo->SysConfig.AcMaxChargingCurrent = ShmSysConfigAndInfo->SysConfig.AcRatingCurrent;
|
|
|
|
|
|
- // printf("CpStatus = %d \n", acStatus.CpStatus);
|
|
|
+ ac_chargingInfo[0]->ConnectorPlugIn = acStatus.CpStatus;
|
|
|
+ // PRINTF_FUNC("CpStatus = %d \n", acStatus.CpStatus);
|
|
|
// printf("CurLimit = %d \n", acStatus.CurLimit);
|
|
|
// printf("PilotVol_P = %d \n", acStatus.PilotVol_P);
|
|
|
// printf("PilotVol_N = %d \n", acStatus.PilotVol_N);
|
|
@@ -1574,6 +1815,8 @@ void GetAcStatus()
|
|
|
//
|
|
|
// ac_chargingInfo[0]->SystemStatus = acStatus.CpStatus;
|
|
|
}
|
|
|
+// else
|
|
|
+// PRINTF_FUNC("GetAcStatus return fail. \n");
|
|
|
}
|
|
|
|
|
|
void GetAcAlarmCode()
|
|
@@ -1626,6 +1869,24 @@ void ChangeToCsuMode()
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
+void ChangeStartOrStopDateTime(byte isStart)
|
|
|
+{
|
|
|
+ char cmdBuf[32];
|
|
|
+ struct timeb csuTime;
|
|
|
+ struct tm *tmCSU;
|
|
|
+
|
|
|
+ ftime(&csuTime);
|
|
|
+ tmCSU = localtime(&csuTime.time);
|
|
|
+
|
|
|
+ sprintf(cmdBuf, "%04d-%02d-%02d %02d:%02d:%02d", tmCSU->tm_year + 1900,
|
|
|
+ tmCSU->tm_mon + 1, tmCSU->tm_mday, tmCSU->tm_hour, tmCSU->tm_min,
|
|
|
+ tmCSU->tm_sec);
|
|
|
+ if (isStart)
|
|
|
+ strcpy((char *)ac_chargingInfo[0]->StartDateTime, cmdBuf);
|
|
|
+ else
|
|
|
+ strcpy((char *)ac_chargingInfo[0]->StopDateTime, cmdBuf);
|
|
|
+}
|
|
|
+
|
|
|
void AcChargeTypeProcess()
|
|
|
{
|
|
|
if (acgunCount > 0)
|
|
@@ -1634,6 +1895,7 @@ void AcChargeTypeProcess()
|
|
|
{
|
|
|
ac_chargingInfo[0]->IsModeChagned = NO;
|
|
|
GetFwVersion_AC();
|
|
|
+ GetAcModelName();
|
|
|
}
|
|
|
else if (ac_chargingInfo[0]->SelfTest_Comp == YES)
|
|
|
{
|
|
@@ -1654,7 +1916,7 @@ void AcChargeTypeProcess()
|
|
|
_status = S_TERMINATING;
|
|
|
else if (ac_chargingInfo[0]->SystemStatus >= S_TERMINATING)
|
|
|
{
|
|
|
- if (GetTimeoutValue(_ac_charging_comp) >= 10000000)
|
|
|
+ if (GetTimeoutValue(_ac_charging_comp) >= 10000000 && acStatus.CpStatus == AC_SYS_A)
|
|
|
_status = S_IDLE;
|
|
|
}
|
|
|
else
|
|
@@ -1668,18 +1930,29 @@ void AcChargeTypeProcess()
|
|
|
else if (GetTimeoutValue(_ac_preparing) >= 30000000)
|
|
|
_status = S_IDLE;
|
|
|
}
|
|
|
- else if (acStatus.CpStatus == AC_SYS_B &&
|
|
|
+ else if ((acStatus.CpStatus == AC_SYS_B || ac_chargingInfo[0]->ConnectorPlugIn == AC_SYS_B) &&
|
|
|
ac_chargingInfo[0]->IsAvailable &&
|
|
|
!ac_chargingInfo[0]->IsErrorOccur &&
|
|
|
(ShmSysConfigAndInfo->SysInfo.WaitForPlugit == YES ||
|
|
|
ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE))
|
|
|
{
|
|
|
- PRINTF_FUNC("** UserId = %s \n", ShmSysConfigAndInfo->SysConfig.UserId);
|
|
|
- strcpy((char *)ac_chargingInfo[0]->StartUserId, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
|
|
|
- PRINTF_FUNC("** CardNumber = %s \n", ac_chargingInfo[0]->StartUserId);
|
|
|
- strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
|
|
|
- ShmSysConfigAndInfo->SysInfo.WaitForPlugit = NO;
|
|
|
- _status = S_PREPARNING;
|
|
|
+ if (ac_chargingInfo[0]->RemoteStartFlag == YES)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("** AC Remote \n");
|
|
|
+ ac_chargingInfo[0]->RemoteStartFlag = NO;
|
|
|
+ strcpy((char *)ac_chargingInfo[0]->StartUserId, "");
|
|
|
+ ShmSysConfigAndInfo->SysInfo.WaitForPlugit = NO;
|
|
|
+ _status = S_PREPARNING;
|
|
|
+ }
|
|
|
+ else if (ShmSysConfigAndInfo->SysInfo.OrderCharging == NO_DEFINE)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("** UserId = %s \n", ShmSysConfigAndInfo->SysConfig.UserId);
|
|
|
+ strcpy((char *)ac_chargingInfo[0]->StartUserId, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
|
|
|
+ PRINTF_FUNC("** CardNumber = %s \n", ac_chargingInfo[0]->StartUserId);
|
|
|
+ strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
|
|
|
+ ShmSysConfigAndInfo->SysInfo.WaitForPlugit = NO;
|
|
|
+ _status = S_PREPARNING;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//printf("_status = %d \n", _status);
|
|
@@ -1698,6 +1971,9 @@ void AcChargeTypeProcess()
|
|
|
if (_isStatusChanged)
|
|
|
{
|
|
|
ac_chargingInfo[0]->PresentChargedEnergy = 0.0;
|
|
|
+ ac_chargingInfo[0]->PresentChargingVoltage = 0;
|
|
|
+ ac_chargingInfo[0]->ChargingFee = 0.0;
|
|
|
+ _beforeChargingTotalEnergy = 0.0;
|
|
|
}
|
|
|
|
|
|
ChangeLedStatus();
|
|
@@ -1709,12 +1985,15 @@ void AcChargeTypeProcess()
|
|
|
{
|
|
|
ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_NONE;
|
|
|
ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = DEFAULT_AC_INDEX;
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.OrderCharging != NO_DEFINE)
|
|
|
+ ShmSysConfigAndInfo->SysInfo.OrderCharging = NO_DEFINE;
|
|
|
gettimeofday(&_ac_preparing, NULL);
|
|
|
}
|
|
|
|
|
|
if (GetChargingEnergy() == PASS)
|
|
|
{
|
|
|
- ac_chargingInfo[0]->PresentChargedEnergy = acChargingEnergy.Energy / 100;
|
|
|
+ //ac_chargingInfo[0]->PresentChargedEnergy = acChargingEnergy.Energy / 100;
|
|
|
+ _beforeChargingTotalEnergy = acChargingEnergy.Energy;
|
|
|
}
|
|
|
|
|
|
SetLegacyReq(YES);
|
|
@@ -1726,17 +2005,31 @@ void AcChargeTypeProcess()
|
|
|
if (_isStatusChanged)
|
|
|
{
|
|
|
ftime(&_ac_startChargingTime);
|
|
|
+ ChangeStartOrStopDateTime(YES);
|
|
|
ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = DEFAULT_AC_INDEX;
|
|
|
}
|
|
|
|
|
|
if (GetChargingEnergy() == PASS)
|
|
|
- ac_chargingInfo[0]->PresentChargedEnergy = acChargingEnergy.Energy / 100;
|
|
|
+ {
|
|
|
+ if ((acChargingEnergy.Energy - _beforeChargingTotalEnergy) > 0)
|
|
|
+ {
|
|
|
+ ac_chargingInfo[0]->PresentChargedEnergy += (acChargingEnergy.Energy - _beforeChargingTotalEnergy) / 100;
|
|
|
+ if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling)
|
|
|
+ {
|
|
|
+ ac_chargingInfo[0]->ChargingFee += ac_chargingInfo[0]->PresentChargedEnergy * ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ _beforeChargingTotalEnergy = acChargingEnergy.Energy;
|
|
|
+ }
|
|
|
|
|
|
if (GetChargingCurrent() == PASS)
|
|
|
- ac_chargingInfo[0]->PresentChargingPower = (220 * (acChargingCurrent.OuputCurrentL1 / 10)) / 1000;
|
|
|
+ ac_chargingInfo[0]->PresentChargingPower = (((float)(AC_DEFAULT_VOL * acChargingCurrent.OuputCurrentL1) / 10) / 1000);
|
|
|
|
|
|
ftime(&_ac_endChargingTime);
|
|
|
- ac_chargingInfo[0]->RemainChargingDuration = DiffTimeb(_ac_startChargingTime, _ac_endChargingTime);
|
|
|
+ ac_chargingInfo[0]->PresentChargedDuration = DiffTimeb(_ac_startChargingTime, _ac_endChargingTime);
|
|
|
+ ac_chargingInfo[0]->PresentChargingVoltage = AC_DEFAULT_VOL;
|
|
|
+ ac_chargingInfo[0]->PresentChargingCurrent = ((float)acChargingCurrent.OuputCurrentL1 / 10);
|
|
|
|
|
|
// 用以判斷是否有在輸出
|
|
|
ac_chargingInfo[0]->IsCharging = acStatus.RelayStatus;
|
|
@@ -1749,6 +2042,7 @@ void AcChargeTypeProcess()
|
|
|
{
|
|
|
if (_isStatusChanged)
|
|
|
{
|
|
|
+ ChangeStartOrStopDateTime(NO);
|
|
|
gettimeofday(&_ac_charging_comp, NULL);
|
|
|
}
|
|
|
|
|
@@ -1763,7 +2057,8 @@ void AcChargeTypeProcess()
|
|
|
{
|
|
|
gettimeofday(&_ac_charging_comp, NULL);
|
|
|
ftime(&_ac_endChargingTime);
|
|
|
- ac_chargingInfo[0]->RemainChargingDuration = DiffTimeb(_ac_startChargingTime, _ac_endChargingTime);
|
|
|
+ ChangeStartOrStopDateTime(NO);
|
|
|
+ ac_chargingInfo[0]->PresentChargedDuration = DiffTimeb(_ac_startChargingTime, _ac_endChargingTime);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
@@ -1811,7 +2106,14 @@ int main(void)
|
|
|
if(Config_Relay_Output(Uart5Fd, Addr.Relay, &outputRelay) != PASS)
|
|
|
PRINTF_FUNC("Config_Relay_Output fail \n");
|
|
|
|
|
|
- bool printRelayStatus = true;
|
|
|
+ cur_led_color.Connect_1_Red = COLOR_MIN_LV;
|
|
|
+ cur_led_color.Connect_1_Green = COLOR_MIN_LV;
|
|
|
+ cur_led_color.Connect_1_Blue = COLOR_MIN_LV;
|
|
|
+ cur_led_color.Connect_2_Red = COLOR_MIN_LV;
|
|
|
+ cur_led_color.Connect_2_Green = COLOR_MIN_LV;
|
|
|
+ cur_led_color.Connect_2_Blue = COLOR_MIN_LV;
|
|
|
+
|
|
|
+ //bool printRelayStatus = true;
|
|
|
for(;;)
|
|
|
{
|
|
|
bool isCharging = false;
|
|
@@ -1832,6 +2134,24 @@ int main(void)
|
|
|
gettimeofday(&_priority_time, NULL);
|
|
|
}
|
|
|
|
|
|
+ // 自檢階段處理,自檢階段如果讀不到版號則代表該系統沒有掛燈板
|
|
|
+ if (ShmLedModuleData->SelfTest_Comp == NO)
|
|
|
+ {
|
|
|
+ // 自檢階段
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.SelfTestSeq <= _STEST_PSU_CAP)
|
|
|
+ {
|
|
|
+ GetFwAndHwVersion_Led();
|
|
|
+ sleep(1);
|
|
|
+ gettimeofday(&_led_priority_time, NULL);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // 自檢階段沒有問到版號
|
|
|
+ if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LedboardStestFail == NO)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LedboardStestFail = YES;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
AcChargeTypeProcess();
|
|
|
|
|
|
if (ShmRelayModuleData->SelfTest_Comp == YES)
|
|
@@ -1911,7 +2231,8 @@ int main(void)
|
|
|
// else
|
|
|
// outputRelay.relay_event.bits.AC_Contactor = NO;
|
|
|
|
|
|
- if (isCharging)
|
|
|
+ if (isCharging ||
|
|
|
+ (ShmPsuData->Work_Step >= _TEST_MODE && ShmPsuData->Work_Step <= _TEST_MODE))
|
|
|
{
|
|
|
isStopChargingCount = false;
|
|
|
outputRelay.relay_event.bits.AC_Contactor = YES;
|
|
@@ -1930,6 +2251,9 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (ShmPsuData->Work_Step >= _TEST_MODE && ShmPsuData->Work_Step <= _TEST_MODE)
|
|
|
+ outputRelay.relay_event.bits.Gun1_N = outputRelay.relay_event.bits.Gun1_P = YES;
|
|
|
+
|
|
|
// 搭上/鬆開 Relay
|
|
|
if(IsNoneMatchRelayStatus())
|
|
|
{
|
|
@@ -2005,6 +2329,14 @@ int main(void)
|
|
|
|
|
|
if (ShmFanModuleData->SelfTest_Comp == YES)
|
|
|
{
|
|
|
+ // 風控修改 :
|
|
|
+ // ******************************************************* //
|
|
|
+ //
|
|
|
+ // 當前PSU輸出總 KW PSU Temp
|
|
|
+ // 30 x -------------------- x ---------- + 14 x (PSU Temp - 45)
|
|
|
+ // 當前樁最大功率 KW 45
|
|
|
+ //
|
|
|
+ // ******************************************************* //
|
|
|
if (GetTimeoutValue(_priority_time) / 1000 >= 1000)
|
|
|
{
|
|
|
GetPsuTempForFanSpeed();
|
|
@@ -2068,6 +2400,23 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (ShmLedModuleData->SelfTest_Comp == YES)
|
|
|
+ {
|
|
|
+ if (GetTimeoutValue(_led_priority_time) / 1000 >= 1000)
|
|
|
+ {
|
|
|
+ if(gunCount == 1)
|
|
|
+ {
|
|
|
+ SetLedColor(_chargingData[0], _chargingData[0]);
|
|
|
+ }
|
|
|
+ else if (gunCount == 2)
|
|
|
+ {
|
|
|
+ SetLedColor(_chargingData[0], _chargingData[1]);
|
|
|
+ }
|
|
|
+
|
|
|
+ gettimeofday(&_led_priority_time, NULL);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
usleep(10000);
|
|
|
}
|
|
|
|