Beispiel #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

            );
Beispiel #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)
            );
Beispiel #3
0
        /// <summary>
        /// Compares two heartbeat requests for equality.
        /// </summary>
        /// <param name="SetChargingPoolAvailabilityStatusRequest">A heartbeat request to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public override Boolean Equals(SetChargingPoolAvailabilityStatusRequest SetChargingPoolAvailabilityStatusRequest)
        {
            if ((Object)SetChargingPoolAvailabilityStatusRequest == null)
            {
                return(false);
            }

            return(((!TransactionId.HasValue && !SetChargingPoolAvailabilityStatusRequest.TransactionId.HasValue) ||
                    (TransactionId.HasValue && SetChargingPoolAvailabilityStatusRequest.TransactionId.HasValue && TransactionId.Value.Equals(SetChargingPoolAvailabilityStatusRequest.TransactionId.Value))) &&

                   PartnerId.Equals(SetChargingPoolAvailabilityStatusRequest.PartnerId) &&
                   OperatorId.Equals(SetChargingPoolAvailabilityStatusRequest.OperatorId) &&
                   ChargingPoolId.Equals(SetChargingPoolAvailabilityStatusRequest.ChargingPoolId) &&
                   StatusEventDate.Equals(SetChargingPoolAvailabilityStatusRequest.StatusEventDate) &&
                   AvailabilityStatus.Equals(SetChargingPoolAvailabilityStatusRequest.AvailabilityStatus) &&

                   ((!AvailabilityStatusUntil.HasValue && !SetChargingPoolAvailabilityStatusRequest.AvailabilityStatusUntil.HasValue) ||
                    (AvailabilityStatusUntil.HasValue && SetChargingPoolAvailabilityStatusRequest.AvailabilityStatusUntil.HasValue && AvailabilityStatusUntil.Value.Equals(SetChargingPoolAvailabilityStatusRequest.AvailabilityStatusUntil.Value))) &&

                   ((!AvailabilityStatusComment.IsNeitherNullNorEmpty() && !SetChargingPoolAvailabilityStatusRequest.AvailabilityStatusComment.IsNeitherNullNorEmpty()) ||
                    (AvailabilityStatusComment.IsNeitherNullNorEmpty() && SetChargingPoolAvailabilityStatusRequest.AvailabilityStatusComment.IsNeitherNullNorEmpty() && AvailabilityStatusComment.Equals(SetChargingPoolAvailabilityStatusRequest.AvailabilityStatusComment))));
        }
Beispiel #4
0
        /// <summary>
        /// Return the HashCode of this object.
        /// </summary>
        /// <returns>The HashCode of this object.</returns>
        public override Int32 GetHashCode()
        {
            unchecked
            {
                return((TransactionId.HasValue
                            ? TransactionId.GetHashCode() * 23
                            : 0) ^

                       PartnerId.GetHashCode() * 21 ^
                       OperatorId.GetHashCode() * 17 ^
                       ChargingPoolId.GetHashCode() * 13 ^
                       StatusEventDate.GetHashCode() * 11 ^
                       AvailabilityStatus.GetHashCode() * 7 ^

                       (AvailabilityStatusUntil.HasValue
                            ? AvailabilityStatusUntil.GetHashCode() * 5
                            : 0) ^

                       (AvailabilityStatusComment.IsNeitherNullNorEmpty()
                            ? AvailabilityStatusComment.GetHashCode() * 3
                            : 0));
            }
        }
Beispiel #5
0
        /// <summary>
        /// Return a XML representation of this object.
        /// </summary>
        /// <param name="CustomSetChargingPoolAvailabilityStatusRequestSerializer">A delegate to serialize custom set ChargingPool availability status request XML elements.</param>
        public XElement ToXML(CustomXMLSerializerDelegate <SetChargingPoolAvailabilityStatusRequest> CustomSetChargingPoolAvailabilityStatusRequestSerializer = null)
        {
            var XML = new XElement(eMIPNS.EVCIDynamic + "eMIP_ToIOP_SetChargingPoolAvailabilityStatusRequest",

                                   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 + "ChargingPoolIdType", ChargingPoolId.Format.ToString()),
                                   new XElement(eMIPNS.EVCIDynamic + "ChargingPoolId", ChargingPoolId.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(CustomSetChargingPoolAvailabilityStatusRequestSerializer != null
                       ? CustomSetChargingPoolAvailabilityStatusRequestSerializer(this, XML)
                       : XML);
        }
Beispiel #6
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

            );