Exemplo n.º 1
0
        /// <summary>
        /// Create a charging reservation.
        /// </summary>
        public ChargingReservation(ChargingReservation_Id Id,
                                   DateTime Timestamp,
                                   DateTime StartTime,
                                   TimeSpan Duration,
                                   DateTime EndTime,
                                   TimeSpan ConsumedReservationTime,
                                   ChargingReservationLevel ReservationLevel,

                                   eMobilityProvider_Id?ProviderId          = null,
                                   RemoteAuthentication StartAuthentication = null,

                                   RoamingNetwork_Id?RoamingNetworkId = null,
                                   ChargingStationOperator_Id?ChargingStationOperatorId = null,
                                   ChargingPool_Id?ChargingPoolId       = null,
                                   ChargingStation_Id?ChargingStationId = null,
                                   EVSE_Id?EVSEId = null,
                                   ChargingProduct ChargingProduct = null,

                                   IEnumerable <Auth_Token> AuthTokens      = null,
                                   IEnumerable <eMobilityAccount_Id> eMAIds = null,
                                   IEnumerable <UInt32> PINs = null,

                                   IEnumerable <ChargingReservation> SubReservations = null)

        {
            this.Id        = Id;
            this.Timestamp = Timestamp.ToUniversalTime();
            this.StartTime = StartTime.ToUniversalTime();
            this.Duration  = Duration;
            this.EndTime   = StartTime.ToUniversalTime() + Duration;
            this.ConsumedReservationTime = ConsumedReservationTime;
            this.ReservationLevel        = ReservationLevel;

            this.ProviderId          = ProviderId;
            this.StartAuthentication = StartAuthentication;

            this.RoamingNetworkId          = RoamingNetworkId;
            this.ChargingStationOperatorId = ChargingStationOperatorId;
            this.ChargingPoolId            = ChargingPoolId;
            this.ChargingStationId         = ChargingStationId;
            this.EVSEId          = EVSEId;
            this.ChargingProduct = ChargingProduct;

            this._AuthTokens = AuthTokens != null ? new HashSet <Auth_Token>         (AuthTokens)      : new HashSet <Auth_Token>();
            this._eMAIds     = eMAIds != null ? new HashSet <eMobilityAccount_Id>(eMAIds)          : new HashSet <eMobilityAccount_Id>();
            this._PINs       = PINs != null ? new HashSet <UInt32>             (PINs)            : new HashSet <UInt32>();

            this._SubReservations = SubReservations != null ? new HashSet <ChargingReservation>(SubReservations) : new HashSet <ChargingReservation>();
        }
Exemplo n.º 2
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

            );
Exemplo n.º 3
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)
            );
