|
@@ -39,6 +39,7 @@
|
|
|
#define TEN_MINUTES 600
|
|
|
#define ENV_TEMP_MIN 45
|
|
|
#define ENV_TEMP_MAX 50
|
|
|
+#define DEFAULT_AC_INDEX 2
|
|
|
|
|
|
struct SysConfigAndInfo *ShmSysConfigAndInfo;
|
|
|
struct StatusCodeData *ShmStatusCodeData;
|
|
@@ -48,16 +49,19 @@ struct CHAdeMOData *ShmCHAdeMOData;
|
|
|
struct CcsData *ShmCcsData;
|
|
|
struct PsuData *ShmPsuData;
|
|
|
|
|
|
-#define VIN_MAX_VOLTAGE 310 // 大於該值 : OVP
|
|
|
-#define VIN_MIN_VOLTAGE 150 // 小於該值 : UVP
|
|
|
+#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_DROP_VOLTAGE 150 // 小於該值 : ac drop
|
|
|
|
|
|
-#define VOUT_MAX_VOLTAGE 750
|
|
|
+#define VOUT_MAX_VOLTAGE 995
|
|
|
#define VOUT_MIN_VOLTAGE 150
|
|
|
#define IOUT_MAX_CURRENT 50
|
|
|
|
|
|
#define MAX_FAN_SPEED 13500
|
|
|
-#define MIN_FAN_SPEED 2800
|
|
|
+#define MIN_FAN_SPEED 3000
|
|
|
#define NORMAL_FAN_SPEED 7000
|
|
|
|
|
|
// GFD Status
|
|
@@ -77,8 +81,10 @@ struct PsuData *ShmPsuData;
|
|
|
#define RELAY_WELDING_DET 300
|
|
|
|
|
|
byte gunCount;
|
|
|
+byte acgunCount;
|
|
|
// 槍資訊
|
|
|
struct ChargingInfoData *_chargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
|
|
|
+struct ChargingInfoData *ac_chargingInfo[AC_QUANTITY];
|
|
|
|
|
|
bool _isOutputNoneMatch[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
|
|
|
struct timeval _checkOutputNoneMatchTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
|
|
@@ -90,14 +96,20 @@ bool FindChargingInfoData(byte target, struct ChargingInfoData **chargingData);
|
|
|
|
|
|
int Uart5Fd;
|
|
|
char *relayRs485PortName = "/dev/ttyS5";
|
|
|
-unsigned short fanSpeedSmoothValue = 1000;
|
|
|
+unsigned short fanSpeedSmoothValue = 500;
|
|
|
|
|
|
bool isStopChargingCount = false;
|
|
|
-bool isSystemBooting = false;
|
|
|
struct timeval _close_ac_contactor;
|
|
|
|
|
|
struct timeval _priority_time;
|
|
|
|
|
|
+struct timeval _ac_charging_comp;
|
|
|
+struct timeval _ac_preparing;
|
|
|
+struct timeb _ac_startChargingTime;
|
|
|
+struct timeb _ac_endChargingTime;
|
|
|
+
|
|
|
+unsigned short _setFanSpeed = 0;
|
|
|
+
|
|
|
Ver ver;
|
|
|
PresentInputVoltage inputVoltage;
|
|
|
PresentOutputVoltage outputVoltage;
|
|
@@ -112,6 +124,37 @@ Relay outputRelay;
|
|
|
Relay regRelay;
|
|
|
Rtc rtc;
|
|
|
|
|
|
+Ac_Status acStatus;
|
|
|
+Ac_Led_Status ledStatus;
|
|
|
+Ac_Alarm_code acAlarmCode;
|
|
|
+Ac_Charging_energy acChargingEnergy;
|
|
|
+Ac_Charging_current acChargingCurrent;
|
|
|
+
|
|
|
+#define AC_OVP 1
|
|
|
+#define AC_UVP 2
|
|
|
+#define AC_OCP 4
|
|
|
+#define AC_OTP 8
|
|
|
+#define AC_GMI_FAULT 16
|
|
|
+#define AC_CP_ERROR 32
|
|
|
+#define AC_AC_LEAKAGE 64
|
|
|
+#define AC_DC_LEAKAGE 128
|
|
|
+#define AC_SYSTEM_SELFTEST_FAULT 256
|
|
|
+#define AC_HANDSHAKE_TIMEOUT 512
|
|
|
+#define AC_EMC_STOP 1024
|
|
|
+#define AC_RELAY_WELDING 2048
|
|
|
+#define AC_GF_MODULE_FAULT 4096
|
|
|
+#define AC_SHUTTER_FAULT 8192
|
|
|
+#define AC_LOCKER_FAULT 16384
|
|
|
+#define AC_POWER_DROP 32768
|
|
|
+#define AC_CIRCUIT_SHORT 65536
|
|
|
+#define AC_ROTARY_SWITCH_FAULT 131072
|
|
|
+#define AC_RELAY_DRIVE_FAULT 262144
|
|
|
+
|
|
|
+int _alarm_code[] = {AC_OVP, AC_UVP, AC_OCP, AC_OTP, AC_GMI_FAULT, AC_CP_ERROR, AC_AC_LEAKAGE
|
|
|
+ , AC_DC_LEAKAGE, AC_SYSTEM_SELFTEST_FAULT, AC_HANDSHAKE_TIMEOUT, AC_EMC_STOP, AC_RELAY_WELDING
|
|
|
+ , AC_GF_MODULE_FAULT, AC_SHUTTER_FAULT, AC_LOCKER_FAULT, AC_POWER_DROP, AC_CIRCUIT_SHORT
|
|
|
+ , AC_ROTARY_SWITCH_FAULT, AC_RELAY_DRIVE_FAULT};
|
|
|
+
|
|
|
void PRINTF_FUNC(char *string, ...);
|
|
|
|
|
|
int StoreLogMsg(const char *fmt, ...);
|
|
@@ -156,11 +199,11 @@ int StoreLogMsg(const char *fmt, ...)
|
|
|
int DiffTimeb(struct timeb ST, struct timeb ET)
|
|
|
{
|
|
|
//return milli-second
|
|
|
- unsigned int StartTime,StopTime;
|
|
|
+ unsigned int StartTime, StopTime;
|
|
|
|
|
|
- StartTime=(unsigned int)ST.time;
|
|
|
- StopTime=(unsigned int)ET.time;
|
|
|
- return (StopTime-StartTime)*1000+ET.millitm-ST.millitm;
|
|
|
+ StartTime = (unsigned int) ST.time;
|
|
|
+ StopTime = (unsigned int) ET.time;
|
|
|
+ return (StopTime - StartTime);
|
|
|
}
|
|
|
|
|
|
unsigned short MaxValue(unsigned short value1, unsigned short value2)
|
|
@@ -223,6 +266,15 @@ void GetFwAndHwVersion_Relay()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void GetFwVersion_AC()
|
|
|
+{
|
|
|
+ if (Query_FW_Ver(Uart5Fd, Addr.AcPlug, &ver) == PASS)
|
|
|
+ {
|
|
|
+ ac_chargingInfo[0]->SelfTest_Comp = YES;
|
|
|
+ strcpy((char *) ac_chargingInfo[0]->version, ver.Version_FW);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void SetRtcData_Relay()
|
|
|
{
|
|
|
struct timeb csuTime;
|
|
@@ -316,38 +368,77 @@ void GetPresentInputVol()
|
|
|
ShmSysConfigAndInfo->SysInfo.InputVoltageT = ShmRelayModuleData->InputL3Volt = inputVoltage.L3N_L31;
|
|
|
|
|
|
//********************************************************************************************************//
|
|
|
- // VIN < 170
|
|
|
- if (inputVoltage.L1N_L12 < VIN_MIN_VOLTAGE)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = YES;
|
|
|
- else
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = NO;
|
|
|
+ // Vin (UVP)
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_IEC)
|
|
|
+ {
|
|
|
+ if (inputVoltage.L1N_L12 < VIN_MIN_VOLTAGE_IEC)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = YES;
|
|
|
+ else
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = NO;
|
|
|
|
|
|
- if (inputVoltage.L2N_L23 < VIN_MIN_VOLTAGE)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = YES;
|
|
|
- else
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = NO;
|
|
|
+ if (inputVoltage.L2N_L23 < VIN_MIN_VOLTAGE_IEC)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = YES;
|
|
|
+ else
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = NO;
|
|
|
|
|
|
- if (inputVoltage.L3N_L31 < VIN_MIN_VOLTAGE)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = YES;
|
|
|
- else
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = NO;
|
|
|
+ if (inputVoltage.L3N_L31 < VIN_MIN_VOLTAGE_IEC)
|
|
|
+ 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)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = YES;
|
|
|
+ else
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = NO;
|
|
|
+
|
|
|
+ if (inputVoltage.L2N_L23 < VIN_MIN_VOLTAGE_UL)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = YES;
|
|
|
+ else
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = NO;
|
|
|
|
|
|
+ if (inputVoltage.L3N_L31 < VIN_MIN_VOLTAGE_UL)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = YES;
|
|
|
+ else
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = NO;
|
|
|
+ }
|
|
|
//********************************************************************************************************//
|
|
|
- // VIN > 277
|
|
|
- if (inputVoltage.L1N_L12 > VIN_MAX_VOLTAGE)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = YES;
|
|
|
- else
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = NO;
|
|
|
+ // Vin (OVP)
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_IEC)
|
|
|
+ {
|
|
|
+ if (inputVoltage.L1N_L12 > VIN_MAX_VOLTAGE_IEC)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = YES;
|
|
|
+ else
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = NO;
|
|
|
|
|
|
- if (inputVoltage.L2N_L23 > VIN_MAX_VOLTAGE)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = YES;
|
|
|
- else
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = NO;
|
|
|
+ if (inputVoltage.L2N_L23 > VIN_MAX_VOLTAGE_IEC)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = YES;
|
|
|
+ else
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = NO;
|
|
|
|
|
|
- if (inputVoltage.L3N_L31 > VIN_MAX_VOLTAGE)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = YES;
|
|
|
- else
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = NO;
|
|
|
+ if (inputVoltage.L3N_L31 > VIN_MAX_VOLTAGE_IEC)
|
|
|
+ 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)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = YES;
|
|
|
+ else
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = NO;
|
|
|
+
|
|
|
+ if (inputVoltage.L2N_L23 > VIN_MAX_VOLTAGE_UL)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = YES;
|
|
|
+ else
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = NO;
|
|
|
+
|
|
|
+ if (inputVoltage.L3N_L31 > VIN_MAX_VOLTAGE_UL)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = YES;
|
|
|
+ else
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = NO;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -449,11 +540,21 @@ void CheckK1K2RelayOutput(byte index)
|
|
|
|
|
|
if(_chargingData[index]->Type == _Type_CCS_2)
|
|
|
{
|
|
|
+ if (gunCount == 1)
|
|
|
+ {
|
|
|
if (regRelay.relay_event.bits.Gun1_N == YES && regRelay.relay_event.bits.CCS_Precharge == YES)
|
|
|
_chargingData[index]->RelayKPK2Status = YES;
|
|
|
else
|
|
|
_chargingData[index]->RelayKPK2Status = NO;
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (_chargingData[index]->SystemStatus == S_CCS_PRECHARGE_ST0)
|
|
|
+ _chargingData[index]->RelayKPK2Status = YES;
|
|
|
+ else
|
|
|
+ _chargingData[index]->RelayKPK2Status = NO;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
else if (_chargingData[index]->Evboard_id == 0x02)
|
|
|
{
|
|
@@ -505,7 +606,7 @@ void GetGfdAdc()
|
|
|
{
|
|
|
for (int i = 0; i < gunCount; i++)
|
|
|
{
|
|
|
- if (_chargingData[i]->Type == 9)
|
|
|
+ if (_chargingData[i]->Type == 0x09 && !ShmSysConfigAndInfo->SysConfig.AlwaysGfdFlag)
|
|
|
{
|
|
|
if ((_chargingData[i]->PresentChargingVoltage * 10) >= VOUT_MIN_VOLTAGE)
|
|
|
_chargingData[i]->GroundFaultStatus = GFD_PASS;
|
|
@@ -646,78 +747,22 @@ void GetAuxPower()
|
|
|
void SetFanModuleSpeed()
|
|
|
{
|
|
|
// 調整風扇速度要漸進式 : 500 rpm/p
|
|
|
- if (ShmFanModuleData->PresentFan1Speed != ShmFanModuleData->SetFan1Speed ||
|
|
|
- ShmFanModuleData->PresentFan2Speed != ShmFanModuleData->SetFan2Speed ||
|
|
|
- ShmFanModuleData->PresentFan3Speed != ShmFanModuleData->SetFan3Speed ||
|
|
|
- ShmFanModuleData->PresentFan4Speed != ShmFanModuleData->SetFan4Speed)
|
|
|
- {
|
|
|
- //printf("ShmFanModuleData->SetFan1Speed = %d \n", ShmFanModuleData->SetFan1Speed);
|
|
|
-
|
|
|
- FanSpeed _fanSpeed;
|
|
|
-
|
|
|
- unsigned short speed = ShmFanModuleData->PresentFan1Speed + fanSpeedSmoothValue;
|
|
|
- if (speed >= ShmFanModuleData->SetFan1Speed)
|
|
|
- speed = ShmFanModuleData->SetFan1Speed;
|
|
|
- _fanSpeed.speed[0] = speed;
|
|
|
-
|
|
|
- speed = ShmFanModuleData->PresentFan2Speed + fanSpeedSmoothValue;
|
|
|
- if (speed >= ShmFanModuleData->SetFan2Speed)
|
|
|
- speed = ShmFanModuleData->SetFan2Speed;
|
|
|
- _fanSpeed.speed[1] = speed;
|
|
|
-
|
|
|
- speed = ShmFanModuleData->PresentFan3Speed + fanSpeedSmoothValue;
|
|
|
- if (speed >= ShmFanModuleData->SetFan3Speed)
|
|
|
- speed = ShmFanModuleData->SetFan3Speed;
|
|
|
- _fanSpeed.speed[2] = speed;
|
|
|
+ FanSpeed _fanSpeed;
|
|
|
|
|
|
- speed = ShmFanModuleData->PresentFan4Speed + fanSpeedSmoothValue;
|
|
|
- if (speed >= ShmFanModuleData->SetFan4Speed)
|
|
|
- speed = ShmFanModuleData->SetFan4Speed;
|
|
|
- _fanSpeed.speed[3] = speed;
|
|
|
+ _setFanSpeed += fanSpeedSmoothValue;
|
|
|
|
|
|
- if (Config_Fan_Speed(Uart5Fd, Addr.Fan, &_fanSpeed) == PASS)
|
|
|
- {
|
|
|
- //PRINTF_FUNC("successfully Fan\n");
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void SetRelayModuleFanSpeed()
|
|
|
-{
|
|
|
- // 調整風扇速度要漸進式 : 100 rpm/p
|
|
|
- if (ShmFanModuleData->PresentFan1Speed != ShmFanModuleData->SetFan1Speed)
|
|
|
+ if (_setFanSpeed >= ShmFanModuleData->SetFan1Speed)
|
|
|
+ _setFanSpeed = ShmFanModuleData->SetFan1Speed;
|
|
|
{
|
|
|
- FanSpeed _fanSpeed;
|
|
|
- unsigned short speed = 0;
|
|
|
-
|
|
|
- if (ShmFanModuleData->SetFan1Speed > ShmFanModuleData->PresentFan1Speed)
|
|
|
- {
|
|
|
- speed = ShmFanModuleData->PresentFan1Speed + fanSpeedSmoothValue;
|
|
|
- if (speed >= ShmFanModuleData->SetFan1Speed)
|
|
|
- speed = ShmFanModuleData->SetFan1Speed;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- speed = ShmFanModuleData->PresentFan1Speed - fanSpeedSmoothValue;
|
|
|
- if (speed <= 0)
|
|
|
- speed = ShmFanModuleData->SetFan1Speed;
|
|
|
- }
|
|
|
-
|
|
|
- _fanSpeed.speed[0] = speed & 0xff;
|
|
|
- _fanSpeed.speed[1] = (speed >> 8) & 0xff;
|
|
|
- ShmFanModuleData->PresentFan1Speed = speed;
|
|
|
-
|
|
|
- Config_Fan_Speed(Uart5Fd, Addr.Relay, &_fanSpeed);
|
|
|
+ _fanSpeed.speed[0] = _setFanSpeed;
|
|
|
}
|
|
|
-}
|
|
|
|
|
|
-void GetRelayModuleFanSpeed()
|
|
|
-{
|
|
|
- PRINTF_FUNC("Get fan board speed \n");
|
|
|
- if (Query_Fan_Speed(Uart5Fd, Addr.Relay, &fanSpeed) == PASS)
|
|
|
+ _fanSpeed.speed[1] = _setFanSpeed;
|
|
|
+ _fanSpeed.speed[2] = _setFanSpeed;
|
|
|
+ _fanSpeed.speed[3] = _setFanSpeed;
|
|
|
+ if (Config_Fan_Speed(Uart5Fd, Addr.Fan, &_fanSpeed) == PASS)
|
|
|
{
|
|
|
- ShmFanModuleData->PresentFan1Speed = fanSpeed.speed[0] + (fanSpeed.speed[1] >> 8);
|
|
|
- PRINTF_FUNC("SystemFanRotaSpeed_1 = %d \n", fanSpeed.speed[0]);
|
|
|
+ //PRINTF_FUNC("successfully Fan\n");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -735,7 +780,7 @@ void SetK1K2RelayStatus(byte index)
|
|
|
else if (regRelay.relay_event.bits.Gun1_N == YES)
|
|
|
outputRelay.relay_event.bits.Gun1_N = NO;
|
|
|
|
|
|
- if (_chargingData[index]->Type == _Type_CCS_2)
|
|
|
+ if (gunCount == 1 && _chargingData[index]->Type == _Type_CCS_2)
|
|
|
{
|
|
|
if(regRelay.relay_event.bits.CCS_Precharge == YES)
|
|
|
outputRelay.relay_event.bits.CCS_Precharge = NO;
|
|
@@ -759,24 +804,25 @@ void SetK1K2RelayStatus(byte index)
|
|
|
_chargingData[index]->SystemStatus <= S_CHARGING))
|
|
|
{
|
|
|
if (_chargingData[index]->RelayWeldingCheck == YES)
|
|
|
- {
|
|
|
- if (_chargingData[index]->Evboard_id == 0x01)
|
|
|
- {
|
|
|
- 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;
|
|
|
- }
|
|
|
- else if (_chargingData[index]->Evboard_id == 0x02)
|
|
|
{
|
|
|
- if(regRelay.relay_event.bits.Gun2_N == NO)
|
|
|
- outputRelay.relay_event.bits.Gun2_N = YES;
|
|
|
- else if (regRelay.relay_event.bits.Gun2_P == NO)
|
|
|
- outputRelay.relay_event.bits.Gun2_P = YES;
|
|
|
+ if (_chargingData[index]->Evboard_id == 0x01)
|
|
|
+ {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ else if (_chargingData[index]->Evboard_id == 0x02)
|
|
|
+ {
|
|
|
+ if(regRelay.relay_event.bits.Gun2_N == NO)
|
|
|
+ outputRelay.relay_event.bits.Gun2_N = YES;
|
|
|
+ else if (regRelay.relay_event.bits.Gun2_P == NO)
|
|
|
+ outputRelay.relay_event.bits.Gun2_P = YES;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- else if ((_chargingData[index]->SystemStatus >= S_TERMINATING && _chargingData[index]->SystemStatus <= S_COMPLETE))
|
|
|
+ else if ((_chargingData[index]->SystemStatus >= S_TERMINATING &&
|
|
|
+ _chargingData[index]->SystemStatus <= S_COMPLETE))
|
|
|
{
|
|
|
if ((_chargingData[index]->PresentChargingCurrent * 10) <= SEFETY_SWITCH_RELAY_CUR)
|
|
|
{
|
|
@@ -802,10 +848,13 @@ void SetK1K2RelayStatus(byte index)
|
|
|
{
|
|
|
if (_chargingData[index]->Type == _Type_CCS_2)
|
|
|
{
|
|
|
- if (regRelay.relay_event.bits.CCS_Precharge == NO)
|
|
|
- outputRelay.relay_event.bits.CCS_Precharge = YES;
|
|
|
- else if (regRelay.relay_event.bits.CCS_Precharge == YES)
|
|
|
- outputRelay.relay_event.bits.Gun1_P = NO;
|
|
|
+ if (gunCount == 1)
|
|
|
+ {
|
|
|
+ if (regRelay.relay_event.bits.CCS_Precharge == NO)
|
|
|
+ outputRelay.relay_event.bits.CCS_Precharge = YES;
|
|
|
+ else if (regRelay.relay_event.bits.CCS_Precharge == YES)
|
|
|
+ outputRelay.relay_event.bits.Gun1_P = NO;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else if (_chargingData[index]->Evboard_id == 0x02)
|
|
@@ -825,10 +874,13 @@ void SetK1K2RelayStatus(byte index)
|
|
|
{
|
|
|
if (_chargingData[index]->Type == _Type_CCS_2)
|
|
|
{
|
|
|
- if (regRelay.relay_event.bits.Gun1_P == NO)
|
|
|
- outputRelay.relay_event.bits.Gun1_P = YES;
|
|
|
- else if(regRelay.relay_event.bits.Gun1_P == YES)
|
|
|
- outputRelay.relay_event.bits.CCS_Precharge = NO;
|
|
|
+ if (gunCount == 1)
|
|
|
+ {
|
|
|
+ if (regRelay.relay_event.bits.Gun1_P == NO)
|
|
|
+ outputRelay.relay_event.bits.Gun1_P = YES;
|
|
|
+ else if(regRelay.relay_event.bits.Gun1_P == YES)
|
|
|
+ outputRelay.relay_event.bits.CCS_Precharge = NO;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else if (_chargingData[index]->Evboard_id == 0x02)
|
|
@@ -847,8 +899,8 @@ void SetK1K2RelayStatus(byte index)
|
|
|
void CheckAcInputOvpStatus(byte index)
|
|
|
{
|
|
|
if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP == YES ||
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == YES ||
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == YES)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == YES ||
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == YES)
|
|
|
{
|
|
|
_chargingData[index]->StopChargeFlag = YES;
|
|
|
}
|
|
@@ -857,8 +909,8 @@ void CheckAcInputOvpStatus(byte index)
|
|
|
void CheckPhaseLossStatus(byte index)
|
|
|
{
|
|
|
if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == YES ||
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == YES ||
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == YES)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == YES ||
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == YES)
|
|
|
{
|
|
|
_chargingData[index]->StopChargeFlag = YES;
|
|
|
}
|
|
@@ -869,7 +921,7 @@ void SetParalleRelayStatus()
|
|
|
if (gunCount >= 2 && ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == NO)
|
|
|
{
|
|
|
if (_chargingData[0]->SystemStatus == S_BOOTING || _chargingData[1]->SystemStatus == S_BOOTING ||
|
|
|
- (_chargingData[0]->SystemStatus == S_IDLE && _chargingData[1]->SystemStatus == S_IDLE))
|
|
|
+ (_chargingData[0]->SystemStatus == S_IDLE && _chargingData[1]->SystemStatus == S_IDLE))
|
|
|
{
|
|
|
// 初始化~ 不搭橋接
|
|
|
if (regRelay.relay_event.bits.Gun1_Parallel_P == YES)
|
|
@@ -880,7 +932,7 @@ void SetParalleRelayStatus()
|
|
|
else
|
|
|
{
|
|
|
if (_chargingData[0]->IsReadyToCharging == YES ||
|
|
|
- _chargingData[1]->IsReadyToCharging == YES)
|
|
|
+ _chargingData[1]->IsReadyToCharging == YES)
|
|
|
{
|
|
|
// ************需考慮在切換中 - 切開 relay 與搭回 relay 的時機點************
|
|
|
if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_MAX)
|
|
@@ -926,6 +978,67 @@ void SetParalleRelayStatus()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void CheckAlarmOccur()
|
|
|
+{
|
|
|
+ bool isErr = false;
|
|
|
+ for(byte count = 0; count < sizeof(_alarm_code)/sizeof(_alarm_code[0]); count++)
|
|
|
+ {
|
|
|
+ if (acAlarmCode.AcAlarmCode & _alarm_code[count])
|
|
|
+ {
|
|
|
+ isErr = true;
|
|
|
+ switch(_alarm_code[count])
|
|
|
+ {
|
|
|
+ case AC_OVP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcSystemInputOVP = YES; break;
|
|
|
+ case AC_UVP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcSystemInputUVP = YES; break;
|
|
|
+ case AC_OCP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP = YES; break;
|
|
|
+ case AC_OTP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAmbientOTP = YES; break;
|
|
|
+ case AC_GMI_FAULT: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcGroundfaultFail = YES; break;
|
|
|
+ case AC_CP_ERROR: ShmStatusCodeData->InfoCode.InfoEvents.bits.PilotFault = YES; break;
|
|
|
+ case AC_AC_LEAKAGE: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip = YES; break;
|
|
|
+ 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_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;
|
|
|
+ case AC_LOCKER_FAULT: ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail = YES; break;
|
|
|
+ case AC_POWER_DROP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop = YES; break;
|
|
|
+ case AC_CIRCUIT_SHORT: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShort = YES; break;
|
|
|
+ case AC_ROTARY_SWITCH_FAULT: break;
|
|
|
+ case AC_RELAY_DRIVE_FAULT: ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayDrivingFault = YES; break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ switch(_alarm_code[count])
|
|
|
+ {
|
|
|
+ case AC_OVP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcSystemInputOVP = NO; break;
|
|
|
+ case AC_UVP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcSystemInputUVP = NO; break;
|
|
|
+ case AC_OCP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP = NO; break;
|
|
|
+ case AC_OTP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAmbientOTP = NO; break;
|
|
|
+ case AC_GMI_FAULT: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcGroundfaultFail = NO; break;
|
|
|
+ case AC_CP_ERROR: ShmStatusCodeData->InfoCode.InfoEvents.bits.PilotFault = NO; break;
|
|
|
+ case AC_AC_LEAKAGE: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip = NO; break;
|
|
|
+ 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_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;
|
|
|
+ case AC_LOCKER_FAULT: ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail = NO; break;
|
|
|
+ case AC_POWER_DROP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop = NO; break;
|
|
|
+ case AC_CIRCUIT_SHORT: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShort = NO; break;
|
|
|
+ case AC_ROTARY_SWITCH_FAULT: break;
|
|
|
+ case AC_RELAY_DRIVE_FAULT: ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayDrivingFault = NO; break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ac_chargingInfo[0]->IsErrorOccur = isErr;
|
|
|
+}
|
|
|
+
|
|
|
//==========================================
|
|
|
// Init all share memory
|
|
|
//==========================================
|
|
@@ -1120,6 +1233,17 @@ bool FindChargingInfoData(byte target, struct ChargingInfoData **chargingData)
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+bool FindAcChargingInfoData(byte target, struct ChargingInfoData **acChargingData)
|
|
|
+{
|
|
|
+ if (target < AC_QUANTITY)
|
|
|
+ {
|
|
|
+ acChargingData[target] = &ShmSysConfigAndInfo->SysInfo.AcChargingData[target];
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
void Initialization()
|
|
|
{
|
|
|
bool isPass = false;
|
|
@@ -1142,6 +1266,25 @@ void Initialization()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ isPass = false;
|
|
|
+
|
|
|
+ if (acgunCount > 0)
|
|
|
+ {
|
|
|
+ while(!isPass)
|
|
|
+ {
|
|
|
+ isPass = true;
|
|
|
+ for (byte _index = 0; _index < acgunCount; _index++)
|
|
|
+ {
|
|
|
+ if (!FindAcChargingInfoData(_index, &ac_chargingInfo[0]))
|
|
|
+ {
|
|
|
+ DEBUG_ERROR("EvComm : FindAcChargingInfoData false \n");
|
|
|
+ isPass = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
bool IsNoneMatchRelayStatus()
|
|
@@ -1197,7 +1340,7 @@ void MatchRelayStatus()
|
|
|
void CheckRelayStatusByADC()
|
|
|
{
|
|
|
if (ShmRelayModuleData->Gun1FuseOutputVolt > 0 && ShmRelayModuleData->Gun1RelayOutputVolt > 0 &&
|
|
|
- (ShmRelayModuleData->Gun1FuseOutputVolt == ShmRelayModuleData->Gun1RelayOutputVolt))
|
|
|
+ (ShmRelayModuleData->Gun1FuseOutputVolt == ShmRelayModuleData->Gun1RelayOutputVolt))
|
|
|
{
|
|
|
// Relay 前後電壓一致
|
|
|
_chargingData[0]->RelayK1K2Status = 0x01;
|
|
@@ -1206,7 +1349,7 @@ void CheckRelayStatusByADC()
|
|
|
_chargingData[0]->RelayK1K2Status = 0x00;
|
|
|
|
|
|
if (ShmRelayModuleData->Gun2FuseOutputVolt > 0 && ShmRelayModuleData->Gun2RelayOutputVolt > 0 &&
|
|
|
- (ShmRelayModuleData->Gun2FuseOutputVolt == ShmRelayModuleData->Gun2RelayOutputVolt))
|
|
|
+ (ShmRelayModuleData->Gun2FuseOutputVolt == ShmRelayModuleData->Gun2RelayOutputVolt))
|
|
|
{
|
|
|
// Relay 前後電壓一致
|
|
|
_chargingData[1]->RelayK1K2Status = 0x01;
|
|
@@ -1238,13 +1381,14 @@ void CableCheckDetected(byte index)
|
|
|
// Warning : Rgfd <= 150 歐/V 假設電壓為 500V 則~ Rgfd <= 75000 歐
|
|
|
// Pre-Warning : 150 歐/V < Rgfd <= 500 歐/V 假設電壓為 500V 則 75000 歐 < Rgfd <= 250000
|
|
|
// SO Normal : Rgfd > 500 歐/V 假設電壓為 500 V 則 Rgfd > 250000 歐
|
|
|
- if (_chargingData[index]->Type >= _Type_Chademo && _chargingData[index]->Type <= _Type_GB)
|
|
|
+ if ((_chargingData[index]->Type >= _Type_Chademo && _chargingData[index]->Type <= _Type_GB) ||
|
|
|
+ (_chargingData[index]->Type == 0x09 && ShmSysConfigAndInfo->SysConfig.AlwaysGfdFlag))
|
|
|
{
|
|
|
if ((_chargingData[index]->SystemStatus >= S_PREPARING_FOR_EVSE && _chargingData[index]->SystemStatus <= S_CHARGING) ||
|
|
|
(_chargingData[index]->SystemStatus >= S_CCS_PRECHARGE_ST0 && _chargingData[index]->SystemStatus <= S_CCS_PRECHARGE_ST1))
|
|
|
{
|
|
|
if (_chargingData[index]->SystemStatus == S_PREPARING_FOR_EVSE &&
|
|
|
- _chargingData[index]->RelayWeldingCheck == YES)
|
|
|
+ _chargingData[index]->RelayWeldingCheck == YES)
|
|
|
{
|
|
|
SetGfdConfig(index, GFD_CABLECHK);
|
|
|
}
|
|
@@ -1258,7 +1402,7 @@ void CableCheckDetected(byte index)
|
|
|
if (_chargingData[index]->Type == _Type_GB)
|
|
|
SetGfdConfig(index, GFD_IDLE);
|
|
|
else
|
|
|
- SetGfdConfig(index, GFD_CHARGING);
|
|
|
+ SetGfdConfig(index, GFD_CHARGING);
|
|
|
}
|
|
|
}
|
|
|
else if(_chargingData[index]->SystemStatus == S_COMPLETE || _chargingData[index]->SystemStatus == S_PREPARNING
|
|
@@ -1275,9 +1419,9 @@ void CheckOutputPowerOverCarReq(byte index)
|
|
|
float carV = _chargingData[index]->EvBatterytargetVoltage;
|
|
|
|
|
|
if (_chargingData[index]->EvBatterytargetVoltage > 1500 &&
|
|
|
- (_chargingData[index]->Type == _Type_Chademo ||
|
|
|
- _chargingData[index]->Type == _Type_CCS_2 ||
|
|
|
- _chargingData[index]->Type == _Type_GB))
|
|
|
+ (_chargingData[index]->Type == _Type_Chademo ||
|
|
|
+ _chargingData[index]->Type == _Type_CCS_2 ||
|
|
|
+ _chargingData[index]->Type == _Type_GB))
|
|
|
{
|
|
|
if (fireV >= (carV + (carV * 0.1)))
|
|
|
{
|
|
@@ -1293,12 +1437,12 @@ void CheckOutputPowerOverCarReq(byte index)
|
|
|
void CheckOutputVolNoneMatchFire(byte index)
|
|
|
{
|
|
|
if (_chargingData[index]->EvBatterytargetVoltage > 1500 &&
|
|
|
- (_chargingData[index]->Type == _Type_Chademo ||
|
|
|
- _chargingData[index]->Type == _Type_CCS_2 ||
|
|
|
- _chargingData[index]->Type == _Type_GB))
|
|
|
+ (_chargingData[index]->Type == _Type_Chademo ||
|
|
|
+ _chargingData[index]->Type == _Type_CCS_2 ||
|
|
|
+ _chargingData[index]->Type == _Type_GB))
|
|
|
{
|
|
|
if (((_chargingData[index]->PresentChargingVoltage * 10) < _chargingData[index]->FireChargingVoltage - 300) ||
|
|
|
- ((_chargingData[index]->PresentChargingVoltage * 10) > _chargingData[index]->FireChargingVoltage + 300))
|
|
|
+ ((_chargingData[index]->PresentChargingVoltage * 10) > _chargingData[index]->FireChargingVoltage + 300))
|
|
|
{
|
|
|
if (!_isOutputNoneMatch[index])
|
|
|
{
|
|
@@ -1384,6 +1528,228 @@ void GetPsuTempForFanSpeed()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void GetAcStatus()
|
|
|
+{
|
|
|
+ if (Query_AC_Status(Uart5Fd, Addr.AcPlug, &acStatus) == PASS)
|
|
|
+ {
|
|
|
+ ShmSysConfigAndInfo->SysConfig.AcRatingCurrent = acStatus.MaxCurrent;
|
|
|
+
|
|
|
+ if(ShmSysConfigAndInfo->SysConfig.AcMaxChargingCurrent == 0)
|
|
|
+ ShmSysConfigAndInfo->SysConfig.AcMaxChargingCurrent = ShmSysConfigAndInfo->SysConfig.AcRatingCurrent;
|
|
|
+
|
|
|
+ // printf("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);
|
|
|
+ // printf("LockStatus = %d \n", acStatus.LockStatus);
|
|
|
+ // printf("RelayStatus = %d \n", acStatus.RelayStatus);
|
|
|
+ // printf("ShutterStatus = %d \n", acStatus.ShutterStatus);
|
|
|
+ // printf("MeterStatus = %d \n", acStatus.MeterStatus);
|
|
|
+ // printf("PpStatus = %d \n", acStatus.PpStatus);
|
|
|
+ // printf("MaxCurrent = %d \n", acStatus.MaxCurrent);
|
|
|
+ // printf("RotateSwitchStatus = %d \n", acStatus.RelayStatus);
|
|
|
+ // printf("============================== \n");
|
|
|
+ //
|
|
|
+ // ac_chargingInfo[0]->SystemStatus = acStatus.CpStatus;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void GetAcAlarmCode()
|
|
|
+{
|
|
|
+ if (Query_AC_Alarm_Code(Uart5Fd, Addr.AcPlug, &acAlarmCode) == PASS)
|
|
|
+ {
|
|
|
+ CheckAlarmOccur();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+unsigned char GetChargingEnergy()
|
|
|
+{
|
|
|
+ return Query_Charging_Energy(Uart5Fd, Addr.AcPlug, &acChargingEnergy);
|
|
|
+}
|
|
|
+
|
|
|
+unsigned char GetChargingCurrent()
|
|
|
+{
|
|
|
+ return Query_Charging_Current(Uart5Fd, Addr.AcPlug, &acChargingCurrent);
|
|
|
+}
|
|
|
+
|
|
|
+void ChangeLedStatus()
|
|
|
+{
|
|
|
+ if (ac_chargingInfo[0]->SystemStatus == S_IDLE)
|
|
|
+ ledStatus.ActionMode = 1;
|
|
|
+ else if (ac_chargingInfo[0]->SystemStatus == S_PREPARNING)
|
|
|
+ ledStatus.ActionMode = 3;
|
|
|
+ else if (ac_chargingInfo[0]->SystemStatus == S_CHARGING)
|
|
|
+ ledStatus.ActionMode = 4;
|
|
|
+
|
|
|
+ Config_LED_Status(Uart5Fd, Addr.AcPlug, &ledStatus);
|
|
|
+}
|
|
|
+
|
|
|
+void SetLegacyReq(byte _switch)
|
|
|
+{
|
|
|
+ Config_Legacy_Req(Uart5Fd, Addr.AcPlug, _switch);
|
|
|
+}
|
|
|
+
|
|
|
+void SetCpDuty(byte _value)
|
|
|
+{
|
|
|
+ Config_Ac_Duty(Uart5Fd, Addr.AcPlug, _value);
|
|
|
+}
|
|
|
+
|
|
|
+void ChangeToCsuMode()
|
|
|
+{
|
|
|
+ ac_chargingInfo[0]->IsModeChagned = Config_CSU_Mode(Uart5Fd, Addr.AcPlug);
|
|
|
+
|
|
|
+// if (ac_chargingInfo[0]->IsModeChagned == PASS)
|
|
|
+// {
|
|
|
+// Config_Reset_MCU(Uart5Fd, Addr.AcPlug);
|
|
|
+// }
|
|
|
+}
|
|
|
+
|
|
|
+void AcChargeTypeProcess()
|
|
|
+{
|
|
|
+ if (acgunCount > 0)
|
|
|
+ {
|
|
|
+ if (ac_chargingInfo[0]->SelfTest_Comp == NO)
|
|
|
+ {
|
|
|
+ ac_chargingInfo[0]->IsModeChagned = NO;
|
|
|
+ GetFwVersion_AC();
|
|
|
+ }
|
|
|
+ else if (ac_chargingInfo[0]->SelfTest_Comp == YES)
|
|
|
+ {
|
|
|
+ if (ac_chargingInfo[0]->IsModeChagned != PASS)
|
|
|
+ {
|
|
|
+ ChangeToCsuMode();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ GetAcStatus();
|
|
|
+ GetAcAlarmCode();
|
|
|
+
|
|
|
+ byte _status = S_NONE;
|
|
|
+ bool _isStatusChanged = false;
|
|
|
+
|
|
|
+ if (acStatus.CpStatus == AC_SYS_A || ac_chargingInfo[0]->IsErrorOccur)
|
|
|
+ {
|
|
|
+ if (ac_chargingInfo[0]->SystemStatus == S_CHARGING)
|
|
|
+ _status = S_TERMINATING;
|
|
|
+ else if (ac_chargingInfo[0]->SystemStatus >= S_TERMINATING)
|
|
|
+ {
|
|
|
+ if (GetTimeoutValue(_ac_charging_comp) >= 10000000)
|
|
|
+ _status = S_IDLE;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ _status = S_IDLE;
|
|
|
+ }
|
|
|
+ else if (ac_chargingInfo[0]->SystemStatus >= S_PREPARNING &&
|
|
|
+ ac_chargingInfo[0]->SystemStatus < S_CHARGING)
|
|
|
+ {
|
|
|
+ if (acStatus.CpStatus == AC_SYS_C && acStatus.RelayStatus == YES)
|
|
|
+ _status = S_CHARGING;
|
|
|
+ else if (GetTimeoutValue(_ac_preparing) >= 30000000)
|
|
|
+ _status = S_IDLE;
|
|
|
+ }
|
|
|
+ else if (acStatus.CpStatus == 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ //printf("_status = %d \n", _status);
|
|
|
+
|
|
|
+ if (_status != S_NONE && ac_chargingInfo[0]->SystemStatus != _status)
|
|
|
+ {
|
|
|
+ _isStatusChanged = true;
|
|
|
+ ac_chargingInfo[0]->SystemStatus = _status;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 設定限制最大充電電流 >= 6 ~ <= 32
|
|
|
+ switch(ac_chargingInfo[0]->SystemStatus)
|
|
|
+ {
|
|
|
+ case S_IDLE:
|
|
|
+ {
|
|
|
+ if (_isStatusChanged)
|
|
|
+ {
|
|
|
+ ac_chargingInfo[0]->PresentChargedEnergy = 0.0;
|
|
|
+ }
|
|
|
+
|
|
|
+ ChangeLedStatus();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case S_PREPARNING:
|
|
|
+ {
|
|
|
+ if (_isStatusChanged)
|
|
|
+ {
|
|
|
+ ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_NONE;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = DEFAULT_AC_INDEX;
|
|
|
+ gettimeofday(&_ac_preparing, NULL);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (GetChargingEnergy() == PASS)
|
|
|
+ {
|
|
|
+ ac_chargingInfo[0]->PresentChargedEnergy = acChargingEnergy.Energy / 100;
|
|
|
+ }
|
|
|
+
|
|
|
+ SetLegacyReq(YES);
|
|
|
+ ChangeLedStatus();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case S_CHARGING:
|
|
|
+ {
|
|
|
+ if (_isStatusChanged)
|
|
|
+ {
|
|
|
+ ftime(&_ac_startChargingTime);
|
|
|
+ ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = DEFAULT_AC_INDEX;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (GetChargingEnergy() == PASS)
|
|
|
+ ac_chargingInfo[0]->PresentChargedEnergy = acChargingEnergy.Energy / 100;
|
|
|
+
|
|
|
+ if (GetChargingCurrent() == PASS)
|
|
|
+ ac_chargingInfo[0]->PresentChargingPower = (220 * (acChargingCurrent.OuputCurrentL1 / 10)) / 1000;
|
|
|
+
|
|
|
+ ftime(&_ac_endChargingTime);
|
|
|
+ ac_chargingInfo[0]->RemainChargingDuration = DiffTimeb(_ac_startChargingTime, _ac_endChargingTime);
|
|
|
+
|
|
|
+ // 用以判斷是否有在輸出
|
|
|
+ ac_chargingInfo[0]->IsCharging = acStatus.RelayStatus;
|
|
|
+
|
|
|
+ SetCpDuty(ShmSysConfigAndInfo->SysConfig.AcMaxChargingCurrent);
|
|
|
+ ChangeLedStatus();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case S_TERMINATING:
|
|
|
+ {
|
|
|
+ if (_isStatusChanged)
|
|
|
+ {
|
|
|
+ gettimeofday(&_ac_charging_comp, NULL);
|
|
|
+ }
|
|
|
+
|
|
|
+ SetLegacyReq(NO);
|
|
|
+ if (acStatus.RelayStatus == NO)
|
|
|
+ ac_chargingInfo[0]->SystemStatus = S_COMPLETE;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case S_COMPLETE:
|
|
|
+ {
|
|
|
+ if (_isStatusChanged)
|
|
|
+ {
|
|
|
+ gettimeofday(&_ac_charging_comp, NULL);
|
|
|
+ ftime(&_ac_endChargingTime);
|
|
|
+ ac_chargingInfo[0]->RemainChargingDuration = DiffTimeb(_ac_startChargingTime, _ac_endChargingTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
int main(void)
|
|
|
{
|
|
|
if(InitShareMemory() == FAIL)
|
|
@@ -1400,6 +1766,7 @@ int main(void)
|
|
|
}
|
|
|
|
|
|
gunCount = ShmSysConfigAndInfo->SysConfig.TotalConnectorCount;
|
|
|
+ acgunCount = ShmSysConfigAndInfo->SysConfig.AcConnectorCount;
|
|
|
// Open Uart5 for RB
|
|
|
Uart5Fd = InitComPort();
|
|
|
Initialization();
|
|
@@ -1442,6 +1809,8 @@ int main(void)
|
|
|
gettimeofday(&_priority_time, NULL);
|
|
|
}
|
|
|
|
|
|
+ AcChargeTypeProcess();
|
|
|
+
|
|
|
if (ShmRelayModuleData->SelfTest_Comp == YES)
|
|
|
{
|
|
|
// ==============優先權最高 10 ms ==============
|
|
@@ -1451,7 +1820,8 @@ int main(void)
|
|
|
// 三相輸入電壓
|
|
|
GetPresentInputVol();
|
|
|
|
|
|
- // 讀取當前 relay 狀態
|
|
|
+ // 讀取當前 AC relay 狀態
|
|
|
+ regRelay.relay_event.bits.AC_Contactor = ShmSysConfigAndInfo->SysInfo.AcContactorStatus;
|
|
|
//GetRelayOutputStatus();
|
|
|
|
|
|
for (int i = 0; i < gunCount; i++)
|
|
@@ -1477,8 +1847,9 @@ int main(void)
|
|
|
}
|
|
|
|
|
|
if (_chargingData[i]->SystemStatus == S_BOOTING ||
|
|
|
- (_chargingData[i]->SystemStatus >= S_PREPARNING && _chargingData[i]->SystemStatus <= S_COMPLETE) ||
|
|
|
+ (_chargingData[i]->SystemStatus >= S_REASSIGN_CHECK && _chargingData[i]->SystemStatus <= S_COMPLETE) ||
|
|
|
(_chargingData[i]->SystemStatus >= S_CCS_PRECHARGE_ST0 && _chargingData[i]->SystemStatus <= S_CCS_PRECHARGE_ST1) ||
|
|
|
+ ShmSysConfigAndInfo->SysInfo.WaitForPlugit == YES ||
|
|
|
(ShmSysConfigAndInfo->SysInfo.PageIndex >= _LCM_AUTHORIZING && ShmSysConfigAndInfo->SysInfo.PageIndex <= _LCM_WAIT_FOR_PLUG))
|
|
|
{
|
|
|
_chargingData[i]->IsReadyToCharging = YES;
|
|
@@ -1511,12 +1882,6 @@ int main(void)
|
|
|
// 橋接 relay
|
|
|
SetParalleRelayStatus();
|
|
|
|
|
|
- // 搭上 AC Contactor
|
|
|
- if (isCharging)
|
|
|
- outputRelay.relay_event.bits.AC_Contactor = YES;
|
|
|
- else
|
|
|
- outputRelay.relay_event.bits.AC_Contactor = NO;
|
|
|
-
|
|
|
if (isCharging)
|
|
|
{
|
|
|
isStopChargingCount = false;
|
|
@@ -1531,8 +1896,7 @@ int main(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (!isSystemBooting ||
|
|
|
- (outputRelay.relay_event.bits.AC_Contactor == YES && GetTimeoutValue(_close_ac_contactor) / 1000 >= (TEN_MINUTES * 1000)))
|
|
|
+ if ((outputRelay.relay_event.bits.AC_Contactor == YES && GetTimeoutValue(_close_ac_contactor) / 1000 >= (TEN_MINUTES * 1000)))
|
|
|
outputRelay.relay_event.bits.AC_Contactor = NO;
|
|
|
}
|
|
|
}
|
|
@@ -1541,8 +1905,7 @@ int main(void)
|
|
|
if(IsNoneMatchRelayStatus())
|
|
|
{
|
|
|
if (Config_Relay_Output(Uart5Fd, Addr.Relay, &outputRelay))
|
|
|
- {
|
|
|
- regRelay.relay_event.bits.AC_Contactor = ShmSysConfigAndInfo->SysInfo.AcContactorStatus;
|
|
|
+ {
|
|
|
regRelay.relay_event.bits.CCS_Precharge = outputRelay.relay_event.bits.CCS_Precharge;
|
|
|
regRelay.relay_event.bits.Gun1_P = outputRelay.relay_event.bits.Gun1_P;
|
|
|
regRelay.relay_event.bits.Gun1_N = outputRelay.relay_event.bits.Gun1_N;
|
|
@@ -1571,19 +1934,16 @@ int main(void)
|
|
|
GetPsuTempForFanSpeed();
|
|
|
|
|
|
GetFanSpeed();
|
|
|
+ ShmSysConfigAndInfo->SysInfo.SystemFanRotaSpeed = _setFanSpeed;
|
|
|
+
|
|
|
gettimeofday(&_priority_time, NULL);
|
|
|
if (isCharging)
|
|
|
{
|
|
|
- if (ShmFanModuleData->PresentFan1Speed < MAX_FAN_SPEED ||
|
|
|
- ShmFanModuleData->PresentFan2Speed < MAX_FAN_SPEED ||
|
|
|
- ShmFanModuleData->PresentFan3Speed < MAX_FAN_SPEED ||
|
|
|
- ShmFanModuleData->PresentFan4Speed < MAX_FAN_SPEED)
|
|
|
- {
|
|
|
- ShmFanModuleData->SetFan1Speed = MAX_FAN_SPEED;
|
|
|
- ShmFanModuleData->SetFan2Speed = MAX_FAN_SPEED;
|
|
|
- ShmFanModuleData->SetFan3Speed = MAX_FAN_SPEED;
|
|
|
- ShmFanModuleData->SetFan4Speed = MAX_FAN_SPEED;
|
|
|
- }
|
|
|
+ // 在還沒問到 PSU 溫度~ 還是要有個最小轉速
|
|
|
+ ShmFanModuleData->SetFan1Speed = MIN_FAN_SPEED;
|
|
|
+ ShmFanModuleData->SetFan2Speed = MIN_FAN_SPEED;
|
|
|
+ ShmFanModuleData->SetFan3Speed = MIN_FAN_SPEED;
|
|
|
+ ShmFanModuleData->SetFan4Speed = MIN_FAN_SPEED;
|
|
|
|
|
|
if (ShmFanModuleData->TestFanSpeed > 0)
|
|
|
{
|
|
@@ -1595,16 +1955,10 @@ int main(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (ShmFanModuleData->PresentFan1Speed > MIN_FAN_SPEED ||
|
|
|
- ShmFanModuleData->PresentFan2Speed > MIN_FAN_SPEED ||
|
|
|
- ShmFanModuleData->PresentFan3Speed > MIN_FAN_SPEED ||
|
|
|
- ShmFanModuleData->PresentFan4Speed > MIN_FAN_SPEED)
|
|
|
- {
|
|
|
- ShmFanModuleData->SetFan1Speed = MIN_FAN_SPEED;
|
|
|
- ShmFanModuleData->SetFan2Speed = MIN_FAN_SPEED;
|
|
|
- ShmFanModuleData->SetFan3Speed = MIN_FAN_SPEED;
|
|
|
- ShmFanModuleData->SetFan4Speed = MIN_FAN_SPEED;
|
|
|
- }
|
|
|
+ ShmFanModuleData->SetFan1Speed = MIN_FAN_SPEED;
|
|
|
+ ShmFanModuleData->SetFan2Speed = MIN_FAN_SPEED;
|
|
|
+ ShmFanModuleData->SetFan3Speed = MIN_FAN_SPEED;
|
|
|
+ ShmFanModuleData->SetFan4Speed = MIN_FAN_SPEED;
|
|
|
|
|
|
// 停止時,如溫度還是很高,則需要維持該轉速直到溫度降低
|
|
|
if (ShmFanModuleData->TestFanSpeed >= MAX_FAN_SPEED)
|