Forráskód Böngészése

2022-02-19 / Wendell

Actions
1. [add] add transaction id in capability packet
2. [add] Tcci QR Code display logic
3. [add] deduct info
4. [add] clean Tcci SerialNo
5. [add] disable standby mode for Tcci
6. [add] misc command: Line Status、Final Cost、Time Offset
7. [mod] AutoStartCharging authorize logic
8. [mod] improve log logic
9. [mod] sation packet

Files
1. As follow commit history

Image version : V1.10.XX.XXXX.XX
Wendell 3 éve
szülő
commit
fd5149bbb7

+ 56 - 25
EVSE/Projects/DO360/Apps/Config.h

@@ -289,9 +289,6 @@ enum _ETHERNET_USAGE
 
 #define STR_PAGE_NONE               "PageNone"
 #define STR_REMOTE_NO_ID            "PlugInPage"
-#define STR_REFUND_AMOUNT           "RefundAmount"
-#define STR_PREPAYMENT              "Prepayment"
-#define STR_PAYMENT_FAIL            "PaymentFail"
 
 enum _CONN_STATUS
 {
@@ -518,16 +515,22 @@ typedef union
     }bits;
 }PsuControl;
 
+enum _OCPP_PAGE_INDEX
+{
+    _OCPP_Page_None             = 0,                // page none
+    _OCPP_Page_LineStatus_1     = 1,                // line status 1 page
+    _OCPP_Page_LineStatus_2     = 2,                // line status 2 page
+    _OCPP_Page_LineStatus_3     = 3,                // line status 3 page
+    _OCPP_Page_LineStatus_4     = 4,                // line status 4 page
+};
+
 typedef union
 {
     unsigned int CtrlValue;
     struct
     {
         unsigned int RemoteStartNoId:1;             // 0: no effect,                1: trigger remote start without connector id
-        unsigned int RefundAmount:1;                // 0: no effect,                1: trigger refund amount
-        unsigned int PrepaymentInfo:1;              // 0: no effect,                1: trigger prepayment info
-        unsigned int PaymentFail:1;                 // 0: no effect,                1: trigger payment fail
-        unsigned int res:25;
+        unsigned int res:31;
     }bits;
 }OcppControl;
 
@@ -885,9 +888,6 @@ typedef struct
 }SlaveCabinetControl;
 // ************************************************************************************************* //
 #define LCM_REQ_REMOTE_START_NO_ID          0x00000001
-#define LCM_REQ_REFUND_AMOUNT               0x00000002
-#define LCM_REQ_PREPAYMENT                  0x00000004
-#define LCM_REQ_PAYMENT_FAIL                0x00000008
 
 typedef union
 {
@@ -896,10 +896,7 @@ typedef union
     {
         // cabinet -> connector
         unsigned int RemoteStartNoID:1;                 // 0: no request,  1: lcm page change to RemoteStartNoID
-        unsigned int RefundAmount:1;                    // 0: no request,  1: lcm page change to RefundAmount
-        unsigned int PrepaymentInfo:1;                  // 0: no request,  1: lcm page change to PrepaymentInfo
-        unsigned int PaymentFail:1;                     // 0: no request,  1: lcm page change to PaymentFail
-        unsigned int res:28;
+        unsigned int res:31;
     }bits;
 }ConnectorPageControl;
 
@@ -919,6 +916,7 @@ typedef union
 #define MISC_DISP_SOFTWARE_RESET            0x00002000
 #define MISC_DISP_CHANGE_LCM_INFO           0x00004000
 #define MISC_DISP_STATION_INFO              0x00008000
