Beispiel #1
0
        /// <summary>
        /// Try to parse the given XML representation of a SendLocalList request.
        /// </summary>
        /// <param name="XML">The XML to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="SendLocalListRequest">The parsed SendLocalList request.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        public static Boolean TryParse(XElement XML,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out SendLocalListRequest SendLocalListRequest,
                                       OnExceptionDelegate OnException = null)
        {
            try
            {
                SendLocalListRequest = new SendLocalListRequest(

                    ChargeBoxId,

                    XML.MapValueOrFail(OCPPNS.OCPPv1_6_CP + "listVersion",
                                       UInt64.Parse),

                    XML.MapEnumValuesOrFail(OCPPNS.OCPPv1_6_CP + "updateType",
                                            UpdateTypesExtentions.Parse),

                    XML.MapElements(OCPPNS.OCPPv1_6_CP + "localAuthorizationList",
                                    AuthorizationData.Parse),

                    RequestId

                    );

                return(true);
            }
            catch (Exception e)
            {
                OnException?.Invoke(DateTime.UtcNow, XML, e);

                SendLocalListRequest = null;
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Try to parse the given XML representation of a RemoteStopTransaction request.
        /// </summary>
        /// <param name="XML">The XML to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="RemoteStopTransactionRequest">The parsed RemoteStopTransaction request.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        public static Boolean TryParse(XElement XML,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out RemoteStopTransactionRequest RemoteStopTransactionRequest,
                                       OnExceptionDelegate OnException = null)
        {
            try
            {
                RemoteStopTransactionRequest = new RemoteStopTransactionRequest(

                    ChargeBoxId,

                    XML.MapValueOrFail(OCPPNS.OCPPv1_6_CP + "transactionId",
                                       Transaction_Id.Parse),

                    RequestId

                    );

                return(true);
            }
            catch (Exception e)
            {
                OnException?.Invoke(Timestamp.Now, XML, e);

                RemoteStopTransactionRequest = null;
                return(false);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Try to parse the given XML representation of a GetCompositeSchedule request.
        /// </summary>
        /// <param name="XML">The XML to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="GetCompositeScheduleRequest">The parsed GetCompositeSchedule request.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        public static Boolean TryParse(XElement XML,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out GetCompositeScheduleRequest GetCompositeScheduleRequest,
                                       OnExceptionDelegate OnException = null)
        {
            try
            {
                GetCompositeScheduleRequest = new GetCompositeScheduleRequest(

                    ChargeBoxId,

                    XML.MapValueOrFail(OCPPNS.OCPPv1_6_CP + "connectorId",
                                       Connector_Id.Parse),

                    XML.MapValueOrFail(OCPPNS.OCPPv1_6_CP + "duration",
                                       s => TimeSpan.FromSeconds(UInt32.Parse(s))),

                    XML.MapValueOrNullable(OCPPNS.OCPPv1_6_CP + "chargingRateUnit",
                                           ChargingRateUnitsExtentions.Parse),

                    RequestId

                    );

                return(true);
            }
            catch (Exception e)
            {
                OnException?.Invoke(DateTime.UtcNow, XML, e);

                GetCompositeScheduleRequest = null;
                return(false);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Try to parse the given XML representation of a FirmwareStatusNotification request.
        /// </summary>
        /// <param name="XML">The XML to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="FirmwareStatusNotificationRequest">The parsed FirmwareStatusNotification request.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        public static Boolean TryParse(XElement XML,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out FirmwareStatusNotificationRequest FirmwareStatusNotificationRequest,
                                       OnExceptionDelegate OnException = null)
        {
            try
            {
                FirmwareStatusNotificationRequest = new FirmwareStatusNotificationRequest(
                    ChargeBoxId,
                    XML.MapValueOrFail(OCPPNS.OCPPv1_6_CS + "status",
                                       FirmwareStatusExtentions.Parse),
                    RequestId
                    );

                return(true);
            }
            catch (Exception e)
            {
                OnException?.Invoke(DateTime.UtcNow, XML, e);

                FirmwareStatusNotificationRequest = null;
                return(false);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Try to parse the given XML representation of a ChangeConfiguration request.
        /// </summary>
        /// <param name="XML">The XML to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="ChangeConfigurationRequest">The parsed ChangeConfiguration request.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        public static Boolean TryParse(XElement XML,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out ChangeConfigurationRequest ChangeConfigurationRequest,
                                       OnExceptionDelegate OnException = null)
        {
            try
            {
                ChangeConfigurationRequest = new ChangeConfigurationRequest(

                    ChargeBoxId,

                    XML.ElementValueOrFail(OCPPNS.OCPPv1_6_CP + "key"),
                    XML.ElementValueOrFail(OCPPNS.OCPPv1_6_CP + "value"),

                    RequestId

                    );

                return(true);
            }
            catch (Exception e)
            {
                OnException?.Invoke(DateTime.UtcNow, XML, e);

                ChangeConfigurationRequest = null;
                return(false);
            }
        }
        /// <summary>
        /// Try to parse the given XML representation of a TriggerMessage request.
        /// </summary>
        /// <param name="XML">The XML to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="TriggerMessageRequest">The parsed TriggerMessage request.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        public static Boolean TryParse(XElement XML,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out TriggerMessageRequest TriggerMessageRequest,
                                       OnExceptionDelegate OnException = null)
        {
            try
            {
                TriggerMessageRequest = new TriggerMessageRequest(

                    ChargeBoxId,

                    XML.MapEnumValuesOrFail(OCPPNS.OCPPv1_6_CP + "requestedMessage",
                                            MessageTriggersExtentions.Parse),

                    XML.MapValueOrNullable(OCPPNS.OCPPv1_6_CP + "connectorId",
                                           Connector_Id.Parse),

                    RequestId

                    );

                return(true);
            }
            catch (Exception e)
            {
                OnException?.Invoke(Timestamp.Now, XML, e);

                TriggerMessageRequest = null;
                return(false);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Try to parse the given XML representation of a RemoteStartTransaction request.
        /// </summary>
        /// <param name="XML">The XML to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="RemoteStartTransactionRequest">The parsed RemoteStartTransaction request.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        public static Boolean TryParse(XElement XML,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out RemoteStartTransactionRequest RemoteStartTransactionRequest,
                                       OnExceptionDelegate OnException = null)
        {
            try
            {
                RemoteStartTransactionRequest = new RemoteStartTransactionRequest(

                    ChargeBoxId,

                    XML.MapValueOrFail(OCPPNS.OCPPv1_6_CP + "idTag",
                                       IdToken.Parse),

                    XML.MapValueOrNullable(OCPPNS.OCPPv1_6_CP + "connectorId",
                                           Connector_Id.Parse),

                    XML.MapElement(OCPPNS.OCPPv1_6_CP + "chargingProfile",
                                   ChargingProfile.Parse),

                    RequestId

                    );

                return(true);
            }
            catch (Exception e)
            {
                OnException?.Invoke(Timestamp.Now, XML, e);

                RemoteStartTransactionRequest = null;
                return(false);
            }
        }
Beispiel #8
0
        /// <summary>
        /// Try to parse the given XML representation of a GetConfigurationn request.
        /// </summary>
        /// <param name="XML">The XML to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="GetConfigurationRequest">The parsed GetConfigurationn request.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        public static Boolean TryParse(XElement XML,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out GetConfigurationRequest GetConfigurationRequest,
                                       OnExceptionDelegate OnException = null)
        {
            try
            {
                GetConfigurationRequest = new GetConfigurationRequest(

                    ChargeBoxId,

                    XML.ElementValues(OCPPNS.OCPPv1_6_CP + "key"),

                    RequestId

                    );

                return(true);
            }
            catch (Exception e)
            {
                OnException?.Invoke(Timestamp.Now, XML, e);

                GetConfigurationRequest = null;
                return(false);
            }
        }
        /// <summary>
        /// Try to parse the given XML representation of a CancelReservation request.
        /// </summary>
        /// <param name="XML">The XML to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="CancelReservationRequest">The parsed CancelReservation request.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        public static Boolean TryParse(XElement XML,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out CancelReservationRequest CancelReservationRequest,
                                       OnExceptionDelegate OnException = null)
        {
            try
            {
                CancelReservationRequest = new CancelReservationRequest(

                    ChargeBoxId,

                    XML.MapValueOrFail(OCPPNS.OCPPv1_6_CP + "reservationId",
                                       Reservation_Id.Parse),

                    RequestId

                    );

                return(true);
            }
            catch (Exception e)
            {
                OnException?.Invoke(Timestamp.Now, XML, e);

                CancelReservationRequest = null;
                return(false);
            }
        }
Beispiel #10
0
        /// <summary>
        /// Try to parse the given XML representation of an Authorize request.
        /// </summary>
        /// <param name="XML">The XML to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="AuthorizeRequest">The parsed authorize request.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        public static Boolean TryParse(XElement XML,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out AuthorizeRequest AuthorizeRequest,
                                       OnExceptionDelegate OnException = null)
        {
            try
            {
                AuthorizeRequest = new AuthorizeRequest(
                    ChargeBoxId,
                    XML.MapValueOrFail(OCPPNS.OCPPv1_6_CS + "idTag",
                                       IdToken.Parse),
                    RequestId
                    );

                return(true);
            }
            catch (Exception e)
            {
                OnException?.Invoke(DateTime.UtcNow, XML, e);

                AuthorizeRequest = null;
                return(false);
            }
        }
Beispiel #11
0
        /// <summary>
        /// Try to parse the given XML representation of a DataTransfer request.
        /// </summary>
        /// <param name="XML">The XML to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="DataTransferRequest">The parsed DataTransfer request.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        public static Boolean TryParse(XElement XML,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out DataTransferRequest DataTransferRequest,
                                       OnExceptionDelegate OnException = null)
        {
            try
            {
                DataTransferRequest = new DataTransferRequest(

                    ChargeBoxId,

                    XML.ElementValueOrFail(OCPPNS.OCPPv1_6_CP + "vendorId"),
                    XML.ElementValueOrDefault(OCPPNS.OCPPv1_6_CP + "messageId"),
                    XML.ElementValueOrDefault(OCPPNS.OCPPv1_6_CP + "data"),

                    RequestId

                    );

                return(true);
            }
            catch (Exception e)
            {
                OnException?.Invoke(DateTime.UtcNow, XML, e);

                DataTransferRequest = null;
                return(false);
            }
        }
        /// <summary>
        /// Try to parse the given XML representation of a DiagnosticsStatusNotification request.
        /// </summary>
        /// <param name="XML">The XML to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="DiagnosticsStatusNotificationRequest">The parsed DiagnosticsStatusNotification request.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        public static Boolean TryParse(XElement XML,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out DiagnosticsStatusNotificationRequest DiagnosticsStatusNotificationRequest,
                                       OnExceptionDelegate OnException = null)
        {
            try
            {
                DiagnosticsStatusNotificationRequest = new DiagnosticsStatusNotificationRequest(
                    ChargeBoxId,
                    XML.MapValueOrFail(OCPPNS.OCPPv1_6_CS + "status",
                                       DiagnosticsStatusExtentions.Parse),
                    RequestId
                    );

                return(true);
            }
            catch (Exception e)
            {
                OnException?.Invoke(Timestamp.Now, XML, e);

                DiagnosticsStatusNotificationRequest = null;
                return(false);
            }
        }
