|
@@ -53,6 +53,7 @@ PrepaymentResponseInfo ConnectorPrepayment[GENERAL_GUN_QUANTITY];
|
|
|
PaymentFailResponse ConnectorPaymentFailReason[GENERAL_GUN_QUANTITY];
|
|
|
char _ConnectorQRCode[GENERAL_GUN_QUANTITY][128];
|
|
|
StationInfoData _stationInfo[GENERAL_GUN_QUANTITY];
|
|
|
+DeductResultInfoData _deductResult[GENERAL_GUN_QUANTITY];
|
|
|
|
|
|
void ShowSocketData(struct PACKET_STRUCTURE *packet)
|
|
|
{
|
|
@@ -926,15 +927,26 @@ void PowerCabinetStatusResponse(int socket, struct PACKET_STRUCTURE *packet, uns
|
|
|
char str[256];
|
|
|
memcpy(&CabinetStatusToDispenser[dispenserIndex], &sendBuffer, sizeof(struct PACKET_STRUCTURE));
|
|
|
|
|
|
- sprintf(str, "Cabinet >> Dispenser %d Status Code:", dispenserIndex + 1);
|
|
|
+ if(CabinetStatusToDispenser[dispenserIndex].Header.len > 2)
|
|
|
+ {
|
|
|
+ sprintf(str, "Cabinet >> Dispenser %d Status Code:", dispenserIndex + 1);
|
|
|
+
|
|
|
+ for(int i = 0; i < CabinetStatusToDispenser[dispenserIndex].Header.len - 2; i += 6)
|
|
|
+ {
|
|
|
+ char status[7];
|
|
|
+ char temp[8];
|
|
|
+ memset(status, 0x00, sizeof(status));
|
|
|
+ memcpy(status, (char *)&CabinetStatusToDispenser[dispenserIndex].Payload.data[1 + i], 6);
|
|
|
|
|
|
- for(int i = 0; i < CabinetStatusToDispenser[dispenserIndex].Header.len - 2; i++)
|
|
|
+ sprintf(temp, " %s", status);
|
|
|
+ strcat(str, temp);
|
|
|
+ }
|
|
|
+ LOG_INFO("%s", str);
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- char temp[8];
|
|
|
- sprintf(temp, " %02X", CabinetStatusToDispenser[dispenserIndex].Payload.data[1 + i]);
|
|
|
- strcat(str, temp);
|
|
|
+ LOG_INFO("Cabinet >> Dispenser %d Status Code Clear", dispenserIndex + 1);
|
|
|
}
|
|
|
- LOG_INFO("%s", str);
|
|
|
}
|
|
|
|
|
|
SendPacket(socket, &sendBuffer);
|
|
@@ -1099,7 +1111,9 @@ void ChargingCapabilityResponse(int socket, struct PACKET_STRUCTURE *packet)
|
|
|
struct PACKET_STRUCTURE sendBuffer;
|
|
|
unsigned short voltage = 0, current = 0, power = 0;
|
|
|
unsigned char currency = 0;
|
|
|
- unsigned int price = 0, cost = 0, account = 0, discount = 0;
|
|
|
+ float fPrice = 0, fCost = 0, fBalance = 0, fDiscount = 0;
|
|
|
+ unsigned int lPrice = 0, lCost = 0, lBalance = 0, lDiscount = 0;
|
|
|
+ int transaction = 0;
|
|
|
|
|
|
memset(&sendBuffer, 0x00, sizeof(sendBuffer));
|
|
|
voltage = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].GeneralChargingData.MaximumChargingVoltage;
|
|
@@ -1113,9 +1127,16 @@ void ChargingCapabilityResponse(int socket, struct PACKET_STRUCTURE *packet)
|
|
|
GetMaxChargingProfileLimit(packet->Header.id - 1, &power, ¤t);
|
|
|
|
|
|
currency = ShmChargerInfo->CabinetMiscValue.Currency;
|
|
|
- price = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].UserPrice;
|
|
|
- cost = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].TotalCost;
|
|
|
- account = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].AccountBalance;
|
|
|
+ fPrice = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].UserPrice;
|
|
|
+ fCost = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].TotalCost;
|
|
|
+ fBalance = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].AccountBalance;
|
|
|
+ transaction = ShmChargerInfo->UserTransaction[packet->Header.id - 1].TransactionId;
|
|
|
+ fDiscount = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].CostDiscount;
|
|
|
+
|
|
|
+ lPrice = (unsigned int)(fPrice * 100);
|
|
|
+ lCost = (unsigned int)(fCost * 100);
|
|
|
+ lBalance = (int)(fBalance * 100);
|
|
|
+ lDiscount = (int)(fDiscount * 100);
|
|
|
|
|
|
if((ConnectorCapability[packet->Header.id - 1].MaxOuputVoltage / 10) != (voltage / 10) ||
|
|
|
(ConnectorCapability[packet->Header.id - 1].MaxOuputCurrent / 10) != (current / 10) ||
|
|
@@ -1125,24 +1146,45 @@ void ChargingCapabilityResponse(int socket, struct PACKET_STRUCTURE *packet)
|
|
|
(voltage / 10), (voltage % 10), (current / 10), (current % 10), (power / 10));
|
|
|
}
|
|
|
|
|
|
+ if(ConnectorCapability[packet->Header.id - 1].Currency != currency)
|
|
|
+ {
|
|
|
+ memset(ConnectorCapability[packet->Header.id - 1].CurrencyString, 0x00, sizeof(ConnectorCapability[packet->Header.id - 1].CurrencyString));
|
|
|
+ if(currency < 54)
|
|
|
+ {
|
|
|
+ memcpy(ConnectorCapability[packet->Header.id - 1].CurrencyString, (char *)&Currency[currency][0], 3);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LOG_INFO("Connector %d unknown currency: %d", packet->Header.id, (int)(currency));
|
|
|
+ memcpy(ConnectorCapability[packet->Header.id - 1].CurrencyString, "???", 3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if(ConnectorCapability[packet->Header.id - 1].Currency != currency ||
|
|
|
- ConnectorCapability[packet->Header.id - 1].UserPrice != price ||
|
|
|
- ConnectorCapability[packet->Header.id - 1].TotalCost != cost ||
|
|
|
- ConnectorCapability[packet->Header.id - 1].AccountBalance != account ||
|
|
|
- ConnectorCapability[packet->Header.id - 1].CostDiscount != discount)
|
|
|
+ ConnectorCapability[packet->Header.id - 1].UserPrice != lPrice ||
|
|
|
+ ConnectorCapability[packet->Header.id - 1].TotalCost != lCost ||
|
|
|
+ ConnectorCapability[packet->Header.id - 1].TransactionId != transaction)
|
|
|
{
|
|
|
- LOG_INFO("Connector %d Currency: %d, UserPrice: %d, Cost: %d, Account: %d, Discount: %d", packet->Header.id,
|
|
|
- (int)(currency), (int)(price), (int)(cost), (int)(account), (int)(discount));
|
|
|
+ LOG_INFO("Connector %d TransactionId: %d UserPrice: %4.2f, Cost: %.2f [%s]",
|
|
|
+ packet->Header.id, transaction, fPrice, fCost, ConnectorCapability[packet->Header.id - 1].CurrencyString);
|
|
|
}
|
|
|
|
|
|
+ if(ConnectorCapability[packet->Header.id - 1].AccountBalance != lBalance ||
|
|
|
+ ConnectorCapability[packet->Header.id - 1].CostDiscount != lDiscount)
|
|
|
+ {
|
|
|
+ LOG_INFO("Connector %d TransactionId: %d Account: %7.2f, Discount: %.2f [%s]",
|
|
|
+ packet->Header.id, transaction, fBalance, fDiscount, ConnectorCapability[packet->Header.id - 1].CurrencyString);
|
|
|
+ }
|
|
|
+
|
|
|
ConnectorCapability[packet->Header.id - 1].MaxOuputVoltage = voltage;
|
|
|
ConnectorCapability[packet->Header.id - 1].MaxOuputCurrent = current;
|
|
|
ConnectorCapability[packet->Header.id - 1].MaxOuputPower = power;
|
|
|
ConnectorCapability[packet->Header.id - 1].Currency = currency;
|
|
|
- ConnectorCapability[packet->Header.id - 1].UserPrice = price;
|
|
|
- ConnectorCapability[packet->Header.id - 1].TotalCost = cost;
|
|
|
- ConnectorCapability[packet->Header.id - 1].AccountBalance = account;
|
|
|
- ConnectorCapability[packet->Header.id - 1].CostDiscount = discount;
|
|
|
+ ConnectorCapability[packet->Header.id - 1].UserPrice = lPrice;
|
|
|
+ ConnectorCapability[packet->Header.id - 1].TotalCost = lCost;
|
|
|
+ ConnectorCapability[packet->Header.id - 1].AccountBalance = lBalance;
|
|
|
+ ConnectorCapability[packet->Header.id - 1].CostDiscount = lDiscount;
|
|
|
+ ConnectorCapability[packet->Header.id - 1].TransactionId = transaction;
|
|
|
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].CapabilityVoltage = voltage;
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].CapabilityCurrent = current;
|
|
@@ -1151,7 +1193,7 @@ void ChargingCapabilityResponse(int socket, struct PACKET_STRUCTURE *packet)
|
|
|
sendBuffer.Header.se = packet->Header.se;
|
|
|
sendBuffer.Header.id = packet->Header.id;
|
|
|
sendBuffer.Header.op = _Header_Response;
|
|
|
- sendBuffer.Header.len = 25;
|
|
|
+ sendBuffer.Header.len = 29;
|
|
|
sendBuffer.Payload.reg = _Reg_Charging_Capability;
|
|
|
sendBuffer.Payload.data[0] = _R_OK;
|
|
|
sendBuffer.Payload.data[1] = ((voltage >> 8) & 0xFF);
|
|
@@ -1161,22 +1203,26 @@ void ChargingCapabilityResponse(int socket, struct PACKET_STRUCTURE *packet)
|
|
|
sendBuffer.Payload.data[5] = ((power >> 8) & 0xFF);
|
|
|
sendBuffer.Payload.data[6] = (power & 0xFF);
|
|
|
sendBuffer.Payload.data[7] = currency;
|
|
|
- sendBuffer.Payload.data[8] = ((price >> 24) & 0xFF);
|
|
|
- sendBuffer.Payload.data[9] = ((price >> 16) & 0xFF);
|
|
|
- sendBuffer.Payload.data[10] = ((price >> 8) & 0xFF);
|
|
|
- sendBuffer.Payload.data[11] = (price & 0xFF);
|
|
|
- sendBuffer.Payload.data[12] = ((cost >> 24) & 0xFF);
|
|
|
- sendBuffer.Payload.data[13] = ((cost >> 16) & 0xFF);
|
|
|
- sendBuffer.Payload.data[14] = ((cost >> 8) & 0xFF);
|
|
|
- sendBuffer.Payload.data[15] = (cost & 0xFF);
|
|
|
- sendBuffer.Payload.data[16] = ((account >> 24) & 0xFF);
|
|
|
- sendBuffer.Payload.data[17] = ((account >> 16) & 0xFF);
|
|
|
- sendBuffer.Payload.data[18] = ((account >> 8) & 0xFF);
|
|
|
- sendBuffer.Payload.data[19] = (account & 0xFF);
|
|
|
- sendBuffer.Payload.data[20] = ((discount >> 24) & 0xFF);
|
|
|
- sendBuffer.Payload.data[21] = ((discount >> 16) & 0xFF);
|
|
|
- sendBuffer.Payload.data[22] = ((discount >> 8) & 0xFF);
|
|
|
- sendBuffer.Payload.data[23] = (discount & 0xFF);
|
|
|
+ sendBuffer.Payload.data[8] = ((lPrice >> 24) & 0xFF);
|
|
|
+ sendBuffer.Payload.data[9] = ((lPrice >> 16) & 0xFF);
|
|
|
+ sendBuffer.Payload.data[10] = ((lPrice >> 8) & 0xFF);
|
|
|
+ sendBuffer.Payload.data[11] = (lPrice & 0xFF);
|
|
|
+ sendBuffer.Payload.data[12] = ((lCost >> 24) & 0xFF);
|
|
|
+ sendBuffer.Payload.data[13] = ((lCost >> 16) & 0xFF);
|
|
|
+ sendBuffer.Payload.data[14] = ((lCost >> 8) & 0xFF);
|
|
|
+ sendBuffer.Payload.data[15] = (lCost & 0xFF);
|
|
|
+ sendBuffer.Payload.data[16] = ((lBalance >> 24) & 0xFF);
|
|
|
+ sendBuffer.Payload.data[17] = ((lBalance >> 16) & 0xFF);
|
|
|
+ sendBuffer.Payload.data[18] = ((lBalance >> 8) & 0xFF);
|
|
|
+ sendBuffer.Payload.data[19] = (lBalance & 0xFF);
|
|
|
+ sendBuffer.Payload.data[20] = ((lDiscount >> 24) & 0xFF);
|
|
|
+ sendBuffer.Payload.data[21] = ((lDiscount >> 16) & 0xFF);
|
|
|
+ sendBuffer.Payload.data[22] = ((lDiscount >> 8) & 0xFF);
|
|
|
+ sendBuffer.Payload.data[23] = (lDiscount & 0xFF);
|
|
|
+ sendBuffer.Payload.data[24] = ((transaction >> 24) & 0xFF);
|
|
|
+ sendBuffer.Payload.data[25] = ((transaction >> 16) & 0xFF);
|
|
|
+ sendBuffer.Payload.data[26] = ((transaction >> 8) & 0xFF);
|
|
|
+ sendBuffer.Payload.data[27] = (transaction & 0xFF);
|
|
|
|
|
|
SendPacket(socket, &sendBuffer);
|
|
|
}
|
|
@@ -1344,6 +1390,7 @@ void Clean_LcmPage_Req(int gun_index, int lcm_req)
|
|
|
// LOG_INFO("Cabinet >> Connector %d Balance [%d]", packet->Header.id, (misc.Value));
|
|
|
// LOG_INFO("Cabinet >> Connector %d Reservation [Enable]", packet->Header.id);
|
|
|
// LOG_INFO("Cabinet >> Connector %d QR Code [Enable]", packet->Header.id);
|
|
|
+// LOG_INFO("Cabinet >> Connector %d Final Cost [Enable]", packet->Header.id);
|
|
|
// LOG_INFO("Cabinet >> Dispenser %d PlugTimeout [%d]", dispenserIndex + 1, misc.Value);
|
|
|
// LOG_INFO("Cabinet >> Dispenser %d DefaultPrice [%d]", dispenserIndex + 1, misc.Value);
|
|
|
// LOG_INFO("Cabinet >> Dispenser %d Currency [%d]", dispenserIndex + 1, misc.Value);
|
|
@@ -1363,12 +1410,15 @@ void Clean_LcmPage_Req(int gun_index, int lcm_req)
|
|
|
// LOG_INFO("Cabinet >> Dispenser %d EVCCID [%s]", dispenserIndex + 1, misc.Value ? "Enable" : "Disable");
|
|
|
// LOG_INFO("Cabinet >> Dispenser %d LEDIntensity [%s]", dispenserIndex + 1, strIntensity[misc.Value]);
|
|
|
// LOG_INFO("Cabinet >> Dispenser %d LEDIntensity [%d]", dispenserIndex + 1, misc.Value);
|
|
|
-// LOG_INFO("Cabinet >> Dispenser %d Station Info [%d]", dispenserIndex + 1, misc.Value);
|
|
|
+// LOG_INFO("Cabinet >> Dispenser %d Station Info [%s]", dispenserIndex + 1, misc.Value ? "Enable" : "Disable");
|
|
|
+// LOG_INFO("Cabinet >> Dispenser %d Time Offset [%s%02d:%02d]", dispenserIndex + 1, misc.Value >= 0 ? "+" : "-", (abs(misc.Value) / 60), (abs(misc.Value) % 60));
|
|
|
+// LOG_INFO("Cabinet >> Dispenser %d Time Offset [+%d]", dispenserIndex + 1, misc.Value);
|
|
|
+// LOG_INFO("Cabinet >> Dispenser %d Time Offset [%d]", dispenserIndex + 1, misc.Value);
|
|
|
void MiscCmdRes(int socket, struct PACKET_STRUCTURE *packet, unsigned char dispenserIndex, unsigned char result)
|
|
|
{
|
|
|
char *strConnection[] = {STR_CONN_DISABLE, STR_CONN_CONNECTED, STR_CONN_DISCONNECTED};
|
|
|
char *strIntensity[] = {STR_DARKEST, STR_MEDIUM, STR_BRIGHTEST};
|
|
|
- char *strLcmPage[] = {STR_PAGE_NONE, STR_REMOTE_NO_ID, STR_REFUND_AMOUNT, STR_PREPAYMENT, STR_PAYMENT_FAIL};
|
|
|
+ char *strLcmPage[] = {STR_PAGE_NONE, STR_REMOTE_NO_ID};
|
|
|
struct PACKET_STRUCTURE sendBuffer;
|
|
|
|
|
|
memset(&sendBuffer, 0x00, sizeof(sendBuffer));
|
|
@@ -1450,7 +1500,7 @@ void MiscCmdRes(int socket, struct PACKET_STRUCTURE *packet, unsigned char dispe
|
|
|
{
|
|
|
Clean_Connector_MiscCommand(packet->Header.id - 1, MISC_CONN_ACCOUNT_BALANCE);
|
|
|
misc.Command = _MiscCmd_AccountBalance;
|
|
|
- misc.Value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].AccountBalance;
|
|
|
+ misc.Value = (int)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].AccountBalance * 100);
|
|
|
|
|
|
LOG_INFO("Cabinet >> Connector %d Balance [%d]", packet->Header.id, (misc.Value));
|
|
|
AddMiscCommand(&sendBuffer, &misc);
|
|
@@ -1476,6 +1526,26 @@ void MiscCmdRes(int socket, struct PACKET_STRUCTURE *packet, unsigned char dispe
|
|
|
AddMiscCommand(&sendBuffer, &misc);
|
|
|
}
|
|
|
|
|
|
+ if(Is_Connector_MiscCommand(packet->Header.id - 1, MISC_CONN_FINAL_COST))
|
|
|
+ {
|
|
|
+ Clean_Connector_MiscCommand(packet->Header.id - 1, MISC_CONN_FINAL_COST);
|
|
|
+ misc.Command = _MiscCmd_FinalCost;
|
|
|
+ misc.Value = true;
|
|
|
+
|
|
|
+ LOG_INFO("Cabinet >> Connector %d Final Cost [Enable]", packet->Header.id);
|
|
|
+ AddMiscCommand(&sendBuffer, &misc);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(Is_Connector_MiscCommand(packet->Header.id - 1, MISC_CONN_LINE_STATUS))
|
|
|
+ {
|
|
|
+ Clean_Connector_MiscCommand(packet->Header.id - 1, MISC_CONN_LINE_STATUS);
|
|
|
+ misc.Command = _MiscCmd_LineStatus;
|
|
|
+ misc.Value = ShmChargerInfo->LineApi.StatusCode[packet->Header.id - 1];
|
|
|
+
|
|
|
+ LOG_INFO("Cabinet >> Connector %d Line Status [%d]", packet->Header.id, misc.Value);
|
|
|
+ AddMiscCommand(&sendBuffer, &misc);
|
|
|
+ }
|
|
|
+
|
|
|
// announce misc command to first connector of the dispenser
|
|
|
if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].ConnectorID[0] == packet->Header.id)
|
|
|
{
|
|
@@ -1493,9 +1563,9 @@ void MiscCmdRes(int socket, struct PACKET_STRUCTURE *packet, unsigned char dispe
|
|
|
{
|
|
|
Clean_Dispenser_MiscCommand(dispenserIndex, MISC_DISP_DEFAULT_PRICE);
|
|
|
misc.Command = _MiscCmd_DefaultPrice;
|
|
|
- misc.Value = ShmChargerInfo->CabinetMiscValue.DefaultPrice;
|
|
|
+ misc.Value = (unsigned int)(ShmChargerInfo->CabinetMiscValue.DefaultPrice * 100);
|
|
|
|
|
|
- LOG_INFO("Cabinet >> Dispenser %d DefaultPrice [%d]", dispenserIndex + 1, misc.Value);
|
|
|
+ LOG_INFO("Cabinet >> Dispenser %d DefaultPrice [%d.%02d]", dispenserIndex + 1, (misc.Value / 100), (misc.Value % 100));
|
|
|
AddMiscCommand(&sendBuffer, &misc);
|
|
|
}
|
|
|
|
|
@@ -1671,7 +1741,18 @@ void MiscCmdRes(int socket, struct PACKET_STRUCTURE *packet, unsigned char dispe
|
|
|
misc.Command = _MiscCmd_StationInfo;
|
|
|
misc.Value = true;
|
|
|
|
|
|
- LOG_INFO("Cabinet >> Dispenser %d Station Info [%d]", dispenserIndex + 1, misc.Value);
|
|
|
+ LOG_INFO("Cabinet >> Dispenser %d Station Info [%s]", dispenserIndex + 1, misc.Value ? "Enable" : "Disable");
|
|
|
+ AddMiscCommand(&sendBuffer, &misc);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(Is_Dispenser_MiscCommand(dispenserIndex, MISC_DISP_TIME_OFFSET))
|
|
|
+ {
|
|
|
+ Clean_Dispenser_MiscCommand(dispenserIndex, MISC_DISP_TIME_OFFSET);
|
|
|
+ misc.Command = _MiscCmd_TimeOffset;
|
|
|
+ misc.Value = ShmChargerInfo->CabinetMiscValue.TimeOffset;
|
|
|
+
|
|
|
+ LOG_INFO("Cabinet >> Dispenser %d Time Offset [%s%02d:%02d]",
|
|
|
+ dispenserIndex + 1, misc.Value >= 0 ? "+" : "-", (abs(misc.Value) / 60), (abs(misc.Value) % 60));
|
|
|
AddMiscCommand(&sendBuffer, &misc);
|
|
|
}
|
|
|
}
|
|
@@ -1680,11 +1761,13 @@ void MiscCmdRes(int socket, struct PACKET_STRUCTURE *packet, unsigned char dispe
|
|
|
{
|
|
|
int gun = packet->Header.id - 1;
|
|
|
|
|
|
- for(int i = 0; i < _LCM_Page_PaymentFail; i++)
|
|
|
+ for(int i = 0; i < _LCM_Page_RemoteStartNoID; i++)
|
|
|
{
|
|
|
- if(Is_LcmPageChange_Req(gun, i + 1))
|
|
|
+ unsigned int pageReq = 1 << i;
|
|
|
+
|
|
|
+ if(Is_LcmPageChange_Req(gun, pageReq))
|
|
|
{
|
|
|
- Clean_LcmPage_Req(gun, i + 1);
|
|
|
+ Clean_LcmPage_Req(gun, pageReq);
|
|
|
misc.Command = _MiscCmd_ChangeLcmPage;
|
|
|
misc.Value = i + 1;
|
|
|
|
|
@@ -1769,7 +1852,8 @@ int GetChargerSystemId(char *id)
|
|
|
|
|
|
strcpy((char *)id, "");
|
|
|
|
|
|
- if(ShmChargerInfo->Control.CustomerCode != _CUSTOMER_CODE_Audi)
|
|
|
+ if(ShmChargerInfo->Control.CustomerCode != _CUSTOMER_CODE_Audi &&
|
|
|
+ ShmChargerInfo->Control.CustomerCode != _CUSTOMER_CODE_TCC)
|
|
|
{
|
|
|
ShmChargerInfo->AuthInfo.QRCodeMode = ShmSysConfigAndInfo->SysConfig.QRCodeMadeMode;
|
|
|
}
|
|
@@ -2146,26 +2230,29 @@ void StationInfoResponse(int socket, struct PACKET_STRUCTURE *packet, unsigned c
|
|
|
sendBuffer.Header.se = packet->Header.se;
|
|
|
sendBuffer.Header.id = packet->Header.id;
|
|
|
sendBuffer.Header.op = _Header_Response;
|
|
|
- sendBuffer.Header.len = 90;
|
|
|
+ sendBuffer.Header.len = 78;
|
|
|
sendBuffer.Payload.reg = _Reg_StationInfo;
|
|
|
sendBuffer.Payload.data[0] = result;
|
|
|
|
|
|
- memcpy(&sendBuffer.Payload.data[1], ShmChargerInfo->StationInfo.StationName, 64);
|
|
|
- memcpy(&sendBuffer.Payload.data[65], ShmChargerInfo->StationInfo.StationID, 16);
|
|
|
+ sendBuffer.Payload.data[1] = ((ShmChargerInfo->StationInfo.StationID >> 24) & 0xFF);
|
|
|
+ sendBuffer.Payload.data[2] = ((ShmChargerInfo->StationInfo.StationID >> 16) & 0xFF);
|
|
|
+ sendBuffer.Payload.data[3] = ((ShmChargerInfo->StationInfo.StationID >> 8) & 0xFF);
|
|
|
+ sendBuffer.Payload.data[4] = (ShmChargerInfo->StationInfo.StationID & 0xFF);
|
|
|
+ memcpy(&sendBuffer.Payload.data[5], ShmChargerInfo->StationInfo.StationName, 64);
|
|
|
|
|
|
- sendBuffer.Payload.data[81] = (ShmChargerInfo->StationInfo.WeatherID >> 24) & 0xFF;
|
|
|
- sendBuffer.Payload.data[82] = (ShmChargerInfo->StationInfo.WeatherID >> 16) & 0xFF;
|
|
|
- sendBuffer.Payload.data[83] = (ShmChargerInfo->StationInfo.WeatherID >> 8) & 0xFF;
|
|
|
- sendBuffer.Payload.data[84] = ShmChargerInfo->StationInfo.WeatherID & 0xFF;
|
|
|
+ sendBuffer.Payload.data[69] = (ShmChargerInfo->StationInfo.WeatherID >> 24) & 0xFF;
|
|
|
+ sendBuffer.Payload.data[70] = (ShmChargerInfo->StationInfo.WeatherID >> 16) & 0xFF;
|
|
|
+ sendBuffer.Payload.data[71] = (ShmChargerInfo->StationInfo.WeatherID >> 8) & 0xFF;
|
|
|
+ sendBuffer.Payload.data[72] = ShmChargerInfo->StationInfo.WeatherID & 0xFF;
|
|
|
|
|
|
char *ptr = (char *)&ShmChargerInfo->StationInfo.Temperature;
|
|
|
- sendBuffer.Payload.data[85] = *(ptr + 3);
|
|
|
- sendBuffer.Payload.data[86] = *(ptr + 2);
|
|
|
- sendBuffer.Payload.data[87] = *(ptr + 1);
|
|
|
- sendBuffer.Payload.data[88] = *ptr;
|
|
|
+ sendBuffer.Payload.data[73] = *(ptr + 3);
|
|
|
+ sendBuffer.Payload.data[74] = *(ptr + 2);
|
|
|
+ sendBuffer.Payload.data[75] = *(ptr + 1);
|
|
|
+ sendBuffer.Payload.data[76] = *ptr;
|
|
|
|
|
|
if(strcmp(_stationInfo[dispenserIndex].StationName, ShmChargerInfo->StationInfo.StationName) != 0 ||
|
|
|
- strcmp(_stationInfo[dispenserIndex].StationID, ShmChargerInfo->StationInfo.StationID) != 0 ||
|
|
|
+ _stationInfo[dispenserIndex].StationID != ShmChargerInfo->StationInfo.StationID ||
|
|
|
_stationInfo[dispenserIndex].WeatherID != ShmChargerInfo->StationInfo.WeatherID ||
|
|
|
_stationInfo[dispenserIndex].Temperature != ShmChargerInfo->StationInfo.Temperature)
|
|
|
{
|
|
@@ -2178,7 +2265,7 @@ void StationInfoResponse(int socket, struct PACKET_STRUCTURE *packet, unsigned c
|
|
|
{
|
|
|
sprintf(strWeather, "%d", ShmChargerInfo->StationInfo.WeatherID);
|
|
|
}
|
|
|
- LOG_INFO("Dispenser %d StationID: %s, Name: %s, WeatherID: %s, Temperature: %4.1f",
|
|
|
+ LOG_INFO("Dispenser %d StationID: %d, Name: %s, WeatherID: %s, Temperature: %4.1f",
|
|
|
dispenserIndex + 1,
|
|
|
ShmChargerInfo->StationInfo.StationID,
|
|
|
ShmChargerInfo->StationInfo.StationName,
|
|
@@ -2189,6 +2276,21 @@ void StationInfoResponse(int socket, struct PACKET_STRUCTURE *packet, unsigned c
|
|
|
SendPacket(socket, &sendBuffer);
|
|
|
}
|
|
|
|
|
|
+void DeductResultResponse(int socket, struct PACKET_STRUCTURE *packet, unsigned char result)
|
|
|
+{
|
|
|
+ struct PACKET_STRUCTURE sendBuffer;
|
|
|
+
|
|
|
+ memset(&sendBuffer, 0x00, sizeof(sendBuffer));
|
|
|
+ sendBuffer.Header.se = packet->Header.se;
|
|
|
+ sendBuffer.Header.id = packet->Header.id;
|
|
|
+ sendBuffer.Header.op = _Header_Response;
|
|
|
+ sendBuffer.Header.len = 2;
|
|
|
+ sendBuffer.Payload.reg = _Reg_DeductResult;
|
|
|
+ sendBuffer.Payload.data[0] = result;
|
|
|
+
|
|
|
+ SendPacket(socket, &sendBuffer);
|
|
|
+}
|
|
|
+
|
|
|
BOOL FindConnectorID(unsigned char dispenserIndex, unsigned char id)
|
|
|
{
|
|
|
BOOL find = false;
|
|
@@ -2832,7 +2934,7 @@ unsigned char ChargingPermissionHandler(struct PACKET_STRUCTURE *packet, unsigne
|
|
|
permission = _DAS_NotAllowed;
|
|
|
if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].Parameter.bits.ChargingPermission != permission)
|
|
|
{
|
|
|
- LOG_INFO("Cabinet status idle, not allow dispenser %d connector %d charging",
|
|
|
+ LOG_INFO("Cabinet status idle, not allow Dispenser %d Connector %d Charging",
|
|
|
dispenserIndex + 1, packet->Header.id);
|
|
|
}
|
|
|
}
|
|
@@ -2861,7 +2963,7 @@ unsigned char ChargingPermissionHandler(struct PACKET_STRUCTURE *packet, unsigne
|
|
|
if(!ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].Parameter.bits.PermissionRequest)
|
|
|
{
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].Parameter.bits.PermissionRequest = true;
|
|
|
- LOG_INFO("Allow dispenser index %d connector id %d start preparing to charge", dispenserIndex, packet->Header.id);
|
|
|
+ LOG_INFO("Allow Dispenser %d Connector %d start preparing to charge", dispenserIndex + 1, packet->Header.id);
|
|
|
}
|
|
|
permission = _DAS_Allowed;
|
|
|
}
|
|
@@ -3244,35 +3346,42 @@ unsigned char DispenserReqHandler(struct PACKET_STRUCTURE *packet, int dispenser
|
|
|
{
|
|
|
gun = packet->Header.id - 1;
|
|
|
|
|
|
+ int count = 0;
|
|
|
struct MISC_COMMAND connector_req;
|
|
|
|
|
|
- memset(&connector_req, 0x00, sizeof(struct MISC_COMMAND));
|
|
|
- connector_req.Command = (packet->Payload.data[0] << 8) | packet->Payload.data[1];
|
|
|
- connector_req.Value = (packet->Payload.data[2] << 24) | (packet->Payload.data[3] << 16) | (packet->Payload.data[4] << 8) | packet->Payload.data[5];
|
|
|
-
|
|
|
- switch(connector_req.Command)
|
|
|
+ while((packet->Header.len - 1) > (count * 6))
|
|
|
{
|
|
|
- case _DisReq_RefoundRequest:
|
|
|
- if(connector_req.Value == YES)
|
|
|
- {
|
|
|
- ShmChargerInfo->ConnectorActReq[gun].Flag.bits.RefundRequest = true;
|
|
|
- }
|
|
|
- break;
|
|
|
- case _DisReq_RefoundCancel:
|
|
|
- if(connector_req.Value == YES)
|
|
|
- {
|
|
|
- ShmChargerInfo->ConnectorActReq[gun].Flag.bits.RefundCancel = true;
|
|
|
- }
|
|
|
- break;
|
|
|
- case _DisReq_InvoiceRequest:
|
|
|
- if(connector_req.Value > 0)
|
|
|
+ if(((packet->Header.len - 1) - (count * 6)) % 6 == 0)
|
|
|
+ {
|
|
|
+ memset(&connector_req, 0x00, sizeof(struct MISC_COMMAND));
|
|
|
+ connector_req.Command = (packet->Payload.data[0 + (count * 6)] << 8) | packet->Payload.data[1 + (count * 6)];
|
|
|
+ connector_req.Value = (packet->Payload.data[2 + (count * 6)] << 24) |
|
|
|
+ (packet->Payload.data[3 + (count * 6)] << 16) |
|
|
|
+ (packet->Payload.data[4 + (count * 6)] << 8) |
|
|
|
+ (packet->Payload.data[5 + (count * 6)]);
|
|
|
+ count++;
|
|
|
+
|
|
|
+ switch(connector_req.Command)
|
|
|
{
|
|
|
- ShmChargerInfo->ConnectorActReq[gun].Flag.bits.InvoiceRequest = true;
|
|
|
- ShmChargerInfo->ConnectorActReq[gun].ActionValue.bits.InvoiceIndex = connector_req.Value;
|
|
|
+ case _DisReq_ChargingCancel:
|
|
|
+ if(connector_req.Value == YES)
|
|
|
+ {
|
|
|
+ if(!ShmChargerInfo->ConnectorActReq[gun].Flag.bits.ChargingCancel)
|
|
|
+ {
|
|
|
+ LOG_INFO("Gun %d ChargingCancel Request", gun + 1);
|
|
|
+ }
|
|
|
+ ShmChargerInfo->ConnectorActReq[gun].Flag.bits.ChargingCancel = true;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
break;
|
|
|
- default:
|
|
|
- break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -3373,6 +3482,74 @@ unsigned char GetStationInfoHandler(struct PACKET_STRUCTURE *packet, int dispens
|
|
|
return find;
|
|
|
}
|
|
|
|
|
|
+unsigned char WriteDeductResultHandler(struct PACKET_STRUCTURE *packet, int dispenserIndex)
|
|
|
+{
|
|
|
+ BOOL find = FindConnectorID(dispenserIndex, packet->Header.id);
|
|
|
+ unsigned char gun = 0;
|
|
|
+ DeductResultInfoData deduct;
|
|
|
+ bool done = false;
|
|
|
+
|
|
|
+ if(find || packet->Header.id == 0xFF)
|
|
|
+ {
|
|
|
+ gun = packet->Header.id - 1;
|
|
|
+
|
|
|
+ memset(&deduct, 0x00, sizeof(DeductResultInfoData));
|
|
|
+
|
|
|
+ deduct.DeductResult = packet->Payload.data[0] == YES ? YES : NO;
|
|
|
+ deduct.IsDonateInvoice = packet->Payload.data[1] == YES ? YES : NO;
|
|
|
+ deduct.TransactionId = (packet->Payload.data[2] << 24) +
|
|
|
+ (packet->Payload.data[3] << 16) +
|
|
|
+ (packet->Payload.data[4] << 8) +
|
|
|
+ packet->Payload.data[5];
|
|
|
+ deduct.DeductAmount = (packet->Payload.data[6] << 24) +
|
|
|
+ (packet->Payload.data[7] << 16) +
|
|
|
+ (packet->Payload.data[8] << 8) +
|
|
|
+ packet->Payload.data[9];
|
|
|
+ memcpy(deduct.ApprovalNumber, (char *)&packet->Payload.data[10], sizeof(deduct.ApprovalNumber));
|
|
|
+
|
|
|
+ if(packet->Header.id != 0xFF)
|
|
|
+ {
|
|
|
+ if(deduct.TransactionId == ShmChargerInfo->DeductResultReq[gun].TransactionId)
|
|
|
+ {
|
|
|
+ ShmChargerInfo->DeductResultReq[gun].DeductResult = deduct.DeductResult;
|
|
|
+ ShmChargerInfo->DeductResultReq[gun].IsDonateInvoice = deduct.IsDonateInvoice;
|
|
|
+ ShmChargerInfo->DeductResultReq[gun].DeductAmount = deduct.DeductAmount;
|
|
|
+ memcpy(ShmChargerInfo->DeductResultReq[gun].ApprovalNumber, deduct.ApprovalNumber, sizeof(deduct.ApprovalNumber));
|
|
|
+ ShmChargerInfo->DeductResultReq[gun].DeductReq = YES;
|
|
|
+
|
|
|
+ LOG_INFO("Gun %d TxId: [%d], Deduct: [%s%s], Amount: [%d.%02d], Donate: [%s], ApprovalNo: [%s]",
|
|
|
+ gun + 1,
|
|
|
+ deduct.TransactionId,
|
|
|
+ deduct.DeductResult ? "OK" : "NG",
|
|
|
+ packet->Payload.data[0] == 2 ? "(Cancel)" : "",
|
|
|
+ (deduct.DeductAmount / 100), (deduct.DeductAmount % 100),
|
|
|
+ deduct.IsDonateInvoice ? "Yes" : "No",
|
|
|
+ deduct.ApprovalNumber);
|
|
|
+ done = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!done)
|
|
|
+ {
|
|
|
+ if(!ShmChargerInfo->ReDeductReq.DeductReq)
|
|
|
+ {
|
|
|
+ memcpy(&ShmChargerInfo->ReDeductReq, &deduct, sizeof(DeductResultInfoData));
|
|
|
+ ShmChargerInfo->ReDeductReq.DeductReq = YES;
|
|
|
+ done = true;
|
|
|
+ find = true;
|
|
|
+ }
|
|
|
+ LOG_INFO("Dispenser ReDeduct %s, TxId: [%d] Result: [%s], Amount: [%d.%02d], Donate: [%s]",
|
|
|
+ done ? "OK" : "Wait",
|
|
|
+ deduct.TransactionId,
|
|
|
+ deduct.DeductResult ? "OK" : "NG",
|
|
|
+ (deduct.DeductAmount / 100), (deduct.DeductAmount % 100),
|
|
|
+ deduct.IsDonateInvoice ? "Yes" : "No");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return find;
|
|
|
+}
|
|
|
+
|
|
|
void DisableConnector(unsigned char dispenserIndex)
|
|
|
{
|
|
|
for(int i = 0; i < ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].ConnectorQuantity; i++)
|
|
@@ -3490,8 +3667,10 @@ void DispenserSocketProcess(int socketFd, struct sockaddr_in clientInfo, unsigne
|
|
|
Set_Dispenser_MiscCommand(dispenserIndex, MISC_DISP_STOP_BUTTON_STATUS);
|
|
|
Set_Dispenser_MiscCommand(dispenserIndex, MISC_DISP_AUTH_MODE_CONFIG);
|
|
|
Set_Dispenser_MiscCommand(dispenserIndex, MISC_DISP_EVCCID_CONFIG);
|
|
|
+ Set_Dispenser_MiscCommand(dispenserIndex, MISC_DISP_TIME_OFFSET);
|
|
|
+
|
|
|
if(strlen(ShmChargerInfo->StationInfo.StationName) > 0 ||
|
|
|
- strlen(ShmChargerInfo->StationInfo.StationID) > 0 ||
|
|
|
+ ShmChargerInfo->StationInfo.StationID != 0 ||
|
|
|
ShmChargerInfo->StationInfo.WeatherID != 0 ||
|
|
|
ShmChargerInfo->StationInfo.Temperature != 0)
|
|
|
{
|
|
@@ -3784,6 +3963,16 @@ void DispenserSocketProcess(int socketFd, struct sockaddr_in clientInfo, unsigne
|
|
|
}
|
|
|
StationInfoResponse(socketFd, &receiveBuffer, dispenserIndex, ackResult);
|
|
|
}
|
|
|
+
|
|
|
+ // Reg: 0x1F, Deduct Result
|
|
|
+ if(receiveBuffer.Header.op == _Header_Write && receiveBuffer.Payload.reg == _Reg_DeductResult)
|
|
|
+ {
|
|
|
+ if(WriteDeductResultHandler(&receiveBuffer, dispenserIndex))
|
|
|
+ {
|
|
|
+ ackResult = _R_OK;
|
|
|
+ }
|
|
|
+ DeductResultResponse(socketFd, &receiveBuffer, ackResult);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// clean timeout
|
|
@@ -4122,11 +4311,13 @@ void InitialConnector(void)
|
|
|
for(int i = 0; i < GENERAL_GUN_QUANTITY; i++)
|
|
|
{
|
|
|
memset(&ConnectorCapability[i], 0x00, sizeof(ChargingCapabilityResponseInfo));
|
|
|
+ memcpy(ConnectorCapability[i].CurrencyString, Currency[0], 3);
|
|
|
memset(&ConnectorRefund[i], 0x00, sizeof(RefundResponse));
|
|
|
memset(&ConnectorPrepayment[i], 0x00, sizeof(PrepaymentResponseInfo));
|
|
|
memset(&ConnectorPaymentFailReason[i], 0x00, sizeof(PaymentFailResponse));
|
|
|
memset(&_ConnectorQRCode[i][0], 0x00, 128);
|
|
|
memset(&_stationInfo[i], 0x00, sizeof(StationInfoData));
|
|
|
+ memset(&_deductResult[i], 0x00, sizeof(DeductResultInfoData));
|
|
|
}
|
|
|
}
|
|
|
|