+#define MISC_DISP_TIME_OFFSET               0x00010000
 
 typedef union
 {
@@ -942,7 +940,8 @@ typedef union
         unsigned int SoftwareReset:1;                   // msic: 0x0102,    0: no request,  1: software reset request
         unsigned int ChangeLcmInfo:1;                   // msic: 0x0107,    0: no request,  1: change lcm info request
         unsigned int ChargerStationInfo:1;              // msic: 0x0109,    0: no request,  1: charger station info request
-        unsigned int res:16;
+        unsigned int TimeOffset:1;                      // msic: 0x0010,    0: no request,  1: time offset request
+        unsigned int res:15;
     }bits;
 }DispenserMiscControl;
 
@@ -953,6 +952,8 @@ typedef union
 #define MISC_CONN_UNLOCK                    0x00000010
 #define MISC_CONN_RESERVATION               0x00000020
 #define MISC_CONN_QRCODE_INFO               0x00000040
+#define MISC_CONN_FINAL_COST                0x00000080
+#define MISC_CONN_LINE_STATUS               0x00000100
 
 typedef union
 {
@@ -967,14 +968,16 @@ typedef union
         unsigned int Unlock:1;                          // msic: 0x0105,    0: no request,  1: unlock request
         unsigned int Reservation:1;                     // msic: 0x0106,    0: no request,  1: reservation request
         unsigned int QRCodeRequest:1;                   // msic: 0x0108,    0: no request,  1: QR Code request
-        unsigned int res:25;
+        unsigned int FinalCostRequest:1;                // msic: 0x010A,    0: no request,  1: Final Cost request
+        unsigned int LineStatusRequest:1;               // msic: 0x010B,    0: no request,  1: Line Status request
+        unsigned int res:23;
     }bits;
 }ConnectorMiscControl;
 
 typedef struct
 {
     unsigned int ConnectionTimeout;             // unit: 1s
-    unsigned int DefaultPrice;                  // unit: 0.01 (dollar/kWh)
+    float        DefaultPrice;                  // unit: 1 (dollar/kWh)
     unsigned int Currency;                      // currency index
     unsigned int BackendStatus;                 // 0: disable, 1: connected, 2: disconnected
     unsigned int EthernetStatus;                // 0: disable, 1: connected, 2: disconnected
@@ -987,6 +990,7 @@ typedef struct
     unsigned int AuthModeConfig;                // 0: enable,  1: disable
     unsigned int EVCCIDConfig;                  // 0: disable, 1: enable
     unsigned int LEDIntensity;                  // LED intensity, 0: Darkest  1: Medium   2: Brightest
+    int          TimeOffset;                    // time offset value, unit: 1 minute
 }MiscCommandValue;
 
 typedef union
@@ -994,11 +998,9 @@ typedef union
     unsigned int CtrlValue;
     struct
     {
-        // cabinet -> dispenser
-        unsigned int RefundRequest:1;                   // cmd: 0x0001,     0: no request,  1: refund request
-        unsigned int RefundCancel:1;                    // cmd: 0x0002,     0: no request,  1: refund cancel
-        unsigned int InvoiceRequest:1;                  // cmd: 0x0003,     0: no request,  1: currency request
-        unsigned int res:29;
+        // dispenser -> cabinet
+        unsigned int ChargingCancel:1;                  // cmd: 0x0001,     0: no request,  1: charging cancel request
+        unsigned int res:31;
     }bits;
 }ConnectorActionFlag;
 
@@ -1007,7 +1009,7 @@ typedef union
     unsigned int CtrlValue[32];
     struct
     {
-        // cabinet -> dispenser
+        // dispenser -> cabinet
         unsigned int Refund;                            // 1: request,      other: no effect
         unsigned int RefundCancel;                      // 1: cancel,       other: no effect
         unsigned int InvoiceIndex;                      // invoice index, start from 1 ~
@@ -1015,6 +1017,18 @@ typedef union
     }bits;
 }ConnectorActionValue;
 