Beispiel #13
0
        /// <summary>
        /// Try to parse the given XML representation of a SetChargingProfile request.
        /// </summary>
        /// <param name="XML">The XML to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="SetChargingProfileRequest">The parsed SetChargingProfile request.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        public static Boolean TryParse(XElement XML,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out SetChargingProfileRequest SetChargingProfileRequest,
                                       OnExceptionDelegate OnException = null)
        {
            try
            {
                SetChargingProfileRequest = new SetChargingProfileRequest(

                    ChargeBoxId,

                    XML.MapValueOrFail(OCPPNS.OCPPv1_6_CP + "connectorId",
                                       Connector_Id.Parse),

                    XML.MapElementOrFail(OCPPNS.OCPPv1_6_CP + "csChargingProfiles",
                                         ChargingProfile.Parse),

                    RequestId

                    );

                return(true);
            }
            catch (Exception e)
            {
                OnException?.Invoke(Timestamp.Now, XML, e);

                SetChargingProfileRequest = null;
                return(false);
            }
        }
        /// <summary>
        /// Try to parse the given XML representation of a reset request.
        /// </summary>
        /// <param name="XML">The XML to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="ResetRequest">The parsed reset request.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        public static Boolean TryParse(XElement XML,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out ResetRequest ResetRequest,
                                       OnExceptionDelegate OnException = null)
        {
            try
            {
                ResetRequest = new ResetRequest(

                    ChargeBoxId,

                    XML.MapEnumValuesOrFail(OCPPNS.OCPPv1_6_CP + "type",
                                            ResetTypesExtentions.Parse),

                    RequestId

                    );

                return(true);
            }
            catch (Exception e)
            {
                OnException?.Invoke(Timestamp.Now, XML, e);

                ResetRequest = null;
                return(false);
            }
        }
