|
@@ -27,6 +27,7 @@
|
|
#include "../Config.h"
|
|
#include "../Config.h"
|
|
#include "../SelectGun/SelectGun.h"
|
|
#include "../SelectGun/SelectGun.h"
|
|
#include "../timeout.h"
|
|
#include "../timeout.h"
|
|
|
|
+#include "../DataBase/DataBase.h"
|
|
#include "DoComm.h"
|
|
#include "DoComm.h"
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
//------------------------------------------------------------------------------
|
|
@@ -58,7 +59,9 @@ static char ReservationIdTag[2][32];
|
|
static int LineStatusCode[2] = {0};
|
|
static int LineStatusCode[2] = {0};
|
|
static unsigned int LedIntensity = 0;
|
|
static unsigned int LedIntensity = 0;
|
|
static int TimeZoneOffset = 0;
|
|
static int TimeZoneOffset = 0;
|
|
-
|
|
|
|
|
|
+int RxLen;
|
|
|
|
+char Rxdata[1024];
|
|
|
|
+uint8_t _isplugin = 0;
|
|
//------------------------------------------------------------------------------
|
|
//------------------------------------------------------------------------------
|
|
static void removeFaultCodeToBuf(uint8_t *Code);
|
|
static void removeFaultCodeToBuf(uint8_t *Code);
|
|
static void addFaultCodeToBuf(uint8_t *Code);
|
|
static void addFaultCodeToBuf(uint8_t *Code);
|
|
@@ -200,6 +203,23 @@ static void setTcpStatus(uint8_t setValue)
|
|
static int sendTcpSocket(int fd, uint8_t *data, uint16_t dataLen)
|
|
static int sendTcpSocket(int fd, uint8_t *data, uint16_t dataLen)
|
|
{
|
|
{
|
|
int size = -1;
|
|
int size = -1;
|
|
|
|
+ int i;
|
|
|
|
+ char _info[1024];
|
|
|
|
+ int len = 0;
|
|
|
|
+
|
|
|
|
+ // ReadCmdline show network package
|
|
|
|
+ if (ShmDcCommonData->showNetPackage) {
|
|
|
|
+ len = 0;
|
|
|
|
+ len += sprintf(&_info[len], "Net Tx[%d]:", dataLen);
|
|
|
|
+ for (i = 0; i < dataLen; i++) {
|
|
|
|
+ if (i == 0)
|
|
|
|
+ len += sprintf(&_info[len], "[%X]\t", data[i]);
|
|
|
|
+ else
|
|
|
|
+ len += sprintf(&_info[len], "%X ", data[i]);
|
|
|
|
+ }
|
|
|
|
+ len += sprintf(&_info[len], "\n");
|
|
|
|
+ printf("%s", _info);
|
|
|
|
+ }
|
|
|
|
|
|
size = send(fd, data, dataLen , 0);
|
|
size = send(fd, data, dataLen , 0);
|
|
if ((size < 0) || (errno == EAGAIN)) {
|
|
if ((size < 0) || (errno == EAGAIN)) {
|
|
@@ -211,15 +231,34 @@ static int sendTcpSocket(int fd, uint8_t *data, uint16_t dataLen)
|
|
return size;
|
|
return size;
|
|
}
|
|
}
|
|
|
|
|
|
-static int recvTcpSocket(int fd, uint8_t *data, uint16_t dataLen)
|
|
|
|
|
|
+static int recvTcpSocket(int fd, uint8_t *data, uint16_t dataLen,uint8_t ishead)
|
|
{
|
|
{
|
|
int size = -1;
|
|
int size = -1;
|
|
|
|
+ int i;
|
|
uint8_t *pdata = (uint8_t *)data;
|
|
uint8_t *pdata = (uint8_t *)data;
|
|
|
|
|
|
size = recv(fd, pdata, dataLen, MSG_WAITALL);
|
|
size = recv(fd, pdata, dataLen, MSG_WAITALL);
|
|
if ((errno == EAGAIN) || (size < 0)) {
|
|
if ((errno == EAGAIN) || (size < 0)) {
|
|
log_error("Receive Socket Size = %d, EAGAIN error %d:%s", size, errno, strerror(errno));
|
|
log_error("Receive Socket Size = %d, EAGAIN error %d:%s", size, errno, strerror(errno));
|
|
}
|
|
}
|
|
|
|
+ // ReadCmdline show network package
|
|
|
|
+ if (ShmDcCommonData->showNetPackage) {
|
|
|
|
+ if (ishead) {
|
|
|
|
+ RxLen = 0;
|
|
|
|
+ RxLen += sprintf(&Rxdata[RxLen], "Net Rx[%d]:", size);
|
|
|
|
+ }
|
|
|
|
+ for (i = 0; i < dataLen; i++) {
|
|
|
|
+ if (ishead && i == 0)
|
|
|
|
+ RxLen += sprintf(&Rxdata[RxLen], "[%X]\t", data[i]);
|
|
|
|
+ else
|
|
|
|
+ RxLen += sprintf(&Rxdata[RxLen], "%X ", data[i]);
|
|
|
|
+ }
|
|
|
|
+ if (!ishead) {
|
|
|
|
+ RxLen += sprintf(&Rxdata[RxLen], "\n");
|
|
|
|
+ printf("%s", Rxdata);
|
|
|
|
+ strcpy(Rxdata,"");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
return size;
|
|
return size;
|
|
}
|
|
}
|
|
@@ -925,10 +964,6 @@ void AddDispenserReq(uint8_t* buff, MiscCommand* req)
|
|
buff[5] = req->Value[3];
|
|
buff[5] = req->Value[3];
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
|
|
static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
|
|
{
|
|
{
|
|
uint8_t addr = 0;
|
|
uint8_t addr = 0;
|
|
@@ -981,19 +1016,23 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
|
|
ShmSelectGunInfo->PricesInfo[plugNum].TransactionId = ntohl(pAccountInfo->Transaction);
|
|
ShmSelectGunInfo->PricesInfo[plugNum].TransactionId = ntohl(pAccountInfo->Transaction);
|
|
ShmSelectGunInfo->PricesInfo[plugNum].EnergyCost = transPricesUnit(ntohl(pAccountInfo->EnergyCost));
|
|
ShmSelectGunInfo->PricesInfo[plugNum].EnergyCost = transPricesUnit(ntohl(pAccountInfo->EnergyCost));
|
|
ShmSelectGunInfo->PricesInfo[plugNum].ParkingFee = transPricesUnit(ntohl(pAccountInfo->ParkingFee));
|
|
ShmSelectGunInfo->PricesInfo[plugNum].ParkingFee = transPricesUnit(ntohl(pAccountInfo->ParkingFee));
|
|
|
|
+ pAccountInfo->RemainAmount = ntohl(pAccountInfo->RemainAmount);
|
|
|
|
+ memcpy((char*)&ShmSelectGunInfo->PricesInfo[plugNum].RemainAmount, (char*)&pAccountInfo->RemainAmount, sizeof(uint32_t));
|
|
|
|
|
|
if ((pricesInfo[plugNum].UserPrices != ShmSelectGunInfo->PricesInfo[plugNum].UserPrices) ||
|
|
if ((pricesInfo[plugNum].UserPrices != ShmSelectGunInfo->PricesInfo[plugNum].UserPrices) ||
|
|
(pricesInfo[plugNum].Balance != ShmSelectGunInfo->PricesInfo[plugNum].Balance) ||
|
|
(pricesInfo[plugNum].Balance != ShmSelectGunInfo->PricesInfo[plugNum].Balance) ||
|
|
(pricesInfo[plugNum].Discount != ShmSelectGunInfo->PricesInfo[plugNum].Discount) ||
|
|
(pricesInfo[plugNum].Discount != ShmSelectGunInfo->PricesInfo[plugNum].Discount) ||
|
|
(pricesInfo[plugNum].TransactionId != ShmSelectGunInfo->PricesInfo[plugNum].TransactionId) ||
|
|
(pricesInfo[plugNum].TransactionId != ShmSelectGunInfo->PricesInfo[plugNum].TransactionId) ||
|
|
(pricesInfo[plugNum].EnergyCost != ShmSelectGunInfo->PricesInfo[plugNum].EnergyCost) ||
|
|
(pricesInfo[plugNum].EnergyCost != ShmSelectGunInfo->PricesInfo[plugNum].EnergyCost) ||
|
|
- (pricesInfo[plugNum].ParkingFee != ShmSelectGunInfo->PricesInfo[plugNum].ParkingFee)) {
|
|
|
|
|
|
+ (pricesInfo[plugNum].ParkingFee != ShmSelectGunInfo->PricesInfo[plugNum].ParkingFee) ||
|
|
|
|
+ (pricesInfo[plugNum].RemainAmount != ShmSelectGunInfo->PricesInfo[plugNum].RemainAmount)) {
|
|
pricesInfo[plugNum].UserPrices = ShmSelectGunInfo->PricesInfo[plugNum].UserPrices;
|
|
pricesInfo[plugNum].UserPrices = ShmSelectGunInfo->PricesInfo[plugNum].UserPrices;
|
|
pricesInfo[plugNum].Balance = ShmSelectGunInfo->PricesInfo[plugNum].Balance;
|
|
pricesInfo[plugNum].Balance = ShmSelectGunInfo->PricesInfo[plugNum].Balance;
|
|
pricesInfo[plugNum].Discount = ShmSelectGunInfo->PricesInfo[plugNum].Discount;
|
|
pricesInfo[plugNum].Discount = ShmSelectGunInfo->PricesInfo[plugNum].Discount;
|
|
pricesInfo[plugNum].TransactionId = ShmSelectGunInfo->PricesInfo[plugNum].TransactionId;
|
|
pricesInfo[plugNum].TransactionId = ShmSelectGunInfo->PricesInfo[plugNum].TransactionId;
|
|
pricesInfo[plugNum].ParkingFee = ShmSelectGunInfo->PricesInfo[plugNum].ParkingFee;
|
|
pricesInfo[plugNum].ParkingFee = ShmSelectGunInfo->PricesInfo[plugNum].ParkingFee;
|
|
pricesInfo[plugNum].EnergyCost = ShmSelectGunInfo->PricesInfo[plugNum].EnergyCost;
|
|
pricesInfo[plugNum].EnergyCost = ShmSelectGunInfo->PricesInfo[plugNum].EnergyCost;
|
|
|
|
+ pricesInfo[plugNum].RemainAmount = ShmSelectGunInfo->PricesInfo[plugNum].RemainAmount;
|
|
if (ShmSelectGunInfo->PricesInfo[plugNum].TransactionId != 0) {
|
|
if (ShmSelectGunInfo->PricesInfo[plugNum].TransactionId != 0) {
|
|
|
|
|
|
//ShmDcCommonData->TransactionInfo[plugNum].TransactionId = ShmSelectGunInfo->PricesInfo[plugNum].TransactionId;
|
|
//ShmDcCommonData->TransactionInfo[plugNum].TransactionId = ShmSelectGunInfo->PricesInfo[plugNum].TransactionId;
|
|
@@ -1010,6 +1049,7 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
|
|
log_info("Total Cost:%.2f", pDcChargingInfo->ChargingFee);
|
|
log_info("Total Cost:%.2f", pDcChargingInfo->ChargingFee);
|
|
log_info("Parking Fee:%.2f", ShmSelectGunInfo->PricesInfo[plugNum].ParkingFee);
|
|
log_info("Parking Fee:%.2f", ShmSelectGunInfo->PricesInfo[plugNum].ParkingFee);
|
|
log_info("Energy Cost:%.2f", ShmSelectGunInfo->PricesInfo[plugNum].EnergyCost);
|
|
log_info("Energy Cost:%.2f", ShmSelectGunInfo->PricesInfo[plugNum].EnergyCost);
|
|
|
|
+ log_info("Remain Amount:%.2f", ShmSelectGunInfo->PricesInfo[plugNum].RemainAmount);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1462,6 +1502,22 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
|
|
log_info("Gun%d Receipt:%s", plugNum, ShmDcCommonData->pGunInfo[plugNum].ReceiptInfo);
|
|
log_info("Gun%d Receipt:%s", plugNum, ShmDcCommonData->pGunInfo[plugNum].ReceiptInfo);
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
+ case REG_READ_CHARGING_TIMESTAMP:
|
|
|
|
+ if (pCsuResult->Data.Result == COMMAND_RESULT_NG) {
|
|
|
|
+ return COMMAND_RESULT_NG;
|
|
|
|
+ }
|
|
|
|
+ if (rawDataLen <= 2) {
|
|
|
|
+ log_info("No Charging timestamp");
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ strcpy((char*)ShmDcCommonData->pGunInfo[plugNum].ChargeStartTime, (char*)&pCsuResult->Data.Data[0]);
|
|
|
|
+ int timelen = strlen((char*)ShmDcCommonData->pGunInfo[plugNum].ChargeStartTime);
|
|
|
|
+ if (timelen != 0) {
|
|
|
|
+ timelen = strcpy((char*)ShmDcCommonData->pGunInfo[plugNum].ChargeStopTime, (char*)&pCsuResult->Data.Data[timelen+1]);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
case REG_POWER_CONSUMPTION_INFO:
|
|
case REG_POWER_CONSUMPTION_INFO:
|
|
if (pCsuResult->Data.Result == COMMAND_RESULT_NG) {
|
|
if (pCsuResult->Data.Result == COMMAND_RESULT_NG) {
|
|
return COMMAND_RESULT_NG;
|
|
return COMMAND_RESULT_NG;
|
|
@@ -1486,6 +1542,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
|
|
|
|
|
|
|
|
|
|
break;
|
|
break;
|
|
|
|
+
|
|
default:
|
|
default:
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -1530,14 +1587,14 @@ static int composeSocketData(int fd,
|
|
}
|
|
}
|
|
|
|
|
|
//receive result head
|
|
//receive result head
|
|
- if ((size = recvTcpSocket(fd, (uint8_t *)&csuResult.Head, sizeof(csuResult.Head))) < 0) {
|
|
|
|
|
|
+ if ((size = recvTcpSocket(fd, (uint8_t *)&csuResult.Head, sizeof(csuResult.Head), 1)) < 0) {
|
|
log_error("TCP socket RX head fail = %d", size);
|
|
log_error("TCP socket RX head fail = %d", size);
|
|
gDoCommGblData.DisConnCount++;
|
|
gDoCommGblData.DisConnCount++;
|
|
return FAIL;
|
|
return FAIL;
|
|
}
|
|
}
|
|
|
|
|
|
//receive result raw data
|
|
//receive result raw data
|
|
- if ((size = recvTcpSocket(fd, (uint8_t *)&csuResult.Data, csuResult.Head.DataLen)) < 0) {
|
|
|
|
|
|
+ if ((size = recvTcpSocket(fd, (uint8_t *)&csuResult.Data, csuResult.Head.DataLen, 0)) < 0) {
|
|
log_error("TCP socket RX data fail = %d", size);
|
|
log_error("TCP socket RX data fail = %d", size);
|
|
gDoCommGblData.DisConnCount++;
|
|
gDoCommGblData.DisConnCount++;
|
|
return FAIL;
|
|
return FAIL;
|
|
@@ -1679,11 +1736,29 @@ static int writeDeductInfo(int fd, uint8_t id,uint8_t gunIndex, RecordTransactio
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
*/
|
|
*/
|
|
|
|
+
|
|
|
|
+static int readChargingTimeStamp(int fd, uint8_t id)
|
|
|
|
+{
|
|
|
|
+ int ret = PASS;
|
|
|
|
+ if ((ret = composeSocketData(fd,
|
|
|
|
+ id,
|
|
|
|
+ OP_READ_DATA,
|
|
|
|
+ REG_READ_CHARGING_TIMESTAMP,
|
|
|
|
+ 0,
|
|
|
|
+ NULL)) == FAIL) {
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
static int writeWaitPlugItState(int fd, uint8_t id)
|
|
static int writeWaitPlugItState(int fd, uint8_t id)
|
|
{
|
|
{
|
|
int ret = PASS;
|
|
int ret = PASS;
|
|
uint8_t data[2] = {pSysInfo->WaitForPlugit, 0};
|
|
uint8_t data[2] = {pSysInfo->WaitForPlugit, 0};
|
|
-
|
|
|
|
|
|
+ if (_isplugin != pSysInfo->WaitForPlugit) {
|
|
|
|
+ log_info("Wait for plug:%s", pSysInfo->WaitForPlugit == 0 ? "disable" : "enable");
|
|
|
|
+ _isplugin = pSysInfo->WaitForPlugit;
|
|
|
|
+ }
|
|
//printf("WaitForPlugit = %d", pSysInfo->WaitForPlugit);
|
|
//printf("WaitForPlugit = %d", pSysInfo->WaitForPlugit);
|
|
|
|
|
|
if ((ret = composeSocketData(fd,
|
|
if ((ret = composeSocketData(fd,
|
|
@@ -1852,7 +1927,8 @@ static int writeUserID(int fd, uint8_t id, uint8_t *pUserID)
|
|
|
|
|
|
static int writeConnectorState(int fd, uint8_t plugNum, uint8_t id)
|
|
static int writeConnectorState(int fd, uint8_t plugNum, uint8_t id)
|
|
{
|
|
{
|
|
- uint8_t dataBuf[10] = {'\0'};
|
|
|
|
|
|
+ uint8_t dataBuf[15] = {'\0'};
|
|
|
|
+ uint32_t _consumption;
|
|
ConnectorState *pConnState = (ConnectorState *)dataBuf;
|
|
ConnectorState *pConnState = (ConnectorState *)dataBuf;
|
|
static char vendorErrorCodeTmp[2][WARNING_CODE_SIZE] = {0};
|
|
static char vendorErrorCodeTmp[2][WARNING_CODE_SIZE] = {0};
|
|
int ret = PASS;
|
|
int ret = PASS;
|
|
@@ -1912,7 +1988,10 @@ static int writeConnectorState(int fd, uint8_t plugNum, uint8_t id)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+#ifdef DD360
|
|
|
|
+ memcpy((char*)&_consumption, (char*)&ShmDcCommonData->pGunInfo[plugNum].PowerConsumption, sizeof(float));
|
|
|
|
+ pConnState->consumption = ntohl(_consumption);
|
|
|
|
+#endif
|
|
ret = composeSocketData(fd,
|
|
ret = composeSocketData(fd,
|
|
id,
|
|
id,
|
|
OP_WRITE_DATA,
|
|
OP_WRITE_DATA,
|
|
@@ -2319,7 +2398,7 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
|
|
case REG_CHARGING_CAP:
|
|
case REG_CHARGING_CAP:
|
|
if(gMoreInfoReq[plugNum].bits.FinalCostReq)
|
|
if(gMoreInfoReq[plugNum].bits.FinalCostReq)
|
|
{
|
|
{
|
|
- if (readChargingCapability(fd, gunID) == PASS) {
|
|
|
|
|
|
+ if (readChargingCapability(fd, gunID) == PASS && readChargingTimeStamp(fd, gunID) == PASS) {
|
|
gMoreInfoReq[plugNum].bits.FinalCostReq = false;
|
|
gMoreInfoReq[plugNum].bits.FinalCostReq = false;
|
|
pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(plugNum);
|
|
pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(plugNum);
|
|
//ShmDcCommonData->TransactionInfo[plugNum].Amount = pDcChargingInfo->ChargingFee;
|
|
//ShmDcCommonData->TransactionInfo[plugNum].Amount = pDcChargingInfo->ChargingFee;
|
|
@@ -2399,7 +2478,11 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
|
|
ftime(&gRegTimeUp[plugNum][curReg]);
|
|
ftime(&gRegTimeUp[plugNum][curReg]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- curReg = REG_READ_CABINET_SYSTEMID;
|
|
|
|
|
|
+#ifdef DD360Audi
|
|
|
|
+ curReg = REG_POWER_CONSUMPTION_INFO;
|
|
|
|
+#else
|
|
|
|
+ curReg = REG_READ_CABINET_SYSTEMID;
|
|
|
|
+#endif
|
|
break;
|
|
break;
|
|
//case REG_USER_ID:
|
|
//case REG_USER_ID:
|
|
// writeUserID(fd, gunID, uint8_t *pUserID);
|
|
// writeUserID(fd, gunID, uint8_t *pUserID);
|
|
@@ -2441,53 +2524,14 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
|
|
- //case REG_PRESENT_CHARGING_INFO:
|
|
|
|
- // break;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- //case REG_WAIT_PLUG_IT_STATE:
|
|
|
|
- // if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > (LOOP_RETRY_TIME / 10)) {
|
|
|
|
- // writeWaitPlugItState(fd, gunID);
|
|
|
|
- // ftime(&gRegTimeUp[plugNum][curReg]);
|
|
|
|
- // }
|
|
|
|
- // isContinue = 0;
|
|
|
|
- // break;
|
|
|
|
-
|
|
|
|
- //case REG_CABINET_DCM_VERSION:
|
|
|
|
- // break;
|
|
|
|
-
|
|
|
|
- //case REG_CABINET_OTHER_VERSION:
|
|
|
|
- // break;
|
|
|
|
-
|
|
|
|
- //case REG_TOTAL_PSU_QUANTITY:
|
|
|
|
- // break;
|
|
|
|
-
|
|
|
|
- //case REG_PSU_VERSION:
|
|
|
|
- // break;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- //case REG_DISPENSER_REQUEST:
|
|
|
|
- // break;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
case REG_READ_CABINET_SYSTEMID:
|
|
case REG_READ_CABINET_SYSTEMID:
|
|
- if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME ||
|
|
|
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > (LOOP_RETRY_TIME * 10) ||
|
|
DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
|
|
DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
|
|
readSystemID(fd);
|
|
readSystemID(fd);
|
|
ftime(&gRegTimeUp[plugNum][curReg]);
|
|
ftime(&gRegTimeUp[plugNum][curReg]);
|
|
}
|
|
}
|
|
- curReg = REG_POWER_CONSUMPTION_INFO;
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
- case REG_POWER_CONSUMPTION_INFO:
|
|
|
|
- if (pSysConfig->ShowInformation || ShmDcCommonData->debugflag) {
|
|
|
|
- if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME ||
|
|
|
|
- DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
|
|
|
|
- readConsumptionInfo(fd);
|
|
|
|
- ftime(&gRegTimeUp[plugNum][curReg]);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ curReg = REG_RESERVATION_IDTAG;
|
|
|
|
+ /*
|
|
//check misc command from power cabinet
|
|
//check misc command from power cabinet
|
|
if (gDoCommGblData.MiscCmd != 0) {
|
|
if (gDoCommGblData.MiscCmd != 0) {
|
|
if (gDoCommGblData.MiscCmd != REG_MISC_CONTROL) {
|
|
if (gDoCommGblData.MiscCmd != REG_MISC_CONTROL) {
|
|
@@ -2499,8 +2543,8 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
|
|
} else {
|
|
} else {
|
|
isContinue = 0;
|
|
isContinue = 0;
|
|
}
|
|
}
|
|
|
|
+ */
|
|
break;
|
|
break;
|
|
-
|
|
|
|
case REG_RESERVATION_IDTAG:
|
|
case REG_RESERVATION_IDTAG:
|
|
if (gMoreInfoReq[plugNum].bits.ReservationReq)
|
|
if (gMoreInfoReq[plugNum].bits.ReservationReq)
|
|
{
|
|
{
|
|
@@ -2513,8 +2557,30 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
|
|
ftime(&gRegTimeUp[plugNum][curReg]);
|
|
ftime(&gRegTimeUp[plugNum][curReg]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- curReg = REG_REMOTE_START_NO_ID;
|
|
|
|
|
|
+ curReg = REG_POWER_CONSUMPTION_INFO;
|
|
break;
|
|
break;
|
|
|
|
+ case REG_POWER_CONSUMPTION_INFO:
|
|
|
|
+ if (pSysConfig->ShowInformation || ShmDcCommonData->debugflag) {
|
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME ||
|
|
|
|
+ DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
|
|
|
|
+ readConsumptionInfo(fd);
|
|
|
|
+ ftime(&gRegTimeUp[plugNum][curReg]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //check misc command from power cabinet
|
|
|
|
+ if (gDoCommGblData.MiscCmd != 0) {
|
|
|
|
+ if (gDoCommGblData.MiscCmd != REG_MISC_CONTROL) {
|
|
|
|
+ log_error("misc command failed = %x", gDoCommGblData.MiscCmd);
|
|
|
|
+ }
|
|
|
|
+ curReg = gDoCommGblData.MiscCmd;
|
|
|
|
+ } else if (gMoreInfoReq[plugNum].Value != 0) {
|
|
|
|
+ curReg = REG_REMOTE_START_NO_ID;
|
|
|
|
+ } else {
|
|
|
|
+ isContinue = 0;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+
|
|
case REG_REMOTE_START_NO_ID:
|
|
case REG_REMOTE_START_NO_ID:
|
|
if (gMoreInfoReq[plugNum].bits.RemoteStartNoID)
|
|
if (gMoreInfoReq[plugNum].bits.RemoteStartNoID)
|
|
{
|
|
{
|
|
@@ -2637,6 +2703,17 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
case S_MAINTAIN:
|
|
case S_MAINTAIN:
|
|
case S_ALARM:
|
|
case S_ALARM:
|
|
case S_AUTHORIZING:
|
|
case S_AUTHORIZING:
|
|
|
|
+ /*
|
|
|
|
+ if(pDcChargingInfo->SystemStatus == S_ALARM) {
|
|
|
|
+ ftime(&AuthNowTime);
|
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][REG_READ_CHARGING_TIMESTAMP], AuthNowTime) > (LOOP_RETRY_TIME / 10) ||
|
|
|
|
+ DiffTimeb(gRegTimeUp[plugNum][REG_READ_CHARGING_TIMESTAMP], AuthNowTime) < 0
|
|
|
|
+ ) {
|
|
|
|
+ readChargingTimeStamp(fd, gunID);
|
|
|
|
+ ftime(&gRegTimeUp[plugNum][REG_READ_CHARGING_TIMESTAMP]);
|
|
|
|
+ }
|
|
|
|
+ }*/
|
|
|
|
+
|
|
checkAuthorProcess(fd, plugNum);
|
|
checkAuthorProcess(fd, plugNum);
|
|
|
|
|
|
//authorization complete, write wait plug it state
|
|
//authorization complete, write wait plug it state
|
|
@@ -2805,10 +2882,12 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 0
|
|
DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 0
|
|
) {
|
|
) {
|
|
if (readChargePermission(fd, gunID) == 0) {
|
|
if (readChargePermission(fd, gunID) == 0) {
|
|
- log_info("Stop charging by power cabinet's permission = %d, %d",
|
|
|
|
- plugNum,
|
|
|
|
- REG_CHARGING_PERMISSION);
|
|
|
|
- pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
|
|
|
|
|
|
+ if (pDcChargingInfo->StopChargeFlag != POWER_CABINET_STOP_CHARGING) {
|
|
|
|
+ log_info("Stop charging by power cabinet's permission = %d, %d",
|
|
|
|
+ plugNum,
|
|
|
|
+ REG_CHARGING_PERMISSION);
|
|
|
|
+ pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
|
|
|
|
+ }
|
|
//printf("%d StopChargeFlag = %d\n", plugNum, pDcChargingInfo->StopChargeFlag);
|
|
//printf("%d StopChargeFlag = %d\n", plugNum, pDcChargingInfo->StopChargeFlag);
|
|
}
|
|
}
|
|
ftime(&gRegTimeUp[plugNum][REG_CHARGING_PERMISSION]);
|
|
ftime(&gRegTimeUp[plugNum][REG_CHARGING_PERMISSION]);
|
|
@@ -2823,8 +2902,15 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
ftime(&gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO]);
|
|
ftime(&gRegTimeUp[plugNum][REG_PRESENT_CHARGING_INFO]);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 獲得Charging時間
|
|
|
|
+ ftime(&AuthNowTime);
|
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][REG_READ_CHARGING_TIMESTAMP], AuthNowTime) > (LOOP_RETRY_TIME*5) ||
|
|
|
|
+ DiffTimeb(gRegTimeUp[plugNum][REG_READ_CHARGING_TIMESTAMP], AuthNowTime) < 0
|
|
|
|
+ ) {
|
|
|
|
+ readChargingTimeStamp(fd, gunID);
|
|
|
|
+ ftime(&gRegTimeUp[plugNum][REG_READ_CHARGING_TIMESTAMP]);
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
-
|
|
|
|
case S_COMPLETE:
|
|
case S_COMPLETE:
|
|
ftime(&AuthNowTime);
|
|
ftime(&AuthNowTime);
|
|
if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) > LOOP_RETRY_TIME ||
|
|
if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) > LOOP_RETRY_TIME ||
|
|
@@ -2835,7 +2921,16 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
writeGroundFaultDetection(fd, 0, gunID);
|
|
writeGroundFaultDetection(fd, 0, gunID);
|
|
ftime(&gRegTimeUp[plugNum][REG_CHARGING_CAP]);
|
|
ftime(&gRegTimeUp[plugNum][REG_CHARGING_CAP]);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ // 獲得Charging時間
|
|
|
|
+ /*
|
|
|
|
+ ftime(&AuthNowTime);
|
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][REG_READ_CHARGING_TIMESTAMP], AuthNowTime) > (LOOP_RETRY_TIME / 10) ||
|
|
|
|
+ DiffTimeb(gRegTimeUp[plugNum][REG_READ_CHARGING_TIMESTAMP], AuthNowTime) < 0
|
|
|
|
+ ) {
|
|
|
|
+ readChargingTimeStamp(fd, gunID);
|
|
|
|
+ ftime(&gRegTimeUp[plugNum][REG_READ_CHARGING_TIMESTAMP]);
|
|
|
|
+ }
|
|
|
|
+ */
|
|
break;
|
|
break;
|
|
|
|
|
|
default:
|
|
default:
|