|
@@ -2,9 +2,9 @@
|
|
|
* Module_LcmControl.c
|
|
|
*
|
|
|
* Created on : 2020-10-20
|
|
|
- * Update on : 2021-12-24
|
|
|
+ * Update on : 2022-01-17
|
|
|
* Author : Folus Wen, Eason Yang
|
|
|
- * Version : V0.25
|
|
|
+ * Version : V0.27
|
|
|
*
|
|
|
*/
|
|
|
|
|
@@ -44,6 +44,8 @@ void setQRCodeAlarm();
|
|
|
void setEthernetIcon();
|
|
|
uint8_t getCurrentPage();
|
|
|
void setAlarmCodeAndIcon();
|
|
|
+void setPresentSessionFee();
|
|
|
+void setPresentParkingFee();
|
|
|
void setBillingFromWebsite();
|
|
|
int isEthConnected(char *eth);
|
|
|
void setUserPrice(uint8_t type);
|
|
@@ -116,7 +118,7 @@ int Uart1Fd;
|
|
|
//=======================================
|
|
|
// Record version and date
|
|
|
//=======================================
|
|
|
-char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.25", "2021-12-24", "REV.02.00"};
|
|
|
+char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.27", "2022-01-17", "REV.03.00"};
|
|
|
|
|
|
//=======================================
|
|
|
// Common routine
|
|
@@ -274,6 +276,7 @@ void getDateTimeString(char* result)
|
|
|
CurrentTime = time(NULL);
|
|
|
tm=localtime(&CurrentTime);
|
|
|
|
|
|
+ //sprintf(result, "%04d/%02d/%02d %02d:%02d", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min);
|
|
|
sprintf(result, "%04d/%02d/%02d %02d:%02d %s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,(tm->tm_hour%12),tm->tm_min,((tm->tm_hour/12)>0?"p.m":"a.m"));
|
|
|
}
|
|
|
|
|
@@ -470,6 +473,8 @@ void page_charging(uint8_t gun_index, uint8_t system_mode)
|
|
|
if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
|
|
|
{
|
|
|
setRunningCost(gun_index, TOTAL_COST);
|
|
|
+ setRunningCost(gun_index, SESSION_FEE);
|
|
|
+ setRunningCost(gun_index, OCCUPANCY_FEE);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -480,16 +485,29 @@ void page_charging(uint8_t gun_index, uint8_t system_mode)
|
|
|
{
|
|
|
if(ShmSysConfigAndInfo->SysConfig.BillingData.isBilling == ON)
|
|
|
{
|
|
|
- setDisplayValue(ICON_CHARGING_COST, APPEAR);
|
|
|
+ setDisplayValue(ICON_CHARGING_TOTAL_COST, APPEAR);
|
|
|
+ setDisplayValue(ICON_CHARGING_SESSION_FEE, APPEAR);
|
|
|
+ setDisplayValue(ICON_CHARGING_PARKING_FEE, APPEAR);
|
|
|
+
|
|
|
setPresentFinalCost(getPresentFinalCost(gun_index));
|
|
|
+ //setPresentSessionFee();
|
|
|
+ setPresentParkingFee();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- // User spend cost
|
|
|
- setDisplayValue(ICON_CHARGING_COST, DISAPPEAR);
|
|
|
- setDisplayValue(TEXT_CHARGING_COST, DISAPPEAR);
|
|
|
+ // Total cost disappear
|
|
|
+ setDisplayValue(ICON_CHARGING_TOTAL_COST, DISAPPEAR);
|
|
|
+ setDisplayValue(TEXT_CHARGING_TOTAL_COST, DISAPPEAR);
|
|
|
+
|
|
|
+ // Session fee disappear
|
|
|
+ setDisplayValue(ICON_CHARGING_SESSION_FEE, DISAPPEAR);
|
|
|
+ setDisplayValue(TEXT_CHARGING_SESSION_FEE, DISAPPEAR);
|
|
|
+
|
|
|
+ // Parking fee disappear
|
|
|
+ setDisplayValue(ICON_CHARGING_PARKING_FEE, DISAPPEAR);
|
|
|
+ setDisplayValue(TEXT_CHARGING_PARKING_FEE, DISAPPEAR);
|
|
|
|
|
|
- // User account balance
|
|
|
+ // User account balance disappear
|
|
|
setDisplayValue(ICON_COMPLETE_WALLET, DISAPPEAR);
|
|
|
setDisplayValue(TEXT_REMAINING_ACCOUNT_BALANCE, DISAPPEAR);
|
|
|
}
|
|
@@ -534,6 +552,8 @@ void page_complete(uint8_t gun_index, uint8_t system_mode)
|
|
|
if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
|
|
|
{
|
|
|
setFinalCost(gun_index, TOTAL_COST);
|
|
|
+ setFinalCost(gun_index, SESSION_FEE);
|
|
|
+ setFinalCost(gun_index, OCCUPANCY_FEE);
|
|
|
setFinalCost(gun_index, ACCOUNT_BALANCE);
|
|
|
//setCurrencyAndUnitFromBackend(FINAL_COST, ACCOUNT_BALANCE, gun_index);
|
|
|
}
|
|
@@ -546,19 +566,32 @@ void page_complete(uint8_t gun_index, uint8_t system_mode)
|
|
|
{
|
|
|
if(ShmSysConfigAndInfo->SysConfig.BillingData.isBilling == ON)
|
|
|
{
|
|
|
- setDisplayValue(ICON_CHARGING_COST, APPEAR);
|
|
|
+ setDisplayValue(ICON_CHARGING_TOTAL_COST, APPEAR);
|
|
|
+ setDisplayValue(ICON_CHARGING_SESSION_FEE, APPEAR);
|
|
|
+ setDisplayValue(ICON_CHARGING_PARKING_FEE, APPEAR);
|
|
|
+
|
|
|
setPresentFinalCost(getPresentFinalCost(gun_index));
|
|
|
+ //setPresentSessionFee();
|
|
|
+ setPresentParkingFee();
|
|
|
|
|
|
setDisplayValue(ICON_COMPLETE_WALLET, DISAPPEAR);
|
|
|
setDisplayValue(TEXT_REMAINING_ACCOUNT_BALANCE, DISAPPEAR);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- // User spend cost
|
|
|
- setDisplayValue(ICON_CHARGING_COST, DISAPPEAR);
|
|
|
- setDisplayValue(TEXT_CHARGING_COST, DISAPPEAR);
|
|
|
+ // Total cost disappear
|
|
|
+ setDisplayValue(ICON_CHARGING_TOTAL_COST, DISAPPEAR);
|
|
|
+ setDisplayValue(TEXT_CHARGING_TOTAL_COST, DISAPPEAR);
|
|
|
+
|
|
|
+ // Session fee disappear
|
|
|
+ setDisplayValue(ICON_CHARGING_SESSION_FEE, DISAPPEAR);
|
|
|
+ setDisplayValue(TEXT_CHARGING_SESSION_FEE, DISAPPEAR);
|
|
|
|
|
|
- // User account balance
|
|
|
+ // Parking fee disappear
|
|
|
+ setDisplayValue(ICON_CHARGING_PARKING_FEE, DISAPPEAR);
|
|
|
+ setDisplayValue(TEXT_CHARGING_PARKING_FEE, DISAPPEAR);
|
|
|
+
|
|
|
+ // User account balance disappear
|
|
|
setDisplayValue(ICON_COMPLETE_WALLET, DISAPPEAR);
|
|
|
setDisplayValue(TEXT_REMAINING_ACCOUNT_BALANCE, DISAPPEAR);
|
|
|
}
|
|
@@ -584,6 +617,8 @@ void page_terminating(uint8_t gun_index, uint8_t system_mode)
|
|
|
if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
|
|
|
{
|
|
|
setRunningCost(gun_index, TOTAL_COST);
|
|
|
+ setRunningCost(gun_index, SESSION_FEE);
|
|
|
+ setRunningCost(gun_index, OCCUPANCY_FEE);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -594,16 +629,29 @@ void page_terminating(uint8_t gun_index, uint8_t system_mode)
|
|
|
{
|
|
|
if(ShmSysConfigAndInfo->SysConfig.BillingData.isBilling == ON)
|
|
|
{
|
|
|
- setDisplayValue(ICON_CHARGING_COST, APPEAR);
|
|
|
+ setDisplayValue(ICON_CHARGING_TOTAL_COST, APPEAR);
|
|
|
+ setDisplayValue(ICON_CHARGING_SESSION_FEE, APPEAR);
|
|
|
+ setDisplayValue(ICON_CHARGING_PARKING_FEE, APPEAR);
|
|
|
+
|
|
|
setPresentFinalCost(getPresentFinalCost(gun_index));
|
|
|
+ //setPresentSessionFee();
|
|
|
+ setPresentParkingFee();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- // User spend cost
|
|
|
- setDisplayValue(ICON_CHARGING_COST, DISAPPEAR);
|
|
|
- setDisplayValue(TEXT_CHARGING_COST, DISAPPEAR);
|
|
|
+ // Total cost disappear
|
|
|
+ setDisplayValue(ICON_CHARGING_TOTAL_COST, DISAPPEAR);
|
|
|
+ setDisplayValue(TEXT_CHARGING_TOTAL_COST, DISAPPEAR);
|
|
|
+
|
|
|
+ // Session fee disappear
|
|
|
+ setDisplayValue(ICON_CHARGING_SESSION_FEE, DISAPPEAR);
|
|
|
+ setDisplayValue(TEXT_CHARGING_SESSION_FEE, DISAPPEAR);
|
|
|
|
|
|
- // User account balance
|
|
|
+ // Parking fee disappear
|
|
|
+ setDisplayValue(ICON_CHARGING_PARKING_FEE, DISAPPEAR);
|
|
|
+ setDisplayValue(TEXT_CHARGING_PARKING_FEE, DISAPPEAR);
|
|
|
+
|
|
|
+ // User account balance disappear
|
|
|
setDisplayValue(ICON_COMPLETE_WALLET, DISAPPEAR);
|
|
|
setDisplayValue(TEXT_REMAINING_ACCOUNT_BALANCE, DISAPPEAR);
|
|
|
}
|
|
@@ -1094,15 +1142,52 @@ void setPriceFromWebsite(float monry_rate)
|
|
|
//=======================================
|
|
|
void setPresentFinalCost(float cost)
|
|
|
{
|
|
|
- uint8_t data[16];
|
|
|
- uint8_t finalCost[16];
|
|
|
+ uint8_t data[32];
|
|
|
+ uint8_t finalCost[32];
|
|
|
|
|
|
memset(data, 0x00, ARRAY_SIZE(data));
|
|
|
memset(finalCost, 0x00, ARRAY_SIZE(finalCost));
|
|
|
|
|
|
sprintf((char *)finalCost, "%.2f", cost);
|
|
|
string2ByteArray(finalCost, data);
|
|
|
- lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, data, ARRAY_SIZE(data));
|
|
|
+
|
|
|
+ // Total Cost
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_TOTAL_COST, data, ARRAY_SIZE(data));
|
|
|
+
|
|
|
+ // Session Fee
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_SESSION_FEE, data, ARRAY_SIZE(data));
|
|
|
+}
|
|
|
+
|
|
|
+//=======================================
|
|
|
+// Setting [ Session Fee ] ( WEB PAGE )
|
|
|
+//=======================================
|
|
|
+void setPresentSessionFee()
|
|
|
+{
|
|
|
+ uint8_t data[32];
|
|
|
+ uint8_t sessionFee[32];
|
|
|
+
|
|
|
+ memset(data, 0x00, ARRAY_SIZE(data));
|
|
|
+ memset(sessionFee, 0x00, ARRAY_SIZE(sessionFee));
|
|
|
+
|
|
|
+ strcpy((char*)sessionFee, "-----");
|
|
|
+ string2ByteArray(sessionFee, data);
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_SESSION_FEE, data, ARRAY_SIZE(data));
|
|
|
+}
|
|
|
+
|
|
|
+//=======================================
|
|
|
+// Setting [ Parking Fee ] ( WEB PAGE )
|
|
|
+//=======================================
|
|
|
+void setPresentParkingFee()
|
|
|
+{
|
|
|
+ uint8_t data[32];
|
|
|
+ uint8_t parkingFee[32];
|
|
|
+
|
|
|
+ memset(data, 0x00, ARRAY_SIZE(data));
|
|
|
+ memset(parkingFee, 0x00, ARRAY_SIZE(parkingFee));
|
|
|
+
|
|
|
+ strcpy((char*)parkingFee, "-----");
|
|
|
+ string2ByteArray(parkingFee, data);
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_PARKING_FEE, data, ARRAY_SIZE(data));
|
|
|
}
|
|
|
|
|
|
//=======================================
|
|
@@ -1313,60 +1398,124 @@ void setDefaultPrice(uint8_t type)
|
|
|
void setFinalCost(uint8_t gun_index, uint8_t type)
|
|
|
{
|
|
|
uint8_t output_data[32];
|
|
|
- char input_data[32];
|
|
|
- char tmp[256];
|
|
|
unsigned char cost_empty[32];
|
|
|
unsigned char balance_empty[32];
|
|
|
+ unsigned char session_empty[32];
|
|
|
+ unsigned char occupancy_empty[32];
|
|
|
json_object *jsonDescription;
|
|
|
|
|
|
- memset(tmp, 0, ARRAY_SIZE(tmp));
|
|
|
memset(output_data, 0x00, ARRAY_SIZE(output_data));
|
|
|
- memset(input_data, 0x00, ARRAY_SIZE(input_data));
|
|
|
- memset(cost_empty, 0x00, ARRAY_SIZE(cost_empty));
|
|
|
memset(balance_empty, 0x00, ARRAY_SIZE(balance_empty));
|
|
|
+ memset(cost_empty, 0x00, ARRAY_SIZE(cost_empty));
|
|
|
+ memset(session_empty, 0x00, ARRAY_SIZE(session_empty));
|
|
|
+ memset(occupancy_empty, 0x00, ARRAY_SIZE(occupancy_empty));
|
|
|
|
|
|
switch(type)
|
|
|
{
|
|
|
case CONNECTION_FEE:
|
|
|
break;
|
|
|
case SESSION_FEE:
|
|
|
+
|
|
|
+ if(ShmOCPP16Data->StopTransaction[gun_index].TransactionId != ShmOCPP16Data->Cost.FinalCost[gun_index].txId)
|
|
|
+ {
|
|
|
+ setDisplayValue(ICON_CHARGING_SESSION_FEE, APPEAR);
|
|
|
+
|
|
|
+ strcpy((char*)session_empty, "-----");
|
|
|
+ string2ByteArray(session_empty, output_data);
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_SESSION_FEE, output_data, ARRAY_SIZE(output_data));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ double chargingCost = 0;
|
|
|
+ jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
|
|
|
+
|
|
|
+ if(!is_error(jsonDescription))
|
|
|
+ {
|
|
|
+ if(json_object_object_get(jsonDescription,"chargingFee") != NULL)
|
|
|
+ {
|
|
|
+ chargingCost += json_object_get_double(json_object_object_get(jsonDescription,"chargingFee"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if(chargingCost> 0)
|
|
|
+ sprintf((char*)output_data, "%.2f", chargingCost);
|
|
|
+ else
|
|
|
+ sprintf((char*)output_data, "-----");
|
|
|
+
|
|
|
+ // APPEAR COST ICON
|
|
|
+ setDisplayValue(ICON_CHARGING_SESSION_FEE, APPEAR);
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_SESSION_FEE, output_data, ARRAY_SIZE(output_data));
|
|
|
+ }
|
|
|
+ json_object_put(jsonDescription);
|
|
|
+ }
|
|
|
break;
|
|
|
case OCCUPANCY_FEE:
|
|
|
+
|
|
|
+ if(ShmOCPP16Data->StopTransaction[gun_index].TransactionId != ShmOCPP16Data->Cost.FinalCost[gun_index].txId)
|
|
|
+ {
|
|
|
+ setDisplayValue(ICON_CHARGING_PARKING_FEE, APPEAR);
|
|
|
+
|
|
|
+ strcpy((char*)occupancy_empty, "-----");
|
|
|
+ string2ByteArray(occupancy_empty, output_data);
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_PARKING_FEE, output_data, ARRAY_SIZE(output_data));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ double parkingCost = 0;
|
|
|
+ jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
|
|
|
+
|
|
|
+ if(!is_error(jsonDescription))
|
|
|
+ {
|
|
|
+ if(json_object_object_get(jsonDescription,"parkingFee") != NULL)
|
|
|
+ {
|
|
|
+ parkingCost += json_object_get_double(json_object_object_get(jsonDescription,"parkingFee"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if(parkingCost > 0)
|
|
|
+ sprintf((char*)output_data, "%.2f", parkingCost);
|
|
|
+ else
|
|
|
+ sprintf((char*)output_data, "-----");
|
|
|
+
|
|
|
+ setDisplayValue(ICON_CHARGING_PARKING_FEE, APPEAR);
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_PARKING_FEE, output_data, ARRAY_SIZE(output_data));
|
|
|
+ }
|
|
|
+ json_object_put(jsonDescription);
|
|
|
+ }
|
|
|
break;
|
|
|
case TOTAL_COST:
|
|
|
if(ShmOCPP16Data->StopTransaction[gun_index].TransactionId != ShmOCPP16Data->Cost.FinalCost[gun_index].txId)
|
|
|
{
|
|
|
- setDisplayValue(ICON_CHARGING_COST, APPEAR);
|
|
|
+ setDisplayValue(ICON_CHARGING_TOTAL_COST, APPEAR);
|
|
|
|
|
|
strcpy((char*)cost_empty, "-----");
|
|
|
string2ByteArray(cost_empty, output_data);
|
|
|
- lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, output_data, ARRAY_SIZE(output_data));
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_TOTAL_COST, output_data, ARRAY_SIZE(output_data));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- double totalCost = 0;
|
|
|
+ double chargingCost = 0;
|
|
|
+ double parkingCost = 0;
|
|
|
jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
|
|
|
|
|
|
if(!is_error(jsonDescription))
|
|
|
{
|
|
|
if(json_object_object_get(jsonDescription,"chargingFee") != NULL)
|
|
|
{
|
|
|
- totalCost += json_object_get_double(json_object_object_get(jsonDescription,"chargingFee"));
|
|
|
+ chargingCost += json_object_get_double(json_object_object_get(jsonDescription,"chargingFee"));
|
|
|
}
|
|
|
|
|
|
if(json_object_object_get(jsonDescription,"parkingFee") != NULL)
|
|
|
{
|
|
|
- totalCost += json_object_get_double(json_object_object_get(jsonDescription,"parkingFee"));
|
|
|
+ parkingCost += json_object_get_double(json_object_object_get(jsonDescription,"parkingFee"));
|
|
|
}
|
|
|
|
|
|
- if(totalCost > 0)
|
|
|
- sprintf((char*)output_data, "$ %.2f", totalCost);
|
|
|
+ if((chargingCost + parkingCost) > 0)
|
|
|
+ sprintf((char*)output_data, "%.2f", (chargingCost + parkingCost));
|
|
|
else
|
|
|
sprintf((char*)output_data, "-----");
|
|
|
|
|
|
// APPEAR COST ICON
|
|
|
- setDisplayValue(ICON_CHARGING_COST, APPEAR);
|
|
|
- lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, output_data, ARRAY_SIZE(output_data));
|
|
|
+ setDisplayValue(ICON_CHARGING_TOTAL_COST, APPEAR);
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_TOTAL_COST, output_data, ARRAY_SIZE(output_data));
|
|
|
}
|
|
|
json_object_put(jsonDescription);
|
|
|
}
|
|
@@ -1390,14 +1539,15 @@ void setFinalCost(uint8_t gun_index, uint8_t type)
|
|
|
{
|
|
|
if(json_object_object_get(jsonDescription,"accountBalance") != NULL)
|
|
|
{
|
|
|
- accountBalance += json_object_get_double(json_object_object_get(jsonDescription,"chargingFee"));
|
|
|
+ accountBalance += json_object_get_double(json_object_object_get(jsonDescription,"accountBalance"));
|
|
|
}
|
|
|
|
|
|
if(accountBalance > 0)
|
|
|
- sprintf((char*)output_data, "$ %.2f", accountBalance);
|
|
|
+ sprintf((char*)output_data, "%.2f", accountBalance);
|
|
|
else
|
|
|
sprintf((char*)output_data, "-----");
|
|
|
|
|
|
+
|
|
|
// APPEAR COST ICON
|
|
|
setDisplayValue(ICON_COMPLETE_WALLET, APPEAR);
|
|
|
lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_REMAINING_ACCOUNT_BALANCE, output_data, ARRAY_SIZE(output_data));
|
|
@@ -1415,65 +1565,125 @@ void setFinalCost(uint8_t gun_index, uint8_t type)
|
|
|
//=======================================
|
|
|
void setRunningCost(uint8_t gun_index, uint8_t type)
|
|
|
{
|
|
|
- uint8_t length;
|
|
|
uint8_t output_data[32];
|
|
|
- char input_data[32];
|
|
|
- char tmp[256];
|
|
|
- char *splitString[10];
|
|
|
- const char *Symbol = ";";
|
|
|
unsigned char cost_empty[32];
|
|
|
+ unsigned char session_empty[32];
|
|
|
+ unsigned char occupancy_empty[32];
|
|
|
+ json_object *jsonDescription;
|
|
|
|
|
|
- memset(tmp, 0, ARRAY_SIZE(tmp));
|
|
|
memset(output_data, 0x00, ARRAY_SIZE(output_data));
|
|
|
- memset(input_data, 0x00, ARRAY_SIZE(input_data));
|
|
|
memset(cost_empty, 0x00, ARRAY_SIZE(cost_empty));
|
|
|
+ memset(session_empty, 0x00, ARRAY_SIZE(session_empty));
|
|
|
+ memset(occupancy_empty, 0x00, ARRAY_SIZE(occupancy_empty));
|
|
|
|
|
|
switch(type)
|
|
|
{
|
|
|
case CONNECTION_FEE:
|
|
|
break;
|
|
|
case SESSION_FEE:
|
|
|
+ if(ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId != ShmOCPP16Data->Cost.RunningCost[gun_index].txId)
|
|
|
+ {
|
|
|
+ setDisplayValue(ICON_CHARGING_SESSION_FEE, APPEAR);
|
|
|
+
|
|
|
+ strcpy((char*)session_empty, "-----");
|
|
|
+ string2ByteArray(session_empty, output_data);
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_SESSION_FEE, output_data, ARRAY_SIZE(output_data));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ double chargingCost = 0;
|
|
|
+ jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description);
|
|
|
+
|
|
|
+ if(!is_error(jsonDescription))
|
|
|
+ {
|
|
|
+ if(json_object_object_get(jsonDescription,"chargingFee") != NULL)
|
|
|
+ {
|
|
|
+ chargingCost += json_object_get_double(json_object_object_get(jsonDescription,"chargingFee"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if(chargingCost> 0)
|
|
|
+ sprintf((char*)output_data, "%.2f", chargingCost);
|
|
|
+ else
|
|
|
+ sprintf((char*)output_data, "-----");
|
|
|
+
|
|
|
+ // APPEAR COST ICON
|
|
|
+ setDisplayValue(ICON_CHARGING_SESSION_FEE, APPEAR);
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_SESSION_FEE, output_data, ARRAY_SIZE(output_data));
|
|
|
+ }
|
|
|
+ json_object_put(jsonDescription);
|
|
|
+ }
|
|
|
+
|
|
|
break;
|
|
|
case OCCUPANCY_FEE:
|
|
|
+ if(ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId != ShmOCPP16Data->Cost.RunningCost[gun_index].txId)
|
|
|
+ {
|
|
|
+ setDisplayValue(ICON_CHARGING_PARKING_FEE, APPEAR);
|
|
|
+
|
|
|
+ strcpy((char*)occupancy_empty, "-----");
|
|
|
+ string2ByteArray(occupancy_empty, output_data);
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_PARKING_FEE, output_data, ARRAY_SIZE(output_data));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ double parkingCost = 0;
|
|
|
+ jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description);
|
|
|
+
|
|
|
+ if(!is_error(jsonDescription))
|
|
|
+ {
|
|
|
+ if(json_object_object_get(jsonDescription,"parkingFee") != NULL)
|
|
|
+ {
|
|
|
+ parkingCost += json_object_get_double(json_object_object_get(jsonDescription,"parkingFee"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if(parkingCost > 0)
|
|
|
+ sprintf((char*)output_data, "%.2f", parkingCost);
|
|
|
+ else
|
|
|
+ sprintf((char*)output_data, "-----");
|
|
|
+
|
|
|
+ setDisplayValue(ICON_CHARGING_PARKING_FEE, APPEAR);
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_PARKING_FEE, output_data, ARRAY_SIZE(output_data));
|
|
|
+ }
|
|
|
+ json_object_put(jsonDescription);
|
|
|
+ }
|
|
|
+
|
|
|
break;
|
|
|
case TOTAL_COST:
|
|
|
if(ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId != ShmOCPP16Data->Cost.RunningCost[gun_index].txId)
|
|
|
{
|
|
|
- setDisplayValue(ICON_CHARGING_COST, APPEAR);
|
|
|
+ setDisplayValue(ICON_CHARGING_TOTAL_COST, APPEAR);
|
|
|
|
|
|
strcpy((char*)cost_empty, "-----");
|
|
|
string2ByteArray(cost_empty, output_data);
|
|
|
- lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, output_data, ARRAY_SIZE(output_data));
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_TOTAL_COST, output_data, ARRAY_SIZE(output_data));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if(strlen((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description) > 0)
|
|
|
+ double chargingCost = 0;
|
|
|
+ double parkingCost = 0;
|
|
|
+ jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description);
|
|
|
+
|
|
|
+ if(!is_error(jsonDescription))
|
|
|
{
|
|
|
- if((strstr((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description, "Total Cost:") > 0))
|
|
|
+ if(json_object_object_get(jsonDescription,"chargingFee") != NULL)
|
|
|
{
|
|
|
- // APPEAR COST ICON
|
|
|
- setDisplayValue(ICON_CHARGING_COST, APPEAR);
|
|
|
+ chargingCost += json_object_get_double(json_object_object_get(jsonDescription,"chargingFee"));
|
|
|
+ }
|
|
|
|
|
|
- // APPEAR COST TEXT
|
|
|
- strcpy((char*)tmp,(char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description);
|
|
|
- split((char**)splitString, tmp, Symbol);
|
|
|
- memcpy(input_data, splitString[3], strlen(splitString[3]));
|
|
|
- length = strlen(input_data);
|
|
|
- trim_string(input_data,length);
|
|
|
- memcpy(output_data ,input_data, strlen(input_data));
|
|
|
- lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, output_data, ARRAY_SIZE(output_data));
|
|
|
+ if(json_object_object_get(jsonDescription,"parkingFee") != NULL)
|
|
|
+ {
|
|
|
+ parkingCost += json_object_get_double(json_object_object_get(jsonDescription,"parkingFee"));
|
|
|
}
|
|
|
+
|
|
|
+ if((chargingCost + parkingCost) > 0)
|
|
|
+ sprintf((char*)output_data, "%.2f", (chargingCost + parkingCost));
|
|
|
else
|
|
|
- {
|
|
|
- setDisplayValue(ICON_CHARGING_COST, APPEAR);
|
|
|
+ sprintf((char*)output_data, "-----");
|
|
|
|
|
|
- strcpy((char*)cost_empty, "-----");
|
|
|
- string2ByteArray(cost_empty, output_data);
|
|
|
- lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, output_data, ARRAY_SIZE(output_data));
|
|
|
- }
|
|
|
+ // APPEAR COST ICON
|
|
|
+ setDisplayValue(ICON_CHARGING_TOTAL_COST, APPEAR);
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_TOTAL_COST, output_data, ARRAY_SIZE(output_data));
|
|
|
}
|
|
|
- else
|
|
|
- {}
|
|
|
+ json_object_put(jsonDescription);
|
|
|
}
|
|
|
|
|
|
break;
|
|
@@ -1936,17 +2146,26 @@ void setPresentConnectionTimeout(uint8_t gun_index)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- time = ShmCharger->timeoutSpec.Handshake_Timeout;
|
|
|
- if(time <= 0)
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A))
|
|
|
{
|
|
|
- strcpy((char*)not_counting, "000");
|
|
|
- string2ByteArray(not_counting, data);
|
|
|
- lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_PREPARING_CONNECTION_TIMER, data, ARRAY_SIZE(data));
|
|
|
+ time = ShmCharger->timeoutSpec.Handshake_Timeout;
|
|
|
+ if(time <= 0)
|
|
|
+ {
|
|
|
+ strcpy((char*)not_counting, "000");
|
|
|
+ string2ByteArray(not_counting, data);
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_PREPARING_CONNECTION_TIMER, data, ARRAY_SIZE(data));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sprintf((char *)conntectionTimeout, "%03d ", time);
|
|
|
+ string2ByteArray(conntectionTimeout, data);
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_PREPARING_CONNECTION_TIMER, data, ARRAY_SIZE(data));
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- sprintf((char *)conntectionTimeout, "%03d ", time);
|
|
|
- string2ByteArray(conntectionTimeout, data);
|
|
|
+ strcpy((char*)not_counting, "-----");
|
|
|
+ string2ByteArray(not_counting, data);
|
|
|
lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_PREPARING_CONNECTION_TIMER, data, ARRAY_SIZE(data));
|
|
|
}
|
|
|
}
|
|
@@ -2163,9 +2382,11 @@ void setTextToEmpty(uint8_t gun_index)
|
|
|
strcpy((char*)text_empty, " ");
|
|
|
string2ByteArray(text_empty, data);
|
|
|
|
|
|
- lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, data, ARRAY_SIZE(data));
|
|
|
- lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_REMAINING_ACCOUNT_BALANCE, data, ARRAY_SIZE(data));
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_TOTAL_COST, data, ARRAY_SIZE(data));
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_SESSION_FEE, data, ARRAY_SIZE(data));
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_PARKING_FEE, data, ARRAY_SIZE(data));
|
|
|
lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_USER_ACCOUNT_BALANCE, data, ARRAY_SIZE(data));
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_REMAINING_ACCOUNT_BALANCE, data, ARRAY_SIZE(data));
|
|
|
}
|
|
|
|
|
|
//=======================================
|
|
@@ -2656,6 +2877,7 @@ int main(void)
|
|
|
else
|
|
|
{
|
|
|
refreshStartTimer(&startTime[ShmCharger->gun_selectd][TMR_IDX_SHOW_AUTH_RESULT]);
|
|
|
+ ShmCharger->gun_info[ShmCharger->gun_selectd].isHandshakeTimerRefresh = NO;
|
|
|
|
|
|
switch(ShmSysConfigAndInfo->SysInfo.AcChargingData[ShmCharger->gun_selectd].SystemStatus)
|
|
|
{
|