|
@@ -69,6 +69,7 @@ static float periousClockPowerConsumption[CONNECTOR_QUANTITY] = {0};
|
|
|
// OCPP status/previous related variables
|
|
|
//========================================
|
|
|
static int GunStatusInterval = 10;
|
|
|
+static uint8_t Connector0PreviousSystemStatus;
|
|
|
static uint8_t ChademoPreviousSystemStatus[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
|
|
|
static uint8_t CcsPreviousSystemStatus[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
|
|
|
static uint8_t GbPreviousSystemStatus[(GB_QUANTITY>0?GB_QUANTITY:1)];
|
|
@@ -1471,7 +1472,7 @@ int queryOccupancyDeductCallBack(void *data, int columenCount, char **columnValu
|
|
|
json_object *dataBuf = json_object_new_object();
|
|
|
|
|
|
sprintf((char*)ShmOCPP16Data->DataTransfer[0].VendorId, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
|
|
|
- sprintf((char*)ShmOCPP16Data->DataTransfer[0].MessageId,"%s","ID_CreditDeductResult");
|
|
|
+ sprintf((char*)ShmOCPP16Data->DataTransfer[0].MessageId,"%s","ID_OccupancyDeductResult");
|
|
|
|
|
|
json_object_object_add(dataBuf, "occupancySN", json_object_new_string(columnValue[1]));
|
|
|
json_object_object_add(dataBuf, "creditNo", json_object_new_string(columnValue[2]));
|
|
@@ -5153,6 +5154,126 @@ end:
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+int isConnector0Unavailable()
|
|
|
+{
|
|
|
+ uint8_t result = YES;
|
|
|
+ uint8_t tempIndex;
|
|
|
+
|
|
|
+ for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
|
|
|
+ {
|
|
|
+ if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
|
|
|
+ {
|
|
|
+ if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
|
|
|
+ {
|
|
|
+ tempIndex = ((gun_index==2) ? 1: 0);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ tempIndex = gun_index;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int index = 0; index < CHAdeMO_QUANTITY; index++)
|
|
|
+ {
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
|
|
|
+ {
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_BOOTING) && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_MAINTAIN) && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_DEBUG) && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_UPDATE))
|
|
|
+ {
|
|
|
+ result = NO;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(gunType[gun_index] == GUN_TYPE_CCS)
|
|
|
+ {
|
|
|
+
|
|
|
+ if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
|
|
|
+ {
|
|
|
+ tempIndex = ((gun_index==2) ? 1: 0);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ tempIndex = gun_index;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int index = 0; index < CCS_QUANTITY; index++)
|
|
|
+ {
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
|
|
|
+ {
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_BOOTING) && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_MAINTAIN) && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_DEBUG) && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_UPDATE))
|
|
|
+ {
|
|
|
+ result = NO;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(gunType[gun_index] == GUN_TYPE_GBT)
|
|
|
+ {
|
|
|
+
|
|
|
+ if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
|
|
|
+ {
|
|
|
+ tempIndex = ((gun_index==2) ? 1: 0);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ tempIndex = gun_index;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for (int index = 0; index < GB_QUANTITY; index++)
|
|
|
+ {
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
|
|
|
+ {
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_BOOTING) && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_MAINTAIN) && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_DEBUG) && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_UPDATE))
|
|
|
+ {
|
|
|
+ result = NO;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else if(gunType[gun_index] == GUN_TYPE_DO)
|
|
|
+ {
|
|
|
+ tempIndex = gun_index;
|
|
|
+
|
|
|
+ for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
|
|
|
+ {
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
|
|
|
+ {
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_BOOTING) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_MAINTAIN) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_DEBUG) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_UPDATE))
|
|
|
+ {
|
|
|
+ result = NO;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
|
|
|
+ {
|
|
|
+ tempIndex = 2;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ tempIndex = gun_index;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for (int index = 0; index < AC_QUANTITY; index++)
|
|
|
+ {
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
|
|
|
+ {
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_BOOTING) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_MAINTAIN) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_DEBUG) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_UPDATE))
|
|
|
+ {
|
|
|
+ result = NO;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }// END
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
void CheckSystemValue(void)
|
|
|
{
|
|
|
char filenmae[100]={0};
|
|
@@ -5729,6 +5850,12 @@ void CheckSystemValue(void)
|
|
|
}// END
|
|
|
}
|
|
|
|
|
|
+ if(isWebsocketSendable && (server_sign == TRUE) && (isConnector0Unavailable() != Connector0PreviousSystemStatus))
|
|
|
+ {
|
|
|
+ sendConnector0StatusNotificationRequest();
|
|
|
+ Connector0PreviousSystemStatus = isConnector0Unavailable();
|
|
|
+ }
|
|
|
+
|
|
|
if(isWebsocketSendable && (server_sign == TRUE) && (getDiffSecNow(clientTime.StatusNotification[gun_index]) >= 1) && (ShmOCPP16Data->CsMsg.bits[gun_index].CancelReservationConf != 1) &&
|
|
|
(
|
|
|
(cpinitateMsg.bits[gun_index].StatusNotificationReq == 1) || (cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq == 1) ||
|
|
@@ -6732,6 +6859,52 @@ int sendStartTransactionRequest(int gun_index)
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+int sendConnector0StatusNotificationRequest()
|
|
|
+{
|
|
|
+ mtrace();
|
|
|
+ int result = FAIL;
|
|
|
+
|
|
|
+ char message[600]={0};
|
|
|
+ char guid[37];
|
|
|
+ struct timeval tmnow;
|
|
|
+ struct tm *tm;
|
|
|
+ char buf[28];//, usec_buf[6];
|
|
|
+ char tempdata[65]={0};
|
|
|
+
|
|
|
+ DEBUG_INFO("sendConnector0StatusNotificationRequest...\n");
|
|
|
+ gettimeofday(&tmnow, NULL);
|
|
|
+
|
|
|
+ time_t t;
|
|
|
+ t = time(NULL);
|
|
|
+ /*UTC time and date*/
|
|
|
+ tm = gmtime(&t);
|
|
|
+ strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
|
|
|
+
|
|
|
+ random_uuid(guid);
|
|
|
+ sprintf(message, "[%d,\"%s\",\"StatusNotification\",{\"connectorId\":0,\"errorCode\":\"%s\",\"info\":\"%s\",\"status\":\"%s\",\"timestamp\":\"%s\",\"vendorId\":\"%s\",\"vendorErrorCode\":\"%s\"}]"
|
|
|
+ , MESSAGE_TYPE_CALL
|
|
|
+ , guid
|
|
|
+ , "NoError"
|
|
|
+ , ""
|
|
|
+ , (isConnector0Unavailable()==YES?"Unavailable":"Available")
|
|
|
+ , buf
|
|
|
+ , ShmSysConfigAndInfo->SysConfig.chargePointVendor
|
|
|
+ , "");
|
|
|
+
|
|
|
+
|
|
|
+ LWS_Send(message);
|
|
|
+
|
|
|
+ sprintf(tempdata, "StatusNotification,%d", 99);
|
|
|
+
|
|
|
+ if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)//if(hashmap_operation(0,NULL/*hashMap*/, guid, mapItem, tempdata/*(void**)(&mapItem)*//*(void**)(&mapItem)*/) == MAP_OK/*hashmap_put(hashMap, mapItem->key_string, mapItem) == MAP_OK*/)
|
|
|
+ {
|
|
|
+ //DEBUG_ERROR("statusNotification mapitem pass");
|
|
|
+ result = PASS;
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
int sendStatusNotificationRequest(int gun_index)
|
|
|
{
|
|
|
mtrace();
|
|
@@ -17612,10 +17785,10 @@ void handleDataTransferResponse(char *payload, int gun_index)
|
|
|
if(json_object_object_get(Data, "occupancyFee") != NULL)
|
|
|
ShmOCPP16Data->TcciCustomData.GetOccupancyFee[json_object_get_int(json_object_object_get(Data, "ConnectorId"))-1].response_occupancyFee = json_object_get_double(json_object_object_get(Data, "occupancyFee"));
|
|
|
}
|
|
|
- ShmOCPP16Data->TcciCustomData.GetOccupancyFee[gun_index].GetOccupancyFeeReq = 0;
|
|
|
+ ShmOCPP16Data->TcciCustomData.GetOccupancyFee[json_object_get_int(json_object_object_get(Data, "ConnectorId"))-1].GetOccupancyFeeReq = 0;
|
|
|
}
|
|
|
|
|
|
- if(strstr(json_object_get_string(json_object_object_get(Data, "msgId")), "ID_OccupancyFeeResult") != NULL)
|
|
|
+ if(strstr(json_object_get_string(json_object_object_get(Data, "msgId")), "ID_OccupancyDeductResult") != NULL)
|
|
|
{
|
|
|
if(json_object_object_get(Data, "occupancySN") != NULL)
|
|
|
OCPP_update_occupancyDeduct_info((char*)json_object_get_string(json_object_object_get(Data, "occupancySN")));
|
|
@@ -17758,7 +17931,8 @@ void handleStatusNotificationResponse(char *payload, int gun_index)
|
|
|
|
|
|
//cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = 0;
|
|
|
//cpinitateMsg.bits[gun_index].StatusNotificationReq = 0;
|
|
|
- cpinitateMsg.bits[gun_index].StatusNotificationConf = 1;
|
|
|
+ if(gun_index != 99)
|
|
|
+ cpinitateMsg.bits[gun_index].StatusNotificationConf = 1;
|
|
|
}
|
|
|
|
|
|
void handleStopTransactionnResponse(char *payload, int gun_index)
|
|
@@ -24094,6 +24268,8 @@ void InitialSystemValue(void)
|
|
|
memset(AcPreviousConnectorPlugIn, 0, ARRAY_SIZE(AcPreviousConnectorPlugIn));
|
|
|
|
|
|
//Status && ConnectorPlugIn Setting
|
|
|
+ Connector0PreviousSystemStatus = 99;
|
|
|
+
|
|
|
for (int index = 0; index < CHAdeMO_QUANTITY; index++)
|
|
|
{
|
|
|
ChademoPreviousSystemStatus[index] = 99; //ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PreviousSystemStatus;
|