Beispiel #15
0
        /// <summary>
        /// Try to parse the given XML representation of a MeterValues request.
        /// </summary>
        /// <param name="XML">The XML to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="MeterValuesRequest">The parsed MeterValues request.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        public static Boolean TryParse(XElement XML,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out MeterValuesRequest MeterValuesRequest,
                                       OnExceptionDelegate OnException = null)
        {
            try
            {
                MeterValuesRequest = new MeterValuesRequest(

                    ChargeBoxId,

                    XML.MapValueOrFail(OCPPNS.OCPPv1_6_CS + "connectorId",
                                       Connector_Id.Parse),

                    XML.MapElementsOrFail(OCPPNS.OCPPv1_6_CS + "meterValue",
                                          MeterValue.Parse),

                    XML.MapValueOrNullable(OCPPNS.OCPPv1_6_CS + "transactionId",
                                           Transaction_Id.Parse),

                    RequestId

                    );

                return(true);
            }
            catch (Exception e)
            {
                OnException?.Invoke(Timestamp.Now, XML, e);

                MeterValuesRequest = null;
                return(false);
            }
        }
        /// <summary>
        /// Try to parse the given XML representation of an UnlockConnector request.
        /// </summary>
        /// <param name="XML">The XML to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="UnlockConnectorRequest">The parsed UnlockConnector request.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        public static Boolean TryParse(XElement XML,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out UnlockConnectorRequest UnlockConnectorRequest,
                                       OnExceptionDelegate OnException = null)
        {
            try
            {
                UnlockConnectorRequest = new UnlockConnectorRequest(

                    ChargeBoxId,

                    XML.MapValueOrFail(OCPPNS.OCPPv1_6_CP + "connectorId",
                                       Connector_Id.Parse),

                    RequestId

                    );

                return(true);
            }
            catch (Exception e)
            {
                OnException?.Invoke(DateTime.UtcNow, XML, e);

                UnlockConnectorRequest = null;
                return(false);
            }
        }
        /// <summary>
        /// Try to parse the given XML representation of a ChangeAvailability request.
        /// </summary>
        /// <param name="XML">The XML to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="ChangeAvailabilityRequest">The parsed ChangeAvailability request.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        public static Boolean TryParse(XElement XML,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out ChangeAvailabilityRequest ChangeAvailabilityRequest,
                                       OnExceptionDelegate OnException = null)
        {
            try
            {
                ChangeAvailabilityRequest = new ChangeAvailabilityRequest(

                    ChargeBoxId,

                    XML.MapValueOrFail(OCPPNS.OCPPv1_6_CP + "connectorId",
                                       Connector_Id.Parse),

                    XML.MapEnumValuesOrFail(OCPPNS.OCPPv1_6_CP + "type",
                                            AvailabilityTypesExtentions.Parse),

                    RequestId

                    );

                return(true);
            }
            catch (Exception e)
            {
                OnException?.Invoke(Timestamp.Now, XML, e);

                ChangeAvailabilityRequest = null;
                return(false);
            }
        }
