Example #1
0
        public JObject ToJSON()

        => JSONObject.Create(

            new JProperty("@id", Id.ToString()),
            new JProperty("timestamp", Timestamp.ToIso8601()),
            new JProperty("startTime", StartTime.ToIso8601()),
            new JProperty("duration", Duration.TotalMinutes),
            new JProperty("endTime", EndTime.ToIso8601()),

            new JProperty("consumedReservationTime", ConsumedReservationTime.TotalMinutes),
            new JProperty("reservationLevel", ReservationLevel.ToString()),

            ProviderId.HasValue
                       ? new JProperty("providerId", ProviderId.ToString())
                       : null,

            StartAuthentication != null
                       ? new JProperty("authentication", EndTime.ToIso8601())
                       : null,

            RoamingNetworkId.HasValue
                       ? new JProperty("roamingNetworkId", RoamingNetworkId.ToString())
                       : null,

            ChargingPoolId.HasValue
                       ? new JProperty("chargingPoolId", ChargingPoolId.ToString())
                       : null,

            ChargingStationId.HasValue
                       ? new JProperty("chargingStationId", ChargingStationId.ToString())
                       : null,

            EVSEId.HasValue
                       ? new JProperty("EVSEId", EVSEId.ToString())
                       : null,

            ChargingProduct != null
                       ? new JProperty("chargingProduct", ChargingProduct.ToJSON())
                       : null,

            ChargingSession != null
                       ? new JProperty("chargingSessionId", ChargingSession.Id.ToString())
                       : null

            );
Example #2
0
        public JObject ToJSON()

        => JSONObject.Create(

            new JProperty("@id", SessionId.ToString()),
            new JProperty("@context", ""),

            SessionTime.HasValue
                               ? new JProperty("sessionTime", JSONObject.Create(
                                                   new JProperty("start", SessionTime.Value.StartTime.ToIso8601()),
                                                   SessionTime.Value.EndTime.HasValue
                                         ? new JProperty("end", SessionTime.Value.EndTime.Value.ToIso8601())
                                         : null
                                                   ))
                               : null,

            Duration.HasValue
                               ? new JProperty("duration", Duration.Value.TotalSeconds)
                               : null,

            ChargingStationOperatorId.HasValue
                               ? new JProperty("chargingStationOperatorId", ChargingStationOperatorId.ToString())
                               : null,
            ChargingPoolId.HasValue
                               ? new JProperty("chargingPoolId", ChargingPoolId.ToString())
                               : null,
            ChargingStationId.HasValue
                               ? new JProperty("chargingStationId", ChargingStationId.ToString())
                               : null,
            EVSEId.HasValue
                               ? new JProperty("evseId", EVSEId.ToString())
                               : null,


            ChargingProduct != null
                               ? new JProperty("chargingProduct", ChargingProduct.ToJSON())
                               : null

            //new JProperty("meterValue",     MeterValue),
            //new JProperty("meterId",        MeterId.ToString()),

            //new JProperty("userId",         UserId),
            //new JProperty("publicKey",      PublicKey.KeyId),
            //new JProperty("lastSignature",  lastSignature),
            //new JProperty("signature",      Signature)
            );
        /// <summary>
        /// Return a XML representation of this object.
        /// </summary>
        /// <param name="CustomSetChargingStationAvailabilityStatusRequestSerializer">A delegate to serialize custom set ChargingStation availability status request XML elements.</param>
        public XElement ToXML(CustomXMLSerializerDelegate <SetChargingStationAvailabilityStatusRequest> CustomSetChargingStationAvailabilityStatusRequestSerializer = null)
        {
            var XML = new XElement(eMIPNS.EVCIDynamic + "eMIP_ToIOP_SetChargingStationAvailabilityStatusRequest",

                                   TransactionId.HasValue
                              ? new XElement(eMIPNS.EVCIDynamic + "transactionId", TransactionId.ToString())
                              : null,

                                   new XElement(eMIPNS.EVCIDynamic + "partnerIdType", PartnerId.Format.ToString()),
                                   new XElement(eMIPNS.EVCIDynamic + "partnerId", PartnerId.ToString()),

                                   new XElement(eMIPNS.EVCIDynamic + "operatorIdType", OperatorId.Format.ToString()),
                                   new XElement(eMIPNS.EVCIDynamic + "operatorId", OperatorId.ToString()),

                                   new XElement(eMIPNS.EVCIDynamic + "ChargingStationIdType", ChargingStationId.Format.ToString()),
                                   new XElement(eMIPNS.EVCIDynamic + "ChargingStationId", ChargingStationId.ToString()),

                                   new XElement(eMIPNS.EVCIDynamic + "statusEventDate", StatusEventDate.ToIso8601(false)),
                                   new XElement(eMIPNS.EVCIDynamic + "availabilityStatus", AvailabilityStatus.AsNumber()),

                                   AvailabilityStatusUntil.HasValue
                              ? new XElement(eMIPNS.EVCIDynamic + "availabilityStatusUntil", AvailabilityStatusUntil.Value.ToIso8601(false))
                              : null,

                                   AvailabilityStatusComment.IsNeitherNullNorEmpty()
                              ? new XElement(eMIPNS.EVCIDynamic + "availabilityStatusComment", AvailabilityStatusComment)
                              : null

                                   );


            return(CustomSetChargingStationAvailabilityStatusRequestSerializer != null
                       ? CustomSetChargingStationAvailabilityStatusRequestSerializer(this, XML)
                       : XML);
        }
