|
@@ -11791,416 +11791,6 @@ int handleGetLocalListVersionRequest(char *uuid, char *payload)
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-int handleRemoteStartRequestOrg(char *uuid, char *payload)
|
|
|
-{
|
|
|
- mtrace();
|
|
|
- int result = FAIL;
|
|
|
- int connectorIdInt=-1;
|
|
|
- int tempIndex = 0;
|
|
|
- int connectorIdIsNULL, chargingProfileIsNULL;
|
|
|
- char comfirmstr[20]={0};
|
|
|
- char cmdBuf[512];
|
|
|
- json_object *RemoteStartTransaction;
|
|
|
- FILE *fp;
|
|
|
-
|
|
|
- DEBUG_INFO("handleRemoteStartRequest ...\n");
|
|
|
- if(server_pending == TRUE)
|
|
|
- {
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- connectorIdIsNULL = chargingProfileIsNULL= FALSE;
|
|
|
-
|
|
|
- RemoteStartTransaction = json_tokener_parse(payload);
|
|
|
- if(!is_error(RemoteStartTransaction))
|
|
|
- {
|
|
|
- if(json_object_object_get(RemoteStartTransaction, "connectorId") != NULL)
|
|
|
- {
|
|
|
- connectorIdInt = json_object_get_int(json_object_object_get(RemoteStartTransaction, "connectorId"));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- connectorIdIsNULL = TRUE;
|
|
|
- for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
|
|
|
- {
|
|
|
- if(!cpinitateMsg.bits[gun_index].isOnCharging && (strstr((char*)ShmOCPP16DataPH->StatusNotification[gun_index].Status, "Preparing") != NULL))
|
|
|
- {
|
|
|
- connectorIdIsNULL = FALSE;
|
|
|
- connectorIdInt = (gun_index+1);
|
|
|
-
|
|
|
- DEBUG_INFO("Remote start without connectorId but detect connector-%02d connected ready to start.\n", connectorIdInt);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if((connectorIdInt <= gunTotalNumber) && (connectorIdInt > 0))
|
|
|
- {
|
|
|
- memset(&ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1], 0x00, sizeof(struct StructRemoteStartTransaction));
|
|
|
- // Required data
|
|
|
- sprintf((char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag, "%s", json_object_get_string(json_object_object_get(RemoteStartTransaction, "idTag")));
|
|
|
-
|
|
|
- // Optional data
|
|
|
- if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
|
|
|
- {
|
|
|
- ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingProfileId = json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfileId"));
|
|
|
- ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.StackLevel = json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "stackLevel"));
|
|
|
- sprintf((char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")));
|
|
|
- sprintf((char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfileKind")));
|
|
|
-
|
|
|
- if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "transactionId") != NULL)
|
|
|
- ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.TransactionId = json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "transactionId"));
|
|
|
-
|
|
|
- if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "recurrencyKind") != NULL)
|
|
|
- sprintf((char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.RecurrencyKind , "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "recurrencyKind")));
|
|
|
-
|
|
|
- if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "validFrom") != NULL)
|
|
|
- sprintf((char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ValidFrom , "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "validFrom")));
|
|
|
-
|
|
|
- if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "validTo") != NULL)
|
|
|
- sprintf((char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ValidTo , "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "validTo")));
|
|
|
-
|
|
|
- if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule") != NULL)
|
|
|
- {
|
|
|
- sprintf((char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.ChargingRateUnit , "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingRateUnit")));
|
|
|
-
|
|
|
- if(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "duration") != NULL)
|
|
|
- ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.Duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "duration"));
|
|
|
-
|
|
|
- if(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "minChargingRate") != NULL)
|
|
|
- ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.MinChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "minChargingRate"));
|
|
|
-
|
|
|
- if(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "startSchedule") != NULL)
|
|
|
- sprintf((char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.StartSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "startSchedule")));
|
|
|
-
|
|
|
- if(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod") != NULL)
|
|
|
- {
|
|
|
- for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
|
|
|
- {
|
|
|
- ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].StartPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
|
|
|
- ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].Limit = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"));
|
|
|
-
|
|
|
- if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases") != NULL)
|
|
|
- ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingSchedule.ChargingSchedulePeriod[idxPeriod].NumberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- chargingProfileIsNULL = TRUE;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- connectorIdIsNULL = TRUE;
|
|
|
- }
|
|
|
-
|
|
|
- if(connectorIdIsNULL == TRUE) // Number of the connector on which to start the transaction. connectorId SHALL be > 0
|
|
|
- {
|
|
|
- DEBUG_WARN("Connector id is NULL\n.");
|
|
|
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
|
|
|
- goto end;
|
|
|
- }
|
|
|
-
|
|
|
- /*
|
|
|
- enum _SYSTEM_STATUS
|
|
|
- {
|
|
|
- S_BOOTING = 0,
|
|
|
- S_IDLE, = 1
|
|
|
- S_AUTHORIZING, = 2
|
|
|
- S_REASSIGN_CHECK, = 3
|
|
|
- S_REASSIGN, = 4
|
|
|
- S_PRECHARGE, = 5
|
|
|
- S_PREPARING_FOR_EV, = 6
|
|
|
- S_PREPARING_FOR_EVSE, = 7
|
|
|
- S_CHARGING, = 8
|
|
|
- S_TERMINATING, = 9
|
|
|
- S_COMPLETE, = 10
|
|
|
- S_ALARM, = 11
|
|
|
- S_FAULT = 12
|
|
|
- }
|
|
|
- */
|
|
|
- if((connectorIdIsNULL == FALSE)&&(connectorIdInt > 0) && (connectorIdInt <= gunTotalNumber))
|
|
|
- {
|
|
|
- //check Transaction active
|
|
|
- if(gunType[connectorIdInt -1] == GUN_TYPE_CHAdeMO)
|
|
|
- {
|
|
|
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
|
|
|
- {
|
|
|
- tempIndex = ((connectorIdInt -1) == 2) ? 1: 0;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- tempIndex = connectorIdInt -1;
|
|
|
- }
|
|
|
-
|
|
|
- for (int index = 0; index < CHAdeMO_QUANTITY; index++)
|
|
|
- {
|
|
|
- if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex )
|
|
|
- {
|
|
|
-
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16DataPH->ReserveNow[index].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag) == 0))
|
|
|
- {
|
|
|
- //Reserved
|
|
|
- DEBUG_INFO("Reserved now !!!The idTag matches the idTag of Reservation!!!\n");
|
|
|
- }
|
|
|
- else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16DataPH->ReserveNow[index].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag) != 0))
|
|
|
- {
|
|
|
- //Reserved
|
|
|
- DEBUG_INFO("Reserved now !!! The idTag does NOT match the idTag of Reservation!!! Reject it!!!\n");
|
|
|
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
|
|
|
- goto end;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARING ) //S_PRECHARGE
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV ) //S_PREPARING_FOR_EV
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE )) // S_PREPARING_FOR_EVSE
|
|
|
- {
|
|
|
- DEBUG_WARN("CHAdeMO connector not allow start\n.");
|
|
|
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
|
|
|
- goto end;
|
|
|
- }
|
|
|
- }//END FOR ELSE
|
|
|
- }
|
|
|
- }// END FOR CHAdeMO_QUANTITY
|
|
|
- }
|
|
|
- else if(gunType[connectorIdInt -1] == GUN_TYPE_CCS)
|
|
|
- {
|
|
|
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
|
|
|
- {
|
|
|
- tempIndex = ((connectorIdInt -1) == 2) ? 1: 0;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- tempIndex = connectorIdInt -1;
|
|
|
- }
|
|
|
-
|
|
|
- for (int index = 0; index < CCS_QUANTITY; index++)
|
|
|
- {
|
|
|
- if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
|
|
|
- {
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16DataPH->ReserveNow[index].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag) == 0))
|
|
|
- {
|
|
|
- //Reserved
|
|
|
- DEBUG_INFO("Reserved now !!!The idTag matches the idTag of Reservation!!!\n");
|
|
|
- }
|
|
|
- else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16DataPH->ReserveNow[index].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag) != 0))
|
|
|
- {
|
|
|
- //Reserved
|
|
|
- DEBUG_INFO("Reserved now !!! The idTag does NOT match the idTag of Reservation!!! Reject it!!!\n");
|
|
|
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
|
|
|
- goto end;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
|
|
|
- {
|
|
|
- DEBUG_WARN("CCS connector not allow start\n.");
|
|
|
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
|
|
|
- goto end;
|
|
|
- }
|
|
|
-
|
|
|
- }// END FOR ELSE
|
|
|
- }
|
|
|
- }// END FOR CCS_QUANTITY
|
|
|
- }
|
|
|
- else if(gunType[connectorIdInt -1] == GUN_TYPE_GBT)
|
|
|
- {
|
|
|
- if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
|
|
|
- {
|
|
|
- tempIndex = ((connectorIdInt -1) == 2) ? 1: 0;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- tempIndex = connectorIdInt -1;
|
|
|
- }
|
|
|
-
|
|
|
- for (int index = 0; index < GB_QUANTITY; index++)
|
|
|
- {
|
|
|
- if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex )
|
|
|
- {
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16DataPH->ReserveNow[index].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag) == 0))
|
|
|
- {
|
|
|
- //Reserved
|
|
|
- DEBUG_INFO("Reserved now !!!The idTag matches the idTag of Reservation!!!\n");
|
|
|
- }
|
|
|
- else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16DataPH->ReserveNow[index].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag) != 0))
|
|
|
- {
|
|
|
- //Reserved
|
|
|
- DEBUG_INFO("Reserved now !!! The idTag does NOT match the idTag of Reservation!!! Reject it!!!\n");
|
|
|
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
|
|
|
- goto end;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
|
|
|
- {
|
|
|
- DEBUG_WARN("GB connector not allow start\n.");
|
|
|
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
|
|
|
- goto end;
|
|
|
- }
|
|
|
-
|
|
|
- }// END FOR ELSE
|
|
|
- }
|
|
|
- } // END FOR GB_QUANTITY
|
|
|
-
|
|
|
- }
|
|
|
- else if(gunType[connectorIdInt -1] == GUN_TYPE_DO)
|
|
|
- {
|
|
|
- tempIndex = connectorIdInt -1;
|
|
|
-
|
|
|
- for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
|
|
|
- {
|
|
|
- if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex )
|
|
|
- {
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16DataPH->ReserveNow[index].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag) == 0))
|
|
|
- {
|
|
|
- //Reserved
|
|
|
- DEBUG_INFO("Reserved now !!!The idTag matches the idTag of Reservation!!!\n");
|
|
|
- }
|
|
|
- else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16DataPH->ReserveNow[index].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag) != 0))
|
|
|
- {
|
|
|
- //Reserved
|
|
|
- DEBUG_INFO("Reserved now !!! The idTag does NOT match the idTag of Reservation!!! Reject it!!!\n");
|
|
|
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
|
|
|
- goto end;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_IDLE) //S_IDLE
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
|
|
|
- {
|
|
|
- DEBUG_WARN("GB connector not allow start\n.");
|
|
|
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
|
|
|
- goto end;
|
|
|
- }
|
|
|
-
|
|
|
- }// END FOR ELSE
|
|
|
- }
|
|
|
- } // END FOR GB_QUANTITY
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
|
|
|
- {
|
|
|
- tempIndex = 2;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- tempIndex = connectorIdInt -1;
|
|
|
- }
|
|
|
-
|
|
|
- for (int index = 0; index < AC_QUANTITY; index++)
|
|
|
- {
|
|
|
- if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex )
|
|
|
- {
|
|
|
-
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16DataPH->ReserveNow[index].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag) == 0))
|
|
|
- {
|
|
|
- //Reserved
|
|
|
- DEBUG_INFO("Reserved now !!!The idTag matches the idTag of Reservation!!!\n");
|
|
|
- }
|
|
|
- else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP16DataPH->ReserveNow[index].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag) != 0))
|
|
|
- {
|
|
|
- //Reserved
|
|
|
- DEBUG_INFO("Reserved now !!! The idTag does NOT match the idTag of Reservation!!! Reject it!!!\n");
|
|
|
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
|
|
|
- goto end;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
|
|
|
- {
|
|
|
- DEBUG_WARN("AC connector not allow start\n.");
|
|
|
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
|
|
|
- goto end;
|
|
|
- }
|
|
|
-
|
|
|
- }//END FOR ELSE
|
|
|
- }
|
|
|
- }// END FOR AC_QUANTITY
|
|
|
- }
|
|
|
-
|
|
|
- if(chargingProfileIsNULL == FALSE)
|
|
|
- {
|
|
|
- if(strcmp((char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ChargingProfile.ChargingProfilePurpose, ChargingProfilePurposeTypeStr[TxProfile]) == 0)
|
|
|
- {
|
|
|
- ShmOCPP16DataPH->CsMsg.bits[connectorIdInt -1].RemoteStartTransactionReq = 1;
|
|
|
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Accepted]);
|
|
|
-
|
|
|
- //memset idTag
|
|
|
- memset((char *)ShmOCPP16DataPH->StartTransaction[connectorIdInt -1].IdTag,0, 20);
|
|
|
- strcpy((char *)ShmOCPP16DataPH->StartTransaction[connectorIdInt -1].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag);
|
|
|
-
|
|
|
- memset((char *)ShmOCPP16DataPH->StopTransaction[connectorIdInt -1].IdTag,0, 20);
|
|
|
- strcpy((char *)ShmOCPP16DataPH->StopTransaction[connectorIdInt -1].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag);
|
|
|
-
|
|
|
- // Save profile to file
|
|
|
- sprintf(cmdBuf, "rm -f /Storage/OCPP_PH/TxProfile_%d.json", connectorIdInt);
|
|
|
- system(cmdBuf);
|
|
|
-
|
|
|
- sprintf(cmdBuf, "/Storage/OCPP_PH/TxProfile_%d.json", connectorIdInt);
|
|
|
- fp = fopen(cmdBuf, "w");
|
|
|
- fprintf(fp, "{\"connectorId\":%d,\"csChargingProfiles\":%s}\n", connectorIdInt, json_object_to_json_string_ext(json_object_object_get(RemoteStartTransaction, "chargingProfile"), JSON_C_TO_STRING_PLAIN));
|
|
|
- fclose(fp);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- DEBUG_WARN("Carging profile purpose not TxProfile.\n.");
|
|
|
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- ShmOCPP16DataPH->CsMsg.bits[connectorIdInt -1].RemoteStartTransactionReq = 1;
|
|
|
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Accepted]);
|
|
|
-
|
|
|
- //memset idTag
|
|
|
- memset((char *)ShmOCPP16DataPH->StartTransaction[connectorIdInt -1].IdTag,0, 20);
|
|
|
- strcpy((char *)ShmOCPP16DataPH->StartTransaction[connectorIdInt -1].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag);
|
|
|
-
|
|
|
- memset((char *)ShmOCPP16DataPH->StopTransaction[connectorIdInt -1].IdTag,0, 20);
|
|
|
- strcpy((char *)ShmOCPP16DataPH->StopTransaction[connectorIdInt -1].IdTag, (char*)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].IdTag);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- DEBUG_WARN("Connector id over\n.");
|
|
|
- strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
|
|
|
- //sprintf((char *)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ResponseStatus, "%s" ,comfirmstr);
|
|
|
- }
|
|
|
-
|
|
|
-end:
|
|
|
- json_object_put(RemoteStartTransaction);
|
|
|
-
|
|
|
- if((connectorIdIsNULL == FALSE) && (connectorIdInt <= gunTotalNumber))
|
|
|
- {
|
|
|
- ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ConnectorId = connectorIdInt;
|
|
|
- sprintf((char *)ShmOCPP16DataPH->RemoteStartTransaction[connectorIdInt -1].ResponseStatus, "%s" ,comfirmstr);
|
|
|
- }
|
|
|
-
|
|
|
- //OCPP send RemoteStartConfirmation by first.
|
|
|
- sendRemoteStartConfirmation(uuid, comfirmstr);
|
|
|
-
|
|
|
- return result;
|
|
|
-}
|
|
|
-
|
|
|
int handleRemoteStartRequest(char *uuid, char *payload)
|
|
|
{
|
|
|
mtrace();
|
|
@@ -12409,10 +11999,7 @@ int handleRemoteStartRequest(char *uuid, char *payload)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARING ) //S_PRECHARGE
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV ) //S_PREPARING_FOR_EV
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE )) // S_PREPARING_FOR_EVSE
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) || ShmOCPP16DataPH->MsMsg.bits.isRemoteStartWaitReq)
|
|
|
{
|
|
|
DEBUG_WARN("CHAdeMO connector not allow start cause busy.\n");
|
|
|
strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
|
|
@@ -12455,10 +12042,7 @@ int handleRemoteStartRequest(char *uuid, char *payload)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) || ShmOCPP16DataPH->MsMsg.bits.isRemoteStartWaitReq)
|
|
|
{
|
|
|
DEBUG_WARN("CCS connector not allow start cause busy.\n");
|
|
|
strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
|
|
@@ -12502,10 +12086,7 @@ int handleRemoteStartRequest(char *uuid, char *payload)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) || ShmOCPP16DataPH->MsMsg.bits.isRemoteStartWaitReq)
|
|
|
{
|
|
|
DEBUG_WARN("GBT connector not allow start cause busy.\n");
|
|
|
strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
|
|
@@ -12543,10 +12124,7 @@ int handleRemoteStartRequest(char *uuid, char *payload)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_IDLE) //S_IDLE
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_IDLE) || ShmOCPP16DataPH->MsMsg.bits.isRemoteStartWaitReq)
|
|
|
{
|
|
|
DEBUG_WARN("Dispenser connector not allow start cause busy.\n");
|
|
|
strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
|
|
@@ -12592,10 +12170,7 @@ int handleRemoteStartRequest(char *uuid, char *payload)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
|
|
|
- && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) || ShmOCPP16DataPH->MsMsg.bits.isRemoteStartWaitReq)
|
|
|
{
|
|
|
DEBUG_WARN("AC connector not allow start cause busy.\n");
|
|
|
strcpy(comfirmstr, RemoteStartStopStatusStr[RemoteStartStopStatus_Rejected]);
|
|
@@ -12650,7 +12225,7 @@ int handleRemoteStartRequest(char *uuid, char *payload)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(isHasIdleConnector == TRUE)
|
|
|
+ if((isHasIdleConnector == TRUE) && !ShmOCPP16DataPH->MsMsg.bits.isRemoteStartWaitReq)
|
|
|
{
|
|
|
DEBUG_INFO("Start wait connector link to EV in %s seconds.\n", ShmOCPP16DataPH->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemData);
|
|
|
|