|
@@ -74,6 +74,9 @@ Connector_GFD *LocaltionGfd[MAX_GROUP_QUANTITY];
|
|
|
#define VIN_MIN_VOLTAGE_UL 210 // 小於該值 : UVP
|
|
|
#define VIN_MIN_REV_VOLTAGE_UL 220 // 大於賦歸 UVP
|
|
|
|
|
|
+#define DCIN_OVP_THRESHOLD_VOL 825 // dc input ovp threshold voltage
|
|
|
+#define DCIN_OVP_RECOVERY_VOL 815 // dc input ovp recovery voltage
|
|
|
+
|
|
|
#define VIN_DROP_VOLTAGE 150 // 小於該值 : ac drop
|
|
|
|
|
|
#define VOUT_MAX_VOLTAGE 995
|
|
@@ -128,6 +131,7 @@ struct timespec _checkOutputNoneMatchTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_
|
|
|
bool _isRelayWelding[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
|
|
|
struct timespec _checkRelayWeldingTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
|
|
|
|
|
|
+byte _dcOvpCnt = 0;
|
|
|
byte _threePhaseOvp[3] = {0, 0, 0};
|
|
|
byte _threePhaseUvp[3] = {0, 0, 0};
|
|
|
|
|
@@ -137,16 +141,9 @@ int Uart5Fd;
|
|
|
char *relayRs485PortName = "/dev/ttyS5";
|
|
|
unsigned short fanSpeedSmoothValue = 500;
|
|
|
|
|
|
-//struct timeval _close_ac_contactor;
|
|
|
-
|
|
|
struct timespec _priority_time;
|
|
|
struct timespec _led_priority_time;
|
|
|
|
|
|
-//struct timeval _ac_charging_comp;
|
|
|
-//struct timeval _ac_preparing;
|
|
|
-//struct timeb _ac_startChargingTime;
|
|
|
-//struct timeb _ac_endChargingTime;
|
|
|
-
|
|
|
unsigned short _setFanSpeed = 0;
|
|
|
float _beforeChargingTotalEnergy = 0.0;
|
|
|
byte _checkLedChanged = 3;
|
|
@@ -155,6 +152,7 @@ bool _isGfdEnable = false;
|
|
|
|
|
|
Ver ver;
|
|
|
PresentInputVoltage inputVoltage;
|
|
|
+DCInputVoltage dcInputVoltage;
|
|
|
PresentOutputVoltage outputVoltage;
|
|
|
FanSpeed fanSpeed;
|
|
|
Temperature temperature;
|
|
@@ -170,12 +168,6 @@ Rtc rtc;
|
|
|
Led_Color cur_led_color;
|
|
|
Led_Color led_color;
|
|
|
|
|
|
-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
|
|
@@ -417,274 +409,300 @@ void GetPresentInputVol()
|
|
|
{
|
|
|
if(ShmChargerInfo->Control.RelayCtrl.bits.AcInputDisable == YES)
|
|
|
{
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = NO;
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = NO;
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = NO;
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = NO;
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = NO;
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = NO;
|
|
|
- return;
|
|
|
+ if(Query_DC_InputVoltage(Uart5Fd, Addr.DO360_RC1, &dcInputVoltage) == PASS)
|
|
|
+ {
|
|
|
+ ShmSysConfigAndInfo->SysInfo.InputVoltageDc = dcInputVoltage.DC_Input_1;
|
|
|
+
|
|
|
+ if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DcInputOVP == NO)
|
|
|
+ {
|
|
|
+ if(dcInputVoltage.DC_Input_1 > DCIN_OVP_THRESHOLD_VOL)
|
|
|
+ {
|
|
|
+ _dcOvpCnt++;
|
|
|
+ if(_dcOvpCnt >= OVP_UVP_CHK_COUNT)
|
|
|
+ {
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DcInputOVP = YES;
|
|
|
+ LOG_INFO("Dc Input OVP: %.1f V", dcInputVoltage.DC_Input_1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ _dcOvpCnt = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(dcInputVoltage.DC_Input_1 < DCIN_OVP_RECOVERY_VOL)
|
|
|
+ {
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DcInputOVP = NO;
|
|
|
+ LOG_INFO("Dc Input OVP Recovery: %.1f V", dcInputVoltage.DC_Input_1);
|
|
|
+ }
|
|
|
+ _dcOvpCnt = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- if (Query_Present_InputVoltage(Uart5Fd, Addr.DO360_RC1, &inputVoltage) == PASS)
|
|
|
- {
|
|
|
- // resolution : 0.1
|
|
|
- ShmSysConfigAndInfo->SysInfo.InputVoltageR = ShmRelayModuleData[0]->InputL1Volt = inputVoltage.L1N_L12;
|
|
|
- ShmSysConfigAndInfo->SysInfo.InputVoltageS = ShmRelayModuleData[0]->InputL2Volt = inputVoltage.L2N_L23;
|
|
|
- ShmSysConfigAndInfo->SysInfo.InputVoltageT = ShmRelayModuleData[0]->InputL3Volt = inputVoltage.L3N_L31;
|
|
|
-
|
|
|
- //********************************************************************************************************//
|
|
|
- // Vin (UVP)
|
|
|
- if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_IEC)
|
|
|
- {
|
|
|
- if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == NO)
|
|
|
- {
|
|
|
- if (inputVoltage.L1N_L12 <= VIN_MIN_VOLTAGE_IEC)
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (Query_Present_InputVoltage(Uart5Fd, Addr.DO360_RC1, &inputVoltage) == PASS)
|
|
|
+ {
|
|
|
+ // resolution : 0.1
|
|
|
+ ShmSysConfigAndInfo->SysInfo.InputVoltageR = ShmRelayModuleData[0]->InputL1Volt = inputVoltage.L1N_L12;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.InputVoltageS = ShmRelayModuleData[0]->InputL2Volt = inputVoltage.L2N_L23;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.InputVoltageT = ShmRelayModuleData[0]->InputL3Volt = inputVoltage.L3N_L31;
|
|
|
+
|
|
|
+ //********************************************************************************************************//
|
|
|
+ // Vin (UVP)
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_IEC)
|
|
|
+ {
|
|
|
+ if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == NO)
|
|
|
{
|
|
|
- LOG_INFO("In Uvp L1N_L12 = %f", inputVoltage.L1N_L12);
|
|
|
- if (_threePhaseUvp[0] >= OVP_UVP_CHK_COUNT)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = YES;
|
|
|
- else
|
|
|
- _threePhaseUvp[0] += 1;
|
|
|
+ if (inputVoltage.L1N_L12 < VIN_MIN_VOLTAGE_IEC)
|
|
|
+ {
|
|
|
+ LOG_INFO("In Uvp L1N_L12 = %f", inputVoltage.L1N_L12);
|
|
|
+ if (_threePhaseUvp[0] >= OVP_UVP_CHK_COUNT)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = YES;
|
|
|
+ else
|
|
|
+ _threePhaseUvp[0] += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (inputVoltage.L1N_L12 > VIN_MIN_REV_VOLTAGE_IEC)
|
|
|
+ {
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = NO;
|
|
|
+ _threePhaseUvp[0] = 0;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (inputVoltage.L1N_L12 >= VIN_MIN_REV_VOLTAGE_IEC)
|
|
|
- {
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = NO;
|
|
|
- _threePhaseUvp[0] = 0;
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == NO)
|
|
|
- {
|
|
|
- if (inputVoltage.L2N_L23 <= VIN_MIN_VOLTAGE_IEC)
|
|
|
+ if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == NO)
|
|
|
{
|
|
|
- LOG_INFO("In Uvp L2N_L23 = %f", inputVoltage.L2N_L23);
|
|
|
- if (_threePhaseUvp[1] >= OVP_UVP_CHK_COUNT)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = YES;
|
|
|
- else
|
|
|
- _threePhaseUvp[1] += 1;
|
|
|
+ if (inputVoltage.L2N_L23 < VIN_MIN_VOLTAGE_IEC)
|
|
|
+ {
|
|
|
+ LOG_INFO("In Uvp L2N_L23 = %f", inputVoltage.L2N_L23);
|
|
|
+ if (_threePhaseUvp[1] >= OVP_UVP_CHK_COUNT)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = YES;
|
|
|
+ else
|
|
|
+ _threePhaseUvp[1] += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (inputVoltage.L2N_L23 > VIN_MIN_REV_VOLTAGE_IEC)
|
|
|
+ {
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = NO;
|
|
|
+ _threePhaseUvp[1] = 0;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (inputVoltage.L2N_L23 >= VIN_MIN_REV_VOLTAGE_IEC)
|
|
|
- {
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = NO;
|
|
|
- _threePhaseUvp[1] = 0;
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == NO)
|
|
|
- {
|
|
|
- if (inputVoltage.L3N_L31 <= VIN_MIN_VOLTAGE_IEC)
|
|
|
+ if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == NO)
|
|
|
{
|
|
|
- LOG_INFO("In Uvp L3N_L31 = %f", inputVoltage.L3N_L31);
|
|
|
- if (_threePhaseUvp[2] >= OVP_UVP_CHK_COUNT)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = YES;
|
|
|
- else
|
|
|
- _threePhaseUvp[2] += 1;
|
|
|
+ if (inputVoltage.L3N_L31 < VIN_MIN_VOLTAGE_IEC)
|
|
|
+ {
|
|
|
+ LOG_INFO("In Uvp L3N_L31 = %f", inputVoltage.L3N_L31);
|
|
|
+ if (_threePhaseUvp[2] >= OVP_UVP_CHK_COUNT)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = YES;
|
|
|
+ else
|
|
|
+ _threePhaseUvp[2] += 1;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (inputVoltage.L3N_L31 >= VIN_MIN_REV_VOLTAGE_IEC)
|
|
|
- {
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = NO;
|
|
|
- _threePhaseUvp[2] = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_UL)
|
|
|
- {
|
|
|
- if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == NO)
|
|
|
- {
|
|
|
- if (inputVoltage.L1N_L12 <= VIN_MIN_VOLTAGE_UL)
|
|
|
+ else
|
|
|
{
|
|
|
- LOG_INFO("In Uvp L1N_L12 = %f", inputVoltage.L1N_L12);
|
|
|
- if (_threePhaseUvp[0] >= OVP_UVP_CHK_COUNT)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = YES;
|
|
|
- else
|
|
|
- _threePhaseUvp[0] += 1;
|
|
|
+ if (inputVoltage.L3N_L31 > VIN_MIN_REV_VOLTAGE_IEC)
|
|
|
+ {
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = NO;
|
|
|
+ _threePhaseUvp[2] = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_UL)
|
|
|
+ {
|
|
|
+ if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == NO)
|
|
|
+ {
|
|
|
+ if (inputVoltage.L1N_L12 < VIN_MIN_VOLTAGE_UL)
|
|
|
+ {
|
|
|
+ LOG_INFO("In Uvp L1N_L12 = %f", inputVoltage.L1N_L12);
|
|
|
+ if (_threePhaseUvp[0] >= OVP_UVP_CHK_COUNT)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = YES;
|
|
|
+ else
|
|
|
+ _threePhaseUvp[0] += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (inputVoltage.L1N_L12 > VIN_MIN_REV_VOLTAGE_UL)
|
|
|
+ {
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = NO;
|
|
|
+ _threePhaseUvp[0] = 0;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (inputVoltage.L1N_L12 >= VIN_MIN_REV_VOLTAGE_UL)
|
|
|
- {
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = NO;
|
|
|
- _threePhaseUvp[0] = 0;
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == NO)
|
|
|
- {
|
|
|
- if (inputVoltage.L2N_L23 <= VIN_MIN_VOLTAGE_UL)
|
|
|
+ if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == NO)
|
|
|
{
|
|
|
- LOG_INFO("In Uvp L2N_L23 = %f", inputVoltage.L2N_L23);
|
|
|
- if (_threePhaseUvp[1] >= OVP_UVP_CHK_COUNT)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = YES;
|
|
|
- else
|
|
|
- _threePhaseUvp[1] += 1;
|
|
|
+ if (inputVoltage.L2N_L23 < VIN_MIN_VOLTAGE_UL)
|
|
|
+ {
|
|
|
+ LOG_INFO("In Uvp L2N_L23 = %f", inputVoltage.L2N_L23);
|
|
|
+ if (_threePhaseUvp[1] >= OVP_UVP_CHK_COUNT)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = YES;
|
|
|
+ else
|
|
|
+ _threePhaseUvp[1] += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (inputVoltage.L2N_L23 > VIN_MIN_REV_VOLTAGE_UL)
|
|
|
+ {
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = NO;
|
|
|
+ _threePhaseUvp[1] = 0;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (inputVoltage.L2N_L23 >= VIN_MIN_REV_VOLTAGE_UL)
|
|
|
- {
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = NO;
|
|
|
- _threePhaseUvp[1] = 0;
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == NO)
|
|
|
- {
|
|
|
- if (inputVoltage.L3N_L31 <= VIN_MIN_VOLTAGE_UL)
|
|
|
+ if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == NO)
|
|
|
{
|
|
|
- LOG_INFO("In Uvp L3N_L31 = %f", inputVoltage.L3N_L31);
|
|
|
- if (_threePhaseUvp[2] >= OVP_UVP_CHK_COUNT)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = YES;
|
|
|
- else
|
|
|
- _threePhaseUvp[2] += 1;
|
|
|
+ if (inputVoltage.L3N_L31 < VIN_MIN_VOLTAGE_UL)
|
|
|
+ {
|
|
|
+ LOG_INFO("In Uvp L3N_L31 = %f", inputVoltage.L3N_L31);
|
|
|
+ if (_threePhaseUvp[2] >= OVP_UVP_CHK_COUNT)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = YES;
|
|
|
+ else
|
|
|
+ _threePhaseUvp[2] += 1;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (inputVoltage.L3N_L31 >= VIN_MIN_REV_VOLTAGE_UL)
|
|
|
- {
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = NO;
|
|
|
- _threePhaseUvp[2] = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //********************************************************************************************************//
|
|
|
- // Vin (OVP)
|
|
|
- if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_IEC)
|
|
|
- {
|
|
|
- if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP == NO)
|
|
|
- {
|
|
|
- if (inputVoltage.L1N_L12 >= VIN_MAX_VOLTAGE_IEC)
|
|
|
+ else
|
|
|
{
|
|
|
- LOG_INFO("In Ovp L1N_L12 = %f", inputVoltage.L1N_L12);
|
|
|
- if (_threePhaseOvp[0] >= OVP_UVP_CHK_COUNT)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = YES;
|
|
|
- else
|
|
|
- _threePhaseOvp[0] += 1;
|
|
|
+ if (inputVoltage.L3N_L31 > VIN_MIN_REV_VOLTAGE_UL)
|
|
|
+ {
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = NO;
|
|
|
+ _threePhaseUvp[2] = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //********************************************************************************************************//
|
|
|
+ // Vin (OVP)
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_IEC)
|
|
|
+ {
|
|
|
+ if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP == NO)
|
|
|
+ {
|
|
|
+ if (inputVoltage.L1N_L12 > VIN_MAX_VOLTAGE_IEC)
|
|
|
+ {
|
|
|
+ LOG_INFO("In Ovp L1N_L12 = %f", inputVoltage.L1N_L12);
|
|
|
+ if (_threePhaseOvp[0] >= OVP_UVP_CHK_COUNT)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = YES;
|
|
|
+ else
|
|
|
+ _threePhaseOvp[0] += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (inputVoltage.L1N_L12 < VIN_MAX_REV_VOLTAGE_IEC)
|
|
|
+ {
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = NO;
|
|
|
+ _threePhaseOvp[0] = 0;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (inputVoltage.L1N_L12 <= VIN_MAX_REV_VOLTAGE_IEC)
|
|
|
- {
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = NO;
|
|
|
- _threePhaseOvp[0] = 0;
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == NO)
|
|
|
- {
|
|
|
- if (inputVoltage.L2N_L23 >= VIN_MAX_VOLTAGE_IEC)
|
|
|
+ if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == NO)
|
|
|
{
|
|
|
- LOG_INFO("In Ovp L2N_L23 = %f", inputVoltage.L2N_L23);
|
|
|
- if (_threePhaseOvp[1] >= OVP_UVP_CHK_COUNT)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = YES;
|
|
|
- else
|
|
|
- _threePhaseOvp[1] += 1;
|
|
|
+ if (inputVoltage.L2N_L23 > VIN_MAX_VOLTAGE_IEC)
|
|
|
+ {
|
|
|
+ LOG_INFO("In Ovp L2N_L23 = %f", inputVoltage.L2N_L23);
|
|
|
+ if (_threePhaseOvp[1] >= OVP_UVP_CHK_COUNT)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = YES;
|
|
|
+ else
|
|
|
+ _threePhaseOvp[1] += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (inputVoltage.L2N_L23 < VIN_MAX_REV_VOLTAGE_IEC)
|
|
|
+ {
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = NO;
|
|
|
+ _threePhaseOvp[1] = 0;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (inputVoltage.L2N_L23 <= VIN_MAX_REV_VOLTAGE_IEC)
|
|
|
- {
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = NO;
|
|
|
- _threePhaseOvp[1] = 0;
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == NO)
|
|
|
- {
|
|
|
- if (inputVoltage.L3N_L31 >= VIN_MAX_VOLTAGE_IEC)
|
|
|
+ if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == NO)
|
|
|
{
|
|
|
- LOG_INFO("In Ovp L3N_L31 = %f", inputVoltage.L3N_L31);
|
|
|
- if (_threePhaseOvp[2] >= OVP_UVP_CHK_COUNT)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = YES;
|
|
|
- else
|
|
|
- _threePhaseOvp[2] += 1;
|
|
|
+ if (inputVoltage.L3N_L31 > VIN_MAX_VOLTAGE_IEC)
|
|
|
+ {
|
|
|
+ LOG_INFO("In Ovp L3N_L31 = %f", inputVoltage.L3N_L31);
|
|
|
+ if (_threePhaseOvp[2] >= OVP_UVP_CHK_COUNT)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = YES;
|
|
|
+ else
|
|
|
+ _threePhaseOvp[2] += 1;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (inputVoltage.L3N_L31 <= VIN_MAX_REV_VOLTAGE_IEC)
|
|
|
- {
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = NO;
|
|
|
- _threePhaseOvp[2] = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_UL)
|
|
|
- {
|
|
|
- if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP == NO)
|
|
|
- {
|
|
|
- if (inputVoltage.L1N_L12 >= VIN_MAX_VOLTAGE_UL)
|
|
|
+ else
|
|
|
{
|
|
|
- LOG_INFO("In Ovp L1N_L12 = %f", inputVoltage.L1N_L12);
|
|
|
- if (_threePhaseOvp[0] >= OVP_UVP_CHK_COUNT)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = YES;
|
|
|
- else
|
|
|
- _threePhaseOvp[0] += 0;
|
|
|
+ if (inputVoltage.L3N_L31 < VIN_MAX_REV_VOLTAGE_IEC)
|
|
|
+ {
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = NO;
|
|
|
+ _threePhaseOvp[2] = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_UL)
|
|
|
+ {
|
|
|
+ if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP == NO)
|
|
|
+ {
|
|
|
+ if (inputVoltage.L1N_L12 > VIN_MAX_VOLTAGE_UL)
|
|
|
+ {
|
|
|
+ LOG_INFO("In Ovp L1N_L12 = %f", inputVoltage.L1N_L12);
|
|
|
+ if (_threePhaseOvp[0] >= OVP_UVP_CHK_COUNT)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = YES;
|
|
|
+ else
|
|
|
+ _threePhaseOvp[0] += 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (inputVoltage.L1N_L12 < VIN_MAX_REV_VOLTAGE_UL)
|
|
|
+ {
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = NO;
|
|
|
+ _threePhaseOvp[0] = 0;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (inputVoltage.L1N_L12 <= VIN_MAX_REV_VOLTAGE_UL)
|
|
|
- {
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = NO;
|
|
|
- _threePhaseOvp[0] = 0;
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == NO)
|
|
|
- {
|
|
|
- if (inputVoltage.L2N_L23 >= VIN_MAX_VOLTAGE_UL)
|
|
|
+ if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == NO)
|
|
|
{
|
|
|
- LOG_INFO("In Ovp L2N_L23 = %f", inputVoltage.L2N_L23);
|
|
|
- if (_threePhaseOvp[1] >= OVP_UVP_CHK_COUNT)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = YES;
|
|
|
- else
|
|
|
- _threePhaseOvp[1] += 0;
|
|
|
+ if (inputVoltage.L2N_L23 > VIN_MAX_VOLTAGE_UL)
|
|
|
+ {
|
|
|
+ LOG_INFO("In Ovp L2N_L23 = %f", inputVoltage.L2N_L23);
|
|
|
+ if (_threePhaseOvp[1] >= OVP_UVP_CHK_COUNT)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = YES;
|
|
|
+ else
|
|
|
+ _threePhaseOvp[1] += 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (inputVoltage.L2N_L23 < VIN_MAX_REV_VOLTAGE_UL)
|
|
|
+ {
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = NO;
|
|
|
+ _threePhaseOvp[1] = 0;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (inputVoltage.L2N_L23 <= VIN_MAX_REV_VOLTAGE_UL)
|
|
|
- {
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = NO;
|
|
|
- _threePhaseOvp[1] = 0;
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == NO)
|
|
|
- {
|
|
|
- if (inputVoltage.L3N_L31 >= VIN_MAX_VOLTAGE_UL)
|
|
|
+ if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == NO)
|
|
|
{
|
|
|
- LOG_INFO("In Ovp L3N_L31 = %f", inputVoltage.L3N_L31);
|
|
|
- if (_threePhaseOvp[2] >= OVP_UVP_CHK_COUNT)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = YES;
|
|
|
- else
|
|
|
- _threePhaseOvp[2] += 1;
|
|
|
+ if (inputVoltage.L3N_L31 > VIN_MAX_VOLTAGE_UL)
|
|
|
+ {
|
|
|
+ LOG_INFO("In Ovp L3N_L31 = %f", inputVoltage.L3N_L31);
|
|
|
+ if (_threePhaseOvp[2] >= OVP_UVP_CHK_COUNT)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = YES;
|
|
|
+ else
|
|
|
+ _threePhaseOvp[2] += 1;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (inputVoltage.L3N_L31 <= VIN_MAX_REV_VOLTAGE_UL)
|
|
|
- {
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = NO;
|
|
|
- _threePhaseOvp[2] = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (inputVoltage.L3N_L31 < VIN_MAX_REV_VOLTAGE_UL)
|
|
|
+ {
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = NO;
|
|
|
+ _threePhaseOvp[2] = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 左右槍的 Relay 前後的輸出電壓
|
|
@@ -847,58 +865,6 @@ void CheckK1K2RelayOutput(byte index)
|
|
|
_chargingData[index]->RelayK1K2Status = LocationRelayCtrl[location]->bits.Gun_N ? YES : NO;
|
|
|
}
|
|
|
}
|
|
|
-#if 0
|
|
|
- if(ShmChargerInfo->Control.SysCtrl.bits.SecondRelayBoardEnable)
|
|
|
- {
|
|
|
- // two relay board
|
|
|
- if (index == 0)
|
|
|
- {
|
|
|
- if (regRelay[0].relay_event.bits.Gun1_N == YES && regRelay[0].relay_event.bits.Gun1_P == YES)
|
|
|
- _chargingData[index]->RelayK1K2Status = YES;
|
|
|
- else
|
|
|
- _chargingData[index]->RelayK1K2Status = NO;
|
|
|
- }
|
|
|
- else if (index == 1)
|
|
|
- {
|
|
|
- if (regRelay[1].relay_event.bits.Gun2_N == YES && regRelay[1].relay_event.bits.Gun2_P == YES)
|
|
|
- _chargingData[index]->RelayK1K2Status = YES;
|
|
|
- else
|
|
|
- _chargingData[index]->RelayK1K2Status = NO;
|
|
|
- }
|
|
|
-
|
|
|
- if (regRelay[0].relay_event.bits.Gun1_Parallel_N == YES && regRelay[0].relay_event.bits.Gun1_Parallel_P == YES &&
|
|
|
- regRelay[0].relay_event.bits.Gun2_Parallel_N == YES && regRelay[0].relay_event.bits.Gun2_Parallel_P == YES &&
|
|
|
- regRelay[1].relay_event.bits.Gun1_Parallel_N == YES && regRelay[1].relay_event.bits.Gun1_Parallel_P == YES)
|
|
|
- ShmSysConfigAndInfo->SysInfo.BridgeRelayStatus = YES;
|
|
|
- else
|
|
|
- ShmSysConfigAndInfo->SysInfo.BridgeRelayStatus = NO;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- // only one relay board
|
|
|
- if (index == 0)
|
|
|
- {
|
|
|
- if (regRelay[0].relay_event.bits.Gun1_N == YES && regRelay[0].relay_event.bits.Gun1_P == YES)
|
|
|
- _chargingData[index]->RelayK1K2Status = YES;
|
|
|
- else
|
|
|
- _chargingData[index]->RelayK1K2Status = NO;
|
|
|
- }
|
|
|
- else if (index == 1)
|
|
|
- {
|
|
|
- if (regRelay[0].relay_event.bits.Gun2_N == YES && regRelay[0].relay_event.bits.Gun2_P == YES)
|
|
|
- _chargingData[index]->RelayK1K2Status = YES;
|
|
|
- else
|
|
|
- _chargingData[index]->RelayK1K2Status = NO;
|
|
|
- }
|
|
|
-
|
|
|
- if (regRelay[0].relay_event.bits.Gun1_Parallel_N == YES && regRelay[0].relay_event.bits.Gun2_Parallel_N == YES)
|
|
|
- ShmSysConfigAndInfo->SysInfo.BridgeRelayStatus = YES;
|
|
|
- else
|
|
|
- ShmSysConfigAndInfo->SysInfo.BridgeRelayStatus = NO;
|
|
|
- }
|
|
|
-// LOG_INFO("Check Relay Output. index = %d, RelayKPK2Status = %d, BridgeRelayStatus = %d",
|
|
|
-// index, _chargingData[index]->RelayKPK2Status, ShmSysConfigAndInfo->SysInfo.BridgeRelayStatus);
|
|
|
-#endif
|
|
|
}
|
|
|
|
|
|
void GetGfdAdc(void)
|
|
@@ -974,103 +940,6 @@ void GetGfdAdc(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void GetGpioInput()
|
|
|
-{
|
|
|
- if (Query_Gpio_Input(Uart5Fd, Addr.Aux, &gpio_in) == PASS)
|
|
|
- {
|
|
|
- // AC Contactor Status
|
|
|
- if (gpio_in.AC_MainBreaker == 1)
|
|
|
- {
|
|
|
- // AC Main Breaker ON
|
|
|
- LOG_INFO("RB AC Main Breaker.");
|
|
|
- }
|
|
|
-
|
|
|
- if (gpio_in.SPD == 1)
|
|
|
- {
|
|
|
- // SPD (雷擊保護) ON
|
|
|
- LOG_INFO("RB SPD.");
|
|
|
- }
|
|
|
-
|
|
|
- if (gpio_in.Door_Open == 1)
|
|
|
- {
|
|
|
- // Door Open
|
|
|
- LOG_INFO("RB Door Open.");
|
|
|
- }
|
|
|
-
|
|
|
- if (gpio_in.GFD[0] == 1)
|
|
|
- {
|
|
|
- // GFD_1 Trigger
|
|
|
- }
|
|
|
-
|
|
|
- if (gpio_in.GFD[1] == 1)
|
|
|
- {
|
|
|
- // GFD_2 Trigger
|
|
|
- }
|
|
|
-
|
|
|
- if (gpio_in.AC_Drop == 1)
|
|
|
- {
|
|
|
- // AC Drop
|
|
|
- LOG_INFO("RB AC Drop.");
|
|
|
- }
|
|
|
-
|
|
|
- if (gpio_in.Emergency_IO == 1)
|
|
|
- {
|
|
|
- // Emergency IO ON
|
|
|
- LOG_INFO("RB Emergency IO ON.");
|
|
|
- }
|
|
|
-
|
|
|
- if (gpio_in.Button_Emergency_Press == 1)
|
|
|
- {
|
|
|
- // Emergency button Press
|
|
|
- }
|
|
|
-
|
|
|
- if (gpio_in.Button_On_Press == 1)
|
|
|
- {
|
|
|
- // On button Press
|
|
|
- }
|
|
|
-
|
|
|
- if (gpio_in.Button_Off_Press == 1)
|
|
|
- {
|
|
|
- // Off button Press
|
|
|
- }
|
|
|
-
|
|
|
- if (gpio_in.Key_1_Press == 1)
|
|
|
- {
|
|
|
- // key 1 press
|
|
|
- }
|
|
|
-
|
|
|
- if (gpio_in.Key_2_Press == 1)
|
|
|
- {
|
|
|
- // key 2 press
|
|
|
- }
|
|
|
-
|
|
|
- if (gpio_in.Key_3_Press == 1)
|
|
|
- {
|
|
|
- // key 3 press
|
|
|
- }
|
|
|
-
|
|
|
- if (gpio_in.Key_4_Press == 1)
|
|
|
- {
|
|
|
- // key 4 press
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-// 5V 12V 24V 48V
|
|
|
-void GetAuxPower()
|
|
|
-{
|
|
|
- if (Query_Aux_PowerVoltage(Uart5Fd, Addr.Fan, &auxPower) == PASS)
|
|
|
- {
|
|
|
- ShmSysConfigAndInfo->SysInfo.AuxPower48V = auxPower.voltage[0];
|
|
|
- ShmSysConfigAndInfo->SysInfo.AuxPower24V = auxPower.voltage[1];
|
|
|
- //ShmSysConfigAndInfo->SysInfo.AuxPower12V = auxPower.voltage[4];
|
|
|
- //ShmSysConfigAndInfo->SysInfo.AuxPower5V = auxPower.voltage[6];
|
|
|
- // aux power voltage
|
|
|
- //LOG_INFO("aux1 = %x,", auxPower.voltage[0]);
|
|
|
- //LOG_INFO("aux2 = %x,", auxPower.voltage[1]);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
void SetFanModuleSpeed()
|
|
|
{
|
|
|
{
|
|
@@ -1327,67 +1196,6 @@ void SetAcContactorStatus(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-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;
|
|
|
-}
|
|
|
-
|
|
|
bool IsNoneMatchLedColor()
|
|
|
{
|
|
|
bool result = false;
|
|
@@ -1550,7 +1358,6 @@ int InitShareMemory()
|
|
|
#endif
|
|
|
result = FAIL;
|
|
|
}
|
|
|
- //memset(ShmFanModuleData,0,sizeof(struct FanModuleData));
|
|
|
|
|
|
if ((MeterSMId = shmget(ShmRelayBdKey, sizeof(struct RelayModuleData), 0777)) < 0)
|
|
|
{
|
|
@@ -1566,7 +1373,6 @@ int InitShareMemory()
|
|
|
#endif
|
|
|
result = FAIL;
|
|
|
}
|
|
|
- //memset(ShmRelayModuleData[0],0,sizeof(struct RelayModuleData));
|
|
|
|
|
|
// DO360 RC2
|
|
|
if ((MeterSMId = shmget(ShmRelay2BdKey, sizeof(struct RelayModuleData), 0777)) < 0)
|
|
@@ -1583,8 +1389,6 @@ int InitShareMemory()
|
|
|
#endif
|
|
|
result = FAIL;
|
|
|
}
|
|
|
- //memset(ShmRelayModuleData[1],0,sizeof(struct RelayModuleData));
|
|
|
-
|
|
|
|
|
|
if ((MeterSMId = shmget(ShmLedBdKey, sizeof(struct LedModuleData), 0777)) < 0)
|
|
|
{
|
|
@@ -1600,7 +1404,6 @@ int InitShareMemory()
|
|
|
#endif
|
|
|
result = FAIL;
|
|
|
}
|
|
|
- //memset(ShmLedModuleData,0,sizeof(struct LedModuleData));
|
|
|
|
|
|
if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
|
|
|
{
|
|
@@ -2185,352 +1988,6 @@ void GetFanSpeedByFunction()
|
|
|
// printf("ShmFanModuleData->TestFanSpeed = %d \n", ShmFanModuleData->TestFanSpeed);
|
|
|
}
|
|
|
|
|
|
-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;
|
|
|
-
|
|
|
- ac_chargingInfo[0]->ConnectorPlugIn = acStatus.CpStatus;
|
|
|
- // LOG_INFO("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;
|
|
|
- }
|
|
|
-// else
|
|
|
-// LOG_INFO("GetAcStatus return fail. \n");
|
|
|
-}
|
|
|
-
|
|
|
-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 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 OcppStartTransation(byte gunIndex)
|
|
|
-{
|
|
|
- if(strcmp((char *)ac_chargingInfo[0]->StartUserId, "") == EQUAL)
|
|
|
- strcpy((char *)ShmOCPP16Data->StartTransaction[gunIndex].IdTag, (char *)ShmOCPP16Data->StartTransaction[gunIndex].IdTag);
|
|
|
- else
|
|
|
- strcpy((char *)ShmOCPP16Data->StartTransaction[gunIndex].IdTag, (char *)ac_chargingInfo[0]->StartUserId);
|
|
|
-
|
|
|
- LOG_INFO("AC IdTag = %s", ShmOCPP16Data->StartTransaction[gunIndex].IdTag);
|
|
|
- ShmOCPP16Data->CpMsg.bits[gunIndex].StartTransactionReq = YES;
|
|
|
-}
|
|
|
-
|
|
|
-void OcppStopTransation(byte gunIndex)
|
|
|
-{
|
|
|
- if(strcmp((char *)ac_chargingInfo[0]->StartUserId, "") == EQUAL)
|
|
|
- strcpy((char *)ShmOCPP16Data->StopTransaction[gunIndex].IdTag, (char *)ShmOCPP16Data->StopTransaction[gunIndex].IdTag);
|
|
|
- else
|
|
|
- strcpy((char *)ShmOCPP16Data->StopTransaction[gunIndex].IdTag, (char *)ac_chargingInfo[0]->StartUserId);
|
|
|
-
|
|
|
- LOG_INFO("AC IdTag = %s", ShmOCPP16Data->StopTransaction[gunIndex].IdTag);
|
|
|
- ShmOCPP16Data->CpMsg.bits[gunIndex].StopTransactionReq = YES;
|
|
|
-}
|
|
|
-
|
|
|
-bool OcppRemoteStop(byte gunIndex)
|
|
|
-{
|
|
|
- bool result = ShmOCPP16Data->CsMsg.bits[gunIndex].RemoteStopTransactionReq;
|
|
|
-
|
|
|
- if (ShmOCPP16Data->CsMsg.bits[gunIndex].RemoteStopTransactionReq == YES)
|
|
|
- {
|
|
|
- strcpy((char *)ShmOCPP16Data->StopTransaction[gunIndex].StopReason, "Remote");
|
|
|
- ShmOCPP16Data->CsMsg.bits[gunIndex].RemoteStopTransactionReq = NO;
|
|
|
- }
|
|
|
-
|
|
|
- return result;
|
|
|
-}
|
|
|
-
|
|
|
-unsigned char isModeChange()
|
|
|
-{
|
|
|
- unsigned char result = NO;
|
|
|
-
|
|
|
- if(ac_chargingInfo[0]->SystemStatus != ac_chargingInfo[0]->PreviousSystemStatus)
|
|
|
- {
|
|
|
- result = YES;
|
|
|
- ac_chargingInfo[0]->PreviousSystemStatus = ac_chargingInfo[0]->SystemStatus;
|
|
|
- }
|
|
|
-
|
|
|
- return result;
|
|
|
-}
|
|
|
-#if 0
|
|
|
-void AcChargeTypeProcess()
|
|
|
-{
|
|
|
- if (acgunCount > 0)
|
|
|
- {
|
|
|
- //ac_chargingInfo[0]->SelfTest_Comp = YES;
|
|
|
- //ac_chargingInfo[0]->IsModeChagned = PASS;
|
|
|
- //---------------------------------------------
|
|
|
- if (ac_chargingInfo[0]->SelfTest_Comp == NO)
|
|
|
- {
|
|
|
- ac_chargingInfo[0]->IsModeChagned = NO;
|
|
|
- GetFwVersion_AC();
|
|
|
- GetAcModelName();
|
|
|
- }
|
|
|
- else if (ac_chargingInfo[0]->SelfTest_Comp == YES)
|
|
|
- {
|
|
|
- if (ac_chargingInfo[0]->IsModeChagned != PASS)
|
|
|
- {
|
|
|
- ChangeToCsuMode();
|
|
|
- return;
|
|
|
- }
|
|
|
- GetAcStatus();
|
|
|
- GetAcAlarmCode();
|
|
|
-
|
|
|
- byte _status = S_NONE;
|
|
|
-
|
|
|
- if (ac_chargingInfo[0]->SystemStatus == S_IDLE && ac_chargingInfo[0]->IsErrorOccur)
|
|
|
- {
|
|
|
- _status = S_ALARM;
|
|
|
- }
|
|
|
- else 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 && acStatus.CpStatus == AC_SYS_A)
|
|
|
- _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]->ConnectorPlugIn == AC_SYS_B) &&
|
|
|
- ac_chargingInfo[0]->IsAvailable &&
|
|
|
- !ac_chargingInfo[0]->IsErrorOccur &&
|
|
|
- (ShmSysConfigAndInfo->SysInfo.WaitForPlugit == YES ||
|
|
|
- ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE))
|
|
|
- {
|
|
|
- if (ac_chargingInfo[0]->RemoteStartFlag == YES)
|
|
|
- {
|
|
|
- LOG_INFO("** AC Remote");
|
|
|
- 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)
|
|
|
- {
|
|
|
- LOG_INFO("** UserId = %s", ShmSysConfigAndInfo->SysConfig.UserId);
|
|
|
- strcpy((char *)ac_chargingInfo[0]->StartUserId, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
|
|
|
- LOG_INFO("** CardNumber = %s", ac_chargingInfo[0]->StartUserId);
|
|
|
- strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
|
|
|
- ShmSysConfigAndInfo->SysInfo.WaitForPlugit = NO;
|
|
|
- _status = S_PREPARNING;
|
|
|
- }
|
|
|
- }
|
|
|
- else if (ac_chargingInfo[0]->SystemStatus == S_CHARGING)
|
|
|
- {
|
|
|
- if (OcppRemoteStop(1))
|
|
|
- _status = S_TERMINATING;
|
|
|
- }
|
|
|
-
|
|
|
- //printf("_status = %d \n", _status);
|
|
|
-
|
|
|
- if (_status != S_NONE && ac_chargingInfo[0]->SystemStatus != _status)
|
|
|
- {
|
|
|
- ac_chargingInfo[0]->SystemStatus = _status;
|
|
|
- }
|
|
|
-
|
|
|
- // 設定限制最大充電電流 >= 6 ~ <= 32
|
|
|
- switch(ac_chargingInfo[0]->SystemStatus)
|
|
|
- {
|
|
|
- case S_IDLE:
|
|
|
- case S_ALARM:
|
|
|
- {
|
|
|
- if (isModeChange())
|
|
|
- {
|
|
|
- ac_chargingInfo[0]->PresentChargedEnergy = 0.0;
|
|
|
- ac_chargingInfo[0]->PresentChargingVoltage = 0;
|
|
|
- ac_chargingInfo[0]->ChargingFee = 0.0;
|
|
|
- strcpy((char *)ac_chargingInfo[0]->StartDateTime, "");
|
|
|
- strcpy((char *)ac_chargingInfo[0]->StopDateTime, "");
|
|
|
- _beforeChargingTotalEnergy = 0.0;
|
|
|
- }
|
|
|
-
|
|
|
- ChangeLedStatus();
|
|
|
- }
|
|
|
- break;
|
|
|
- case S_PREPARNING:
|
|
|
- {
|
|
|
- if (isModeChange())
|
|
|
- {
|
|
|
- //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;
|
|
|
- _beforeChargingTotalEnergy = acChargingEnergy.Energy;
|
|
|
- }
|
|
|
-
|
|
|
- SetLegacyReq(YES);
|
|
|
- ChangeLedStatus();
|
|
|
- }
|
|
|
- break;
|
|
|
- case S_CHARGING:
|
|
|
- {
|
|
|
- if (isModeChange())
|
|
|
- {
|
|
|
- ftime(&_ac_startChargingTime);
|
|
|
- OcppStartTransation(1);
|
|
|
- ChangeStartOrStopDateTime(YES);
|
|
|
- ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = DEFAULT_AC_INDEX;
|
|
|
- }
|
|
|
-
|
|
|
- if (GetChargingEnergy() == PASS)
|
|
|
- {
|
|
|
- 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 = (((float)(AC_DEFAULT_VOL * acChargingCurrent.OuputCurrentL1) / 10) / 1000);
|
|
|
-
|
|
|
- ftime(&_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;
|
|
|
-
|
|
|
- SetCpDuty(ShmSysConfigAndInfo->SysConfig.AcMaxChargingCurrent);
|
|
|
- ChangeLedStatus();
|
|
|
- }
|
|
|
- break;
|
|
|
- case S_TERMINATING:
|
|
|
- {
|
|
|
- if (isModeChange())
|
|
|
- {
|
|
|
- ChangeStartOrStopDateTime(NO);
|
|
|
- gettimeofday(&_ac_charging_comp, NULL);
|
|
|
- }
|
|
|
-
|
|
|
- SetLegacyReq(NO);
|
|
|
- if (acStatus.RelayStatus == NO)
|
|
|
- ac_chargingInfo[0]->SystemStatus = S_COMPLETE;
|
|
|
- }
|
|
|
- break;
|
|
|
- case S_COMPLETE:
|
|
|
- {
|
|
|
- if (isModeChange())
|
|
|
- {
|
|
|
- gettimeofday(&_ac_charging_comp, NULL);
|
|
|
- ftime(&_ac_endChargingTime);
|
|
|
- if (strcmp((char *)ac_chargingInfo[0]->StartDateTime, "") != EQUAL)
|
|
|
- {
|
|
|
- // AC 固定為第2把槍
|
|
|
- OcppStopTransation(1);
|
|
|
- }
|
|
|
-
|
|
|
- ChangeStartOrStopDateTime(NO);
|
|
|
- ac_chargingInfo[0]->PresentChargedDuration = DiffTimeb(_ac_startChargingTime, _ac_endChargingTime);
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-#endif
|
|
|
-
|
|
|
int main(void)
|
|
|
{
|
|
|
if(InitShareMemory() == FAIL)
|