|
@@ -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
|
|
|
#define OUTPUT_VOL_CHK_TIME 200
|
|
|
#define TEN_MINUTES 600
|
|
@@ -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
|
|
|
-#define VIN_MAX_REV_VOLTAGE_IEC 275
|
|
|
-#define VIN_MIN_VOLTAGE_IEC 160
|
|
|
-#define VIN_MIN_REV_VOLTAGE_IEC 170
|
|
|
+#define VIN_MAX_VOLTAGE_IEC 285
|
|
|
+#define VIN_MAX_REV_VOLTAGE_IEC 275
|
|
|
+#define VIN_MIN_VOLTAGE_IEC 160
|
|
|
+#define VIN_MIN_REV_VOLTAGE_IEC 170
|
|
|
|
|
|
-#define VIN_MAX_VOLTAGE_UL 315
|
|
|
-#define VIN_MAX_REV_VOLTAGE_UL 305
|
|
|
-#define VIN_MIN_VOLTAGE_UL 210
|
|
|
-#define VIN_MIN_REV_VOLTAGE_UL 220
|
|
|
+#define VIN_MAX_VOLTAGE_UL 315
|
|
|
+#define VIN_MAX_REV_VOLTAGE_UL 305
|
|
|
+#define VIN_MIN_VOLTAGE_UL 210
|
|
|
+#define VIN_MIN_REV_VOLTAGE_UL 220
|
|
|
|
|
|
-#define VIN_DROP_VOLTAGE 150
|
|
|
+#define VIN_DROP_VOLTAGE 150
|
|
|
|
|
|
#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
|
|
|
|
|
|
-
|
|
|
+
|
|
|
#define SELF_TO_CHANGE_RELAY_STATUS 600
|
|
|
-
|
|
|
+
|
|
|
#define CHECK_RELAY_STATUS 300
|
|
|
#define CHECK_RELAY_STATUS_GAP 100
|
|
|
-
|
|
|
+
|
|
|
#define SEFETY_SWITCH_RELAY_CUR 50
|
|
|
-
|
|
|
+
|
|
|
#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()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
void GetPresentInputVol()
|
|
|
{
|
|
|
if (Query_Present_InputVoltage(Uart5Fd, Addr.Relay, &inputVoltage) == PASS)
|
|
@@ -717,7 +718,7 @@ void GetPresentInputVol()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
void GetPersentOutputVol()
|
|
|
{
|
|
|
if (Query_Present_OutputVoltage(Uart5Fd, Addr.Relay, &outputVoltage) == PASS)
|
|
@@ -758,8 +759,8 @@ void GetPersentOutputVol()
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
if (_chargingData[index]->Type == _Type_Chademo)
|
|
|
{
|
|
|
|
|
@@ -773,7 +774,7 @@ void GetPersentOutputVol()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
void GetFanSpeed()
|
|
|
{
|
|
|
|
|
@@ -792,7 +793,7 @@ void GetFanSpeed()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
void GetRelayOutputStatus()
|
|
|
{
|
|
|
if (Query_Relay_Output(Uart5Fd, Addr.Relay, ®Relay) == PASS)
|
|
@@ -801,7 +802,7 @@ void GetRelayOutputStatus()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
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 (_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 (_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 (_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()
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
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)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
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;
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
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;
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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;
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -1817,7 +1943,7 @@ bool IsNoneMatchRelayStatus()
|
|
|
|
|
|
void MatchRelayStatus()
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
|
|
|
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))
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
_chargingData[0]->RelayK1K2Status = 0x01;
|
|
|
}
|
|
|
else
|
|
@@ -1843,7 +1969,7 @@ void CheckRelayStatusByADC()
|
|
|
if (ShmRelayModuleData->Gun2FuseOutputVolt > 0 && ShmRelayModuleData->Gun2RelayOutputVolt > 0 &&
|
|
|
(ShmRelayModuleData->Gun2FuseOutputVolt == ShmRelayModuleData->Gun2RelayOutputVolt))
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
_chargingData[1]->RelayK1K2Status = 0x01;
|
|
|
}
|
|
|
else
|
|
@@ -1867,12 +1993,12 @@ void SetGfdConfig(byte index, byte resister)
|
|
|
void CableCheckDetected(byte index)
|
|
|
{
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
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 CheckRelayWeldingStatus(byte index)
|
|
|
{
|
|
@@ -2058,18 +2196,18 @@ void GetPsuTempForFanSpeed()
|
|
|
|
|
|
void GetFanSpeedByFunction()
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
unsigned int _maxPower = ShmPsuData->SystemAvailablePower;
|
|
|
-
|
|
|
+
|
|
|
unsigned char temp = 0;
|
|
|
float power = 0;
|
|
|
|
|
@@ -2097,7 +2235,7 @@ void GetFanSpeedByFunction()
|
|
|
if (temp > 70)
|
|
|
_temp_diff = temp - 70;
|
|
|
|
|
|
-
|
|
|
+
|
|
|
if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES)
|
|
|
{
|
|
|
|
|
@@ -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;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
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)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
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;
|
|
|
-
|
|
|
+
|
|
|
if (ShmRelayModuleData->SelfTest_Comp == NO)
|
|
|
{
|
|
|
GetFwAndHwVersion_Relay();
|
|
@@ -2557,10 +2656,10 @@ int main(void)
|
|
|
gettimeofday(&_priority_time, NULL);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
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)
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
GetPersentOutputVol();
|
|
|
|
|
|
-
|
|
|
+
|
|
|
GetPresentInputVol();
|
|
|
|
|
|
-
|
|
|
+
|
|
|
regRelay.relay_event.bits.AC_Contactor = ShmSysConfigAndInfo->SysInfo.AcContactorStatus;
|
|
|
GetRelayOutputStatus();
|
|
|
|
|
@@ -2595,17 +2694,18 @@ int main(void)
|
|
|
|
|
|
CableCheckDetected(i);
|
|
|
|
|
|
-
|
|
|
+
|
|
|
CheckK1K2RelayOutput(i);
|
|
|
|
|
|
-
|
|
|
+
|
|
|
SetK1K2RelayStatus(i);
|
|
|
|
|
|
- if (_chargingData[i]->SystemStatus == S_IDLE)
|
|
|
+ if (_chargingData[i]->SystemStatus == S_IDLE ||
|
|
|
+ _chargingData[i]->SystemStatus == S_RESERVATION ||
|
|
|
+ _chargingData[i]->SystemStatus == S_MAINTAIN)
|
|
|
{
|
|
|
|
|
|
_isOvpChkTimeFlag[i] = NO;
|
|
|
- ResetDetAlarmStatus(i);
|
|
|
}
|
|
|
|
|
|
if (_chargingData[i]->SystemStatus == S_BOOTING ||
|
|
@@ -2631,17 +2731,16 @@ int main(void)
|
|
|
|
|
|
GetGfdAdc();
|
|
|
|
|
|
-
|
|
|
+
|
|
|
SetParalleRelayStatus();
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- 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;
|
|
|
|
|
|
-
|
|
|
+
|
|
|
if(IsNoneMatchRelayStatus())
|
|
|
{
|
|
|
relayMatchFlag = NO;
|