|
@@ -2,9 +2,9 @@
|
|
|
* Module_LcmControl.c
|
|
|
*
|
|
|
* Created on : 2020-10-20
|
|
|
- * Update on : 2022-01-07
|
|
|
+ * Update on : 2021-12-24
|
|
|
* Author : Folus Wen, Eason Yang
|
|
|
- * Version : V0.26
|
|
|
+ * Version : V0.25
|
|
|
*
|
|
|
*/
|
|
|
|
|
@@ -102,6 +102,8 @@ struct timespec startTime[AC_QUANTITY][TMR_IDX_SHOW_AUTH_RESULT];
|
|
|
#define TIME_AUTH_RESULT_TIME 5 // Unit: Second
|
|
|
#define TIME_REFRESH_INFO 3 // Unit: Second
|
|
|
|
|
|
+#define is_error(ptr) ((unsigned long)ptr > (unsigned long)-4000L)
|
|
|
+
|
|
|
//=======================================
|
|
|
// Declare Variable
|
|
|
//=======================================
|
|
@@ -114,7 +116,7 @@ int Uart1Fd;
|
|
|
//=======================================
|
|
|
// Record version and date
|
|
|
//=======================================
|
|
|
-char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.26", "2022-01-07", "REV.02.00"};
|
|
|
+char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.25", "2021-12-24", "REV.02.00"};
|
|
|
|
|
|
//=======================================
|
|
|
// Common routine
|
|
@@ -272,7 +274,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"));
|
|
|
}
|
|
|
|
|
|
//======================================================
|
|
@@ -1310,14 +1312,12 @@ void setDefaultPrice(uint8_t type)
|
|
|
//=======================================
|
|
|
void setFinalCost(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 balance_empty[32];
|
|
|
+ json_object *jsonDescription;
|
|
|
|
|
|
memset(tmp, 0, ARRAY_SIZE(tmp));
|
|
|
memset(output_data, 0x00, ARRAY_SIZE(output_data));
|
|
@@ -1344,28 +1344,31 @@ void setFinalCost(uint8_t gun_index, uint8_t type)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if((strstr((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description, "Total Cost:") > 0))
|
|
|
- {
|
|
|
- // APPEAR COST ICON
|
|
|
- setDisplayValue(ICON_CHARGING_COST, APPEAR);
|
|
|
+ double totalCost = 0;
|
|
|
+ jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
|
|
|
|
|
|
- // APPEAR COST TEXT
|
|
|
- strcpy((char*)tmp,(char*)ShmOCPP16Data->Cost.FinalCost[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));
|
|
|
- }
|
|
|
- else
|
|
|
+ if(!is_error(jsonDescription))
|
|
|
{
|
|
|
- setDisplayValue(ICON_CHARGING_COST, APPEAR);
|
|
|
+ if(json_object_object_get(jsonDescription,"chargingFee") != NULL)
|
|
|
+ {
|
|
|
+ totalCost += 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"));
|
|
|
+ }
|
|
|
|
|
|
- strcpy((char*)cost_empty, "-----");
|
|
|
- string2ByteArray(cost_empty, output_data);
|
|
|
+ if(totalCost > 0)
|
|
|
+ sprintf((char*)output_data, "$ %.2f", totalCost);
|
|
|
+ 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));
|
|
|
}
|
|
|
+ json_object_put(jsonDescription);
|
|
|
}
|
|
|
break;
|
|
|
case ACCOUNT_BALANCE:
|
|
@@ -1380,29 +1383,26 @@ void setFinalCost(uint8_t gun_index, uint8_t type)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if((strstr((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description, "Account Balance:") > 0))
|
|
|
- {
|
|
|
- // APPEAR BALANCE ICON
|
|
|
- setDisplayValue(ICON_COMPLETE_WALLET, APPEAR);
|
|
|
+ double accountBalance = 0;
|
|
|
+ jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
|
|
|
|
|
|
- // APPEAR BALANCE TEXT
|
|
|
- strcpy((char*)tmp,(char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
|
|
|
- split((char**)splitString, tmp, Symbol);
|
|
|
- memcpy(input_data, splitString[4], strlen(splitString[4]));
|
|
|
- length = strlen(input_data);
|
|
|
- trim_string(input_data,length);
|
|
|
- memcpy(output_data ,input_data, strlen(input_data));
|
|
|
- lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_REMAINING_ACCOUNT_BALANCE, output_data, ARRAY_SIZE(output_data));
|
|
|
- }
|
|
|
- else
|
|
|
+ if(!is_error(jsonDescription))
|
|
|
{
|
|
|
- setDisplayValue(ICON_COMPLETE_WALLET, APPEAR);
|
|
|
+ if(json_object_object_get(jsonDescription,"accountBalance") != NULL)
|
|
|
+ {
|
|
|
+ accountBalance += json_object_get_double(json_object_object_get(jsonDescription,"chargingFee"));
|
|
|
+ }
|
|
|
|
|
|
- strcpy((char*)balance_empty, "-----");
|
|
|
- string2ByteArray(balance_empty, output_data);
|
|
|
+ if(accountBalance > 0)
|
|
|
+ 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));
|
|
|
}
|
|
|
+ json_object_put(jsonDescription);
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
@@ -2656,7 +2656,6 @@ 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)
|
|
|
{
|