|
@@ -7,7 +7,6 @@
|
|
|
#include <sys/socket.h>
|
|
|
#include <sys/ipc.h>
|
|
|
#include <sys/shm.h>
|
|
|
-#include <sys/shm.h>
|
|
|
#include <sys/mman.h>
|
|
|
#include <linux/wireless.h>
|
|
|
#include <arpa/inet.h>
|
|
@@ -15,13 +14,12 @@
|
|
|
|
|
|
#include <unistd.h>
|
|
|
#include <stdarg.h>
|
|
|
-#include <stdio.h> /*璅蹱�頛詨�頛詨枂摰𡁶儔*/
|
|
|
-#include <stdlib.h> /*璅蹱��賣彍摨怠�蝢�*/
|
|
|
-#include <unistd.h> /*Unix 璅蹱��賣彍摰𡁶儔*/
|
|
|
-#include <fcntl.h> /*瑼娍綉�嗅�蝢�*/
|
|
|
-#include <termios.h> /*PPSIX 蝯�垢�批�摰𡁶儔*/
|
|
|
-#include <errno.h> /*�航炊�笔�蝢�*/
|
|
|
-#include <errno.h>
|
|
|
+#include <stdio.h> /*標準輸入輸出定義*/
|
|
|
+#include <stdlib.h> /*標準函數庫定義*/
|
|
|
+#include <unistd.h> /*Unix 標準函數定義*/
|
|
|
+#include <fcntl.h> /*檔控制定義*/
|
|
|
+#include <termios.h> /*PPSIX 終端控制定義*/
|
|
|
+#include <errno.h> /*錯誤號定義*/
|
|
|
#include <string.h>
|
|
|
#include <time.h>
|
|
|
#include <ctype.h>
|
|
@@ -38,6 +36,7 @@
|
|
|
#define NO 0
|
|
|
#define STOP 0
|
|
|
#define START 1
|
|
|
+#define ABNORMAL 1
|
|
|
#define RELAY_CHECK_TIME 5 // s
|
|
|
#define OUTPUT_VOL_CHK_TIME 200 // ms
|
|
|
#define TEN_MINUTES 600 // s
|
|
@@ -63,19 +62,21 @@ struct RelayModuleData *ShmRelayModuleData;
|
|
|
struct LedModuleData *ShmLedModuleData;
|
|
|
struct PsuData *ShmPsuData;
|
|
|
struct OCPP16Data *ShmOCPP16Data;
|
|
|
+struct OCPP20Data *ShmOCPP20Data;
|
|
|
+struct PrimaryMcuData *ShmPrimaryMcuData;
|
|
|
struct DcCommonInformation *ShmDcCommonData;
|
|
|
|
|
|
-#define VIN_MAX_VOLTAGE_IEC 285 // 憭扳䲰閰脣�� : OVP
|
|
|
-#define VIN_MAX_REV_VOLTAGE_IEC 275 // 撠𤩺䲰鞈行飛 OVP
|
|
|
-#define VIN_MIN_VOLTAGE_IEC 160 // 撠𤩺䲰閰脣�� : UVP
|
|
|
-#define VIN_MIN_REV_VOLTAGE_IEC 170 // 憭扳䲰鞈行飛 UVP
|
|
|
+#define VIN_MAX_VOLTAGE_IEC 285 // 大於該值 : OVP
|
|
|
+#define VIN_MAX_REV_VOLTAGE_IEC 275 // 小於賦歸 OVP
|
|
|
+#define VIN_MIN_VOLTAGE_IEC 160 // 小於該值 : UVP
|
|
|
+#define VIN_MIN_REV_VOLTAGE_IEC 170 // 大於賦歸 UVP
|
|
|
|
|
|
-#define VIN_MAX_VOLTAGE_UL 315 // 憭扳䲰閰脣�� : OVP // 蝢舘� (W)
|
|
|
-#define VIN_MAX_REV_VOLTAGE_UL 305 // 撠𤩺䲰鞈行飛 OVP
|
|
|
-#define VIN_MIN_VOLTAGE_UL 210 // 撠𤩺䲰閰脣�� : UVP
|
|
|
-#define VIN_MIN_REV_VOLTAGE_UL 220 // 憭扳䲰鞈行飛 UVP
|
|
|
+#define VIN_MAX_VOLTAGE_UL 315 // 大於該值 : OVP // 美規 (W)
|
|
|
+#define VIN_MAX_REV_VOLTAGE_UL 305 // 小於賦歸 OVP
|
|
|
+#define VIN_MIN_VOLTAGE_UL 210 // 小於該值 : UVP
|
|
|
+#define VIN_MIN_REV_VOLTAGE_UL 220 // 大於賦歸 UVP
|
|
|
|
|
|
-#define VIN_DROP_VOLTAGE 150 // 撠𤩺䲰閰脣�� : ac drop
|
|
|
+#define VIN_DROP_VOLTAGE 150 // 小於該值 : ac drop
|
|
|
|
|
|
#define VOUT_MAX_VOLTAGE 995
|
|
|
#define VOUT_MIN_VOLTAGE 150
|
|
@@ -101,19 +102,19 @@ struct DcCommonInformation *ShmDcCommonData;
|
|
|
#define LED_BRIGHTNESS_LV_MID 0.5
|
|
|
#define LED_BRIGHTNESS_LV_LOW 0.2
|
|
|
|
|
|
-// ��撠誩��� Relay �餃�
|
|
|
+// 最小切換 Relay 電壓
|
|
|
#define SELF_TO_CHANGE_RELAY_STATUS 600
|
|
|
-// �誯��餃�蝣箄� Relay �臬炏�凋�����𡁻𤓖憯�
|
|
|
+// 透過電壓確認 Relay 是否搭上的依據電壓
|
|
|
#define CHECK_RELAY_STATUS 300
|
|
|
#define CHECK_RELAY_STATUS_GAP 100
|
|
|
-// 摰匧��典�甇W��餌�摨譍葉�琿� Relay ��𤓖瘚�
|
|
|
+// 安全在停止充電程序中斷開 Relay 的電流
|
|
|
#define SEFETY_SWITCH_RELAY_CUR 50
|
|
|
-// 蝣箄� Relay Welding �餃�
|
|
|
+// 確認 Relay Welding 電壓
|
|
|
#define RELAY_WELDING_DET 300
|
|
|
|
|
|
byte gunCount;
|
|
|
byte acgunCount;
|
|
|
-// 瑽滩�閮�
|
|
|
+// 槍資訊
|
|
|
struct ChargingInfoData *_chargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
|
|
|
struct ChargingInfoData *ac_chargingInfo[AC_QUANTITY];
|
|
|
|
|
@@ -277,7 +278,7 @@ void PRINTF_FUNC(char *string, ...)
|
|
|
vsnprintf(buffer, sizeof(buffer), string, args);
|
|
|
va_end(args);
|
|
|
|
|
|
- DEBUG_INFO("%s \n", buffer);
|
|
|
+ DEBUG_INFO("%s ", buffer);
|
|
|
}
|
|
|
|
|
|
//==========================================
|
|
@@ -452,7 +453,7 @@ void SetModelName_Fan()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// AC 銝厩㮾頛詨��餃�
|
|
|
+// AC 三相輸入電壓
|
|
|
void GetPresentInputVol()
|
|
|
{
|
|
|
if (Query_Present_InputVoltage(Uart5Fd, Addr.Relay, &inputVoltage) == PASS)
|
|
@@ -717,7 +718,7 @@ void GetPresentInputVol()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// 撌血𢰧瑽滨� Relay �滚���撓�粹𤓖憯�
|
|
|
+// 左右槍的 Relay 前後的輸出電壓
|
|
|
void GetPersentOutputVol()
|
|
|
{
|
|
|
if (Query_Present_OutputVoltage(Uart5Fd, Addr.Relay, &outputVoltage) == PASS)
|
|
@@ -758,8 +759,8 @@ void GetPersentOutputVol()
|
|
|
|
|
|
//unsigned short Ovp = 0;
|
|
|
//unsigned short Ocp = 0;
|
|
|
- //Ovp = MIN [VOUT_MAX_VOLTAGE, EV_BATTERY_VOLTAGE] // ��憭扯撓�粹𤓖憯栞��餅��餃���憭批��
|
|
|
- //Ocp = MIN [IOUT_MAX_CURRENT, EV_CURRENT_REQ] // ��憭扯撓�粹𤓖瘚����瘙�𤓖瘚��撠誩��
|
|
|
+ //Ovp = MIN [VOUT_MAX_VOLTAGE, EV_BATTERY_VOLTAGE] // 最大輸出電壓與電池電壓最大值
|
|
|
+ //Ocp = MIN [IOUT_MAX_CURRENT, EV_CURRENT_REQ] // 最大輸出電流與需求電流最小值
|
|
|
if (_chargingData[index]->Type == _Type_Chademo)
|
|
|
{
|
|
|
//Ovp = MaxValue(_chargingData[index]->MaximumChargingVoltage, _chargingData[index]->EvBatteryMaxVoltage);
|
|
@@ -773,7 +774,7 @@ void GetPersentOutputVol()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// 憸冽��笔漲
|
|
|
+// 風扇速度
|
|
|
void GetFanSpeed()
|
|
|
{
|
|
|
//PRINTF_FUNC("Get fan board speed \n");
|
|
@@ -792,7 +793,7 @@ void GetFanSpeed()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// 霈��� Relay ����
|
|
|
+// 讀取 Relay 狀態
|
|
|
void GetRelayOutputStatus()
|
|
|
{
|
|
|
if (Query_Relay_Output(Uart5Fd, Addr.Relay, ®Relay) == PASS)
|
|
@@ -801,7 +802,7 @@ void GetRelayOutputStatus()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// 蝣箄� K1 K2 relay �����
|
|
|
+// 確認 K1 K2 relay 的狀態
|
|
|
void CheckK1K2RelayOutput(byte index)
|
|
|
{
|
|
|
if (index == 0)
|
|
@@ -815,14 +816,14 @@ 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 (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;
|
|
@@ -840,7 +841,12 @@ void CheckK1K2RelayOutput(byte index)
|
|
|
|
|
|
if(_chargingData[index]->Type == _Type_CCS_2)
|
|
|
{
|
|
|
- if (regRelay.relay_event.bits.Gun2_N == YES && regRelay.relay_event.bits.CCS_Precharge == YES)
|
|
|
+// if (regRelay.relay_event.bits.Gun2_N == YES && regRelay.relay_event.bits.CCS_Precharge == YES)
|
|
|
+// _chargingData[index]->RelayKPK2Status = YES;
|
|
|
+// else
|
|
|
+// _chargingData[index]->RelayKPK2Status = NO;
|
|
|
+
|
|
|
+ if (_chargingData[index]->SystemStatus == S_CCS_PRECHARGE_ST0)
|
|
|
_chargingData[index]->RelayKPK2Status = YES;
|
|
|
else
|
|
|
_chargingData[index]->RelayKPK2Status = NO;
|
|
@@ -856,7 +862,12 @@ void CheckK1K2RelayOutput(byte index)
|
|
|
|
|
|
if(_chargingData[index]->Type == _Type_CCS_2)
|
|
|
{
|
|
|
- if (regRelay.relay_event.bits.Gun2_N == YES && regRelay.relay_event.bits.CCS_Precharge == YES)
|
|
|
+// if (regRelay.relay_event.bits.Gun2_N == YES && regRelay.relay_event.bits.CCS_Precharge == YES)
|
|
|
+// _chargingData[index]->RelayKPK2Status = YES;
|
|
|
+// else
|
|
|
+// _chargingData[index]->RelayKPK2Status = NO;
|
|
|
+
|
|
|
+ if (_chargingData[index]->SystemStatus == S_CCS_PRECHARGE_ST0)
|
|
|
_chargingData[index]->RelayKPK2Status = YES;
|
|
|
else
|
|
|
_chargingData[index]->RelayKPK2Status = NO;
|
|
@@ -882,9 +893,9 @@ void CheckK1K2RelayOutput(byte index)
|
|
|
|
|
|
void GetGfdAdc()
|
|
|
{
|
|
|
- // define : 瘥� 0.2 ~ 1 蝘雴�甈�
|
|
|
- // occur : <= 75k 甇𣂼� @ 150 - 750 Vdc
|
|
|
- // warning : >= 100 甇𣂼� && <= 500 甇𣂼� @ 150-750 Vdc
|
|
|
+ // define : 每 0.2 ~ 1 秒一次
|
|
|
+ // occur : <= 75k 歐姆 @ 150 - 750 Vdc
|
|
|
+ // warning : >= 100 歐姆 && <= 500 歐姆 @ 150-750 Vdc
|
|
|
if (Query_Gfd_Adc(Uart5Fd, Addr.Relay, &gfd_adc) == PASS)
|
|
|
{
|
|
|
for (int i = 0; i < gunCount; i++)
|
|
@@ -951,7 +962,7 @@ void GetGpioInput()
|
|
|
|
|
|
if (gpio_in.SPD == 1)
|
|
|
{
|
|
|
- // SPD (�瑟�靽肽風) ON
|
|
|
+ // SPD (雷擊保護) ON
|
|
|
PRINTF_FUNC("RB SPD. \n");
|
|
|
}
|
|
|
|
|
@@ -1149,68 +1160,68 @@ void SetK1K2RelayStatus(byte index)
|
|
|
}
|
|
|
else if (_chargingData[index]->SystemStatus == S_CCS_PRECHARGE_ST0)
|
|
|
{
|
|
|
- if (_chargingData[index]->Evboard_id == 0x01)
|
|
|
- {
|
|
|
- if (_chargingData[index]->Type == _Type_CCS_2)
|
|
|
- {
|
|
|
- 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)
|
|
|
- {
|
|
|
- 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.Gun2_P = NO;
|
|
|
- }
|
|
|
- }
|
|
|
+// if (_chargingData[index]->Evboard_id == 0x01)
|
|
|
+// {
|
|
|
+// if (_chargingData[index]->Type == _Type_CCS_2)
|
|
|
+// {
|
|
|
+// 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)
|
|
|
+// {
|
|
|
+// 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.Gun2_P = NO;
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
else if (_chargingData[index]->SystemStatus == S_CCS_PRECHARGE_ST1)
|
|
|
{
|
|
|
- if (_chargingData[index]->Evboard_id == 0x01)
|
|
|
- {
|
|
|
- if (_chargingData[index]->Type == _Type_CCS_2)
|
|
|
- {
|
|
|
- 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)
|
|
|
- {
|
|
|
- if (_chargingData[index]->Type == _Type_CCS_2)
|
|
|
- {
|
|
|
- if (regRelay.relay_event.bits.Gun2_P == NO)
|
|
|
- outputRelay.relay_event.bits.Gun2_P = YES;
|
|
|
- else if(regRelay.relay_event.bits.Gun2_P == YES)
|
|
|
- outputRelay.relay_event.bits.CCS_Precharge = NO;
|
|
|
- }
|
|
|
- }
|
|
|
+// if (_chargingData[index]->Evboard_id == 0x01)
|
|
|
+// {
|
|
|
+// if (_chargingData[index]->Type == _Type_CCS_2)
|
|
|
+// {
|
|
|
+// 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)
|
|
|
+// {
|
|
|
+// if (_chargingData[index]->Type == _Type_CCS_2)
|
|
|
+// {
|
|
|
+// if (regRelay.relay_event.bits.Gun2_P == NO)
|
|
|
+// outputRelay.relay_event.bits.Gun2_P = YES;
|
|
|
+// else if(regRelay.relay_event.bits.Gun2_P == YES)
|
|
|
+// outputRelay.relay_event.bits.CCS_Precharge = NO;
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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[0]->SystemStatus == S_MAINTAIN) &&
|
|
|
(_chargingData[1]->SystemStatus == S_IDLE || _chargingData[1]->SystemStatus == S_MAINTAIN)))
|
|
|
{
|
|
|
- // �嘥��𤦸 銝齿𨰹璈𧢲𦻖
|
|
|
+ // 初始化~ 不搭橋接
|
|
|
if (regRelay.relay_event.bits.Gun1_Parallel_P == YES)
|
|
|
outputRelay.relay_event.bits.Gun1_Parallel_P = NO;
|
|
|
else if (regRelay.relay_event.bits.Gun1_Parallel_N == YES)
|
|
@@ -1221,12 +1232,12 @@ void SetParalleRelayStatus()
|
|
|
if (_chargingData[0]->IsReadyToCharging == YES ||
|
|
|
_chargingData[1]->IsReadyToCharging == YES)
|
|
|
{
|
|
|
- // ************������典��𥕢葉 - ��� relay ��𨰹�� relay ���璈罸�************
|
|
|
+ // ************需考慮在切換中 - 切開 relay 與搭回 relay 的時機點************
|
|
|
if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_MAX)
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag < _REASSIGNED_RELAY_M_TO_A)
|
|
|
{
|
|
|
- // ��憭批� - �凋�璈𧢲𦻖
|
|
|
+ // 最大充 - 搭上橋接
|
|
|
if (regRelay.relay_event.bits.Gun1_Parallel_N == NO)
|
|
|
outputRelay.relay_event.bits.Gun1_Parallel_N = YES;
|
|
|
else if (regRelay.relay_event.bits.Gun1_Parallel_P == NO)
|
|
@@ -1234,7 +1245,7 @@ void SetParalleRelayStatus()
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- // 撟喳��� - 銝齿𨰹
|
|
|
+ // 平均充 - 不搭
|
|
|
if (regRelay.relay_event.bits.Gun1_Parallel_P == YES)
|
|
|
outputRelay.relay_event.bits.Gun1_Parallel_P = NO;
|
|
|
else if (regRelay.relay_event.bits.Gun1_Parallel_N == YES)
|
|
@@ -1245,7 +1256,7 @@ void SetParalleRelayStatus()
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag < _REASSIGNED_RELAY_A_TO_M)
|
|
|
{
|
|
|
- // 撟喳��� - 銝齿𨰹
|
|
|
+ // 平均充 - 不搭
|
|
|
if (regRelay.relay_event.bits.Gun1_Parallel_P == YES)
|
|
|
outputRelay.relay_event.bits.Gun1_Parallel_P = NO;
|
|
|
else if (regRelay.relay_event.bits.Gun1_Parallel_N == YES)
|
|
@@ -1253,7 +1264,7 @@ void SetParalleRelayStatus()
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- // ��憭批� - �凋�璈𧢲𦻖
|
|
|
+ // 最大充 - 搭上橋接
|
|
|
if (regRelay.relay_event.bits.Gun1_Parallel_N == NO)
|
|
|
outputRelay.relay_event.bits.Gun1_Parallel_N = YES;
|
|
|
else if (regRelay.relay_event.bits.Gun1_Parallel_P == NO)
|
|
@@ -1365,8 +1376,8 @@ void SetLedColor(struct ChargingInfoData *chargingData_1, struct ChargingInfoDat
|
|
|
{
|
|
|
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))
|
|
|
+ if ((chargingData_1->SystemStatus == S_BOOTING || chargingData_1->SystemStatus == S_IDLE || chargingData_1->SystemStatus == S_RESERVATION || chargingData_1->SystemStatus == S_MAINTAIN) &&
|
|
|
+ (chargingData_2->SystemStatus == S_BOOTING || chargingData_2->SystemStatus == S_IDLE || chargingData_2->SystemStatus == S_RESERVATION || chargingData_2->SystemStatus == S_MAINTAIN))
|
|
|
{
|
|
|
led_color.Connect_1_Green = _colorBuf;
|
|
|
led_color.Connect_1_Blue = COLOR_MIN_LV;
|
|
@@ -1390,7 +1401,10 @@ void SetLedColor(struct ChargingInfoData *chargingData_1, struct ChargingInfoDat
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (chargingData_1->SystemStatus == S_BOOTING || chargingData_1->SystemStatus == S_IDLE || chargingData_1->SystemStatus == S_RESERVATION)
|
|
|
+ if (chargingData_1->SystemStatus == S_BOOTING ||
|
|
|
+ chargingData_1->SystemStatus == S_IDLE ||
|
|
|
+ chargingData_1->SystemStatus == S_RESERVATION ||
|
|
|
+ chargingData_1->SystemStatus == S_MAINTAIN)
|
|
|
{
|
|
|
led_color.Connect_1_Green = _colorBuf;
|
|
|
led_color.Connect_1_Blue = COLOR_MIN_LV;
|
|
@@ -1405,7 +1419,10 @@ void SetLedColor(struct ChargingInfoData *chargingData_1, struct ChargingInfoDat
|
|
|
}
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
- if (chargingData_2->SystemStatus == S_BOOTING || chargingData_2->SystemStatus == S_IDLE || chargingData_2->SystemStatus == S_RESERVATION)
|
|
|
+ if (chargingData_2->SystemStatus == S_BOOTING ||
|
|
|
+ chargingData_2->SystemStatus == S_IDLE ||
|
|
|
+ chargingData_2->SystemStatus == S_RESERVATION ||
|
|
|
+ chargingData_2->SystemStatus == S_MAINTAIN)
|
|
|
{
|
|
|
led_color.Connect_2_Green = _colorBuf;
|
|
|
led_color.Connect_2_Blue = COLOR_MIN_LV;
|
|
@@ -1554,6 +1571,36 @@ int InitShareMemory()
|
|
|
result = FAIL;
|
|
|
}
|
|
|
|
|
|
+ if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), IPC_CREAT | 0777)) < 0)
|
|
|
+ {
|
|
|
+ #ifdef SystemLogMessage
|
|
|
+ DEBUG_ERROR("shmat ShmOCPP20Data NG \n");
|
|
|
+ #endif
|
|
|
+ result = FAIL;
|
|
|
+ }
|
|
|
+ else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
|
|
|
+ {
|
|
|
+ #ifdef SystemLogMessage
|
|
|
+ DEBUG_ERROR("shmat ShmOCPP20Data NG \n");
|
|
|
+ #endif
|
|
|
+ result = FAIL;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((MeterSMId = shmget(ShmPrimaryMcuKey, sizeof(struct PrimaryMcuData), 0777)) < 0)
|
|
|
+ {
|
|
|
+ #ifdef SystemLogMessage
|
|
|
+ DEBUG_ERROR("shmget ShmPrimaryMcuData NG\n");
|
|
|
+ #endif
|
|
|
+ result = FAIL;
|
|
|
+ }
|
|
|
+ else if ((ShmPrimaryMcuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
|
|
|
+ {
|
|
|
+ #ifdef ShmPrimaryMcuData
|
|
|
+ DEBUG_ERROR("shmat ShmPrimaryMcuData NG\n");
|
|
|
+ #endif
|
|
|
+ result = FAIL;
|
|
|
+ }
|
|
|
+
|
|
|
if ((MeterSMId = shmget(ShmCommonKey, sizeof(struct DcCommonInformation), IPC_CREAT | 0777)) < 0)
|
|
|
{
|
|
|
#ifdef SystemLogMessage
|
|
@@ -1604,6 +1651,85 @@ int InitComPort()
|
|
|
return fd;
|
|
|
}
|
|
|
|
|
|
+//===============================================
|
|
|
+// OCPP routine
|
|
|
+//===============================================
|
|
|
+void ocpp_startTransation_cmd(byte gunIndex)
|
|
|
+{
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
|
|
|
+ {
|
|
|
+ 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);
|
|
|
+
|
|
|
+ PRINTF_FUNC("AC IdTag = %s \n", ShmOCPP16Data->StartTransaction[gunIndex].IdTag);
|
|
|
+ ShmOCPP16Data->CpMsg.bits[gunIndex].StartTransactionReq = YES;
|
|
|
+ }
|
|
|
+ else if (ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
|
|
|
+ {
|
|
|
+ if(strcmp((char *)ac_chargingInfo[0]->StartUserId, "") == EQUAL)
|
|
|
+ strcpy((char *)ShmOCPP20Data->TransactionEvent[gunIndex].idToken.idToken, (char *)ShmOCPP20Data->TransactionEvent[gunIndex].idToken.idToken);
|
|
|
+ else
|
|
|
+ strcpy((char *)ShmOCPP20Data->TransactionEvent[gunIndex].idToken.idToken, (char *)ac_chargingInfo[0]->StartUserId);
|
|
|
+
|
|
|
+ PRINTF_FUNC("AC IdTag = %s \n", ShmOCPP20Data->TransactionEvent[gunIndex].idToken.idToken);
|
|
|
+ ShmOCPP20Data->CpMsg.bits[gunIndex].TransactionEventReq = YES;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void ocpp_stopTransation_cmd(byte gunIndex)
|
|
|
+{
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
|
|
|
+ {
|
|
|
+ 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);
|
|
|
+
|
|
|
+ PRINTF_FUNC("AC IdTag = %s \n", ShmOCPP16Data->StopTransaction[gunIndex].IdTag);
|
|
|
+ ShmOCPP16Data->CpMsg.bits[gunIndex].StopTransactionReq = YES;
|
|
|
+ }
|
|
|
+ else if (ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
|
|
|
+ {
|
|
|
+ if(strcmp((char *)ac_chargingInfo[0]->StartUserId, "") == EQUAL)
|
|
|
+ strcpy((char *)ShmOCPP20Data->TransactionEvent[gunIndex].idToken.idToken, (char *)ShmOCPP20Data->TransactionEvent[gunIndex].idToken.idToken);
|
|
|
+ else
|
|
|
+ strcpy((char *)ShmOCPP20Data->TransactionEvent[gunIndex].idToken.idToken, (char *)ac_chargingInfo[0]->StartUserId);
|
|
|
+
|
|
|
+ PRINTF_FUNC("AC IdTag = %s \n", ShmOCPP20Data->TransactionEvent[gunIndex].idToken.idToken);
|
|
|
+ ShmOCPP20Data->CpMsg.bits[gunIndex].TransactionEventReq = YES;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+bool ocpp_remoteStopReq_cmd(byte gunIndex)
|
|
|
+{
|
|
|
+ bool result = false;
|
|
|
+
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
|
|
|
+ {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
|
|
|
+ {
|
|
|
+ result = ShmOCPP20Data->CsMsg.bits[gunIndex].RequestStopTransactionReq;
|
|
|
+
|
|
|
+ if (ShmOCPP20Data->CsMsg.bits[gunIndex].RequestStopTransactionReq == YES)
|
|
|
+ {
|
|
|
+ strcpy((char *)ShmOCPP20Data->TransactionEvent[gunIndex].transactionInfo.stoppedReason, "Remote");
|
|
|
+ ShmOCPP20Data->CsMsg.bits[gunIndex].RequestStopTransactionReq = NO;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
//================================================
|
|
|
// Main process
|
|
|
//================================================
|
|
@@ -1817,7 +1943,7 @@ bool IsNoneMatchRelayStatus()
|
|
|
|
|
|
void MatchRelayStatus()
|
|
|
{
|
|
|
- // �删� AC Contactor 瘝埝� Feedback嚗峕�隞交麱����蹱見�閧�
|
|
|
+ // 因為 AC Contactor 沒有 Feedback,所以暫時先這樣處理
|
|
|
//regRelay.relay_event.bits.AC_Contactor = outputRelay.relay_event.bits.AC_Contactor;
|
|
|
ShmSysConfigAndInfo->SysInfo.AcContactorStatus = regRelay.relay_event.bits.AC_Contactor = outputRelay.relay_event.bits.AC_Contactor;
|
|
|
regRelay.relay_event.bits.CCS_Precharge = outputRelay.relay_event.bits.CCS_Precharge;
|
|
@@ -1834,7 +1960,7 @@ void CheckRelayStatusByADC()
|
|
|
if (ShmRelayModuleData->Gun1FuseOutputVolt > 0 && ShmRelayModuleData->Gun1RelayOutputVolt > 0 &&
|
|
|
(ShmRelayModuleData->Gun1FuseOutputVolt == ShmRelayModuleData->Gun1RelayOutputVolt))
|
|
|
{
|
|
|
- // Relay �滚��餃�銝���
|
|
|
+ // Relay 前後電壓一致
|
|
|
_chargingData[0]->RelayK1K2Status = 0x01;
|
|
|
}
|
|
|
else
|
|
@@ -1843,7 +1969,7 @@ void CheckRelayStatusByADC()
|
|
|
if (ShmRelayModuleData->Gun2FuseOutputVolt > 0 && ShmRelayModuleData->Gun2RelayOutputVolt > 0 &&
|
|
|
(ShmRelayModuleData->Gun2FuseOutputVolt == ShmRelayModuleData->Gun2RelayOutputVolt))
|
|
|
{
|
|
|
- // Relay �滚��餃�銝���
|
|
|
+ // Relay 前後電壓一致
|
|
|
_chargingData[1]->RelayK1K2Status = 0x01;
|
|
|
}
|
|
|
else
|
|
@@ -1867,12 +1993,12 @@ void SetGfdConfig(byte index, byte resister)
|
|
|
void CableCheckDetected(byte index)
|
|
|
{
|
|
|
// Cable Check
|
|
|
- // �嗥�蝺帋���𤓖憯� = 頠羓垢閬����𤓖憯㯄𤓖瘚�
|
|
|
+ // 當火線上的電壓 = 車端要求的電壓電流
|
|
|
// _chargingData[targetGun]->EvBatterytargetVoltage
|
|
|
- // �滚虾隞仿�憪见�皜� 1s
|
|
|
- // 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 甇�
|
|
|
+ // 才可以開始偵測 1s
|
|
|
+ // 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) ||
|
|
|
(_chargingData[index]->Type == 0x09 && ShmSysConfigAndInfo->SysConfig.AlwaysGfdFlag))
|
|
|
{
|
|
@@ -1936,11 +2062,23 @@ void CheckOutputPowerOverCarReq(byte index)
|
|
|
_chargingData[index]->FireChargingVoltage, (_chargingData[index]->EvBatterytargetVoltage * 10), carV);
|
|
|
|
|
|
if (_chargingData[index]->Type == _Type_Chademo)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemChademoOutputOVP = YES;
|
|
|
+ {
|
|
|
+ ShmDcCommonData->ConnectErrList[index].GunBits.ChaConnectOVP = YES;
|
|
|
+ if (strncmp((char *)_chargingData[index]->ConnectorAlarmCode, "", 6) == EQUAL)
|
|
|
+ memcpy(_chargingData[index]->ConnectorAlarmCode, "012217", 6);
|
|
|
+ }
|
|
|
else if (_chargingData[index]->Type == _Type_CCS_2)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemCcsOutputOVP = YES;
|
|
|
+ {
|
|
|
+ ShmDcCommonData->ConnectErrList[index].GunBits.CCSConnectOVP = YES;
|
|
|
+ if (strncmp((char *)_chargingData[index]->ConnectorAlarmCode, "", 6) == EQUAL)
|
|
|
+ memcpy(_chargingData[index]->ConnectorAlarmCode, "012219", 6);
|
|
|
+ }
|
|
|
else if (_chargingData[index]->Type == _Type_GB)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemGbOutputOVP = YES;
|
|
|
+ {
|
|
|
+ ShmDcCommonData->ConnectErrList[index].GunBits.GBTConnectOVP = YES;
|
|
|
+ if (strncmp((char *)_chargingData[index]->ConnectorAlarmCode, "", 6) == EQUAL)
|
|
|
+ memcpy(_chargingData[index]->ConnectorAlarmCode, "012221", 6);
|
|
|
+ }
|
|
|
|
|
|
_chargingData[index]->StopChargeFlag = YES;
|
|
|
}
|
|
@@ -1951,45 +2089,45 @@ void CheckOutputPowerOverCarReq(byte index)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void CheckOutputVolNoneMatchFire(byte index)
|
|
|
-{
|
|
|
- if ((_chargingData[index]->EvBatterytargetVoltage * 10) > 1500 &&
|
|
|
- (_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))
|
|
|
- {
|
|
|
- if (!_isOutputNoneMatch[index])
|
|
|
- {
|
|
|
- _isOutputNoneMatch[index] = YES;
|
|
|
- gettimeofday(&_checkOutputNoneMatchTimer[index], NULL);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if ((GetTimeoutValue(_checkOutputNoneMatchTimer[index]) / 1000) >= 5000)
|
|
|
- {
|
|
|
- PRINTF_FUNC("[Module_InternalComm]CheckOutputVolNoneMatchFire NG (%d) : pre = %f, fire = %f \n",
|
|
|
- index, (_chargingData[index]->PresentChargingVoltage * 10), _chargingData[index]->FireChargingVoltage);
|
|
|
- DEBUG_ERROR("[Module_InternalComm]CheckOutputVolNoneMatchFire NG (%d): pre = %f, fire = %f \n",
|
|
|
- index, (_chargingData[index]->PresentChargingVoltage * 10), _chargingData[index]->FireChargingVoltage);
|
|
|
-
|
|
|
- if (_chargingData[index]->Type == _Type_Chademo)
|
|
|
- ShmStatusCodeData->FaultCode.FaultEvents.bits.ChademoOutputRelayDrivingFault = YES;
|
|
|
- else if (_chargingData[index]->Type == _Type_GB)
|
|
|
- ShmStatusCodeData->FaultCode.FaultEvents.bits.GbOutputRelayDrivingFault = YES;
|
|
|
- else if (_chargingData[index]->Type == _Type_CCS_2)
|
|
|
- ShmStatusCodeData->FaultCode.FaultEvents.bits.CcsOutputRelayDrivingFault = YES;
|
|
|
-
|
|
|
- _chargingData[index]->StopChargeFlag = YES;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- _isOutputNoneMatch[index] = NO;
|
|
|
- }
|
|
|
-}
|
|
|
+//void CheckOutputVolNoneMatchFire(byte index)
|
|
|
+//{
|
|
|
+// if ((_chargingData[index]->EvBatterytargetVoltage * 10) > 1500 &&
|
|
|
+// (_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))
|
|
|
+// {
|
|
|
+// if (!_isOutputNoneMatch[index])
|
|
|
+// {
|
|
|
+// _isOutputNoneMatch[index] = YES;
|
|
|
+// gettimeofday(&_checkOutputNoneMatchTimer[index], NULL);
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// if ((GetTimeoutValue(_checkOutputNoneMatchTimer[index]) / 1000) >= 5000)
|
|
|
+// {
|
|
|
+// PRINTF_FUNC("[Module_InternalComm]CheckOutputVolNoneMatchFire NG (%d) : pre = %f, fire = %f \n",
|
|
|
+// index, (_chargingData[index]->PresentChargingVoltage * 10), _chargingData[index]->FireChargingVoltage);
|
|
|
+// DEBUG_ERROR("[Module_InternalComm]CheckOutputVolNoneMatchFire NG (%d): pre = %f, fire = %f \n",
|
|
|
+// index, (_chargingData[index]->PresentChargingVoltage * 10), _chargingData[index]->FireChargingVoltage);
|
|
|
+//
|
|
|
+// if (_chargingData[index]->Type == _Type_Chademo)
|
|
|
+// ShmStatusCodeData->FaultCode.FaultEvents.bits.ChademoOutputRelayDrivingFault = YES;
|
|
|
+// else if (_chargingData[index]->Type == _Type_GB)
|
|
|
+// ShmStatusCodeData->FaultCode.FaultEvents.bits.GbOutputRelayDrivingFault = YES;
|
|
|
+// else if (_chargingData[index]->Type == _Type_CCS_2)
|
|
|
+// ShmStatusCodeData->FaultCode.FaultEvents.bits.CcsOutputRelayDrivingFault = YES;
|
|
|
+//
|
|
|
+// _chargingData[index]->StopChargeFlag = YES;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// else
|
|
|
+// _isOutputNoneMatch[index] = NO;
|
|
|
+// }
|
|
|
+//}
|
|
|
|
|
|
void CheckRelayWeldingStatus(byte index)
|
|
|
{
|
|
@@ -2058,18 +2196,18 @@ void GetPsuTempForFanSpeed()
|
|
|
|
|
|
void GetFanSpeedByFunction()
|
|
|
{
|
|
|
- // 憸冽綉靽格㺿 :
|
|
|
+ // 風控修改 :
|
|
|
// ******************************************************* //
|
|
|
//
|
|
|
- // �嗅�PSU頛詨枂蝮� KW PSU Temp
|
|
|
+ // 當前PSU輸出總 KW PSU Temp
|
|
|
// 50 x -------------------- x ---------- + 0.5 x (PSU Temp - 70)
|
|
|
- // �嗅�璅��憭批��� KW 50
|
|
|
+ // 當前樁最大功率 KW 50
|
|
|
//
|
|
|
// ******************************************************* //
|
|
|
|
|
|
- // �嗅�璅��憭批��� KW : ShmPsuData->SystemAvailablePower
|
|
|
+ // 當前樁最大功率 KW : ShmPsuData->SystemAvailablePower
|
|
|
unsigned int _maxPower = ShmPsuData->SystemAvailablePower;
|
|
|
- // �嗅�PSU頛詨枂蝮� KW & PSU Temp :
|
|
|
+ // 當前PSU輸出總 KW & PSU Temp :
|
|
|
unsigned char temp = 0;
|
|
|
float power = 0;
|
|
|
|
|
@@ -2097,7 +2235,7 @@ void GetFanSpeedByFunction()
|
|
|
if (temp > 70)
|
|
|
_temp_diff = temp - 70;
|
|
|
|
|
|
- // debug mode �湔𦻖�啣枂鞈��敺屸𣪧��
|
|
|
+ // debug mode 直接印出資訊後離開
|
|
|
if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES)
|
|
|
{
|
|
|
// printf("Fan Speed Information: power = %f, _maxPower = %d, temp = %d -- _pw_rate = %f, _temp_rate = %f, _temp_diff = %d \n",
|
|
@@ -2224,37 +2362,17 @@ void ChangeStartOrStopDateTime(byte isStart)
|
|
|
|
|
|
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);
|
|
|
-
|
|
|
- PRINTF_FUNC("AC IdTag = %s \n", ShmOCPP16Data->StartTransaction[gunIndex].IdTag);
|
|
|
- ShmOCPP16Data->CpMsg.bits[gunIndex].StartTransactionReq = YES;
|
|
|
+ ocpp_startTransation_cmd(gunIndex);
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
-
|
|
|
- PRINTF_FUNC("AC IdTag = %s \n", ShmOCPP16Data->StopTransaction[gunIndex].IdTag);
|
|
|
- ShmOCPP16Data->CpMsg.bits[gunIndex].StopTransactionReq = YES;
|
|
|
+ ocpp_stopTransation_cmd(gunIndex);
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
+ return ocpp_remoteStopReq_cmd(gunIndex);
|
|
|
}
|
|
|
|
|
|
unsigned char isModeChange()
|
|
@@ -2356,7 +2474,7 @@ void AcChargeTypeProcess()
|
|
|
ac_chargingInfo[0]->SystemStatus = _status;
|
|
|
}
|
|
|
|
|
|
- // 閮剖��𣂼���憭批��駁𤓖瘚� >= 6 ~ <= 32
|
|
|
+ // 設定限制最大充電電流 >= 6 ~ <= 32
|
|
|
switch(ac_chargingInfo[0]->SystemStatus)
|
|
|
{
|
|
|
case S_IDLE:
|
|
@@ -2428,7 +2546,7 @@ void AcChargeTypeProcess()
|
|
|
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);
|
|
@@ -2456,7 +2574,7 @@ void AcChargeTypeProcess()
|
|
|
ftime(&_ac_endChargingTime);
|
|
|
if (strcmp((char *)ac_chargingInfo[0]->StartDateTime, "") != EQUAL)
|
|
|
{
|
|
|
- // AC �箏��箇洵2�𦠜�
|
|
|
+ // AC 固定為第2把槍
|
|
|
OcppStopTransation(1);
|
|
|
}
|
|
|
|
|
@@ -2470,25 +2588,6 @@ void AcChargeTypeProcess()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void ResetDetAlarmStatus(byte gun)
|
|
|
-{
|
|
|
- if (_chargingData[gun]->Type == _Type_Chademo)
|
|
|
- {
|
|
|
- if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemChademoOutputOVP == YES)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemChademoOutputOVP = NO;
|
|
|
- }
|
|
|
- else if (_chargingData[gun]->Type == _Type_GB)
|
|
|
- {
|
|
|
- if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemGbOutputOVP == YES)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemGbOutputOVP = NO;
|
|
|
- }
|
|
|
- else if (_chargingData[gun]->Type == _Type_CCS_2)
|
|
|
- {
|
|
|
- if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemCcsOutputOVP == YES)
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemCcsOutputOVP = NO;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
int main(void)
|
|
|
{
|
|
|
if(InitShareMemory() == FAIL)
|
|
@@ -2539,7 +2638,7 @@ int main(void)
|
|
|
for(;;)
|
|
|
{
|
|
|
bool isCharging = false;
|
|
|
- // 蝔见��见�銋见�~ 敹����Ⅱ摰� FW ��𧋦��′擃𠉛��穿�蝣箄�敺�!!~ 閰脫芋蝯��蝞埈糓��迤�� Initial Comp.
|
|
|
+ // 程序開始之前~ 必須先確定 FW 版本與硬體版本,確認後!!~ 該模組才算是真正的 Initial Comp.
|
|
|
if (ShmRelayModuleData->SelfTest_Comp == NO)
|
|
|
{
|
|
|
GetFwAndHwVersion_Relay();
|
|
@@ -2557,10 +2656,10 @@ int main(void)
|
|
|
gettimeofday(&_priority_time, NULL);
|
|
|
}
|
|
|
|
|
|
- // �芣炎�擧挾�閧�嚗諹䌊瑼a�畾萄��𡏭�銝滚������誨銵刻府蝟餌絞瘝埝��𤤿���
|
|
|
+ // 自檢階段處理,自檢階段如果讀不到版號則代表該系統沒有掛燈板
|
|
|
if (ShmLedModuleData->SelfTest_Comp == NO)
|
|
|
{
|
|
|
- // �芣炎�擧挾
|
|
|
+ // 自檢階段
|
|
|
if (ShmSysConfigAndInfo->SysInfo.SelfTestSeq <= _STEST_PSU_CAP)
|
|
|
{
|
|
|
GetFwAndHwVersion_Led();
|
|
@@ -2569,7 +2668,7 @@ int main(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- // �芣炎�擧挾瘝埝��誩����
|
|
|
+ // 自檢階段沒有問到版號
|
|
|
if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LedboardStestFail == NO)
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LedboardStestFail = YES;
|
|
|
}
|
|
@@ -2579,14 +2678,14 @@ int main(void)
|
|
|
|
|
|
if (ShmRelayModuleData->SelfTest_Comp == YES)
|
|
|
{
|
|
|
- // ==============�芸�甈𦠜�擃� 10 ms ==============
|
|
|
- // 頛詨枂�餃�
|
|
|
+ // ==============優先權最高 10 ms ==============
|
|
|
+ // 輸出電壓
|
|
|
GetPersentOutputVol();
|
|
|
|
|
|
- // 銝厩㮾頛詨��餃�
|
|
|
+ // 三相輸入電壓
|
|
|
GetPresentInputVol();
|
|
|
|
|
|
- // 霈��𣇉訜�� AC relay ����
|
|
|
+ // 讀取當前 AC relay 狀態
|
|
|
regRelay.relay_event.bits.AC_Contactor = ShmSysConfigAndInfo->SysInfo.AcContactorStatus;
|
|
|
GetRelayOutputStatus();
|
|
|
|
|
@@ -2595,17 +2694,18 @@ int main(void)
|
|
|
// Cable check (Set)
|
|
|
CableCheckDetected(i);
|
|
|
|
|
|
- // check k1 k2 relay ����
|
|
|
+ // check k1 k2 relay 狀態
|
|
|
CheckK1K2RelayOutput(i);
|
|
|
|
|
|
- // 靘脲��嗅��������钅��� �凋�/�暸� Relay
|
|
|
+ // 依據當前各槍的狀態選擇 搭上/放開 Relay
|
|
|
SetK1K2RelayStatus(i);
|
|
|
|
|
|
- if (_chargingData[i]->SystemStatus == S_IDLE)
|
|
|
+ if (_chargingData[i]->SystemStatus == S_IDLE ||
|
|
|
+ _chargingData[i]->SystemStatus == S_RESERVATION ||
|
|
|
+ _chargingData[i]->SystemStatus == S_MAINTAIN)
|
|
|
{
|
|
|
//_chargingData[i]->RelayWeldingCheck = NO;
|
|
|
_isOvpChkTimeFlag[i] = NO;
|
|
|
- ResetDetAlarmStatus(i);
|
|
|
}
|
|
|
|
|
|
if (_chargingData[i]->SystemStatus == S_BOOTING ||
|
|
@@ -2631,17 +2731,16 @@ int main(void)
|
|
|
// Cable check (Get)
|
|
|
GetGfdAdc();
|
|
|
|
|
|
- // 璈𧢲𦻖 relay
|
|
|
+ // 橋接 relay
|
|
|
SetParalleRelayStatus();
|
|
|
|
|
|
- // �凋� AC Contactor
|
|
|
+ // 搭上 AC Contactor
|
|
|
// if (isCharging)
|
|
|
// outputRelay.relay_event.bits.AC_Contactor = YES;
|
|
|
// else
|
|
|
// outputRelay.relay_event.bits.AC_Contactor = NO;
|
|
|
|
|
|
- if (isCharging ||
|
|
|
- (ShmPsuData->Work_Step >= _TEST_MODE && ShmPsuData->Work_Step <= _TEST_MODE))
|
|
|
+ if (isCharging || (ShmPsuData->Work_Step == _TEST_MODE))
|
|
|
{
|
|
|
isStopChargingCount = false;
|
|
|
outputRelay.relay_event.bits.AC_Contactor = YES;
|
|
@@ -2660,10 +2759,15 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (ShmPrimaryMcuData->InputDet.bits.EmergencyButton == ABNORMAL)
|
|
|
+ outputRelay.relay_event.bits.AC_Contactor = NO;
|
|
|
+
|
|
|
+ ShmDcCommonData->acContactSwitch = outputRelay.relay_event.bits.AC_Contactor;
|
|
|
+
|
|
|
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
|
|
|
+ // 搭上/鬆開 Relay
|
|
|
if(IsNoneMatchRelayStatus())
|
|
|
{
|
|
|
relayMatchFlag = NO;
|