+typedef struct
+{
+    unsigned char DeductReq;                // 0: no request,       1: deduct request
+    unsigned char res;
+    int TransactionId;
+    unsigned char creditNo[64];
+    unsigned char DeductResult;             // DeductResult,        0: Fail, 1: Pass
+    unsigned char IsDonateInvoice;          // IsDonateInvoice,     0: Do not donate, 1: Donate
+    int DeductAmount;                       // DeductAmount,        unit = 0.01 dollar
+    char ApprovalNumber[12];                // ApprovalNumber
+}DeductResultInfoData;
+
 typedef struct
 {
     ConnectorActionFlag Flag;
@@ -1042,13 +1056,26 @@ enum _WEATHER_INFO
 
 typedef struct
 {
+    int StationID;
     char StationName[64];
-    char StationID[16];
-    char ConnectorID[MAX_GROUP_QUANTITY][16];
     char QRCode[MAX_GROUP_QUANTITY][128];
     int WeatherID;
     float Temperature;
 }StationInfoData;
+
+typedef struct
+{
+    int StatusCode[MAX_GROUP_QUANTITY];
+}LineApiStatusInfo;
+
+typedef struct
+{
+    int TransactionId;                      // connector TransactionId
+    float UserPrice;                        // connector user's user price, unit: 1 (dollar / kWh)
+    float TotalCost;                        // connector user's total cost, unit: 1 dollar
+    float AccountBalance;                   // connector user's account balance, unit: 1 dollar
+    float CostDiscount;                     // connector user's account balance, unit: 1 dollar
+}TransactionInfoData;
 // ************************************************************************************************* //
 
 typedef struct
@@ -1066,6 +1093,10 @@ typedef struct
     MiscCommandValue CabinetMiscValue;
     ConnectorActionRequest ConnectorActReq[MAX_GROUP_QUANTITY];
     StationInfoData StationInfo;
+    TransactionInfoData UserTransaction[MAX_GROUP_QUANTITY];
+    DeductResultInfoData DeductResultReq[MAX_GROUP_QUANTITY];
+    DeductResultInfoData ReDeductReq;
+    LineApiStatusInfo LineApi;
 }ChargerInfoData;
 
 #endif /* CONFIG_H_ */

+ 19 - 0
EVSE/Projects/DO360/Apps/Module_Authorize.c

@@ -49,6 +49,7 @@
 #define SYS_AUTHORIZE_COMP_TIMEOUT      1               // unit: 1s
 #define AUTH_TIME_OFFSET_TIME           3               // unit: 1s
 #define AUTO_START_CHARGING             "AutoStartCharging"
+#define DEFAULT_SN                      "NeedSetupSN"
 
 struct SysConfigAndInfo             *ShmSysConfigAndInfo;
 ChargerInfoData                     *ShmChargerInfo;
@@ -292,6 +293,23 @@ void SetAuthorize(AuthorizingInfoData *AuthInfo, unsigned char type)
     ShmSysConfigAndInfo->SysInfo.AuthorizedType = type;
 }
 
+void CheckAutoStartChargingToSNToOcpp(void)
+{
+    if(strcmp((char *)&ShmSysConfigAndInfo->SysConfig.UserId, AUTO_START_CHARGING) == EQUAL)
+    {
+        int len = strlen((char *)&ShmSysConfigAndInfo->SysConfig.SerialNumber);
+        if(len > 0 && len < sizeof(ShmSysConfigAndInfo->SysConfig.UserId))
+        {
+            strcpy((char *)&ShmSysConfigAndInfo->SysConfig.UserId, (char *)&ShmSysConfigAndInfo->SysConfig.SerialNumber);
+        }
+        else
+        {
+            strcpy((char *)&ShmSysConfigAndInfo->SysConfig.UserId, DEFAULT_SN);
+        }
+        AUTH_INFO("Received Auto Start Charging IdTag, Set SN [%s] To Authorize", ShmSysConfigAndInfo->SysConfig.UserId);
+    }
+}
+
 bool IsRemoteStartRequest(int *connector)
 {
     AuthorizingInfoData *AuthInfo;
@@ -586,6 +604,7 @@ int main(void)
 
                 if(_needOcppAuthorize)
                 {
+                    CheckAutoStartChargingToSNToOcpp();
                     Set_Ocpp_AuthorizeReq();
                     AUTH_INFO("*********** Set OPCC AuthorizeReq ***********");
                     ShmSysConfigAndInfo->SysInfo.AuthorizedStatus = _AuthorizeStatus_Busy;

+ 277 - 86
EVSE/Projects/DO360/Apps/Module_EvComm.c

@@ -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, &current);
 
 	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));
     }
 }
 