Beispiel #18
0
        /// <summary>
        /// Try to parse the given XML representation of a BootNotification request.
        /// </summary>
        /// <param name="XML">The XML to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="BootNotificationRequest">The parsed BootNotification request.</param>
        /// <param name="OnException">An optional delegate called whenever an exception occured.</param>
        public static Boolean TryParse(XElement XML,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out BootNotificationRequest BootNotificationRequest,
                                       OnExceptionDelegate OnException = null)
        {
            try
            {
                BootNotificationRequest = new BootNotificationRequest(
                    ChargeBoxId,
                    XML.ElementValueOrFail(OCPPNS.OCPPv1_6_CS + "chargePointVendor"),
                    XML.ElementValueOrFail(OCPPNS.OCPPv1_6_CS + "chargePointModel"),
                    XML.ElementValueOrDefault(OCPPNS.OCPPv1_6_CS + "chargePointSerialNumber"),
                    XML.ElementValueOrDefault(OCPPNS.OCPPv1_6_CS + "chargeBoxSerialNumber"),
                    XML.ElementValueOrDefault(OCPPNS.OCPPv1_6_CS + "firmwareVersion"),
                    XML.ElementValueOrDefault(OCPPNS.OCPPv1_6_CS + "iccid"),
                    XML.ElementValueOrDefault(OCPPNS.OCPPv1_6_CS + "imsi"),
                    XML.ElementValueOrDefault(OCPPNS.OCPPv1_6_CS + "meterType"),
                    XML.ElementValueOrDefault(OCPPNS.OCPPv1_6_CS + "meterSerialNumber"),
                    RequestId
                    );

                return(true);
            }
            catch (Exception e)
            {
                OnException?.Invoke(Timestamp.Now, XML, e);

                BootNotificationRequest = null;
                return(false);
            }
        }