Example #4
0
        //public ChargingSession AddUserData(String Key, Object Value)
        //{
        //    this._UserDefined
        //}



        public JObject ToJSON(Boolean Embedded = false)

            => JSONObject.Create(

                   Id.ToJSON("@id"),

                   Embedded
                       ? new JProperty("@context",  "https://open.charging.cloud/contexts/wwcp+json/chargingSession")
                       : null,

                   new JProperty("sessionTime",           JSONObject.Create(
                         new JProperty("start",             SessionTime.StartTime.ToIso8601()),
                         SessionTime.EndTime.HasValue
                             ? new JProperty("end",         SessionTime.EndTime.Value.ToIso8601())
                             : null
                     )),

                   new JProperty("duration",                Duration.TotalSeconds),


                   RoamingNetworkId.HasValue
                       ? new JProperty("roamingNetworkId",           RoamingNetworkId.ToString())
                       : null,

                   ChargingStationOperatorId.HasValue
                       ? new JProperty("chargingStationOperatorId",  ChargingStationOperatorId.ToString())
                       : null,

                   ChargingPoolId.HasValue
                       ? new JProperty("chargingPoolId",             ChargingPoolId.           ToString())
                       : null,

                   ChargingStationId.HasValue
                       ? new JProperty("chargingStationId",          ChargingStationId.        ToString())
                       : null,

                   EVSEId.HasValue
                       ? new JProperty("EVSEId",                     EVSEId.                   ToString())
                       : null,

                   ChargingProduct != null
                       ? new JProperty("chargingProduct",            ChargingProduct.          ToJSON())
                       : null,


                   ProviderIdStart != null
                       ? new JProperty("providerIdStart",            ProviderIdStart.ToString())
                       : null,

                   ProviderIdStop != null
                       ? new JProperty("providerIdStop",             ProviderIdStop.ToString())
                       : null,

                   AuthenticationStart.IsDefined()
                       ? new JProperty("authenticationStart",        AuthenticationStart.ToJSON())
                       : null,

                   AuthenticationStop.IsDefined()
                       ? new JProperty("authenticationStop",         AuthenticationStop.ToJSON())
                       : null,




                   Reservation != null

                       ? new JProperty("reservation", new JObject(
                                                          new JProperty("reservationId",  Reservation.Id.ToString()),
                                                          new JProperty("start",          Reservation.StartTime.ToIso8601()),
                                                          new JProperty("duration",       Reservation.Duration.TotalSeconds)
                                                          )
                                                      )

                       : ReservationId != null
                             ? new JProperty("reservationId",            ReservationId.ToString())
                             : null,





                   EnergyMeterId.HasValue
                       ? new JProperty("energyMeterId",              EnergyMeterId.ToString())
                       : null,

                   EnergyMeteringValues.Any()
                       ? new JProperty("energyMeterValues",          new JObject(
                                                                         EnergyMeteringValues.
                                                                         Select(MeterValue => new JProperty(MeterValue.Timestamp.ToIso8601(),
                                                                                                            MeterValue.Value))
                                                                     ))
                       : null

            );