Exemplo n.º 4
0
        /// <summary>
        /// Create a charge detail record for the given charging session (identification).
        /// </summary>
        /// <param name="SessionId">The unique charging session identification.</param>
        /// <param name="SessionTime">The timestamps when the charging session started and ended.</param>
        /// <param name="Duration">The duration of the charging session, whenever it is more than the time span between its start- and endtime, e.g. caused by a tariff granularity of 15 minutes.</param>
        ///
        /// <param name="EVSE">The EVSE used for charging.</param>
        /// <param name="EVSEId">The identification of the EVSE used for charging.</param>
        /// <param name="ChargingStation">The charging station of the charging station used for charging.</param>
        /// <param name="ChargingStationId">The identification of the charging station used for charging.</param>
        /// <param name="ChargingPool">The charging pool of the charging pool used for charging.</param>
        /// <param name="ChargingPoolId">The identification of the charging pool used for charging.</param>
        /// <param name="ChargingStationOperator">The charging station operator used for charging.</param>
        /// <param name="ChargingStationOperatorId">The identification of the charging station operator used for charging.</param>
        /// <param name="ChargingProduct">The consumed charging product.</param>
        /// <param name="ChargingPrice">The charging price.</param>
        ///
        /// <param name="AuthenticationStart">The authentication used for starting this charging process.</param>
        /// <param name="AuthenticationStop">The authentication used for stopping this charging process.</param>
        /// <param name="ProviderIdStart">The identification of the e-mobility provider used for starting this charging process.</param>
        /// <param name="ProviderIdStop">The identification of the e-mobility provider used for stopping this charging process.</param>
        ///
        /// <param name="Reservation">The optional charging reservation used before charging.</param>
        /// <param name="ReservationId">The optional charging reservation identification used before charging.</param>
        /// <param name="ReservationTime">Optional timestamps when the reservation started and ended.</param>
        ///
        /// <param name="ParkingSpaceId">The optional identification of the parkging space.</param>
        /// <param name="ParkingTime">Optional timestamps when the parking started and ended.</param>
        /// <param name="ParkingFee">The optional fee for parking.</param>
        ///
        /// <param name="EnergyMeterId">An optional unique identification of the energy meter.</param>
        /// <param name="EnergyMeteringValues">An optional enumeration of intermediate energy metering values.</param>
        ///
        /// <param name="CustomData">An optional dictionary of customer-specific data.</param>
        public ChargeDetailRecord(ChargingSession_Id SessionId,
                                  StartEndDateTime?SessionTime,
                                  TimeSpan?Duration = null,

                                  EVSE EVSE      = null,
                                  EVSE_Id?EVSEId = null,
                                  ChargingStation ChargingStation                      = null,
                                  ChargingStation_Id?ChargingStationId                 = null,
                                  ChargingPool ChargingPool                            = null,
                                  ChargingPool_Id?ChargingPoolId                       = null,
                                  ChargingStationOperator ChargingStationOperator      = null,
                                  ChargingStationOperator_Id?ChargingStationOperatorId = null,
                                  ChargingProduct ChargingProduct                      = null,
                                  Decimal?ChargingPrice = null,

                                  AAuthentication AuthenticationStart  = null,
                                  AAuthentication AuthenticationStop   = null,
                                  eMobilityProvider_Id?ProviderIdStart = null,
                                  eMobilityProvider_Id?ProviderIdStop  = null,

                                  ChargingReservation Reservation      = null,
                                  ChargingReservation_Id?ReservationId = null,
                                  StartEndDateTime?ReservationTime     = null,

                                  ParkingSpace_Id?ParkingSpaceId = null,
                                  StartEndDateTime?ParkingTime   = null,
                                  Decimal?ParkingFee             = null,

                                  EnergyMeter_Id?EnergyMeterId = null,
                                  IEnumerable <Timestamped <Single> > EnergyMeteringValues = null,
                                  IEnumerable <SignedMeteringValue> SignedMeteringValues   = null,
                                  IEnumerable <String> Signatures = null,

                                  IReadOnlyDictionary <String, Object> CustomData = null)

            : base(CustomData)

        {
            this.SessionId   = SessionId;
            this.SessionTime = SessionTime;
            this.Duration    = Duration;

            this.EVSE                      = EVSE;
            this.EVSEId                    = EVSEId ?? EVSE?.Id;
            this.ChargingStation           = ChargingStation;
            this.ChargingStationId         = ChargingStationId ?? ChargingStation?.Id;
            this.ChargingPool              = ChargingPool;
            this.ChargingPoolId            = ChargingPoolId ?? ChargingPool?.Id;
            this.ChargingStationOperator   = ChargingStationOperator;
            this.ChargingStationOperatorId = ChargingStationOperatorId ?? ChargingStationOperator?.Id;
            this.ChargingProduct           = ChargingProduct;
            this.ChargingPrice             = ChargingPrice;

            this.IdentificationStart = AuthenticationStart;
            this.IdentificationStop  = AuthenticationStop;
            this.ProviderIdStart     = ProviderIdStart;
            this.ProviderIdStop      = ProviderIdStop;

            this.Reservation     = Reservation;
            this.ReservationId   = ReservationId ?? Reservation?.Id;
            this.ReservationTime = ReservationTime;

            this.ParkingSpaceId = ParkingSpaceId;
            this.ParkingTime    = ParkingTime;
            this.ParkingFee     = ParkingFee;

            this.EnergyMeterId        = EnergyMeterId;
            this.EnergyMeteringValues = EnergyMeteringValues ?? new Timestamped <Single> [0];
            this.SignedMeteringValues = SignedMeteringValues ?? new SignedMeteringValue[0];
            this._Signatures          = Signatures.SafeAny()  ? new HashSet <String>(Signatures) : new HashSet <String>();

            if (SignedMeteringValues.SafeAny() && !EnergyMeteringValues.SafeAny())
            {
                this.EnergyMeteringValues = SignedMeteringValues.Select(svalue => new Timestamped <Single>(svalue.Timestamp,
                                                                                                           (Single)svalue.MeterValue));
            }
        }
Exemplo n.º 5
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

            );