+ 8 - 6
EVSE/Projects/DO360/Apps/Module_EvComm.h

@@ -85,6 +85,7 @@ enum PAYLOAD_REGISTER
     _Reg_PaymentFailReason          = 0x1C,
     _Reg_ConnectorQRCode            = 0x1D,
     _Reg_StationInfo                = 0x1E,
+    _Reg_DeductResult               = 0x1F,
 };
 
 enum Response_Result
@@ -174,9 +175,6 @@ enum LcmPage
 {
     _LCM_None                   = 0x00,
     _LCM_Page_RemoteStartNoID   = 0x01,
-    _LCM_Page_RefundAmount      = 0x02,
-    _LCM_Page_PrepaymentInfo    = 0x03,
-    _LCM_Page_PaymentFail       = 0x04,
 };
 
 struct MISC_COMMAND
@@ -202,6 +200,8 @@ enum MiscCommand
     _MiscCmd_AuthDisable        = 0x000C,
     _MiscCmd_EVCCIDEnable       = 0x000D,
     _MiscCmd_LEDIntensity       = 0x000E,
+    _MiscCmd_AcContactor        = 0x000E,
+    _MiscCmd_TimeOffset         = 0x0010,
     _MiscCmd_HardwareReboot     = 0x0101,
     _MiscCmd_SoftwareRestart    = 0x0102,
     _MiscCmd_RemoteStart        = 0x0103,
@@ -211,14 +211,14 @@ enum MiscCommand
     _MiscCmd_ChangeLcmPage      = 0x0107,
     _MiscCmd_QRCodeRequest      = 0x0108,
     _MiscCmd_StationInfo        = 0x0109,
+    _MiscCmd_FinalCost          = 0x010A,
+    _MiscCmd_LineStatus         = 0x010B,
 };
 
 enum DispenserMisc_Request
 {
     _DisReq_None                = 0x0000,
-    _DisReq_RefoundRequest      = 0x0001,
-    _DisReq_RefoundCancel       = 0x0002,
-    _DisReq_InvoiceRequest      = 0x0003,
+    _DisReq_ChargingCancel      = 0x0001,
 };
 
 typedef struct
@@ -232,6 +232,8 @@ typedef struct
     unsigned int   TotalCost;               // unit = 0.01 dollar
     int            AccountBalance;          // unit = 0.01 dollar
     int            CostDiscount;            // unit = 0.01 dollar
+    int            TransactionId;           // unit = 0.01 dollar
+    char           CurrencyString[4];
 }ChargingCapabilityResponseInfo;
 
 enum WaitPlug

+ 59 - 6
EVSE/Projects/DO360/Apps/ReadCmdline.c