Beispiel #19
0
 public WSResponseMessage(Request_Id RequestId,
                          JObject Message,
                          Byte MessageType = 3)
 {
     this.RequestId   = RequestId;
     this.Message     = Message ?? new JObject();
     this.MessageType = MessageType;
 }
Beispiel #20
0
 public WSRequestMessage(Request_Id RequestId,
                         String Action,
                         JObject Data)
 {
     this.RequestId = RequestId;
     this.Action    = Action;
     this.Data      = Data ?? new JObject();
 }
Beispiel #21
0
 public WSRequestMessage(Request_Id RequestId,
                         String Action,
                         JObject Message,
                         Byte MessageType = 2)
 {
     this.MessageType = MessageType;
     this.RequestId   = RequestId;
     this.Action      = Action;
     this.Message     = Message ?? new JObject();
 }
Beispiel #22
0
        public WSErrorMessage(Request_Id RequestId,
                              WSErrorCodes ErrorCode,
                              String ErrorDescription = null,
                              JObject ErrorDetails    = null)

        {
            this.RequestId        = RequestId;
            this.ErrorCode        = ErrorCode;
            this.ErrorDescription = ErrorDescription ?? "";
            this.ErrorDetails     = ErrorDetails ?? new JObject();
        }
Beispiel #23
0
        // Note: The following is needed to satisfy pattern matching delegates! Do not refactor it!

        /// <summary>
        /// Try to parse the given JSON representation of an Authorize request.
        /// </summary>
        /// <param name="JSON">The JSON to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="AuthorizeRequest">The parsed authorize request.</param>
        /// <param name="ErrorResponse">An optional error response.</param>
        public static Boolean TryParse(JObject JSON,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out AuthorizeRequest AuthorizeRequest,
                                       out String ErrorResponse)

        => TryParse(JSON,
                    RequestId,
                    ChargeBoxId,
                    out AuthorizeRequest,
                    out ErrorResponse);
