Пример #1
0
        public void New(ChargingReservation NewChargingReservation)
        {
            lock (InternalData)
            {
                if (!InternalData.ContainsKey(NewChargingReservation.Id))
                {
                    InternalData.Add(NewChargingReservation.Id, new ChargingReservationCollection(NewChargingReservation));

                    LogIt("new",
                          NewChargingReservation.Id,
                          "reservations",
                          new JArray(NewChargingReservation.ToJSON()));
                }

                else
                {
                    InternalData[NewChargingReservation.Id].Add(NewChargingReservation);

                    LogIt("update",
                          NewChargingReservation.Id,
                          "reservations",
                          new JArray(InternalData[NewChargingReservation.Id].Select(reservation => reservation.ToJSON())));
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Create a new reserve result.
 /// </summary>
 /// <param name="Result">The result of the reserve operation.</param>
 /// <param name="Message">An optional message.</param>
 private ReservationResult(ReservationResultType Result,
                           String Message = null)
 {
     this._Result      = Result;
     this._Reservation = null;
     this._Message     = Message;
 }
Пример #3
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="ChargingReservation">An optional charging reservation used for charging.</param>
        ///
        /// <param name="EVSE">The EVSE of the EVSE used for charging.</param>
        /// <param name="ChargingStation">The charging station of the charging station used for charging.</param>
        /// <param name="ChargingPool">The charging pool of the charging pool used for charging.</param>
        /// <param name="EVSEOperator">The EVSE operator used for charging.</param>
        /// <param name="ChargingProductId">An unqiue identification for the consumed charging product.</param>
        ///
        /// <param name="ReservationTime">Optional timestamps when the reservation started and ended.</param>
        /// <param name="ParkingTime">Optional timestamps when the parking started and ended.</param>
        /// <param name="SessionTime">Optional timestamps when the charging session started and ended.</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="MeteringSignature">An optional signature for the metering values.</param>
        ///
        /// <param name="IdentificationStart">The identification for the start of the charging process.</param>
        /// <param name="IdentificationStop">The identification for the stop of the charging process.</param>
        public ChargeDetailRecord(ChargingSession_Id SessionId,
                                  ChargingReservation Reservation      = null,
                                  ChargingReservation_Id ReservationId = null,

                                  EVSEOperator EVSEOperator       = null,
                                  ChargingPool ChargingPool       = null,
                                  ChargingStation ChargingStation = null,
                                  EVSE EVSE      = null,
                                  EVSE_Id EVSEId = null,
                                  ChargingProduct_Id ChargingProductId = null,

                                  EVSP_Id ProviderId = null,

                                  StartEndDateTime?ReservationTime = null,
                                  StartEndDateTime?ParkingTime     = null,
                                  StartEndDateTime?SessionTime     = null,

                                  EnergyMeter_Id EnergyMeterId = null,
                                  IEnumerable <Timestamped <Double> > EnergyMeteringValues = null,
                                  String MeteringSignature = null,

                                  AuthInfo IdentificationStart = null,
                                  AuthInfo IdentificationStop  = null)

        {
            #region Initial checks

            if (SessionId == null)
            {
                throw new ArgumentNullException("Id", "The charging session identification must not be null!");
            }

            #endregion

            this._SessionId = SessionId;

            this._Reservation     = Reservation;
            this._ReservationId   = ReservationId != null ? ReservationId : Reservation != null ? Reservation.Id : null;
            this._ReservationTime = ReservationTime;

            this._EVSE              = EVSE;
            this._EVSEId            = EVSE != null ? EVSE.Id : EVSEId;
            this._ChargingStation   = ChargingStation;
            this._ChargingPool      = ChargingPool;
            this._EVSEOperator      = EVSEOperator;
            this._ChargingProductId = ChargingProductId;

            this._ParkingTime = ParkingTime;
            this._SessionTime = SessionTime;

            this._EnergyMeterId        = EnergyMeterId;
            this._EnergyMeteringValues = EnergyMeteringValues != null ? EnergyMeteringValues : new Timestamped <Double> [0];

            this._IdentificationStart = IdentificationStart;
            this._IdentificationStop  = IdentificationStop;
        }
Пример #4
0
        /// <summary>
        /// The cancel reservation request was successful.
        /// </summary>
        /// <param name="ReservationId">A reservation identification.</param>
        /// <param name="Reason">A reason for the charging reservation cancellation.</param>
        /// <param name="Reservation">A charging reservation.</param>
        /// <param name="Runtime">The optional runtime of the reequest.</param>
        public static CancelReservationResult Success(ChargingReservation_Id ReservationId,
                                                      ChargingReservationCancellationReason Reason,
                                                      ChargingReservation Reservation = null,
                                                      TimeSpan?Runtime = null)

        => new CancelReservationResult(CancelReservationResultTypes.Success,
                                       ReservationId,
                                       Reason,
                                       Reservation,
                                       Runtime: Runtime);
Пример #5
0
        public Boolean TryGetLatest(ChargingReservation_Id Id,
                                    out ChargingReservation LatestReservation)
        {
            if (InternalData.TryGetValue(Id, out ChargingReservationCollection ReservationCollection))
            {
                LatestReservation = ReservationCollection.LastOrDefault();
                return(true);
            }

            LatestReservation = null;
            return(false);
        }
Пример #6
0
        /// <summary>
        /// Create a new successful reserve result.
        /// </summary>
        /// <param name="Reservation">The charging reservation.</param>
        private ReservationResult(ChargingReservation Reservation)
        {
            #region Initial checks

            if (Reservation == null)
            {
                throw new ArgumentNullException(nameof(Reservation), "The given charging reservation must not be null!");
            }

            #endregion

            this.Result      = ReservationResultType.Success;
            this.Reservation = Reservation;
        }
Пример #7
0
 /// <summary>
 /// Create a new cancel reservation result.
 /// </summary>
 /// <param name="Result">The result of a cancel reservation operation.</param>
 /// <param name="ReservationId">The charging reservation identification.</param>
 /// <param name="Reservation">The optional charging reservation.</param>
 /// <param name="Reason">A reason for the charging reservation cancellation.</param>
 /// <param name="Message">An optional message.</param>
 /// <param name="AdditionalInfo">An optional additional information on this error, e.g. the HTTP error response.</param>
 /// <param name="Runtime">The optional runtime of this request.</param>
 private CancelReservationResult(CancelReservationResultTypes Result,
                                 ChargingReservation_Id ReservationId,
                                 ChargingReservationCancellationReason Reason,
                                 ChargingReservation Reservation = null,
                                 String Message        = null,
                                 Object AdditionalInfo = null,
                                 TimeSpan?Runtime      = null)
 {
     this.Result         = Result;
     this.ReservationId  = ReservationId;
     this.Reason         = Reason;
     this.Reservation    = Reservation;
     this.Message        = Message;
     this.AdditionalInfo = AdditionalInfo;
     this.Runtime        = Runtime;
 }
Пример #8
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));
            }
        }
Пример #9
0
        /// <summary>
        /// The reservation was successful.
        /// </summary>
        public static ReservationResult Success(ChargingReservation Reservation)

        => new ReservationResult(Reservation);
Пример #10
0
 /// <summary>
 /// The reservation was successful.
 /// </summary>
 public static ReservationResult Success(ChargingReservation Reservation)
 {
     return(new ReservationResult(Reservation));
 }