@@ -3421,17 +3421,15 @@ void ShowWebInfo(char *v1)
 void ShowGunInfo(int gun)
 {
     char *str_gun_type[] = {"CHAdeMO", "  CCS  ", "  GBT  "};
-    char acceptId[128];
-    Get_Ocpp_TransactionId(gun, acceptId);
-    printf(" Gun %d (%s)   Soc:   %3d %s,  Energy:   %7.1f kWh, IdTag [%16s] Transaction [%s], TotalCost: %d.%02d\r\n",
+
+    printf(" Gun %d (%s)   Soc:   %3d %s,  Energy:   %7.1f kWh, IdTag [%16s] Transaction [%d], TotalCost: %.2f\r\n",
         gun + 1,
         ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun].Enable ? str_gun_type[_chargingData[gun]->Type] : "Disable",
         _chargingData[gun]->EvBatterySoc, "%",
         _chargingData[gun]->PresentChargedEnergy,
         _chargingData[gun]->StartUserId,
-        acceptId,
-        (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun].TotalCost / 100),
-        (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun].TotalCost % 100));
+        ShmChargerInfo->UserTransaction[gun].TransactionId,
+        ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun].TotalCost);
     //printf(" Gun %d (%s) IdTag [%16s]    Soc:  %3d %s, Energy: %4.1f kWh\r\n",
     //    i + 1,
     //    ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].Enable ? str_gun_type[_chargingData[i]->Type] : "Disable",
@@ -3884,6 +3882,61 @@ int main(void)
         {
 
         }
+		/*
+        else if(strcmp(newString[0], "dbop") == 0)
+        {
+            if(DeductDB_Open())
+            {
+                printf ("Deduct DB Open OK\n\n");
+            }
+            else
+            {
+                printf ("Deduct DB Open OK\n\n");
+            }
+        }
+        else if(strcmp(newString[0], "dbup") == 0)
+        {
+            int gun = 0;
+            RecordTransactionInfo deduct;
+
+            if(DB_GetReUploadDeduct(&gun, &deduct) == PASS)
+            {
+                printf("Get Gun %d, TxId: %d, Result: %d, Donate: %d, ApprovalNo: %s, CardNo: %s, VemData: %s, Amount: %f, IsUpload: %d\r\n",
+                    gun, deduct.TransactionId, deduct.DeductResult, deduct.IsDonateInvoice, deduct.ApprovalNo, deduct.CardNo, deduct.VemData, deduct.Amount, deduct.IsUpload);
+
+                deduct.IsUpload = YES;
+                printf("Set this deduct upload OK, and restore into database\r\n");
+                UpdateDeductInfoStatus(gun, &deduct);
+            }
+            else
+            {
+                printf("There is no deduct info need to upload\r\n");
+            }
+        }
+        else if(strcmp(newString[0], "dbde") == 0)
+        {
+            int gun = 0;
+            RecordTransactionInfo deduct;
+
+            if(DB_GetReDeductInfo(&gun, &deduct) == PASS)
+            {
+                printf("Get Gun %d, TxId: %d, Result: %d, Donate: %d, ApprovalNo: %s, CardNo: %s, VemData: %s, Amount: %f, IsUpload: %d\r\n",
+                    gun, deduct.TransactionId, deduct.DeductResult, deduct.IsDonateInvoice, deduct.ApprovalNo, deduct.CardNo, deduct.VemData, deduct.Amount, deduct.IsUpload);
+
+                deduct.DeductResult = YES;
+                printf("Set this deduct result OK, and restore into database\r\n");
+                UpdateDeductInfoStatus(gun, &deduct);
+            }
+            else
+            {
+                printf("There is no deduct info need to re-deduct\r\n");
+            }
+        }
+        else if(strcmp(newString[0], "db") == 0)
+        {
+            DB_GetAllDeductInfo();
+        }
+        */
         else if(strcmp(newString[0], "gcmd") == 0)
         {
             if(strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0 ||

+ 1 - 1
EVSE/Projects/DO360/Apps/kill.sh

@@ -14,7 +14,7 @@ pkill Module_CabinetParallel
 pkill Module_LedIndication
 pkill Module_Authorize
 pkill main
-
+fuser -k /dev/watchdog
 sleep 1
 
 echo V > /dev/watchdog

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 379 - 242
EVSE/Projects/DO360/Apps/main.c


BIN
EVSE/Projects/DO360/Images/FactoryDefaultConfig.bin


BIN
EVSE/Projects/DO360/Images/ramdisk.gz


Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott