|
@@ -59,7 +59,7 @@ static char ReservationIdTag[2][32];
|
|
|
static int LineStatusCode[2] = {0};
|
|
|
static unsigned int LedIntensity = 0;
|
|
|
static int TimeZoneOffset = 0;
|
|
|
-
|
|
|
+uint8_t _isplugin[2] = { 0 };
|
|
|
//------------------------------------------------------------------------------
|
|
|
static void removeFaultCodeToBuf(uint8_t *Code);
|
|
|
static void addFaultCodeToBuf(uint8_t *Code);
|
|
@@ -176,7 +176,7 @@ int string2Date(char* input, uint8_t* output)
|
|
|
}
|
|
|
static void unixSocketSigPipeHandle(int sig)
|
|
|
{
|
|
|
- log_error("socket packet error %x", sig);
|
|
|
+ //log_error("socket packet error %x", sig);
|
|
|
}
|
|
|
|
|
|
static void InitSocketSigPipe(void)
|
|
@@ -316,17 +316,22 @@ static void ClearAuthorizedFlag(void)
|
|
|
pSysInfo->AuthorizeFlag = NO;
|
|
|
}
|
|
|
|
|
|
-static void ClearDetectPluginFlag(void)
|
|
|
+static void ClearDetectPluginFlag(int gunIndex)
|
|
|
{
|
|
|
- pSysInfo->WaitForPlugit = NO;
|
|
|
+ //pSysInfo->WaitForPlugit = NO;
|
|
|
+ ShmDcCommonData->pGunInfo[gunIndex].WaitForPlugit = NO;
|
|
|
}
|
|
|
|
|
|
-static bool isDetectPlugin(void)
|
|
|
+static bool isDetectPlugin(int gunIndex)
|
|
|
{
|
|
|
+ if (ShmDcCommonData->pGunInfo[gunIndex].WaitForPlugit == YES) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ /*
|
|
|
if (pSysInfo->WaitForPlugit == YES) {
|
|
|
return YES;
|
|
|
}
|
|
|
-
|
|
|
+ */
|
|
|
return NO;
|
|
|
}
|
|
|
|
|
@@ -367,29 +372,6 @@ static void destroySelectGun(uint8_t curGun)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static int getConfirmSelectedGun(uint8_t curSel)
|
|
|
-{
|
|
|
- if (((curSel == LEFT_GUN_NUM) && (ShmSelectGunInfo->SelGunInfo.LeftGun >= SEL_GUN_CONFIRM)) ||
|
|
|
- ((curSel == RIGHT_GUN_NUM) && (ShmSelectGunInfo->SelGunInfo.RightGun >= SEL_GUN_CONFIRM))) {
|
|
|
- return PASS;
|
|
|
- }
|
|
|
-
|
|
|
- return FAIL;
|
|
|
-}
|
|
|
-
|
|
|
-static int getSelGunWaitToAuthor(uint8_t curGun)
|
|
|
-{
|
|
|
- if (curGun == LEFT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_ATHOR) {
|
|
|
- return FAIL;
|
|
|
- }
|
|
|
-
|
|
|
- if (curGun == RIGHT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_ATHOR) {
|
|
|
- return FAIL;
|
|
|
- }
|
|
|
-
|
|
|
- return PASS;
|
|
|
-}
|
|
|
-
|
|
|
static void setConfirmSelGun(uint8_t selGun)
|
|
|
{
|
|
|
if (selGun == LEFT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_RELEASE) {
|
|
@@ -489,7 +471,7 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
|
|
|
string2Date((char*)data, (uint8_t*)_setTime);
|
|
|
//printf("SystemId = %s", pSysConfig->SystemId);
|
|
|
if (!timecmp(localTime, _setTime)) {
|
|
|
- log_info("Set Timer:%s", _setTime);
|
|
|
+ //log_info("Set Timer:%s", _setTime);
|
|
|
sprintf((char*)cmdBuf, "date -u -s \"%s\" >> /dev/null &", _setTime);
|
|
|
system((char*)cmdBuf);
|
|
|
system("hwclock -w -u");
|
|
@@ -654,13 +636,6 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
-#if defined DD360Audi
|
|
|
- if (getConfirmSelectedGun(plugNum) == FAIL) {
|
|
|
- log_info("Remote start not select gun");
|
|
|
- break;
|
|
|
- }
|
|
|
-#endif //DD360Audi
|
|
|
-
|
|
|
ShmSelectGunInfo->PricesInfo[plugNum].Balance = transPricesUnit((int)value);
|
|
|
log_info("%d misc balance = %.2f", plugNum, ShmSelectGunInfo->PricesInfo[plugNum].Balance);
|
|
|
clearMiscCommand();
|
|
@@ -728,45 +703,10 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
|
|
|
}
|
|
|
log_info("Remote start charging plugNum = %d", plugNum);
|
|
|
|
|
|
-#if defined DD360Audi
|
|
|
- if (getSelGunWaitToAuthor(plugNum) == FAIL) {
|
|
|
- log_error("Remote start gun already charging");
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- 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 *)pSysConfig->UserId, "");
|
|
|
- pSysInfo->WaitForPlugit = NO;
|
|
|
- sleep(1); //Jerry add
|
|
|
- pSysInfo->SystemPage = _LCM_SELECT_GUN;
|
|
|
- GetClockTime(&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 *)pSysConfig->UserId, "");
|
|
|
- pSysInfo->WaitForPlugit = NO;
|
|
|
- sleep(1); //Jerry add
|
|
|
- pSysInfo->SystemPage = _LCM_SELECT_GUN;
|
|
|
- GetClockTime(&pSysInfo->SystemTimeoutTimer, NULL);
|
|
|
- pSysInfo->SystemTimeoutFlag = Timeout_None;
|
|
|
- }
|
|
|
-
|
|
|
- pSysInfo->CurGunSelected = (plugNum);
|
|
|
- pSysInfo->CurGunSelectedByAc = NO_DEFINE;
|
|
|
- }
|
|
|
-#else
|
|
|
//pSysInfo->CurGunSelected = (plugNum);
|
|
|
pSysInfo->CurGunSelectedByAc = NO_DEFINE;
|
|
|
-#endif //DD360Audi
|
|
|
- setConfirmSelGun(pSysInfo->CurGunSelected);
|
|
|
+
|
|
|
+ setConfirmSelGun(plugNum);
|
|
|
|
|
|
ShmOCPP16Data->CsMsg.bits[plugNum].RemoteStartTransactionReq = YES;
|
|
|
ShmSelectGunInfo->PricesInfo[plugNum].Balance = 0.00;
|
|
@@ -782,7 +722,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
|
|
|
}
|
|
|
|
|
|
strcpy((char *)pSysConfig->UserId, "");
|
|
|
- pSysInfo->WaitForPlugit = NO;
|
|
|
+ ClearDetectPluginFlag(plugNum);
|
|
|
//pSysInfo->SystemPage = _LCM_SELECT_GUN;
|
|
|
GetClockTime(&pSysInfo->SystemTimeoutTimer, NULL);
|
|
|
pSysInfo->SystemTimeoutFlag = Timeout_None;
|
|
@@ -799,10 +739,9 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- if (isDetectPlugin() == YES) {
|
|
|
- ClearDetectPluginFlag();
|
|
|
+ if (isDetectPlugin(plugNum) == YES) {
|
|
|
+ ClearDetectPluginFlag(plugNum);
|
|
|
strcpy((char *)pSysConfig->UserId, "");
|
|
|
- pSysInfo->WaitForPlugit = NO;
|
|
|
//pSysInfo->SystemPage = _LCM_SELECT_GUN;
|
|
|
GetClockTime(&pSysInfo->SystemTimeoutTimer, NULL);
|
|
|
pSysInfo->SystemTimeoutFlag = Timeout_None;
|
|
@@ -871,8 +810,12 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
|
|
|
break;
|
|
|
case MISC_CMD_LINE_STATUS_REQ:
|
|
|
LineStatusCode[plugNum] = value;
|
|
|
- ShmDcCommonData->LineStatus[plugNum] = value;
|
|
|
+ ShmDcCommonData->TransactionInfo[plugNum].LineStatus = value;
|
|
|
log_info("Gun %d Line Status Code: %d", plugNum, LineStatusCode[plugNum]);
|
|
|
+ if (ShmDcCommonData->TransactionInfo[plugNum].LineStatus != value &&
|
|
|
+ strcmp((char*)ShmDcCommonData->TransactionInfo[plugNum].pCreditCard.VemData, "") != 0) {
|
|
|
+ UpdateDeductInfoStatus(plugNum,&ShmDcCommonData->TransactionInfo[plugNum]);
|
|
|
+ }
|
|
|
break;
|
|
|
case MISC_CMD_LED_INTENSITY:
|
|
|
LedIntensity = value;
|
|
@@ -889,6 +832,13 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
|
|
|
}
|
|
|
*/
|
|
|
break;
|
|
|
+ case MISC_CMD_CHARGING_BILL:
|
|
|
+ if (value != YES)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ gMoreInfoReq[plugNum].bits.ChargingBill = YES;
|
|
|
+ break;
|
|
|
default:
|
|
|
clearMiscCommand();
|
|
|
break;
|
|
@@ -912,8 +862,29 @@ void AddDispenserReq(uint8_t* buff, MiscCommand* req)
|
|
|
}
|
|
|
|
|
|
|
|
|
+static int chargingbillHandle(uint8_t* data, uint8_t gunIndex)
|
|
|
+{
|
|
|
|
|
|
+ ChargingBillInfo* pBillInfo = (ChargingBillInfo*)&data[0];
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gunIndex);
|
|
|
|
|
|
+ ShmDcCommonData->PriceBill.TotalCost = transPricesUnit(ntohl(pBillInfo->TotalCost));
|
|
|
+ ShmDcCommonData->PriceBill.Balance = transPricesUnit(ntohl(pBillInfo->Balance));
|
|
|
+ ShmDcCommonData->PriceBill.Discount = transPricesUnit(ntohl(pBillInfo->Discount));
|
|
|
+ ShmDcCommonData->PriceBill.TransactionId = ntohl(pBillInfo->Transaction);
|
|
|
+ ShmDcCommonData->PriceBill.EnergyCost = transPricesUnit(ntohl(pBillInfo->EnergyCost));
|
|
|
+ ShmDcCommonData->PriceBill.ParkingFee = transPricesUnit(ntohl(pBillInfo->ParkingFee));
|
|
|
+ pBillInfo->RemainAmount = ntohl(pBillInfo->RemainAmount);
|
|
|
+ memcpy((char*)&ShmDcCommonData->PriceBill.RemainAmount, (char*)&pBillInfo->RemainAmount, sizeof(uint32_t));
|
|
|
+ log_info("\t ******* TxId %d Charging Bill *******\n", ShmDcCommonData->PriceBill.TransactionId);
|
|
|
+ log_info("\t Total Cost = %.2f\n", ShmDcCommonData->PriceBill.TotalCost);
|
|
|
+ log_info("\t Discount = %.2f\n", ShmDcCommonData->PriceBill.Discount);
|
|
|
+ log_info("\t EnergyCost = %.2f\n", ShmDcCommonData->PriceBill.EnergyCost);
|
|
|
+ log_info("\t ParkingFee = %.2f\n", ShmDcCommonData->PriceBill.ParkingFee);
|
|
|
+ log_info("\t RemainAmount = %.2f\n", ShmDcCommonData->PriceBill.RemainAmount);
|
|
|
+ if (ShmDcCommonData->PriceBill.TransactionId != ShmDcCommonData->TransactionInfo[gunIndex].TransactionId)
|
|
|
+ UpdateRedeuctBill(ShmDcCommonData->PriceBill.TransactionId, ShmDcCommonData->PriceBill.TotalCost);
|
|
|
+}
|
|
|
|
|
|
static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
|
|
|
{
|
|
@@ -965,6 +936,10 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
|
|
|
ShmSelectGunInfo->PricesInfo[plugNum].Balance = transPricesUnit(ntohl(pAccountInfo->Balance));
|
|
|
ShmSelectGunInfo->PricesInfo[plugNum].Discount = transPricesUnit(ntohl(pAccountInfo->Discount));
|
|
|
ShmSelectGunInfo->PricesInfo[plugNum].TransactionId = ntohl(pAccountInfo->Transaction);
|
|
|
+ ShmSelectGunInfo->PricesInfo[plugNum].EnergyCost = transPricesUnit(ntohl(pAccountInfo->EnergyCost));
|
|
|
+ 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) ||
|
|
|
(pricesInfo[plugNum].Balance != ShmSelectGunInfo->PricesInfo[plugNum].Balance) ||
|
|
@@ -974,9 +949,13 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
|
|
|
pricesInfo[plugNum].Balance = ShmSelectGunInfo->PricesInfo[plugNum].Balance;
|
|
|
pricesInfo[plugNum].Discount = ShmSelectGunInfo->PricesInfo[plugNum].Discount;
|
|
|
pricesInfo[plugNum].TransactionId = ShmSelectGunInfo->PricesInfo[plugNum].TransactionId;
|
|
|
+ pricesInfo[plugNum].ParkingFee = ShmSelectGunInfo->PricesInfo[plugNum].ParkingFee;
|
|
|
+ pricesInfo[plugNum].EnergyCost = ShmSelectGunInfo->PricesInfo[plugNum].EnergyCost;
|
|
|
+ pricesInfo[plugNum].RemainAmount = ShmSelectGunInfo->PricesInfo[plugNum].RemainAmount;
|
|
|
if (ShmSelectGunInfo->PricesInfo[plugNum].TransactionId != 0) {
|
|
|
|
|
|
ShmDcCommonData->TransactionInfo[plugNum].TransactionId = ShmSelectGunInfo->PricesInfo[plugNum].TransactionId;
|
|
|
+
|
|
|
UpdateDeductInfoStatus(plugNum, &ShmDcCommonData->TransactionInfo[plugNum]);
|
|
|
|
|
|
log_info("id = %d, transaction id = %d, user prices = %.2f, Discount = %.2f, Total cost = %.2f, Account balances = %.2f, currency = %s",
|
|
@@ -988,6 +967,10 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
|
|
|
ShmSelectGunInfo->PricesInfo[plugNum].Balance,
|
|
|
(uint8_t*)GetCurrency(pSysConfig->BillingData.Currency)
|
|
|
);
|
|
|
+ log_info("Total Cost:%.2f", pDcChargingInfo->ChargingFee);
|
|
|
+ log_info("Parking Fee:%.2f", ShmSelectGunInfo->PricesInfo[plugNum].ParkingFee);
|
|
|
+ log_info("Energy Cost:%.2f", ShmSelectGunInfo->PricesInfo[plugNum].EnergyCost);
|
|
|
+ log_info("Remain Amount:%.2f", ShmSelectGunInfo->PricesInfo[plugNum].RemainAmount);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1177,7 +1160,49 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
|
|
|
|
|
|
return PASS;
|
|
|
}
|
|
|
-
|
|
|
+void CheckTaiwanEastWest(int id)
|
|
|
+{
|
|
|
+ ShmDcCommonData->TaiwanEast = TRUE;
|
|
|
+ //西半部
|
|
|
+ if (id >= 100 && id <= 116) {//台北
|
|
|
+ ShmDcCommonData->TaiwanEast = FALSE;
|
|
|
+ } else if (id >= 200 && id <= 206) { //基隆
|
|
|
+ ShmDcCommonData->TaiwanEast = FALSE;
|
|
|
+ } else if (id >= 207 && id <= 253) { //新北
|
|
|
+ ShmDcCommonData->TaiwanEast = FALSE;
|
|
|
+ } else if (id >= 300 && id <= 315) { //新竹
|
|
|
+ ShmDcCommonData->TaiwanEast = FALSE;
|
|
|
+ } else if (id >= 320 && id <= 338) { //桃園
|
|
|
+ ShmDcCommonData->TaiwanEast = FALSE;
|
|
|
+ } else if (id >= 350 && id <= 369) { //苗栗
|
|
|
+ ShmDcCommonData->TaiwanEast = FALSE;
|
|
|
+ } else if (id >= 400 && id <= 439) { //台中
|
|
|
+ ShmDcCommonData->TaiwanEast = FALSE;
|
|
|
+ } else if (id >= 500 && id <= 530) { //彰化
|
|
|
+ ShmDcCommonData->TaiwanEast = FALSE;
|
|
|
+ } else if (id >= 600 && id <= 625) { //嘉義
|
|
|
+ ShmDcCommonData->TaiwanEast = FALSE;
|
|
|
+ } else if (id >= 630 && id <= 655) { //雲林
|
|
|
+ ShmDcCommonData->TaiwanEast = FALSE;
|
|
|
+ } else if (id >= 700 && id <= 745) { //台南
|
|
|
+ ShmDcCommonData->TaiwanEast = FALSE;
|
|
|
+ } else if (id >= 800 && id <= 852) { //高雄
|
|
|
+ ShmDcCommonData->TaiwanEast = FALSE;
|
|
|
+ } else if (id >= 900 && id <= 947) { //屏東
|
|
|
+ ShmDcCommonData->TaiwanEast = FALSE;
|
|
|
+ } else if (id >= 880 && id <= 885) { //澎湖
|
|
|
+ ShmDcCommonData->TaiwanEast = FALSE;
|
|
|
+ // 東半部
|
|
|
+ } else if (id >= 540 && id <= 558) { //南投
|
|
|
+ ShmDcCommonData->TaiwanEast = TRUE;
|
|
|
+ } else if (id >= 260 && id <= 272) { //宜蘭
|
|
|
+ ShmDcCommonData->TaiwanEast = TRUE;
|
|
|
+ } else if (id >= 950 && id <= 966) { //台東
|
|
|
+ ShmDcCommonData->TaiwanEast = TRUE;
|
|
|
+ } else if (id >= 970 && id <= 983) { //花蓮
|
|
|
+ ShmDcCommonData->TaiwanEast = TRUE;
|
|
|
+ }
|
|
|
+}
|
|
|
static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_t reg)
|
|
|
{
|
|
|
int ret = PASS;
|
|
@@ -1329,6 +1354,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
|
|
|
}
|
|
|
uint8_t reservationState = pCsuResult->Data.Data[0] == YES ? YES : NO;
|
|
|
memset(&ReservationIdTag[plugNum][0], 0x00, 32);
|
|
|
+ ShmDcCommonData->pGunInfo[plugNum].ReservationStatus = reservationState;
|
|
|
if(reservationState)
|
|
|
{
|
|
|
strcpy(&ReservationIdTag[plugNum][0], (char *)&pCsuResult->Data.Data[1]);
|
|
@@ -1339,6 +1365,9 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
|
|
|
if(reservationState)
|
|
|
{
|
|
|
log_info("id = %d reservation idTag: %s", pCsuResult->Head.ID, (char *)&ReservationIdTag[plugNum][0]);
|
|
|
+ strcpy(&ShmDcCommonData->pGunInfo[plugNum].ReservationID[0], (char*)&pCsuResult->Data.Data[1]);
|
|
|
+ } else {
|
|
|
+ strcpy(&ShmDcCommonData->pGunInfo[plugNum].ReservationID[0], "");
|
|
|
}
|
|
|
}
|
|
|
ReservationState[plugNum] = reservationState;
|
|
@@ -1382,6 +1411,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
|
|
|
ShmDcCommonData->Temperature = _stationInfo.Temperature;
|
|
|
ShmDcCommonData->Location = atoi(_stationInfo.StationName);
|
|
|
|
|
|
+ CheckTaiwanEastWest(ShmDcCommonData->Location);
|
|
|
log_info("Station Name: %s, ID: %d, Weather: %d, Temperature: %.1f",
|
|
|
_stationInfo.StationName,
|
|
|
_stationInfo.StationID,
|
|
@@ -1395,6 +1425,38 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
+ case REG_POWER_CONSUMPTION_INFO:
|
|
|
+ if (pCsuResult->Data.Result == COMMAND_RESULT_NG) {
|
|
|
+ return COMMAND_RESULT_NG;
|
|
|
+ }
|
|
|
+
|
|
|
+ PowConsumValue* pValue = NULL;
|
|
|
+ pValue = (PowConsumValue*)&pCsuResult->Data.Data[0];
|
|
|
+
|
|
|
+ pValue->Gun1_Consumption = ntohl(pValue->Gun1_Consumption);
|
|
|
+ pValue->Gun2_Consumption = ntohl(pValue->Gun2_Consumption);
|
|
|
+ pValue->Gun3_Consumption = ntohl(pValue->Gun3_Consumption);
|
|
|
+ pValue->Gun4_Consumption = ntohl(pValue->Gun4_Consumption);
|
|
|
+ memcpy((char*)&ShmDcCommonData->pConsumption.Gun1_Consumption, (char*)&pValue->Gun1_Consumption, sizeof(uint32_t));
|
|
|
+ memcpy((char*)&ShmDcCommonData->pConsumption.Gun2_Consumption, (char*)&pValue->Gun2_Consumption, sizeof(uint32_t));
|
|
|
+ memcpy((char*)&ShmDcCommonData->pConsumption.Gun3_Consumption, (char*)&pValue->Gun3_Consumption, sizeof(uint32_t));
|
|
|
+ memcpy((char*)&ShmDcCommonData->pConsumption.Gun4_Consumption, (char*)&pValue->Gun4_Consumption, sizeof(uint32_t));
|
|
|
+
|
|
|
+ log_info("Gun1_Consumption:%f", ShmDcCommonData->pConsumption.Gun1_Consumption);
|
|
|
+ log_info("Gun2_Consumption:%f", ShmDcCommonData->pConsumption.Gun2_Consumption);
|
|
|
+ log_info("Gun3_Consumption:%f", ShmDcCommonData->pConsumption.Gun3_Consumption);
|
|
|
+ log_info("Gun4_Consumption:%f", ShmDcCommonData->pConsumption.Gun4_Consumption);
|
|
|
+
|
|
|
+
|
|
|
+ break;
|
|
|
+ case REG_READ_CHARGING_TIMESTAMP:
|
|
|
+ break;
|
|
|
+ case REG_CHARGING_BILL:
|
|
|
+ if (pCsuResult->Data.Result == COMMAND_RESULT_NG) {
|
|
|
+ return COMMAND_RESULT_NG;
|
|
|
+ }
|
|
|
+ chargingbillHandle(pCsuResult->Data.Data, plugNum);
|
|
|
+ break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
@@ -1433,21 +1495,21 @@ static int composeSocketData(int fd,
|
|
|
|
|
|
//send command packet
|
|
|
if ((size = sendTcpSocket(fd, (uint8_t *)&csuCmdPkt, sendPktLen)) < 0) {
|
|
|
- log_error("TCP socket send packet fail = %d", size);
|
|
|
+ log_error("TCP socket reg=0x%x send packet fail = %d",reg, size);
|
|
|
gDoCommGblData.DisConnCount++;
|
|
|
return FAIL;
|
|
|
}
|
|
|
|
|
|
//receive result head
|
|
|
if ((size = recvTcpSocket(fd, (uint8_t *)&csuResult.Head, sizeof(csuResult.Head))) < 0) {
|
|
|
- log_error("TCP socket RX head fail = %d", size);
|
|
|
+ log_error("TCP socket reg=0x%x RX head fail = %d",reg, size);
|
|
|
gDoCommGblData.DisConnCount++;
|
|
|
return FAIL;
|
|
|
}
|
|
|
|
|
|
//receive result raw data
|
|
|
if ((size = recvTcpSocket(fd, (uint8_t *)&csuResult.Data, csuResult.Head.DataLen)) < 0) {
|
|
|
- log_error("TCP socket RX data fail = %d", size);
|
|
|
+ log_error("TCP socket reg=0x%x RX data fail = %d",reg, size);
|
|
|
gDoCommGblData.DisConnCount++;
|
|
|
return FAIL;
|
|
|
}
|
|
@@ -1525,6 +1587,22 @@ static int readRemoteStartNoIDState(int fd)
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
+static int readChargingBill(int fd)
|
|
|
+{
|
|
|
+ int ret = PASS;
|
|
|
+
|
|
|
+ if ((ret = composeSocketData(fd,
|
|
|
+ ID_REGISTER,
|
|
|
+ OP_READ_DATA,
|
|
|
+ REG_CHARGING_BILL,
|
|
|
+ 0,
|
|
|
+ NULL)) == FAIL) {
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
static int readChargerStationInfo(int fd)
|
|
|
{
|
|
|
int ret = PASS;
|
|
@@ -1544,6 +1622,11 @@ static int readChargerStationInfo(int fd)
|
|
|
static int writeDeductInfo(int fd, uint8_t id,uint8_t gunIndex, RecordTransactionInfo *transactionInfo)
|
|
|
{
|
|
|
int ret = PASS;
|
|
|
+ if (ShmDcCommonData->DebugFlag &&
|
|
|
+ strcmp((char*)transactionInfo->pCreditCard.VemData ,"") == EQUAL) {
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
uint8_t dataBuf[104] = {0};
|
|
|
//int i;
|
|
|
|
|
@@ -1564,11 +1647,7 @@ static int writeDeductInfo(int fd, uint8_t id,uint8_t gunIndex, RecordTransactio
|
|
|
memcpy((char *)&dataBuf[10], transactionInfo->pCreditCard.ApprovalNo,9);
|
|
|
memcpy((char *)&dataBuf[19], transactionInfo->pCreditCard.VemData, 64);
|
|
|
memcpy((char*)&dataBuf[83], transactionInfo->pCreditCard.CardNo, 20);
|
|
|
- /*
|
|
|
- for(i=0;i<22;i++) {
|
|
|
- log_info("dataBuf[%d]:0x%x",i,dataBuf[i]);
|
|
|
- }
|
|
|
- */
|
|
|
+
|
|
|
log_info("Gun[%d] TransactionId:%d DeductResult:%d IsDonateInvoice:%d Amount:%f Approva Num:'%s' VemData:'%s' CardNo:'%s'",
|
|
|
transactionInfo->ConnectorID,
|
|
|
transactionInfo->TransactionId,
|
|
@@ -1592,11 +1671,14 @@ static int writeDeductInfo(int fd, uint8_t id,uint8_t gunIndex, RecordTransactio
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
-static int writeWaitPlugItState(int fd, uint8_t id)
|
|
|
+static int writeWaitPlugItState(int fd, uint8_t id,uint8_t gunIndex)
|
|
|
{
|
|
|
int ret = PASS;
|
|
|
- uint8_t data[2] = {pSysInfo->WaitForPlugit, 0};
|
|
|
-
|
|
|
+ uint8_t data[2] = { ShmDcCommonData->pGunInfo[gunIndex].WaitForPlugit, 0};
|
|
|
+ if (_isplugin[gunIndex] != ShmDcCommonData->pGunInfo[gunIndex].WaitForPlugit) {
|
|
|
+ //log_info("Wait Gun%d for plug:%s", gunIndex, ShmDcCommonData->pGunInfo[gunIndex].WaitForPlugit == 0 ? "disable" : "enable");
|
|
|
+ _isplugin[gunIndex] = ShmDcCommonData->pGunInfo[gunIndex].WaitForPlugit;
|
|
|
+ }
|
|
|
//printf("WaitForPlugit = %d", pSysInfo->WaitForPlugit);
|
|
|
|
|
|
if ((ret = composeSocketData(fd,
|
|
@@ -1760,7 +1842,8 @@ static int writeUserID(int fd, uint8_t id, uint8_t *pUserID)
|
|
|
|
|
|
static int writeConnectorState(int fd, uint8_t plugNum, uint8_t id)
|
|
|
{
|
|
|
- uint8_t dataBuf[10] = {'\0'};
|
|
|
+ uint8_t dataBuf[16] = {'\0'};
|
|
|
+ uint32_t _consumption;
|
|
|
ConnectorState *pConnState = (ConnectorState *)dataBuf;
|
|
|
static char vendorErrorCodeTmp[2][WARNING_CODE_SIZE] = {0};
|
|
|
int ret = PASS;
|
|
@@ -1769,6 +1852,7 @@ static int writeConnectorState(int fd, uint8_t plugNum, uint8_t id)
|
|
|
pConnState->ConnectorTemp = pDcChargingInfo->ConnectorTemp;
|
|
|
pConnState->ChillerTemp = pDcChargingInfo->ChillerTemp;
|
|
|
pConnState->PlugIn = pDcChargingInfo->ConnectorPlugIn;
|
|
|
+ pConnState->ConnectMode = pDcChargingInfo->SystemStatus;
|
|
|
|
|
|
if (pDcChargingInfo->SystemStatus <= S_AUTHORIZING) {
|
|
|
pConnState->State = CONN_ST_IDLE; //idle
|
|
@@ -1821,6 +1905,9 @@ static int writeConnectorState(int fd, uint8_t plugNum, uint8_t id)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ memcpy((char*)&_consumption, (char*)&ShmDcCommonData->pGunInfo[plugNum].PowerConsumption, sizeof(float));
|
|
|
+ pConnState->consumption = ntohl(_consumption);
|
|
|
+
|
|
|
ret = composeSocketData(fd,
|
|
|
id,
|
|
|
OP_WRITE_DATA,
|
|
@@ -2173,29 +2260,6 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
|
|
|
curReg = REG_PLUG_IN_STATE;
|
|
|
break;
|
|
|
|
|
|
- //case REG_CHARGING_TARGET:
|
|
|
- // writeChargingTarget(fd, plugNum, gunID);
|
|
|
- // break;
|
|
|
-
|
|
|
- //case REG_SOFTWARE_UPDATE:
|
|
|
- // if (ChargingData[plugNum]->SystemStatus == S_IDLE) {
|
|
|
- // if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > L OOP_RETRY_TIME||
|
|
|
- //DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0 * 1) {
|
|
|
- // readSoftwareUpdate(fd);
|
|
|
- // ftime(&gRegTimeUp[plugNum][curReg]);
|
|
|
- // }
|
|
|
- // while (pSysInfo->FirmwareUpdate == YES) {
|
|
|
- // ftime(&NowTime);
|
|
|
- // if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowT ime) > LOOP_RETRY_TIME||
|
|
|
- //DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
|
|
|
- // readSoftwareUpdate(fd);
|
|
|
- // }
|
|
|
- // usleep(128);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // isContinue = 0;
|
|
|
- // break;
|
|
|
-
|
|
|
case REG_PLUG_IN_STATE:
|
|
|
if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME ||
|
|
|
DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
|
|
@@ -2225,6 +2289,7 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
|
|
|
gConnectorActReq[plugNum].Value = 0;
|
|
|
log_info("Gun %d CHARGING_CANCEL OK", plugNum);
|
|
|
ShmDcCommonData->OperateIDLE[plugNum] = 0;
|
|
|
+ ShmDcCommonData->TransactionInfo[plugNum].LineStatus = _LINE_INIT;
|
|
|
}
|
|
|
ftime(&gRegTimeUp[plugNum][curReg]);
|
|
|
}
|
|
@@ -2349,9 +2414,22 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
|
|
|
ftime(&gRegTimeUp[plugNum][curReg]);
|
|
|
}
|
|
|
}
|
|
|
+ curReg = REG_CHARGING_BILL;
|
|
|
+ break;
|
|
|
+ case REG_CHARGING_BILL:
|
|
|
+ if (gMoreInfoReq[plugNum].bits.ChargingBill) {
|
|
|
+ if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME ||
|
|
|
+ DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) < 0) {
|
|
|
+ if (readChargingBill(fd) == PASS)
|
|
|
+ {
|
|
|
+ log_info("Need to rededuct Bill");
|
|
|
+ gMoreInfoReq[plugNum].bits.ChargingBill = false;
|
|
|
+ }
|
|
|
+ ftime(&gRegTimeUp[plugNum][curReg]);
|
|
|
+ }
|
|
|
+ }
|
|
|
curReg = REG_REFUND_AMOUNT;
|
|
|
break;
|
|
|
-
|
|
|
case REG_REFUND_AMOUNT:
|
|
|
curReg = REG_PREPAYMENT_INFO;
|
|
|
break;
|
|
@@ -2442,8 +2520,8 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
|
ftime(&SeqEndTime);
|
|
|
SeqEndTime.time = time(NULL);
|
|
|
tm = localtime(&SeqEndTime.time);
|
|
|
-
|
|
|
- if (pSysInfo->SystemPage == _PAGE_IDLE || pSysInfo->SystemPage == _PAGE_SELECT_GUN) {
|
|
|
+
|
|
|
+ if ((pSysInfo->SystemPage == _PAGE_IDLE || pSysInfo->SystemPage == _PAGE_SELECT_GUN)) {
|
|
|
ftime(&AuthNowTime);
|
|
|
if (DiffTimeb(gRegTimeUp[plugNum][REG_DEDUCT_INFO], AuthNowTime) > LOOP_RETRY_TIME ||
|
|
|
DiffTimeb(gRegTimeUp[plugNum][REG_DEDUCT_INFO], AuthNowTime) < 0
|
|
@@ -2452,9 +2530,8 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
|
if (reupload_num >= 1 && reuploadInfo[0].ConnectorID != 0) {
|
|
|
|
|
|
if (writeDeductInfo(fd, reuploadInfo[0].ConnectorID, reupload_gunIndex[0], &reuploadInfo[0]) == PASS) {
|
|
|
- log_info("Reupload Success");
|
|
|
reuploadInfo[0].IsUpload = YES;
|
|
|
- UpdateDeductInfoStatus(reupload_gunIndex[0], &reuploadInfo[0]);
|
|
|
+ UpdateDeductInfoStatus(&reupload_gunIndex[0], &reuploadInfo[0]);
|
|
|
} else
|
|
|
log_info("Reupload fail");
|
|
|
|
|
@@ -2462,6 +2539,7 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
|
ftime(&gRegTimeUp[plugNum][REG_DEDUCT_INFO]);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/*
|
|
|
if (pSysInfo->SystemPage == _PAGE_IDLE || pSysInfo->SystemPage == _PAGE_SELECT_GUN) {
|
|
|
reupload_num = DB_GetMultiReUploadDeduct(&reupload_gunIndex[0], &reuploadInfo[0]);
|
|
@@ -2483,7 +2561,7 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
|
|
|
if (DiffTimeb(gRegTimeUp[plugNum][REG_WAIT_PLUG_IT_STATE], AuthNowTime) > (LOOP_RETRY_TIME / 10) ||
|
|
|
DiffTimeb(gRegTimeUp[plugNum][REG_WAIT_PLUG_IT_STATE], AuthNowTime) < 0
|
|
|
) {
|
|
|
- writeWaitPlugItState(fd, gunID);
|
|
|
+ writeWaitPlugItState(fd, gunID, plugNum);
|
|
|
ftime(&gRegTimeUp[plugNum][REG_WAIT_PLUG_IT_STATE]);
|
|
|
}
|
|
|
/*
|
|
@@ -2733,10 +2811,11 @@ static int networkCreatePorcess(void)
|
|
|
|
|
|
return fd;
|
|
|
}
|
|
|
+
|
|
|
void CreditCardProcess(int fd,int plugNum,int gunID, RecordTransactionInfo *pInfo)
|
|
|
{
|
|
|
- if (pInfo->IsUpload == TRUE || (strcmp(pInfo->pCreditCard.VemData,"") == 0) ||
|
|
|
- pSysInfo->SystemPage == _PAGE_SENSING)
|
|
|
+ if (pInfo->IsUpload == TRUE || (strcmp((char*)pInfo->pCreditCard.VemData,"") == 0) ||
|
|
|
+ pSysInfo->SystemPage == _PAGE_SENSING || ShmDcCommonData->is_RemoteStart[plugNum])
|
|
|
return;
|
|
|
if (ShmDcCommonData->TransactionInfo[plugNum].ConnectorID != 0) {
|
|
|
if (writeDeductInfo(fd, gunID, plugNum, &ShmDcCommonData->TransactionInfo[plugNum]) == PASS) {
|