Beispiel #24
0
        public static Boolean TryParse(String Text, out WSRequestMessage RequestFrame)
        {
            RequestFrame = null;

            if (Text is null)
            {
                return(false);
            }

            // [
            //     2,                  // MessageType: CALL (Client-to-Server)
            //    "19223201",          // RequestId
            //    "BootNotification",  // Action
            //    {
            //        "chargePointVendor": "VendorX",
            //        "chargePointModel":  "SingleSocketCharger"
            //    }
            // ]

            try
            {
                var JSON = JArray.Parse(Text);

                if (JSON.Count != 4)
                {
                    return(false);
                }

                if (!Byte.TryParse(JSON[0].Value <String>(), out Byte messageType))
                {
                    return(false);
                }

                var requestId = Request_Id.Parse(JSON[1].Value <String>());
                var action    = JSON[2].Value <String>();
                var message   = JSON[3] as JObject;

                if (message is null)
                {
                    return(false);
                }

                RequestFrame = new WSRequestMessage(requestId,
                                                    action,
                                                    message,
                                                    messageType);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
        // Note: The following is needed to satisfy pattern matching delegates! Do not refactor it!

        /// <summary>
        /// Try to parse the given JSON representation of a DiagnosticsStatusNotification request.
        /// </summary>
        /// <param name="JSON">The JSON to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="DiagnosticsStatusNotificationRequest">The parsed DiagnosticsStatusNotification request.</param>
        /// <param name="ErrorResponse">An optional error response.</param>
        public static Boolean TryParse(JObject JSON,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out DiagnosticsStatusNotificationRequest DiagnosticsStatusNotificationRequest,
                                       out String ErrorResponse)

        => TryParse(JSON,
                    RequestId,
                    ChargeBoxId,
                    out DiagnosticsStatusNotificationRequest,
                    out ErrorResponse);
        // Note: The following is needed to satisfy pattern matching delegates! Do not refactor it!

        /// <summary>
        /// Try to parse the given JSON representation of a GetLocalListVersion request.
        /// </summary>
        /// <param name="JSON">The JSON to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="GetLocalListVersionRequest">The parsed GetLocalListVersion request.</param>
        /// <param name="ErrorResponse">An optional error response.</param>
        public static Boolean TryParse(JObject JSON,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out GetLocalListVersionRequest GetLocalListVersionRequest,
                                       out String ErrorResponse)

        => TryParse(JSON,
                    RequestId,
                    ChargeBoxId,
                    out GetLocalListVersionRequest,
                    out ErrorResponse,
                    null);
        // Note: The following is needed to satisfy pattern matching delegates! Do not refactor it!

        /// <summary>
        /// Try to parse the given JSON representation of a TriggerMessage request.
        /// </summary>
        /// <param name="JSON">The JSON to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="TriggerMessageRequest">The parsed TriggerMessage request.</param>
        /// <param name="ErrorResponse">An optional error response.</param>
        public static Boolean TryParse(JObject JSON,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out TriggerMessageRequest TriggerMessageRequest,
                                       out String ErrorResponse)

        => TryParse(JSON,
                    RequestId,
                    ChargeBoxId,
                    out TriggerMessageRequest,
                    out ErrorResponse,
                    null);
Beispiel #28
0
        // Note: The following is needed to satisfy pattern matching delegates! Do not refactor it!

        /// <summary>
        /// Try to parse the given JSON representation of a RemoteStartTransaction request.
        /// </summary>
        /// <param name="JSON">The JSON to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="RemoteStartTransactionRequest">The parsed RemoteStartTransaction request.</param>
        /// <param name="ErrorResponse">An optional error response.</param>
        public static Boolean TryParse(JObject JSON,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out RemoteStartTransactionRequest RemoteStartTransactionRequest,
                                       out String ErrorResponse)

        => TryParse(JSON,
                    RequestId,
                    ChargeBoxId,
                    out RemoteStartTransactionRequest,
                    out ErrorResponse,
                    null);
        // Note: The following is needed to satisfy pattern matching delegates! Do not refactor it!

        /// <summary>
        /// Try to parse the given JSON representation of an UnlockConnector request.
        /// </summary>
        /// <param name="JSON">The JSON to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="UnlockConnectorRequest">The parsed UnlockConnector request.</param>
        /// <param name="ErrorResponse">An optional error response.</param>
        public static Boolean TryParse(JObject JSON,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out UnlockConnectorRequest UnlockConnectorRequest,
                                       out String ErrorResponse)

        => TryParse(JSON,
                    RequestId,
                    ChargeBoxId,
                    out UnlockConnectorRequest,
                    out ErrorResponse,
                    null);
        // Note: The following is needed to satisfy pattern matching delegates! Do not refactor it!

        /// <summary>
        /// Try to parse the given JSON representation of a reset request.
        /// </summary>
        /// <param name="ResetRequestJSON">The JSON to be parsed.</param>
        /// <param name="RequestId">The request identification.</param>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="ResetRequest">The parsed reset request.</param>
        /// <param name="ErrorResponse">An optional error response.</param>
        public static Boolean TryParse(JObject ResetRequestJSON,
                                       Request_Id RequestId,
                                       ChargeBox_Id ChargeBoxId,
                                       out ResetRequest ResetRequest,
                                       out String ErrorResponse)

        => TryParse(ResetRequestJSON,
                    RequestId,
                    ChargeBoxId,
                    out ResetRequest,
                    out ErrorResponse,
                    null);