|
@@ -58,21 +58,21 @@ uint8_t _curAutoRunCount = 0;
|
|
uint8_t _usingAutoRun = 0;
|
|
uint8_t _usingAutoRun = 0;
|
|
struct timeval _autoTime;
|
|
struct timeval _autoTime;
|
|
|
|
|
|
-struct SysConfigAndInfo *ShmSysConfigAndInfo;
|
|
|
|
-struct StatusCodeData *ShmStatusCodeData;
|
|
|
|
-struct PrimaryMcuData *ShmPrimaryMcuData;
|
|
|
|
-struct CHAdeMOData *ShmCHAdeMOData;
|
|
|
|
-struct CcsData *ShmCcsData;
|
|
|
|
-struct GBTData *ShmGBTData;
|
|
|
|
-struct FanModuleData *ShmFanModuleData;
|
|
|
|
-struct RelayModuleData *ShmRelayModuleData;
|
|
|
|
-struct LedModuleData *ShmLedModuleData;
|
|
|
|
-struct PsuData *ShmPsuData;
|
|
|
|
-struct OCPP16Data *ShmOCPP16Data;
|
|
|
|
-static SelectGunInfo *gAudiCustInfo = NULL; //Jerry add
|
|
|
|
-
|
|
|
|
-struct ChargingInfoData *_chargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
|
|
|
|
-struct ChargingInfoData *ac_chargingInfo[AC_QUANTITY];
|
|
|
|
|
|
+struct SysConfigAndInfo *ShmSysConfigAndInfo = NULL;
|
|
|
|
+struct StatusCodeData *ShmStatusCodeData = NULL;
|
|
|
|
+struct PrimaryMcuData *ShmPrimaryMcuData = NULL;
|
|
|
|
+struct CHAdeMOData *ShmCHAdeMOData = NULL;
|
|
|
|
+struct CcsData *ShmCcsData = NULL;
|
|
|
|
+struct GBTData *ShmGBTData = NULL;
|
|
|
|
+struct FanModuleData *ShmFanModuleData = NULL;
|
|
|
|
+struct RelayModuleData *ShmRelayModuleData = NULL;
|
|
|
|
+struct LedModuleData *ShmLedModuleData = NULL;
|
|
|
|
+struct PsuData *ShmPsuData = NULL;
|
|
|
|
+struct OCPP16Data *ShmOCPP16Data = NULL;
|
|
|
|
+static SelectGunInfo *ShmSelectGunInfo = NULL; //Jerry add
|
|
|
|
+
|
|
|
|
+struct ChargingInfoData *_chargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
|
|
|
|
+struct ChargingInfoData *ac_chargingInfo[AC_QUANTITY];
|
|
|
|
|
|
char *msg = "state : get gun state (index) \n"
|
|
char *msg = "state : get gun state (index) \n"
|
|
"card : scanning card (x) : \n"
|
|
"card : scanning card (x) : \n"
|
|
@@ -128,16 +128,14 @@ int InitShareMemory()
|
|
result = FAIL;
|
|
result = FAIL;
|
|
} else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
|
|
} else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
|
|
result = FAIL;
|
|
result = FAIL;
|
|
- } else
|
|
|
|
- {}
|
|
|
|
|
|
+ }
|
|
|
|
|
|
//initial ShmStatusCodeData
|
|
//initial ShmStatusCodeData
|
|
if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0) {
|
|
if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0) {
|
|
result = FAIL;
|
|
result = FAIL;
|
|
} else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
|
|
} else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
|
|
result = FAIL;
|
|
result = FAIL;
|
|
- } else
|
|
|
|
- {}
|
|
|
|
|
|
+ }
|
|
|
|
|
|
if (CHAdeMO_QUANTITY > 0) {
|
|
if (CHAdeMO_QUANTITY > 0) {
|
|
if ((MeterSMId = shmget(ShmCHAdeMOCommKey, sizeof(struct CHAdeMOData),
|
|
if ((MeterSMId = shmget(ShmCHAdeMOCommKey, sizeof(struct CHAdeMOData),
|
|
@@ -146,7 +144,6 @@ int InitShareMemory()
|
|
} else if ((ShmCHAdeMOData = shmat(MeterSMId, NULL, 0))
|
|
} else if ((ShmCHAdeMOData = shmat(MeterSMId, NULL, 0))
|
|
== (void *) - 1) {
|
|
== (void *) - 1) {
|
|
result = FAIL;
|
|
result = FAIL;
|
|
- } else {
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -156,7 +153,6 @@ int InitShareMemory()
|
|
result = FAIL;
|
|
result = FAIL;
|
|
} else if ((ShmCcsData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
|
|
} else if ((ShmCcsData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
|
|
result = FAIL;
|
|
result = FAIL;
|
|
- } else {
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -209,7 +205,7 @@ int InitShareMemory()
|
|
|
|
|
|
if ((MeterSMId = shmget(ShmSelectGunInfoKey, sizeof(SelectGunInfo), IPC_CREAT | 0777)) < 0) {
|
|
if ((MeterSMId = shmget(ShmSelectGunInfoKey, sizeof(SelectGunInfo), IPC_CREAT | 0777)) < 0) {
|
|
return FAIL;
|
|
return FAIL;
|
|
- } else if ((gAudiCustInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
|
|
|
|
|
|
+ } else if ((ShmSelectGunInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
|
|
return FAIL;
|
|
return FAIL;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -653,11 +649,11 @@ static void get_char(char *word)
|
|
|
|
|
|
static void setConfirmSelGun(uint8_t selGun)
|
|
static void setConfirmSelGun(uint8_t selGun)
|
|
{
|
|
{
|
|
- if (selGun == LEFT_GUN_NUM && gAudiCustInfo->SelGunInfo.LeftGun == SEL_GUN_RELEASE) {
|
|
|
|
- gAudiCustInfo->SelGunInfo.LeftGun = SEL_GUN_CONFIRM;
|
|
|
|
|
|
+ if (selGun == LEFT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_RELEASE) {
|
|
|
|
+ ShmSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_CONFIRM;
|
|
//printf("confirmSelGun left\r\n");
|
|
//printf("confirmSelGun left\r\n");
|
|
- } else if (selGun == RIGHT_GUN_NUM && gAudiCustInfo->SelGunInfo.RightGun == SEL_GUN_RELEASE) {
|
|
|
|
- gAudiCustInfo->SelGunInfo.RightGun = SEL_GUN_CONFIRM;
|
|
|
|
|
|
+ } else if (selGun == RIGHT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_RELEASE) {
|
|
|
|
+ ShmSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_CONFIRM;
|
|
//printf("confirmSelGun right\r\n");
|
|
//printf("confirmSelGun right\r\n");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -665,8 +661,12 @@ static void setConfirmSelGun(uint8_t selGun)
|
|
void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
|
|
void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
|
|
{
|
|
{
|
|
int _GunIndex;
|
|
int _GunIndex;
|
|
|
|
+ uint8_t gunIndex = 0;
|
|
|
|
+ uint8_t stopChg = 0;
|
|
|
|
+ uint8_t curGun = 0;
|
|
float _Voltage;
|
|
float _Voltage;
|
|
float _Current;
|
|
float _Current;
|
|
|
|
+ uint8_t PreviousSystemStatus[2] = {0xff};
|
|
|
|
|
|
if (strcmp(v1, "auto") == EQUAL) {
|
|
if (strcmp(v1, "auto") == EQUAL) {
|
|
_usingAutoRun = 0x01;
|
|
_usingAutoRun = 0x01;
|
|
@@ -680,14 +680,15 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
|
|
_Current = atof(v3);
|
|
_Current = atof(v3);
|
|
}
|
|
}
|
|
|
|
|
|
- uint8_t PreviousSystemStatus = 0xff;
|
|
|
|
if (!FindChargingInfoData(_GunIndex, &_chargingData[0])) {
|
|
if (!FindChargingInfoData(_GunIndex, &_chargingData[0])) {
|
|
printf ("FindChargingInfoData error\n");
|
|
printf ("FindChargingInfoData error\n");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- printf ("Power = %d, ReqVoltage = %f, ReqCurrent = %f\n",
|
|
|
|
- ShmSysConfigAndInfo->SysConfig.MaxChargingPower, _Voltage, _Current);
|
|
|
|
|
|
+ printf("Power = %d, ReqVoltage = %f, ReqCurrent = %f\n",
|
|
|
|
+ ShmSysConfigAndInfo->SysConfig.MaxChargingPower,
|
|
|
|
+ _Voltage,
|
|
|
|
+ _Current);
|
|
|
|
|
|
if (_Voltage > 1000 || _Voltage < 50) {
|
|
if (_Voltage > 1000 || _Voltage < 50) {
|
|
printf ("Input Voltage over range\n");
|
|
printf ("Input Voltage over range\n");
|
|
@@ -711,32 +712,35 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
|
|
|
|
|
|
//system(STTY_US TTY_PATH);
|
|
//system(STTY_US TTY_PATH);
|
|
|
|
|
|
|
|
+ ShmSysConfigAndInfo->SysInfo.CurGunSelected = _GunIndex;
|
|
|
|
+
|
|
while (true) {
|
|
while (true) {
|
|
|
|
+ curGun = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
|
|
|
|
+
|
|
//fix gun 1
|
|
//fix gun 1
|
|
- ShmSysConfigAndInfo->SysInfo.CurGunSelected = _GunIndex;
|
|
|
|
|
|
+ switch (_chargingData[curGun]->SystemStatus) {
|
|
|
|
+ case S_IDLE:
|
|
|
|
+ if (PreviousSystemStatus[curGun] != _chargingData[curGun]->SystemStatus) {
|
|
|
|
+ PreviousSystemStatus[curGun] = _chargingData[curGun]->SystemStatus;
|
|
#if defined DD360Audi
|
|
#if defined DD360Audi
|
|
- setConfirmSelGun(ShmSysConfigAndInfo->SysInfo.CurGunSelected);
|
|
|
|
|
|
+ setConfirmSelGun(curGun);
|
|
#endif //defined DD360Audi
|
|
#endif //defined DD360Audi
|
|
- switch (_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus) {
|
|
|
|
- case S_IDLE: {
|
|
|
|
- if (PreviousSystemStatus != _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus) {
|
|
|
|
- PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
|
|
|
|
|
|
+
|
|
strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "AutoStartCharging");
|
|
strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "AutoStartCharging");
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->ConnectorPlugIn = 1;
|
|
|
|
|
|
+ _chargingData[curGun]->ConnectorPlugIn = 1;
|
|
printf ("[UnconditionalCharge - S_IDLE]\n");
|
|
printf ("[UnconditionalCharge - S_IDLE]\n");
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->Type = 9;
|
|
|
|
|
|
+ _chargingData[curGun]->Type = 9;
|
|
|
|
|
|
}
|
|
}
|
|
if (ShmOCPP16Data->SpMsg.bits.AuthorizeConf == 1) {
|
|
if (ShmOCPP16Data->SpMsg.bits.AuthorizeConf == 1) {
|
|
ShmSysConfigAndInfo->SysInfo.StartToChargingFlag = 0x01;
|
|
ShmSysConfigAndInfo->SysInfo.StartToChargingFlag = 0x01;
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_PREPARNING;
|
|
|
|
|
|
+ _chargingData[curGun]->SystemStatus = S_PREPARNING;
|
|
}
|
|
}
|
|
- }
|
|
|
|
- break;
|
|
|
|
|
|
+ break;
|
|
|
|
|
|
- case S_PREPARNING: {
|
|
|
|
- if (PreviousSystemStatus != _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus) {
|
|
|
|
- PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
|
|
|
|
|
|
+ case S_PREPARNING:
|
|
|
|
+ if (PreviousSystemStatus[curGun] != _chargingData[curGun]->SystemStatus) {
|
|
|
|
+ PreviousSystemStatus[curGun] = _chargingData[curGun]->SystemStatus;
|
|
|
|
|
|
printf ("[UnconditionalCharge - S_PREPARNIN]\n");
|
|
printf ("[UnconditionalCharge - S_PREPARNIN]\n");
|
|
|
|
|
|
@@ -755,47 +759,45 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
|
|
//sleep(10);
|
|
//sleep(10);
|
|
|
|
|
|
//清除 main timeout 機制
|
|
//清除 main timeout 機制
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->TimeoutFlag = 0;
|
|
|
|
|
|
+ _chargingData[curGun]->TimeoutFlag = 0;
|
|
//不論是什麼 type 的槍都固意設成 Chademo 不跑 Prechage step
|
|
//不論是什麼 type 的槍都固意設成 Chademo 不跑 Prechage step
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->Type = 9;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
|
|
+ _chargingData[curGun]->Type = 9;
|
|
|
|
+ break;
|
|
|
|
|
|
- case S_PREPARING_FOR_EV: {
|
|
|
|
- if (PreviousSystemStatus != _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus) {
|
|
|
|
- PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
|
|
|
|
|
|
+ case S_PREPARING_FOR_EV:
|
|
|
|
+ if (PreviousSystemStatus[curGun] != _chargingData[curGun]->SystemStatus) {
|
|
|
|
+ PreviousSystemStatus[curGun] = _chargingData[curGun]->SystemStatus;
|
|
|
|
|
|
printf ("[UnconditionalCharge - S_PREPARING_FOR_EV]\n");
|
|
printf ("[UnconditionalCharge - S_PREPARING_FOR_EV]\n");
|
|
printf ("ReqVoltage = %f, ReqCurrent = %f \n", _Voltage * 10, _Current * 10);
|
|
printf ("ReqVoltage = %f, ReqCurrent = %f \n", _Voltage * 10, _Current * 10);
|
|
|
|
|
|
}
|
|
}
|
|
//清除 main timeout 機制
|
|
//清除 main timeout 機制
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->TimeoutFlag = 0;
|
|
|
|
|
|
+ _chargingData[curGun]->TimeoutFlag = 0;
|
|
//不論是什麼 type 的槍都固意設成 Chademo 不跑 Prechage step
|
|
//不論是什麼 type 的槍都固意設成 Chademo 不跑 Prechage step
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->Type = 9;
|
|
|
|
|
|
+ _chargingData[curGun]->Type = 9;
|
|
|
|
|
|
//充電電壓電流
|
|
//充電電壓電流
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterySoc = 50;
|
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage = 500;
|
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent = 2;
|
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->AvailableChargingCurrent = 1000;
|
|
|
|
|
|
+ _chargingData[curGun]->EvBatterySoc = 50;
|
|
|
|
+ _chargingData[curGun]->EvBatterytargetVoltage = 500;
|
|
|
|
+ _chargingData[curGun]->EvBatterytargetCurrent = 2;
|
|
|
|
+ _chargingData[curGun]->AvailableChargingCurrent = 1000;
|
|
|
|
|
|
//****** 注意~此行為是防止 K1K2 先開導到無法升壓 ( Relay Board 在此 state 還未搭上 K1K2 )
|
|
//****** 注意~此行為是防止 K1K2 先開導到無法升壓 ( Relay Board 在此 state 還未搭上 K1K2 )
|
|
//確定模組己升壓完成
|
|
//確定模組己升壓完成
|
|
- //if(_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingVoltage <= (3000+500) &&
|
|
|
|
- // _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingVoltage >= (3000-500) )
|
|
|
|
|
|
+ //if(_chargingData[curGun]->PresentChargingVoltage <= (3000+500) &&
|
|
|
|
+ // _chargingData[curGun]->PresentChargingVoltage >= (3000-500) )
|
|
{
|
|
{
|
|
- printf ("Precharge Done = %f \n", _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingVoltage);
|
|
|
|
|
|
+ printf ("Precharge Done = %f \n",
|
|
|
|
+ _chargingData[curGun]->PresentChargingVoltage);
|
|
//EV done
|
|
//EV done
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_PREPARING_FOR_EVSE;
|
|
|
|
|
|
+ _chargingData[curGun]->SystemStatus = S_PREPARING_FOR_EVSE;
|
|
}
|
|
}
|
|
- }
|
|
|
|
- break;
|
|
|
|
|
|
+ break;
|
|
|
|
|
|
- case S_PREPARING_FOR_EVSE: {
|
|
|
|
- if (PreviousSystemStatus != _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus) {
|
|
|
|
- PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
|
|
|
|
|
|
+ case S_PREPARING_FOR_EVSE:
|
|
|
|
+ if (PreviousSystemStatus[curGun] != _chargingData[curGun]->SystemStatus) {
|
|
|
|
+ PreviousSystemStatus[curGun] = _chargingData[curGun]->SystemStatus;
|
|
|
|
|
|
printf ("[UnconditionalCharge - S_PREPARING_FOR_EVSE]\n");
|
|
printf ("[UnconditionalCharge - S_PREPARING_FOR_EVSE]\n");
|
|
|
|
|
|
@@ -804,115 +806,130 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
|
|
//printf ("tar cur = %d \n", _Current);
|
|
//printf ("tar cur = %d \n", _Current);
|
|
|
|
|
|
//清除 main timeout 機制
|
|
//清除 main timeout 機制
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->TimeoutFlag = 0;
|
|
|
|
|
|
+ _chargingData[curGun]->TimeoutFlag = 0;
|
|
//不論是什麼 type 的槍都固意設成 Chademo 不跑 Prechage step
|
|
//不論是什麼 type 的槍都固意設成 Chademo 不跑 Prechage step
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->Type = 9;
|
|
|
|
|
|
+ _chargingData[curGun]->Type = 9;
|
|
|
|
|
|
//充電電壓電流
|
|
//充電電壓電流
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterySoc = 50;
|
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage = 500;
|
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent = 2;
|
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->AvailableChargingCurrent = 1000;
|
|
|
|
|
|
+ _chargingData[curGun]->EvBatterySoc = 50;
|
|
|
|
+ _chargingData[curGun]->EvBatterytargetVoltage = 500;
|
|
|
|
+ _chargingData[curGun]->EvBatterytargetCurrent = 2;
|
|
|
|
+ _chargingData[curGun]->AvailableChargingCurrent = 1000;
|
|
|
|
|
|
- //printf ("tar vol_ = %d \n", _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage);
|
|
|
|
- // printf ("tar cur_ = %d \n", _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent);
|
|
|
|
|
|
+ //printf ("tar vol_ = %d \n", _chargingData[curGun]->EvBatterytargetVoltage);
|
|
|
|
+ // printf ("tar cur_ = %d \n", _chargingData[curGun]->EvBatterytargetCurrent);
|
|
|
|
|
|
//****** 注意~此行為是防止 K1K2 先開導到無法升壓 ( Relay Board 在此 state 還未搭上 K1K2 )
|
|
//****** 注意~此行為是防止 K1K2 先開導到無法升壓 ( Relay Board 在此 state 還未搭上 K1K2 )
|
|
//確定模組己升壓完成
|
|
//確定模組己升壓完成
|
|
- if (_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus == 0x01 ||
|
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus == 0x03) {
|
|
|
|
- printf ("First Ground Fault State (%d)\n", _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus);
|
|
|
|
- printf ("Wait K1K2 = %f \n", _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingVoltage);
|
|
|
|
|
|
+ if (_chargingData[curGun]->GroundFaultStatus == 0x01 ||
|
|
|
|
+ _chargingData[curGun]->GroundFaultStatus == 0x03) {
|
|
|
|
+ printf ("First Ground Fault State (%d)\n",
|
|
|
|
+ _chargingData[curGun]->GroundFaultStatus);
|
|
|
|
+ printf ("Wait K1K2 = %f \n", _chargingData[curGun]->PresentChargingVoltage);
|
|
sleep(5);
|
|
sleep(5);
|
|
//EV done
|
|
//EV done
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_CHARGING;
|
|
|
|
- } else if (_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus > 0x02) {
|
|
|
|
- printf ("First Ground Fault check Fail (%d)\n", _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus);
|
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_TERMINATING;
|
|
|
|
|
|
+ _chargingData[curGun]->SystemStatus = S_CHARGING;
|
|
|
|
+ } else if (_chargingData[curGun]->GroundFaultStatus > 0x02) {
|
|
|
|
+ printf ("First Ground Fault check Fail (%d)\n",
|
|
|
|
+ _chargingData[curGun]->GroundFaultStatus);
|
|
|
|
+ _chargingData[curGun]->SystemStatus = S_TERMINATING;
|
|
}
|
|
}
|
|
|
|
+ break;
|
|
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
- case S_CHARGING: {
|
|
|
|
- if (PreviousSystemStatus != _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus) {
|
|
|
|
- PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
|
|
|
|
|
|
+ case S_CHARGING:
|
|
|
|
+ if (PreviousSystemStatus[curGun] != _chargingData[curGun]->SystemStatus) {
|
|
|
|
+ PreviousSystemStatus[curGun] = _chargingData[curGun]->SystemStatus;
|
|
|
|
|
|
if (_usingAutoRun == 0x00) {
|
|
if (_usingAutoRun == 0x00) {
|
|
//充電電壓電流
|
|
//充電電壓電流
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage = _Voltage;
|
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent = _Current;
|
|
|
|
|
|
+ _chargingData[curGun]->EvBatterytargetVoltage = _Voltage;
|
|
|
|
+ _chargingData[curGun]->EvBatterytargetCurrent = _Current;
|
|
} else {
|
|
} else {
|
|
_curAutoRunCount = 0;
|
|
_curAutoRunCount = 0;
|
|
gettimeofday(&_autoTime, NULL);
|
|
gettimeofday(&_autoTime, NULL);
|
|
}
|
|
}
|
|
|
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterySoc = 50;
|
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->AvailableChargingCurrent = 1000;
|
|
|
|
|
|
+ _chargingData[curGun]->EvBatterySoc = 50;
|
|
|
|
+ _chargingData[curGun]->AvailableChargingCurrent = 1000;
|
|
|
|
|
|
printf ("[UnconditionalCharge - S_CHARGING]\n");
|
|
printf ("[UnconditionalCharge - S_CHARGING]\n");
|
|
}
|
|
}
|
|
|
|
|
|
if (_usingAutoRun == 0x01) {
|
|
if (_usingAutoRun == 0x01) {
|
|
- if (((GetTimeoutValue(_autoTime)) >= AUTORUN_STEP1_TIME_START * 60 && (GetTimeoutValue(_autoTime)) <= AUTORUN_STEP1_TIME_END * 60) ||
|
|
|
|
- ((GetTimeoutValue(_autoTime)) >= AUTORUN_STEP2_TIME_START * 60 && (GetTimeoutValue(_autoTime)) <= AUTORUN_STEP2_TIME_END * 60)) {
|
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage = _Voltage;
|
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent = _Current;
|
|
|
|
|
|
+ if (((GetTimeoutValue(_autoTime)) >= AUTORUN_STEP1_TIME_START * 60 &&
|
|
|
|
+ (GetTimeoutValue(_autoTime)) <= AUTORUN_STEP1_TIME_END * 60) ||
|
|
|
|
+ ((GetTimeoutValue(_autoTime)) >= AUTORUN_STEP2_TIME_START * 60 &&
|
|
|
|
+ (GetTimeoutValue(_autoTime)) <= AUTORUN_STEP2_TIME_END * 60)
|
|
|
|
+ ) {
|
|
|
|
+ _chargingData[curGun]->EvBatterytargetVoltage = _Voltage;
|
|
|
|
+ _chargingData[curGun]->EvBatterytargetCurrent = _Current;
|
|
} else if ((GetTimeoutValue(_autoTime)) >= AUTORUN_END_TIME * 60) {
|
|
} else if ((GetTimeoutValue(_autoTime)) >= AUTORUN_END_TIME * 60) {
|
|
_curAutoRunCount++;
|
|
_curAutoRunCount++;
|
|
if (_curAutoRunCount >= AUTORUN_CYCLE_COUNT) {
|
|
if (_curAutoRunCount >= AUTORUN_CYCLE_COUNT) {
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_TERMINATING;
|
|
|
|
|
|
+ _chargingData[curGun]->SystemStatus = S_TERMINATING;
|
|
} else {
|
|
} else {
|
|
gettimeofday(&_autoTime, NULL);
|
|
gettimeofday(&_autoTime, NULL);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage = 0;
|
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent = 0;
|
|
|
|
|
|
+ _chargingData[curGun]->EvBatterytargetVoltage = 0;
|
|
|
|
+ _chargingData[curGun]->EvBatterytargetCurrent = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// printf("out : vol = %f, cur = %f \n",
|
|
// printf("out : vol = %f, cur = %f \n",
|
|
-// _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage,
|
|
|
|
-// _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent);
|
|
|
|
|
|
+// _chargingData[curGun]->EvBatterytargetVoltage,
|
|
|
|
+// _chargingData[curGun]->EvBatterytargetCurrent);
|
|
//ev task do this
|
|
//ev task do this
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingPower =
|
|
|
|
- ((float)((_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingVoltage) * (_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingCurrent)) / 1000);
|
|
|
|
-
|
|
|
|
- if (_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus == 0x02) {
|
|
|
|
- printf ("Charging Ground Fault check Fail (%d)\n", _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus);
|
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_TERMINATING;
|
|
|
|
|
|
+ _chargingData[curGun]->PresentChargingPower =
|
|
|
|
+ ((float)((_chargingData[curGun]->PresentChargingVoltage) *
|
|
|
|
+ (_chargingData[curGun]->PresentChargingCurrent)) / 1000);
|
|
|
|
+
|
|
|
|
+ if (_chargingData[curGun]->GroundFaultStatus == 0x02) {
|
|
|
|
+ printf ("Charging Ground Fault check Fail (%d)\n",
|
|
|
|
+ _chargingData[curGun]->GroundFaultStatus);
|
|
|
|
+ _chargingData[curGun]->SystemStatus = S_TERMINATING;
|
|
}
|
|
}
|
|
- }
|
|
|
|
- break;
|
|
|
|
|
|
+ break;
|
|
|
|
|
|
- case S_TERMINATING: {
|
|
|
|
- if (PreviousSystemStatus != _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus) {
|
|
|
|
- PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
|
|
|
|
- system("/root/Module_EvComm &");
|
|
|
|
|
|
+ case S_TERMINATING:
|
|
|
|
+ if (PreviousSystemStatus[curGun] != _chargingData[curGun]->SystemStatus) {
|
|
|
|
+ PreviousSystemStatus[curGun] = _chargingData[curGun]->SystemStatus;
|
|
|
|
|
|
printf ("[UnconditionalCharge - S_TERMINATING]\n");
|
|
printf ("[UnconditionalCharge - S_TERMINATING]\n");
|
|
//無阻塞偵測 keybaord 結束
|
|
//無阻塞偵測 keybaord 結束
|
|
system(STTY_DEF TTY_PATH);
|
|
system(STTY_DEF TTY_PATH);
|
|
}
|
|
}
|
|
|
|
|
|
- sleep(3);
|
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_COMPLETE;
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
|
|
+ _chargingData[curGun]->SystemStatus = S_COMPLETE;
|
|
|
|
+ break;
|
|
|
|
|
|
- case S_COMPLETE: {
|
|
|
|
- if (PreviousSystemStatus != _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus) {
|
|
|
|
- PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
|
|
|
|
|
|
+ case S_COMPLETE:
|
|
|
|
+ if (PreviousSystemStatus[curGun] != _chargingData[curGun]->SystemStatus) {
|
|
|
|
+ PreviousSystemStatus[curGun] = _chargingData[curGun]->SystemStatus;
|
|
|
|
|
|
printf ("[UnconditionalCharge - S_COMPLETE]\n");
|
|
printf ("[UnconditionalCharge - S_COMPLETE]\n");
|
|
}
|
|
}
|
|
|
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingPower = 0;
|
|
|
|
- sleep(3);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
|
|
+ PreviousSystemStatus[curGun] = 0xFF;
|
|
|
|
+ stopChg = 0;
|
|
|
|
+ for (gunIndex = 0; gunIndex < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; gunIndex++) {
|
|
|
|
+ if (PreviousSystemStatus[gunIndex] == 0xFF) {
|
|
|
|
+ _chargingData[curGun]->SystemStatus = S_IDLE;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (_chargingData[gunIndex]->SystemStatus == S_IDLE) {
|
|
|
|
+ stopChg++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ _chargingData[curGun]->PresentChargingPower = 0;
|
|
|
|
+
|
|
|
|
+ if (stopChg == ShmSysConfigAndInfo->SysConfig.TotalConnectorCount) {
|
|
|
|
+ system("/root/Module_EvComm &");
|
|
|
|
+ sleep(3);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
|
|
char word[128];
|
|
char word[128];
|
|
@@ -941,8 +958,11 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
|
|
}
|
|
}
|
|
|
|
|
|
if (strcmp(newString[0], "strchg") == 0) {
|
|
if (strcmp(newString[0], "strchg") == 0) {
|
|
- if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0 ||
|
|
|
|
- strcmp(newString[2], "-1") == 0 || strcmp(newString[2], "") == 0) {
|
|
|
|
|
|
+ if (strcmp(newString[1], "-1") == 0 ||
|
|
|
|
+ strcmp(newString[1], "") == 0 ||
|
|
|
|
+ strcmp(newString[2], "-1") == 0 ||
|
|
|
|
+ strcmp(newString[2], "") == 0
|
|
|
|
+ ) {
|
|
printf ("Input cmd fail ------ strchg [vol 150-1000] [cru 2-100]\n");
|
|
printf ("Input cmd fail ------ strchg [vol 150-1000] [cru 2-100]\n");
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -955,14 +975,15 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
|
|
_Voltage = atof((char *)newString[2]);
|
|
_Voltage = atof((char *)newString[2]);
|
|
_Current = atof((char *)newString[3]);
|
|
_Current = atof((char *)newString[3]);
|
|
|
|
|
|
- uint8_t PreviousSystemStatus = 0xff;
|
|
|
|
if (!FindChargingInfoData(_GunIndex, &_chargingData[0])) {
|
|
if (!FindChargingInfoData(_GunIndex, &_chargingData[0])) {
|
|
printf ("FindChargingInfoData error\n");
|
|
printf ("FindChargingInfoData error\n");
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
printf ("Power = %d, ReqVoltage = %f, ReqCurrent = %f\n",
|
|
printf ("Power = %d, ReqVoltage = %f, ReqCurrent = %f\n",
|
|
- ShmSysConfigAndInfo->SysConfig.MaxChargingPower, _Voltage, _Current);
|
|
|
|
|
|
+ ShmSysConfigAndInfo->SysConfig.MaxChargingPower,
|
|
|
|
+ _Voltage,
|
|
|
|
+ _Current);
|
|
|
|
|
|
if (_Voltage > 1000 || _Voltage < 50) {
|
|
if (_Voltage > 1000 || _Voltage < 50) {
|
|
_Voltage = 200;
|
|
_Voltage = 200;
|
|
@@ -970,29 +991,40 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ ShmSysConfigAndInfo->SysInfo.CurGunSelected = _GunIndex;
|
|
|
|
+ strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
|
|
} else if (strcmp(newString[0], "chg") == 0) {
|
|
} else if (strcmp(newString[0], "chg") == 0) {
|
|
- if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0) {
|
|
|
|
|
|
+ if (strcmp(newString[1], "-1") == 0) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- if (strcmp(newString[2], "-1") == 0 || strcmp(newString[2], "") == 0) {
|
|
|
|
|
|
+
|
|
|
|
+ if (strcmp(newString[2], "-1") == 0 ||
|
|
|
|
+ strcmp(newString[2], "") == 0) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- float _vol = atof(newString[1]);
|
|
|
|
- float _cur = atof(newString[2]);
|
|
|
|
|
|
+ if (strcmp(newString[3], "-1") == 0 ||
|
|
|
|
+ strcmp(newString[3], "") == 0) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ _GunIndex = atoi((char *)newString[1]);
|
|
|
|
+ float _vol = atof(newString[2]);
|
|
|
|
+ float _cur = atof(newString[3]);
|
|
|
|
|
|
if (_cur <= 0 || _cur <= 0) {
|
|
if (_cur <= 0 || _cur <= 0) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
printf("vol = %f, cur = %f \n", _vol, _cur);
|
|
printf("vol = %f, cur = %f \n", _vol, _cur);
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage = _vol;
|
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent = _cur;
|
|
|
|
|
|
+ _chargingData[_GunIndex]->EvBatterytargetVoltage = _vol;
|
|
|
|
+ _chargingData[_GunIndex]->EvBatterytargetCurrent = _cur;
|
|
} else if (strcmp(newString[0], "c") == 0) {
|
|
} else if (strcmp(newString[0], "c") == 0) {
|
|
if (atoi((char *)newString[1]) != -1) {
|
|
if (atoi((char *)newString[1]) != -1) {
|
|
ShmSysConfigAndInfo->SysInfo.CurGunSelected = atoi((char *)newString[1]);
|
|
ShmSysConfigAndInfo->SysInfo.CurGunSelected = atoi((char *)newString[1]);
|
|
}
|
|
}
|
|
printf("stop \n\r");
|
|
printf("stop \n\r");
|
|
|
|
+
|
|
ShmSysConfigAndInfo->SysInfo.StartToChargingFlag = 0x00;
|
|
ShmSysConfigAndInfo->SysInfo.StartToChargingFlag = 0x00;
|
|
_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_TERMINATING;
|
|
_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_TERMINATING;
|
|
}
|
|
}
|