|
@@ -21,6 +21,8 @@
|
|
|
#include <unistd.h>
|
|
|
#include <signal.h>
|
|
|
|
|
|
+#include "../Log/log.h"
|
|
|
+#include "../ShareMemory/shmMem.h"
|
|
|
#include "../Define/define.h"
|
|
|
#include "../Config.h"
|
|
|
#include "../SelectGun/SelectGun.h"
|
|
@@ -28,23 +30,28 @@
|
|
|
#include "DoComm.h"
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
-#define log_info(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
|
|
|
-#define log_warn(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
|
|
|
-#define log_error(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
|
|
|
+//#define log_info(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
|
|
|
+//#define log_warn(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
|
|
|
+//#define log_error(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
//static int TcpSock = 0;
|
|
|
//static uint8_t PacketSe;
|
|
|
static DoCommGblData gDoCommGblData = {0};
|
|
|
|
|
|
-static struct SysConfigAndInfo *ShmSysConfigAndInfo = NULL;
|
|
|
-static struct StatusCodeData *ShmStatusCodeData = NULL;
|
|
|
-static struct PsuData *ShmPsuData = NULL;
|
|
|
-static struct OCPP16Data *ShmOCPP16Data = NULL;
|
|
|
-static struct PrimaryMcuData *ShmPrimaryMcuData = NULL;
|
|
|
-static SelectGunInfo *ShmSelectGunInfo = NULL;
|
|
|
-
|
|
|
-static struct ChargingInfoData *ChargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
|
|
|
+//static struct SysConfigAndInfo *ShmSysConfigAndInfo = NULL;
|
|
|
+//static struct StatusCodeData *ShmStatusCodeData = NULL;
|
|
|
+static struct SysConfigData *pSysConfig = NULL;
|
|
|
+static struct SysInfoData *pSysInfo = NULL;
|
|
|
+static struct WARNING_CODE_INFO *pSysWarning = NULL;
|
|
|
+static struct AlarmCodeData *pAlarmCode = NULL;
|
|
|
+static struct PsuData *ShmPsuData = NULL;
|
|
|
+static struct OCPP16Data *ShmOCPP16Data = NULL;
|
|
|
+static struct PrimaryMcuData *ShmPrimaryMcuData = NULL;
|
|
|
+static SelectGunInfo *ShmSelectGunInfo = NULL;
|
|
|
+
|
|
|
+//static struct ChargingInfoData *ChargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY]
|
|
|
+static struct ChargingInfoData *pDcChargingInfo = NULL;
|
|
|
static struct timeb gRegTimeUp[2][MAX_REGISTER_NUM] = {0};
|
|
|
static struct WARNING_CODE_INFO gPreSysWarningInfo = {0};
|
|
|
|
|
@@ -57,7 +64,7 @@ static int writeCsuModuleVersion(int fd);
|
|
|
//------------------------------------------------------------------------------
|
|
|
//--- Common function ---
|
|
|
//------------------------------------------------------------------------------
|
|
|
-static int StoreLogMsg(const char *fmt, ...)
|
|
|
+/*static int StoreLogMsg(const char *fmt, ...)
|
|
|
{
|
|
|
char Buf[4096 + 256];
|
|
|
char buffer[4096];
|
|
@@ -74,7 +81,7 @@ static int StoreLogMsg(const char *fmt, ...)
|
|
|
SeqEndTime.time = time(NULL);
|
|
|
tm = localtime(&SeqEndTime.time);
|
|
|
|
|
|
- if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == 1) {
|
|
|
+ if (pSysConfig->SwitchDebugFlag == 1) {
|
|
|
sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
|
|
|
tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
|
|
|
printf("%s \n", Buf);
|
|
@@ -88,6 +95,7 @@ static int StoreLogMsg(const char *fmt, ...)
|
|
|
|
|
|
return rc;
|
|
|
}
|
|
|
+*/
|
|
|
|
|
|
static int DiffTimeb(struct timeb ST, struct timeb ET)
|
|
|
{
|
|
@@ -187,7 +195,7 @@ static void InitSocketSigPipe(void)
|
|
|
//------------------------------------------------------------------------------
|
|
|
static void setTcpStatus(uint8_t setValue)
|
|
|
{
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DisconnectedFromDo = setValue;
|
|
|
+ pAlarmCode->AlarmEvents.bits.DisconnectedFromDo = setValue;
|
|
|
}
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
@@ -308,17 +316,17 @@ static void clearPricesInfo(uint8_t id)
|
|
|
static void ClearAuthorizedFlag(void)
|
|
|
{
|
|
|
ShmOCPP16Data->SpMsg.bits.AuthorizeConf = NO;
|
|
|
- ShmSysConfigAndInfo->SysInfo.AuthorizeFlag = NO;
|
|
|
+ pSysInfo->AuthorizeFlag = NO;
|
|
|
}
|
|
|
|
|
|
static void ClearDetectPluginFlag(void)
|
|
|
{
|
|
|
- ShmSysConfigAndInfo->SysInfo.WaitForPlugit = NO;
|
|
|
+ pSysInfo->WaitForPlugit = NO;
|
|
|
}
|
|
|
|
|
|
static bool isDetectPlugin(void)
|
|
|
{
|
|
|
- if (ShmSysConfigAndInfo->SysInfo.WaitForPlugit == YES) {
|
|
|
+ if (pSysInfo->WaitForPlugit == YES) {
|
|
|
return YES;
|
|
|
}
|
|
|
|
|
@@ -328,18 +336,20 @@ static bool isDetectPlugin(void)
|
|
|
static void destroySelectGun(uint8_t curGun)
|
|
|
{
|
|
|
uint8_t i = 0;
|
|
|
- uint8_t totalGun = ShmSysConfigAndInfo->SysConfig.TotalConnectorCount;
|
|
|
+ uint8_t totalGun = pSysConfig->TotalConnectorCount;
|
|
|
|
|
|
if (curGun == DESTROY_ALL_SEL) {
|
|
|
ShmSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_RELEASE;
|
|
|
ShmSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_RELEASE;
|
|
|
|
|
|
for (i = 0; i < totalGun; i++) {
|
|
|
- ChargingData[i]->TimeoutFlag = Timeout_None;
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
|
|
|
+
|
|
|
+ pDcChargingInfo->TimeoutFlag = Timeout_None;
|
|
|
clearPricesInfo(i);
|
|
|
}
|
|
|
- ShmSysConfigAndInfo->SysInfo.CurGunSelected = 0;
|
|
|
- strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
|
|
|
+ pSysInfo->CurGunSelected = 0;
|
|
|
+ strcpy((char *)pSysConfig->UserId, "");
|
|
|
}
|
|
|
|
|
|
//for charging timeout or complete
|
|
@@ -465,11 +475,11 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
|
|
|
|
|
|
//copy QR code string
|
|
|
if (strncmp((char *)localTime, (char *)&data[0], timeLen - 2) != 0) {
|
|
|
- memset(ShmSysConfigAndInfo->SysConfig.SystemId, '\0', sizeof(ShmSysConfigAndInfo->SysConfig.SystemId));
|
|
|
+ memset(pSysConfig->SystemId, '\0', sizeof(pSysConfig->SystemId));
|
|
|
//printf("data = %s\r\n", data);
|
|
|
//len =
|
|
|
- string2ByteArray((char *)data, (uint8_t *)ShmSysConfigAndInfo->SysConfig.SystemId);
|
|
|
- //printf("SystemId = %s\r\n", ShmSysConfigAndInfo->SysConfig.SystemId);
|
|
|
+ string2ByteArray((char *)data, (uint8_t *)pSysConfig->SystemId);
|
|
|
+ //printf("SystemId = %s\r\n", pSysConfig->SystemId);
|
|
|
}
|
|
|
|
|
|
//if ((char *)&data[len] == '\0') {
|
|
@@ -500,7 +510,7 @@ static int updateFirmwareHandle(uint8_t *imgName)
|
|
|
log_info("Program ready to check file %s\n", cmdBuf);
|
|
|
if ( access(cmdBuf, F_OK) != -1) {
|
|
|
log_info("File '%s' exist.\n", cmdBuf);
|
|
|
- ShmSysConfigAndInfo->SysInfo.FirmwareUpdate = YES;
|
|
|
+ pSysInfo->FirmwareUpdate = YES;
|
|
|
} else {
|
|
|
log_info("File '%s' doesn't exist.\n", cmdBuf);
|
|
|
ret = FAIL;
|
|
@@ -527,7 +537,7 @@ static int updateFirmwareHandle(uint8_t *imgName)
|
|
|
if (WIFEXITED(status)) {
|
|
|
if (0 == WEXITSTATUS(status)) {
|
|
|
printf("run shell script successfully.\n");
|
|
|
- ShmSysConfigAndInfo->SysInfo.FirmwareUpdate = YES;
|
|
|
+ pSysInfo->FirmwareUpdate = YES;
|
|
|
} else {
|
|
|
printf("run shell script fail, script exit code: %d\n", WEXITSTATUS(status));
|
|
|
}
|
|
@@ -597,9 +607,9 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
|
|
|
prices = transPricesUnit((int)value);
|
|
|
log_info("default prices = %.2f\r\n", prices);
|
|
|
|
|
|
- //ShmSysConfigAndInfo->SysConfig.BillingData.isBilling = YES;
|
|
|
+ //pSysConfig->BillingData.isBilling = YES;
|
|
|
for (j = 0; j < 24; j++) {
|
|
|
- ShmSysConfigAndInfo->SysConfig.BillingData.Fee[j] = prices;
|
|
|
+ pSysConfig->BillingData.Fee[j] = prices;
|
|
|
}
|
|
|
|
|
|
clearMiscCommand();
|
|
@@ -613,12 +623,12 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
|
|
|
|
|
|
//log_info("default currency = %s%c\r\n", (uint8_t *)Currency[value]);
|
|
|
log_info("default currency = %s\r\n", (uint8_t *)GetCurrency(value));
|
|
|
- ShmSysConfigAndInfo->SysConfig.BillingData.Currency = value;
|
|
|
+ pSysConfig->BillingData.Currency = value;
|
|
|
clearMiscCommand();
|
|
|
break;
|
|
|
|
|
|
case MISC_CMD_ACCOUNT_BALANCE:
|
|
|
- if (ShmSysConfigAndInfo->SysInfo.CurGunSelected != (plugNum)) {
|
|
|
+ if (pSysInfo->CurGunSelected != (plugNum)) {
|
|
|
clearMiscCommand();
|
|
|
break;
|
|
|
}
|
|
@@ -652,11 +662,11 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
|
|
|
break;
|
|
|
|
|
|
case MISC_CMD_BILLING_INFO:
|
|
|
- ShmSysConfigAndInfo->SysConfig.BillingData.isBilling = value;
|
|
|
+ pSysConfig->BillingData.isBilling = value;
|
|
|
break;
|
|
|
|
|
|
case MISC_CMD_WEB_STOP_CHARGING:
|
|
|
- ShmSysConfigAndInfo->SysConfig.StopChargingByButton = value;
|
|
|
+ pSysConfig->StopChargingByButton = value;
|
|
|
break;
|
|
|
|
|
|
//--- Control Dispenser ---
|
|
@@ -699,39 +709,39 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- if (ShmSysConfigAndInfo->SysInfo.CurGunSelected != (plugNum)) {
|
|
|
+ if (pSysInfo->CurGunSelected != (plugNum)) {
|
|
|
if (plugNum == LEFT_GUN_NUM &&
|
|
|
(ShmSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_CONFIRM ||
|
|
|
ShmSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_ATHOR)) {
|
|
|
ShmSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_RELEASE;
|
|
|
- strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
|
|
|
- ShmSysConfigAndInfo->SysInfo.WaitForPlugit = NO;
|
|
|
+ strcpy((char *)pSysConfig->UserId, "");
|
|
|
+ pSysInfo->WaitForPlugit = NO;
|
|
|
sleep(1); //Jerry add
|
|
|
- ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_SELECT_GUN;
|
|
|
- gettimeofday(&ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer, NULL);
|
|
|
- ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag = Timeout_None;
|
|
|
+ pSysInfo->SystemPage = _LCM_SELECT_GUN;
|
|
|
+ gettimeofday(&pSysInfo->SystemTimeoutTimer, NULL);
|
|
|
+ pSysInfo->SystemTimeoutFlag = Timeout_None;
|
|
|
}
|
|
|
|
|
|
if (plugNum == RIGHT_GUN_NUM &&
|
|
|
(ShmSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_CONFIRM ||
|
|
|
ShmSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_ATHOR)) {
|
|
|
ShmSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_RELEASE;
|
|
|
- strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
|
|
|
- ShmSysConfigAndInfo->SysInfo.WaitForPlugit = NO;
|
|
|
+ strcpy((char *)pSysConfig->UserId, "");
|
|
|
+ pSysInfo->WaitForPlugit = NO;
|
|
|
sleep(1); //Jerry add
|
|
|
- ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_SELECT_GUN;
|
|
|
- gettimeofday(&ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer, NULL);
|
|
|
- ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag = Timeout_None;
|
|
|
+ pSysInfo->SystemPage = _LCM_SELECT_GUN;
|
|
|
+ gettimeofday(&pSysInfo->SystemTimeoutTimer, NULL);
|
|
|
+ pSysInfo->SystemTimeoutFlag = Timeout_None;
|
|
|
}
|
|
|
|
|
|
- ShmSysConfigAndInfo->SysInfo.CurGunSelected = (plugNum);
|
|
|
- ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = NO_DEFINE;
|
|
|
+ pSysInfo->CurGunSelected = (plugNum);
|
|
|
+ pSysInfo->CurGunSelectedByAc = NO_DEFINE;
|
|
|
}
|
|
|
#else
|
|
|
- ShmSysConfigAndInfo->SysInfo.CurGunSelected = (plugNum);
|
|
|
- ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = NO_DEFINE;
|
|
|
+ pSysInfo->CurGunSelected = (plugNum);
|
|
|
+ pSysInfo->CurGunSelectedByAc = NO_DEFINE;
|
|
|
#endif //DD360Audi
|
|
|
- setConfirmSelGun(ShmSysConfigAndInfo->SysInfo.CurGunSelected);
|
|
|
+ setConfirmSelGun(pSysInfo->CurGunSelected);
|
|
|
|
|
|
ShmOCPP16Data->CsMsg.bits[plugNum].RemoteStartTransactionReq = YES;
|
|
|
ShmSelectGunInfo->PricesInfo[plugNum].Balance = 0.00;
|
|
@@ -746,11 +756,11 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
|
|
|
- ShmSysConfigAndInfo->SysInfo.WaitForPlugit = NO;
|
|
|
- ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_SELECT_GUN;
|
|
|
- gettimeofday(&ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer, NULL);
|
|
|
- ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag = Timeout_None;
|
|
|
+ strcpy((char *)pSysConfig->UserId, "");
|
|
|
+ pSysInfo->WaitForPlugit = NO;
|
|
|
+ pSysInfo->SystemPage = _LCM_SELECT_GUN;
|
|
|
+ gettimeofday(&pSysInfo->SystemTimeoutTimer, NULL);
|
|
|
+ pSysInfo->SystemTimeoutFlag = Timeout_None;
|
|
|
destroySelectGun(plugNum);
|
|
|
|
|
|
clearMiscCommand();
|
|
@@ -766,14 +776,16 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
|
|
|
|
|
|
if (isDetectPlugin() == YES) {
|
|
|
ClearDetectPluginFlag();
|
|
|
- strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
|
|
|
- ShmSysConfigAndInfo->SysInfo.WaitForPlugit = NO;
|
|
|
- ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_SELECT_GUN;
|
|
|
- gettimeofday(&ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer, NULL);
|
|
|
- ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag = Timeout_None;
|
|
|
+ strcpy((char *)pSysConfig->UserId, "");
|
|
|
+ pSysInfo->WaitForPlugit = NO;
|
|
|
+ pSysInfo->SystemPage = _LCM_SELECT_GUN;
|
|
|
+ gettimeofday(&pSysInfo->SystemTimeoutTimer, NULL);
|
|
|
+ pSysInfo->SystemTimeoutFlag = Timeout_None;
|
|
|
destroySelectGun(plugNum);
|
|
|
} else {
|
|
|
- ChargingData[plugNum]->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(plugNum);
|
|
|
+
|
|
|
+ pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -794,6 +806,7 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
|
|
|
static PricesInfo pricesInfo[2] = {0};
|
|
|
CapabilityInfo *pCapabilityInfo = NULL;
|
|
|
AccountInfo *pAccountInfo = NULL;
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(plugNum);
|
|
|
|
|
|
//--- charging capability information --------------------------------------
|
|
|
pCapabilityInfo = (CapabilityInfo *)&data[0];
|
|
@@ -803,7 +816,7 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
|
|
|
if (MaxVolt > MAX_VOLTAGE) {
|
|
|
MaxVolt = MAX_VOLTAGE;
|
|
|
}
|
|
|
- ChargingData[plugNum]->MaximumChargingVoltage = MaxVolt;
|
|
|
+ pDcChargingInfo->MaximumChargingVoltage = MaxVolt;
|
|
|
}
|
|
|
|
|
|
MaxCurrent = (float)(ntohs(pCapabilityInfo->OutputCurrent));
|
|
@@ -811,7 +824,7 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
|
|
|
if (MaxCurrent > MAX_CURRENCY) {
|
|
|
MaxCurrent = MAX_CURRENCY;
|
|
|
}
|
|
|
- ChargingData[plugNum]->AvailableChargingCurrent = MaxCurrent;
|
|
|
+ pDcChargingInfo->AvailableChargingCurrent = MaxCurrent;
|
|
|
}
|
|
|
|
|
|
MaxPower = (float)(ntohs(pCapabilityInfo->OutputPower));
|
|
@@ -819,7 +832,7 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
|
|
|
if (MaxPower > MAX_POWER) {
|
|
|
MaxPower = MAX_POWER;
|
|
|
}
|
|
|
- ChargingData[plugNum]->AvailableChargingPower = MaxPower;
|
|
|
+ pDcChargingInfo->AvailableChargingPower = MaxPower;
|
|
|
}
|
|
|
//MaxVolt = (float)(data[0] << 8 |data[1]);
|
|
|
//MaxCurrent = (float)(data[2] << 8 | data[3]);
|
|
@@ -830,9 +843,9 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
|
|
|
addr = (sizeof(CapabilityInfo) - 2); //2 byte reserved
|
|
|
pAccountInfo = (AccountInfo *)&data[addr];
|
|
|
|
|
|
- ShmSysConfigAndInfo->SysConfig.BillingData.Currency = pAccountInfo->Currency;
|
|
|
+ pSysConfig->BillingData.Currency = pAccountInfo->Currency;
|
|
|
ShmSelectGunInfo->PricesInfo[plugNum].UserPrices = transPricesUnit(ntohl(pAccountInfo->UserPrices));
|
|
|
- ChargingData[plugNum]->ChargingFee = transPricesUnit(ntohl(pAccountInfo->TotalCost));
|
|
|
+ pDcChargingInfo->ChargingFee = transPricesUnit(ntohl(pAccountInfo->TotalCost));
|
|
|
ShmSelectGunInfo->PricesInfo[plugNum].Balance = transPricesUnit(ntohl(pAccountInfo->Balance));
|
|
|
|
|
|
if ((pricesInfo[plugNum].UserPrices != ShmSelectGunInfo->PricesInfo[plugNum].UserPrices) ||
|
|
@@ -843,9 +856,9 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
|
|
|
log_info("id = %d, user prices = %.2f, Total cost = %.2f, Account balances = %.2f, currency = %s\r\n",
|
|
|
plugNum,
|
|
|
ShmSelectGunInfo->PricesInfo[plugNum].UserPrices,
|
|
|
- ChargingData[plugNum]->ChargingFee,
|
|
|
+ pDcChargingInfo->ChargingFee,
|
|
|
ShmSelectGunInfo->PricesInfo[plugNum].Balance,
|
|
|
- (uint8_t *)GetCurrency(ShmSysConfigAndInfo->SysConfig.BillingData.Currency)
|
|
|
+ (uint8_t *)GetCurrency(pSysConfig->BillingData.Currency)
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -854,13 +867,13 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
|
|
|
|
|
|
static void addFaultCodeToBuf(uint8_t *Code)
|
|
|
{
|
|
|
- uint8_t warningCount = ShmSysConfigAndInfo->SysWarningInfo.WarningCount;
|
|
|
+ uint8_t warningCount = pSysWarning->WarningCount;
|
|
|
|
|
|
if (warningCount < 10) {
|
|
|
- memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[warningCount][0],
|
|
|
+ memcpy(&pSysWarning->WarningCode[warningCount][0],
|
|
|
Code,
|
|
|
strlen((char *)Code));
|
|
|
- ShmSysConfigAndInfo->SysWarningInfo.WarningCount++;
|
|
|
+ pSysWarning->WarningCount++;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -876,20 +889,20 @@ static void removeFaultCodeToBuf(uint8_t *Code)
|
|
|
while (find) {
|
|
|
usleep(128);
|
|
|
find = 0x00;
|
|
|
- for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
|
|
|
+ for (i = 0; i < pSysWarning->WarningCount; i++) {
|
|
|
usleep(128);
|
|
|
if (find == 0x00) {
|
|
|
- if (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], _code, 7) == 0) {
|
|
|
+ if (memcmp(&pSysWarning->WarningCode[i][0], _code, 7) == 0) {
|
|
|
find = 0x01;
|
|
|
}
|
|
|
} else {
|
|
|
- memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i - 1][0],
|
|
|
- &ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], 7);
|
|
|
+ memcpy(&pSysWarning->WarningCode[i - 1][0],
|
|
|
+ &pSysWarning->WarningCode[i][0], 7);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (find) {
|
|
|
- ShmSysConfigAndInfo->SysWarningInfo.WarningCount--;
|
|
|
+ pSysWarning->WarningCount--;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -931,15 +944,15 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
|
|
|
if (dataLen < WARNING_CODE_SIZE) {
|
|
|
log_error("fail status code length = %d\r\n", dataLen);
|
|
|
Hexdump(data, dataLen);
|
|
|
- if (ShmSysConfigAndInfo->SysWarningInfo.WarningCount > 0) {
|
|
|
- for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
|
|
|
+ if (pSysWarning->WarningCount > 0) {
|
|
|
+ for (i = 0; i < pSysWarning->WarningCount; i++) {
|
|
|
usleep(128);
|
|
|
- if (ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][1] >= '3' || //from backend or power cabinet
|
|
|
- (ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0] >= 'B' &&
|
|
|
- ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][1] >= '4')) {
|
|
|
+ if (pSysWarning->WarningCode[i][1] >= '3' || //from backend or power cabinet
|
|
|
+ (pSysWarning->WarningCode[i][0] >= 'B' &&
|
|
|
+ pSysWarning->WarningCode[i][1] >= '4')) {
|
|
|
memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
|
|
|
memcpy(EventCodeTmp,
|
|
|
- ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i],
|
|
|
+ pSysWarning->WarningCode[i],
|
|
|
sizeof(EventCodeTmp));
|
|
|
removeFaultCodeToBuf(EventCodeTmp);
|
|
|
}
|
|
@@ -982,9 +995,9 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
|
|
|
strncpy((char *)&StatusArray[count / WARNING_CODE_SIZE], (char *)&data[count], WARNING_CODE_SIZE);
|
|
|
|
|
|
ret = 0;
|
|
|
- for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
|
|
|
+ for (i = 0; i < pSysWarning->WarningCount; i++) {
|
|
|
usleep(128);
|
|
|
- if (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0],
|
|
|
+ if (memcmp(&pSysWarning->WarningCode[i][0],
|
|
|
StatusArray[count / WARNING_CODE_SIZE],
|
|
|
WARNING_CODE_SIZE) == 0) {
|
|
|
ret = 1;
|
|
@@ -1004,17 +1017,17 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
|
|
|
+ for (i = 0; i < pSysWarning->WarningCount; i++) {
|
|
|
usleep(128);
|
|
|
|
|
|
- if (ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][1] >= '3' || //from backend or power cabinet 0x33
|
|
|
- (ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0] >= 'B' &&
|
|
|
- ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][1] >= '4')) {
|
|
|
+ if (pSysWarning->WarningCode[i][1] >= '3' || //from backend or power cabinet 0x33
|
|
|
+ (pSysWarning->WarningCode[i][0] >= 'B' &&
|
|
|
+ pSysWarning->WarningCode[i][1] >= '4')) {
|
|
|
ret = 0;
|
|
|
|
|
|
for (count = 0; count < (dataLen / WARNING_CODE_SIZE); count++) {
|
|
|
usleep(128);
|
|
|
- if (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0],
|
|
|
+ if (memcmp(&pSysWarning->WarningCode[i][0],
|
|
|
StatusArray[count],
|
|
|
WARNING_CODE_SIZE) == 0) {
|
|
|
ret = 1;
|
|
@@ -1025,7 +1038,7 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
|
|
|
if (ret == 0) {
|
|
|
memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
|
|
|
memcpy(EventCodeTmp,
|
|
|
- ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i],
|
|
|
+ pSysWarning->WarningCode[i],
|
|
|
sizeof(EventCodeTmp));
|
|
|
removeFaultCodeToBuf(EventCodeTmp);
|
|
|
}
|
|
@@ -1072,7 +1085,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
|
|
|
case REG_DISPENSER_STATUS:
|
|
|
memset(&gPreSysWarningInfo, 0, sizeof(struct WARNING_CODE_INFO));
|
|
|
memcpy((uint8_t *)&gPreSysWarningInfo,
|
|
|
- &(ShmSysConfigAndInfo->SysWarningInfo),
|
|
|
+ pSysWarning,
|
|
|
sizeof(struct WARNING_CODE_INFO));
|
|
|
break;
|
|
|
|
|
@@ -1220,9 +1233,9 @@ static int composeSocketData(int fd,
|
|
|
static int writeWaitPlugItState(int fd, uint8_t id)
|
|
|
{
|
|
|
int ret = PASS;
|
|
|
- uint8_t data[2] = {ShmSysConfigAndInfo->SysInfo.WaitForPlugit, 0};
|
|
|
+ uint8_t data[2] = {pSysInfo->WaitForPlugit, 0};
|
|
|
|
|
|
- //printf("WaitForPlugit = %d\r\n", ShmSysConfigAndInfo->SysInfo.WaitForPlugit);
|
|
|
+ //printf("WaitForPlugit = %d\r\n", pSysInfo->WaitForPlugit);
|
|
|
|
|
|
if ((ret = composeSocketData(fd,
|
|
|
id,
|
|
@@ -1254,11 +1267,12 @@ static int writePresentChargingInfo(int fd, uint8_t plugNum, uint8_t id)
|
|
|
int ret = PASS;
|
|
|
uint8_t dataBuf[16] = {0};
|
|
|
PreChargingInfo *pPreChargingInfo = (PreChargingInfo *)dataBuf;
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(plugNum);
|
|
|
|
|
|
- pPreChargingInfo->PresentChargingVoltage = htons((uint16_t)ChargingData[plugNum]->PresentChargingVoltage * 10);
|
|
|
- pPreChargingInfo->PresentChargingCurrent = htons((uint16_t)ChargingData[plugNum]->PresentChargingCurrent * 10);
|
|
|
- pPreChargingInfo->RemainChargingDuration = htonl(ChargingData[plugNum]->RemainChargingDuration);
|
|
|
- pPreChargingInfo->EvBatterySoc = ChargingData[plugNum]->EvBatterySoc;
|
|
|
+ pPreChargingInfo->PresentChargingVoltage = htons((uint16_t)pDcChargingInfo->PresentChargingVoltage * 10);
|
|
|
+ pPreChargingInfo->PresentChargingCurrent = htons((uint16_t)pDcChargingInfo->PresentChargingCurrent * 10);
|
|
|
+ pPreChargingInfo->RemainChargingDuration = htonl(pDcChargingInfo->RemainChargingDuration);
|
|
|
+ pPreChargingInfo->EvBatterySoc = pDcChargingInfo->EvBatterySoc;
|
|
|
|
|
|
ret = composeSocketData(fd,
|
|
|
id,
|
|
@@ -1276,15 +1290,15 @@ static int writeOtherModuleVersion(int fd)
|
|
|
uint8_t dataLen = 0;
|
|
|
|
|
|
//report other module version message
|
|
|
- memcpy(&data[dataLen], ShmSysConfigAndInfo->SysInfo.FanModuleFwRev, VERSION_BUF_SIZE);
|
|
|
+ memcpy(&data[dataLen], pSysInfo->FanModuleFwRev, VERSION_BUF_SIZE);
|
|
|
dataLen += VERSION_BUF_SIZE;
|
|
|
- memcpy(&data[dataLen], ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev, VERSION_BUF_SIZE);
|
|
|
+ memcpy(&data[dataLen], pSysInfo->RelayModuleFwRev, VERSION_BUF_SIZE);
|
|
|
dataLen += VERSION_BUF_SIZE;
|
|
|
- memcpy(&data[dataLen], ShmSysConfigAndInfo->SysInfo.Connector1FwRev, VERSION_BUF_SIZE);
|
|
|
+ memcpy(&data[dataLen], pSysInfo->Connector1FwRev, VERSION_BUF_SIZE);
|
|
|
dataLen += VERSION_BUF_SIZE;
|
|
|
- memcpy(&data[dataLen], ShmSysConfigAndInfo->SysInfo.Connector2FwRev, VERSION_BUF_SIZE);
|
|
|
+ memcpy(&data[dataLen], pSysInfo->Connector2FwRev, VERSION_BUF_SIZE);
|
|
|
dataLen += VERSION_BUF_SIZE;
|
|
|
- memcpy(&data[dataLen], ShmSysConfigAndInfo->SysInfo.LedModuleFwRev, VERSION_BUF_SIZE);
|
|
|
+ memcpy(&data[dataLen], pSysInfo->LedModuleFwRev, VERSION_BUF_SIZE);
|
|
|
dataLen += VERSION_BUF_SIZE;
|
|
|
|
|
|
ret = composeSocketData(fd,
|
|
@@ -1304,13 +1318,13 @@ static int writeCsuModuleVersion(int fd)
|
|
|
uint8_t dataLen = 0;
|
|
|
|
|
|
//report CSU platform version message
|
|
|
- memcpy(&data[dataLen], ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev, VERSION_BUF_SIZE);
|
|
|
+ memcpy(&data[dataLen], pSysInfo->CsuBootLoadFwRev, VERSION_BUF_SIZE);
|
|
|
dataLen += VERSION_BUF_SIZE;
|
|
|
- memcpy(&data[dataLen], ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev, VERSION_BUF_SIZE);
|
|
|
+ memcpy(&data[dataLen], pSysInfo->CsuKernelFwRev, VERSION_BUF_SIZE);
|
|
|
dataLen += VERSION_BUF_SIZE;
|
|
|
- memcpy(&data[dataLen], ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, VERSION_BUF_SIZE);
|
|
|
+ memcpy(&data[dataLen], pSysInfo->CsuRootFsFwRev, VERSION_BUF_SIZE);
|
|
|
dataLen += VERSION_BUF_SIZE;
|
|
|
- memcpy(&data[dataLen], ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev, VERSION_BUF_SIZE);
|
|
|
+ memcpy(&data[dataLen], pSysInfo->CsuPrimFwRev, VERSION_BUF_SIZE);
|
|
|
dataLen += VERSION_BUF_SIZE;
|
|
|
|
|
|
ret = composeSocketData(fd,
|
|
@@ -1378,27 +1392,28 @@ static int writeConnectorState(int fd, uint8_t plugNum, uint8_t id)
|
|
|
ConnectorState *pConnState = (ConnectorState *)dataBuf;
|
|
|
static char vendorErrorCodeTmp[2][WARNING_CODE_SIZE] = {0};
|
|
|
int ret = PASS;
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(plugNum);
|
|
|
|
|
|
- pConnState->ConnectorTemp = ChargingData[plugNum]->ConnectorTemp;
|
|
|
- pConnState->ChillerTemp = ChargingData[plugNum]->ChillerTemp;
|
|
|
+ pConnState->ConnectorTemp = pDcChargingInfo->ConnectorTemp;
|
|
|
+ pConnState->ChillerTemp = pDcChargingInfo->ChillerTemp;
|
|
|
|
|
|
- if (ChargingData[plugNum]->SystemStatus <= S_AUTHORIZING) {
|
|
|
+ if (pDcChargingInfo->SystemStatus <= S_AUTHORIZING) {
|
|
|
pConnState->State = CONN_ST_IDLE; //idle
|
|
|
strncpy((char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode,
|
|
|
"",
|
|
|
sizeof(ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode));
|
|
|
|
|
|
strncpy(&vendorErrorCodeTmp[plugNum][0], "", WARNING_CODE_SIZE);
|
|
|
- } else if ((ChargingData[plugNum]->SystemStatus <= S_PREPARING_FOR_EVSE) ||
|
|
|
- (ChargingData[plugNum]->SystemStatus == S_CCS_PRECHARGE_ST0) ||
|
|
|
- (ChargingData[plugNum]->SystemStatus == S_CCS_PRECHARGE_ST1)) {
|
|
|
+ } else if ((pDcChargingInfo->SystemStatus <= S_PREPARING_FOR_EVSE) ||
|
|
|
+ (pDcChargingInfo->SystemStatus == S_CCS_PRECHARGE_ST0) ||
|
|
|
+ (pDcChargingInfo->SystemStatus == S_CCS_PRECHARGE_ST1)) {
|
|
|
pConnState->State = CONN_ST_PREPARING; //preparing
|
|
|
- } else if (ChargingData[plugNum]->SystemStatus == S_CHARGING) {
|
|
|
+ } else if (pDcChargingInfo->SystemStatus == S_CHARGING) {
|
|
|
pConnState->State = CONN_ST_CHARGING; //charging
|
|
|
- } else if (ChargingData[plugNum]->SystemStatus == S_TERMINATING) {
|
|
|
+ } else if (pDcChargingInfo->SystemStatus == S_TERMINATING) {
|
|
|
pConnState->State = CONN_ST_TERMINATING; //terminating
|
|
|
- } else if ((ChargingData[plugNum]->SystemStatus == S_ALARM) ||
|
|
|
- (ChargingData[plugNum]->SystemStatus == S_FAULT)) {
|
|
|
+ } else if ((pDcChargingInfo->SystemStatus == S_ALARM) ||
|
|
|
+ (pDcChargingInfo->SystemStatus == S_FAULT)) {
|
|
|
pConnState->State = CONN_ST_ALARM;
|
|
|
strncpy((char *)pConnState->WarningCode,
|
|
|
(char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode,
|
|
@@ -1440,7 +1455,8 @@ static int writeConnectorState(int fd, uint8_t plugNum, uint8_t id)
|
|
|
static int writePlugInStatus(int fd, uint8_t plugNum, uint8_t id)
|
|
|
{
|
|
|
int ret = PASS;
|
|
|
- uint8_t dataBuf[2] = {ChargingData[plugNum]->ConnectorPlugIn, 0};
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(plugNum);
|
|
|
+ uint8_t dataBuf[2] = {pDcChargingInfo->ConnectorPlugIn, 0};
|
|
|
|
|
|
ret = composeSocketData(fd,
|
|
|
id,
|
|
@@ -1454,7 +1470,7 @@ static int writePlugInStatus(int fd, uint8_t plugNum, uint8_t id)
|
|
|
static int readSoftwareUpdate(int fd, uint8_t gunID)
|
|
|
{
|
|
|
int ret = PASS;
|
|
|
- uint8_t dataBuf[2] = {ShmSysConfigAndInfo->SysInfo.FirmwareUpdate, 0};
|
|
|
+ uint8_t dataBuf[2] = {pSysInfo->FirmwareUpdate, 0};
|
|
|
|
|
|
ret = composeSocketData(fd,
|
|
|
gunID,
|
|
@@ -1471,9 +1487,10 @@ static int writeChargingTarget(int fd, uint8_t plugNum, uint8_t id)
|
|
|
int ret = PASS;
|
|
|
float ChargingVolt, ChargingAmp;
|
|
|
uint8_t dataBuf[4] = {0};
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(plugNum);
|
|
|
|
|
|
- ChargingVolt = ChargingData[plugNum]->EvBatterytargetVoltage;
|
|
|
- ChargingAmp = ChargingData[plugNum]->EvBatterytargetCurrent;
|
|
|
+ ChargingVolt = pDcChargingInfo->EvBatterytargetVoltage;
|
|
|
+ ChargingAmp = pDcChargingInfo->EvBatterytargetCurrent;
|
|
|
ChargingVolt *= 10;
|
|
|
ChargingAmp *= 10;
|
|
|
|
|
@@ -1514,14 +1531,14 @@ static int writeDispenserStatus(int fd, uint8_t gunID)
|
|
|
uint8_t PreWarnCodeTmp[10][6] = {0};
|
|
|
int ret = PASS;
|
|
|
|
|
|
- if ((ShmSysConfigAndInfo->SysWarningInfo.WarningCount <= 0) &&
|
|
|
+ if ((pSysWarning->WarningCount <= 0) &&
|
|
|
(gPreSysWarningInfo.WarningCount <= 0)) {
|
|
|
return FAIL;
|
|
|
}
|
|
|
|
|
|
- warningCount = ShmSysConfigAndInfo->SysWarningInfo.WarningCount;
|
|
|
+ warningCount = pSysWarning->WarningCount;
|
|
|
for (count = 0; count < warningCount; count++) {
|
|
|
- memcpy(CurWarnCodeTmp[count], ShmSysConfigAndInfo->SysWarningInfo.WarningCode[count], WARNING_CODE_SIZE);
|
|
|
+ memcpy(CurWarnCodeTmp[count], pSysWarning->WarningCode[count], WARNING_CODE_SIZE);
|
|
|
}
|
|
|
|
|
|
warningCount = gPreSysWarningInfo.WarningCount;
|
|
@@ -1578,20 +1595,20 @@ static int WriteModelName(int fd)
|
|
|
uint8_t TmpBuf[255] = {0};
|
|
|
|
|
|
memcpy(TmpBuf,
|
|
|
- ShmSysConfigAndInfo->SysConfig.ModelName,
|
|
|
- strlen((char *)ShmSysConfigAndInfo->SysConfig.ModelName));
|
|
|
+ pSysConfig->ModelName,
|
|
|
+ strlen((char *)pSysConfig->ModelName));
|
|
|
|
|
|
Tmp = (uint8_t)(ShmPrimaryMcuData->InputDet.bits.Key2 << 2 |
|
|
|
ShmPrimaryMcuData->InputDet.bits.Key1 << 1 |
|
|
|
ShmPrimaryMcuData->InputDet.bits.Key0);
|
|
|
|
|
|
- TmpBuf[strlen((char *)ShmSysConfigAndInfo->SysConfig.ModelName)] = Tmp; //Dispenser switch value
|
|
|
+ TmpBuf[strlen((char *)pSysConfig->ModelName)] = Tmp; //Dispenser switch value
|
|
|
|
|
|
ret = composeSocketData(fd,
|
|
|
ID_REGISTER,
|
|
|
OP_WRITE_DATA,
|
|
|
REG_MODEL_NAME,
|
|
|
- strlen((char *)ShmSysConfigAndInfo->SysConfig.ModelName) + 1,
|
|
|
+ strlen((char *)pSysConfig->ModelName) + 1,
|
|
|
&TmpBuf[0]);
|
|
|
|
|
|
return ret;
|
|
@@ -1610,7 +1627,7 @@ static void calDisconnectCount(uint8_t *pValue, uint8_t maxCount)
|
|
|
|
|
|
static int CheckNetworkStatus(void)
|
|
|
{
|
|
|
- char *ipAddr = (char *)&ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress;
|
|
|
+ char *ipAddr = (char *)&pSysConfig->Eth0Interface.EthIpAddress;
|
|
|
|
|
|
//printf("Check network IP Header = %s\n", ipAddr);
|
|
|
if (strstr(ipAddr, CMP_ETH_IP_HEAD) != NULL) {
|
|
@@ -1620,27 +1637,28 @@ static int CheckNetworkStatus(void)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+#if 0
|
|
|
static int FindChargingInfoData(uint8_t target, struct ChargingInfoData **chargingData)
|
|
|
{
|
|
|
uint8_t index = 0;
|
|
|
|
|
|
for (index = 0; index < CHAdeMO_QUANTITY; index++) {
|
|
|
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == target) {
|
|
|
- chargingData[target] = &ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index];
|
|
|
+ if (pSysInfo->ChademoChargingData[index].Index == target) {
|
|
|
+ chargingData[target] = &pSysInfo->ChademoChargingData[index];
|
|
|
return 1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (index = 0; index < CCS_QUANTITY; index++) {
|
|
|
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == target) {
|
|
|
- chargingData[target] = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[index];
|
|
|
+ if (pSysInfo->CcsChargingData[index].Index == target) {
|
|
|
+ chargingData[target] = &pSysInfo->CcsChargingData[index];
|
|
|
return 1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (index = 0; index < GB_QUANTITY; index++) {
|
|
|
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == target) {
|
|
|
- chargingData[target] = &ShmSysConfigAndInfo->SysInfo.GbChargingData[index];
|
|
|
+ if (pSysInfo->GbChargingData[index].Index == target) {
|
|
|
+ chargingData[target] = &pSysInfo->GbChargingData[index];
|
|
|
return 1;
|
|
|
}
|
|
|
}
|
|
@@ -1706,6 +1724,7 @@ static int InitShareMemory(void)
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
+#endif //0
|
|
|
|
|
|
static void updateFirmwareProcess(int fd, uint8_t gunID, uint8_t totalConnCount)
|
|
|
{
|
|
@@ -1713,12 +1732,13 @@ static void updateFirmwareProcess(int fd, uint8_t gunID, uint8_t totalConnCount)
|
|
|
uint8_t plugNum = 0;
|
|
|
uint8_t ackCount = 5;
|
|
|
struct timeb updateTime;
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(plugNum);
|
|
|
|
|
|
- if (ShmSysConfigAndInfo->SysWarningInfo.Level != 2) {
|
|
|
+ if (pSysWarning->Level != 2) {
|
|
|
for (plugNum = 0; plugNum < totalConnCount; plugNum++) {
|
|
|
- if (ChargingData[plugNum]->SystemStatus != S_IDLE &&
|
|
|
- ChargingData[plugNum]->SystemStatus != S_RESERVATION &&
|
|
|
- ChargingData[plugNum]->SystemStatus != S_MAINTAIN) {
|
|
|
+ if (pDcChargingInfo->SystemStatus != S_IDLE &&
|
|
|
+ pDcChargingInfo->SystemStatus != S_RESERVATION &&
|
|
|
+ pDcChargingInfo->SystemStatus != S_MAINTAIN) {
|
|
|
canUpdateFirmware = false;
|
|
|
}
|
|
|
}
|
|
@@ -1731,13 +1751,13 @@ static void updateFirmwareProcess(int fd, uint8_t gunID, uint8_t totalConnCount)
|
|
|
ftime(&gRegTimeUp[0][REG_SOFTWARE_UPDATE]);
|
|
|
}
|
|
|
|
|
|
- if (ShmSysConfigAndInfo->SysInfo.FirmwareUpdate == YES) {
|
|
|
+ if (pSysInfo->FirmwareUpdate == YES) {
|
|
|
while (ackCount != 0) {
|
|
|
ftime(&updateTime);
|
|
|
if (DiffTimeb(gRegTimeUp[0][REG_SOFTWARE_UPDATE], updateTime) > LOOP_RETRY_TIME / 2) {
|
|
|
readSoftwareUpdate(fd, gunID);
|
|
|
ftime(&gRegTimeUp[0][REG_SOFTWARE_UPDATE]);
|
|
|
- if (ShmSysConfigAndInfo->SysInfo.FirmwareUpdate == NO) {
|
|
|
+ if (pSysInfo->FirmwareUpdate == NO) {
|
|
|
ackCount--;
|
|
|
}
|
|
|
}
|
|
@@ -1754,22 +1774,22 @@ static void checkAuthorProcess(int fd, uint8_t plugNum)
|
|
|
struct timeb AuthNowTime;
|
|
|
|
|
|
#if defined DD360Audi
|
|
|
- gunID = gDoCommGblData.ConnectorID[ShmSysConfigAndInfo->SysInfo.CurGunSelected];
|
|
|
+ gunID = gDoCommGblData.ConnectorID[pSysInfo->CurGunSelected];
|
|
|
//gunID = gDoCommGblData.ConnectorID[plugNum];
|
|
|
#else
|
|
|
gunID = ID_REGISTER;
|
|
|
|
|
|
- ShmSelectGunInfo->PricesInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected].Balance = 0.0;
|
|
|
+ ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance = 0.0;
|
|
|
#endif // DD360Audi
|
|
|
|
|
|
if ((ShmOCPP16Data->SpMsg.bits.AuthorizeReq == YES) ||
|
|
|
- (ShmSysConfigAndInfo->SysInfo.AuthorizeFlag == YES)) {
|
|
|
+ (pSysInfo->AuthorizeFlag == YES)) {
|
|
|
ftime(&AuthNowTime);
|
|
|
|
|
|
if (DiffTimeb(gRegTimeUp[plugNum][REG_USER_ID], AuthNowTime) > LOOP_RETRY_TIME) {
|
|
|
ret = writeUserID(fd,
|
|
|
gunID,
|
|
|
- ShmSysConfigAndInfo->SysConfig.UserId);
|
|
|
+ pSysConfig->UserId);
|
|
|
if (ret >= 0) {
|
|
|
memset(ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status,
|
|
|
0,
|
|
@@ -1786,11 +1806,11 @@ static void checkAuthorProcess(int fd, uint8_t plugNum)
|
|
|
// FAIL_BALANCE_PRICES);
|
|
|
|
|
|
if (ShmSelectGunInfo->PricesInfo[plugNum].Balance != FAIL_BALANCE_PRICES) {
|
|
|
- ShmOCPP16Data->SpMsg.bits.AuthorizeConf = YES; //isAuthorizedComplete
|
|
|
- ShmOCPP16Data->SpMsg.bits.AuthorizeReq = NO;
|
|
|
- ShmSysConfigAndInfo->SysInfo.AuthorizeFlag = NO;
|
|
|
- ShmPsuData->SystemAvailablePower = NO;
|
|
|
- ShmPsuData->SystemPresentPsuQuantity = NO;
|
|
|
+ ShmOCPP16Data->SpMsg.bits.AuthorizeConf = YES; //isAuthorizedComplete
|
|
|
+ ShmOCPP16Data->SpMsg.bits.AuthorizeReq = NO;
|
|
|
+ pSysInfo->AuthorizeFlag = NO;
|
|
|
+ ShmPsuData->SystemAvailablePower = NO;
|
|
|
+ ShmPsuData->SystemPresentPsuQuantity = NO;
|
|
|
}
|
|
|
}
|
|
|
ftime(&gRegTimeUp[plugNum][REG_USER_ID]);
|
|
@@ -1860,7 +1880,7 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
|
|
|
// readSoftwareUpdate(fd);
|
|
|
// ftime(&gRegTimeUp[plugNum][curReg]);
|
|
|
// }
|
|
|
- // while (ShmSysConfigAndInfo->SysInfo.FirmwareUpdate == YES) {
|
|
|
+ // while (pSysInfo->FirmwareUpdate == YES) {
|
|
|
// ftime(&NowTime);
|
|
|
// if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowT ime) > LOOP_RETRY_TIME||
|
|
|
//DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
|
|
@@ -1971,7 +1991,7 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
|
|
|
|
|
|
//static bool isDetectPlugin()
|
|
|
//{
|
|
|
-// if (ShmSysConfigAndInfo->SysInfo.WaitForPlugit == YES) {
|
|
|
+// if (pSysInfo->WaitForPlugit == YES) {
|
|
|
// return YES;
|
|
|
// }
|
|
|
//
|
|
@@ -1982,8 +2002,9 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
|
{
|
|
|
uint8_t i = 0;
|
|
|
struct timeb AuthNowTime = {0};
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(plugNum);
|
|
|
|
|
|
- switch (ChargingData[plugNum]->SystemStatus) {
|
|
|
+ switch (pDcChargingInfo->SystemStatus) {
|
|
|
case S_IDLE:
|
|
|
case S_RESERVATION:
|
|
|
case S_MAINTAIN:
|
|
@@ -2020,7 +2041,9 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
|
if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) > LOOP_RETRY_TIME) {
|
|
|
if (readChargePermission(fd, gunID) && readChargingCapability(fd, gunID)) {
|
|
|
for (i = 0; i < totalGun; i++) {
|
|
|
- ShmPsuData->SystemAvailablePower += ChargingData[i]->AvailableChargingPower;
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
|
|
|
+
|
|
|
+ ShmPsuData->SystemAvailablePower += pDcChargingInfo->AvailableChargingPower;
|
|
|
}
|
|
|
ShmPsuData->SystemPresentPsuQuantity = (ShmPsuData->SystemAvailablePower / 30);
|
|
|
}
|
|
@@ -2047,7 +2070,7 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
|
log_info("S_PREPARING_FOR_EV Stop charging by power cabinet's permission = %d, %d\r\n",
|
|
|
plugNum,
|
|
|
REG_CHARGING_PERMISSION);
|
|
|
- ChargingData[plugNum]->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
|
|
|
+ pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
|
|
|
}
|
|
|
ftime(&gRegTimeUp[plugNum][REG_CHARGING_PERMISSION]);
|
|
|
}
|
|
@@ -2076,7 +2099,7 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
|
log_info("S_PREPARING_FOR_EVSE Stop charging by power cabinet's permission = %d, %d\r\n",
|
|
|
plugNum,
|
|
|
REG_CHARGING_PERMISSION);
|
|
|
- ChargingData[plugNum]->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
|
|
|
+ pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
|
|
|
}
|
|
|
ftime(&gRegTimeUp[plugNum][REG_CHARGING_PERMISSION]);
|
|
|
}
|
|
@@ -2102,8 +2125,8 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
|
log_info("Stop charging by power cabinet's permission = %d, %d\r\n",
|
|
|
plugNum,
|
|
|
REG_CHARGING_PERMISSION);
|
|
|
- ChargingData[plugNum]->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
|
|
|
- //printf("%d StopChargeFlag = %d\r\n", plugNum, ChargingData[plugNum]->StopChargeFlag);
|
|
|
+ pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
|
|
|
+ //printf("%d StopChargeFlag = %d\r\n", plugNum, pDcChargingInfo->StopChargeFlag);
|
|
|
}
|
|
|
ftime(&gRegTimeUp[plugNum][REG_CHARGING_PERMISSION]);
|
|
|
}
|
|
@@ -2133,7 +2156,7 @@ static int networkCreatePorcess(void)
|
|
|
{
|
|
|
int fd = 0;
|
|
|
|
|
|
- while (ShmSysConfigAndInfo->SysInfo.SelfTestSeq != _STEST_COMPLETE) {
|
|
|
+ while (pSysInfo->SelfTestSeq != _STEST_COMPLETE) {
|
|
|
usleep(128);
|
|
|
}
|
|
|
|
|
@@ -2141,7 +2164,7 @@ static int networkCreatePorcess(void)
|
|
|
|
|
|
/**************** Check Network **********/
|
|
|
log_info("Check Dispenser Network Information");
|
|
|
- while (ShmSysConfigAndInfo->SysInfo.SelfTestSeq != _STEST_COMPLETE) {
|
|
|
+ while (pSysInfo->SelfTestSeq != _STEST_COMPLETE) {
|
|
|
usleep(125);
|
|
|
}
|
|
|
|
|
@@ -2150,9 +2173,9 @@ static int networkCreatePorcess(void)
|
|
|
log_error("disconnect count = % d\r\n", gDoCommGblData.DisConnCount);
|
|
|
}
|
|
|
log_info("Dispenser Network Information checked: IP = % s Netmask = % s, Gateway = % s",
|
|
|
- ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress,
|
|
|
- ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthSubmaskAddress,
|
|
|
- ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthGatewayAddress);
|
|
|
+ pSysConfig->Eth0Interface.EthIpAddress,
|
|
|
+ pSysConfig->Eth0Interface.EthSubmaskAddress,
|
|
|
+ pSysConfig->Eth0Interface.EthGatewayAddress);
|
|
|
|
|
|
gDoCommGblData.DisConnCount = 0;
|
|
|
|
|
@@ -2164,9 +2187,9 @@ static int networkCreatePorcess(void)
|
|
|
}
|
|
|
log_info("Power cabinet connected(fd = % d): IP = % s Netmask = % s, Gateway = % s",
|
|
|
fd,
|
|
|
- ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress,
|
|
|
- ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthSubmaskAddress,
|
|
|
- ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthGatewayAddress);
|
|
|
+ pSysConfig->Eth0Interface.EthIpAddress,
|
|
|
+ pSysConfig->Eth0Interface.EthSubmaskAddress,
|
|
|
+ pSysConfig->Eth0Interface.EthGatewayAddress);
|
|
|
|
|
|
gDoCommGblData.DisConnCount = 0;
|
|
|
destroySelectGun(DESTROY_ALL_SEL);
|
|
@@ -2191,9 +2214,9 @@ int main(int argc, char *argv[])
|
|
|
InitSocketSigPipe();
|
|
|
|
|
|
/**************** Initialization **********/
|
|
|
- if (InitShareMemory() == 0) {
|
|
|
+ /*if (InitShareMemory() == 0) {
|
|
|
if (ShmStatusCodeData != NULL) {
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory = YES;
|
|
|
+ pAlarmCode->AlarmEvents.bits.FailToCreateShareMemory = YES;
|
|
|
}
|
|
|
|
|
|
log_error("DoComm Initial share memory fail\r\n");
|
|
@@ -2201,14 +2224,31 @@ int main(int argc, char *argv[])
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
+ */
|
|
|
+ if (CreateAllCsuShareMemory() == FAIL) {
|
|
|
+ log_error("create share memory error\r\n");
|
|
|
+ return FAIL;
|
|
|
+ }
|
|
|
|
|
|
- totalConnCount = ShmSysConfigAndInfo->SysConfig.TotalConnectorCount;
|
|
|
+ MappingGunChargingInfo("DoComm Task");
|
|
|
+
|
|
|
+ pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
|
|
|
+ pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
|
|
|
+ pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
|
|
|
+
|
|
|
+ pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
|
|
|
+ ShmPsuData = (struct PsuData *)GetShmPsuData();
|
|
|
+ ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
|
|
|
+ ShmOCPP16Data = (struct OCPP16Data *)GetShmOCPP16Data();
|
|
|
+ ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
|
|
|
+
|
|
|
+ totalConnCount = pSysConfig->TotalConnectorCount;
|
|
|
|
|
|
for (index = 0; index < totalConnCount; index++) {
|
|
|
- if (!FindChargingInfoData(index, &ChargingData[0])) {
|
|
|
- log_error("FindChargingInfoData false \n");
|
|
|
- break;
|
|
|
- }
|
|
|
+ //if (!FindChargingInfoData(index, &ChargingData[0])) {
|
|
|
+ // log_error("FindChargingInfoData false \n");
|
|
|
+ // break;
|
|
|
+ //}
|
|
|
clearPricesInfo(index);
|
|
|
}
|
|
|
|
|
@@ -2253,10 +2293,10 @@ int main(int argc, char *argv[])
|
|
|
setTcpStatus(ABNORMAL);
|
|
|
|
|
|
|
|
|
- if (ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient == 0) {
|
|
|
+ if (pSysConfig->Eth0Interface.EthDhcpClient == 0) {
|
|
|
sprintf(tmpbuf,
|
|
|
"/sbin/udhcpc -i eth0 -x hostname:CSU3_%s -s /root/dhcp_script/eth0.script > /dev/null &",
|
|
|
- ShmSysConfigAndInfo->SysConfig.SystemId);
|
|
|
+ pSysConfig->SystemId);
|
|
|
system(tmpbuf);
|
|
|
}
|
|
|
|