示例#1
0
        public void SetEVehicleAdminStatus(eVehicle_Id eVehicleId,
                                           eVehicleAdminStatusType NewStatus,
                                           DateTime Timestamp)
        {
            eVehicle _eVehicle = null;

            if (TryGetEVehicleById(eVehicleId, out _eVehicle))
            {
                _eVehicle.SetAdminStatus(NewStatus, Timestamp);
            }
        }
示例#2
0
        /// <summary>
        /// Create a new e-mobility station status.
        /// </summary>
        /// <param name="Id">The unique identification of a e-mobility station.</param>
        /// <param name="Status">The current status of a e-mobility station.</param>
        /// <param name="Timestamp">The timestamp of the current status of the e-mobility station.</param>
        public eVehicleAdminStatus(eVehicle_Id Id,
                                   eVehicleAdminStatusType Status,
                                   DateTime Timestamp)

        {
            #region Initial checks

            if (Id == null)
            {
                throw new ArgumentNullException(nameof(Id), "The given unique identification of a e-mobility station must not be null!");
            }

            #endregion

            this.Id        = Id;
            this.Status    = Status;
            this.Timestamp = Timestamp;
        }
示例#3
0
        /// <summary>
        /// Create a new e-vehicle having the given identification.
        /// </summary>
        /// <param name="Id">The unique identification of the e-vehicle pool.</param>
        /// <param name="MaxAdminStatusListSize">The default size of the admin status list.</param>
        internal eVehicle(eVehicle_Id Id,
                          eMobilityStation Station,
                          Action <eVehicle> Configurator = null,
                          RemoteEVehicleCreatorDelegate RemoteEVehicleCreator = null,
                          eVehicleAdminStatusType AdminStatus = eVehicleAdminStatusType.Operational,
                          eVehicleStatusType Status           = eVehicleStatusType.Available,
                          UInt16 MaxAdminStatusListSize       = DefaultMaxAdminStatusListSize,
                          UInt16 MaxStatusListSize            = DefaultMaxStatusListSize)

            : this(Id,
                   Station.Provider,
                   Configurator,
                   RemoteEVehicleCreator,
                   AdminStatus,
                   Status,
                   MaxAdminStatusListSize,
                   MaxStatusListSize)

        {
            this.Station = Station;
        }
示例#4
0
        /// <summary>
        /// Create and register a new eVehicle having the given
        /// unique eVehicle identification.
        /// </summary>
        /// <param name="eVehicleId">The unique identification of the new eVehicle.</param>
        /// <param name="Configurator">An optional delegate to configure the new eVehicle before its successful creation.</param>
        /// <param name="OnSuccess">An optional delegate to configure the new eVehicle after its successful creation.</param>
        /// <param name="OnError">An optional delegate to be called whenever the creation of the eVehicle failed.</param>
        public eVehicle CreateNewEVehicle(eVehicle_Id eVehicleId         = null,
                                          Action <eVehicle> Configurator = null,
                                          RemoteEVehicleCreatorDelegate RemoteeVehicleCreator = null,
                                          eVehicleAdminStatusType AdminStatus            = eVehicleAdminStatusType.Operational,
                                          eVehicleStatusType Status                      = eVehicleStatusType.Available,
                                          Action <eVehicle> OnSuccess                    = null,
                                          Action <eMobilityStation, eVehicle_Id> OnError = null)

        {
            #region Initial checks

            if (eVehicleId == null)
            {
                eVehicleId = eVehicle_Id.Random(Provider.Id);
            }

            // Do not throw an exception when an OnError delegate was given!
            if (_eVehicles.Any(pool => pool.Id == eVehicleId))
            {
                if (OnError == null)
                {
                    throw new eVehicleAlreadyExistsInStation(this, eVehicleId);
                }
                else
                {
                    OnError?.Invoke(this, eVehicleId);
                }
            }

            #endregion

            var _eVehicle = new eVehicle(eVehicleId,
                                         Provider,
                                         Configurator,
                                         RemoteeVehicleCreator,
                                         AdminStatus,
                                         Status);


            if (eVehicleAddition.SendVoting(DateTime.UtcNow, this, _eVehicle))
            {
                if (_eVehicles.TryAdd(_eVehicle))
                {
                    _eVehicle.OnDataChanged        += UpdateEVehicleData;
                    _eVehicle.OnStatusChanged      += UpdateEVehicleStatus;
                    _eVehicle.OnAdminStatusChanged += UpdateEVehicleAdminStatus;

                    //_eVehicle.OnNewReservation                     += SendNewReservation;
                    //_eVehicle.OnCancelReservationResponse               += SendOnCancelReservationResponse;
                    //_eVehicle.OnNewChargingSession                 += SendNewChargingSession;
                    //_eVehicle.OnNewChargeDetailRecord              += SendNewChargeDetailRecord;


                    OnSuccess?.Invoke(_eVehicle);
                    eVehicleAddition.SendNotification(DateTime.UtcNow, this, _eVehicle);

                    return(_eVehicle);
                }
            }

            return(null);
        }
示例#5
0
 /// <summary>
 /// Set the admin status.
 /// </summary>
 /// <param name="NewAdminStatus">A new admin status.</param>
 /// <param name="Timestamp">The timestamp when this change was detected.</param>
 public void SetAdminStatus(eVehicleAdminStatusType NewAdminStatus,
                            DateTime Timestamp)
 {
     _AdminStatusSchedule.Insert(NewAdminStatus, Timestamp);
 }
示例#6
0
 /// <summary>
 /// Set the admin status.
 /// </summary>
 /// <param name="NewAdminStatus">A new timestamped admin status.</param>
 public void SetAdminStatus(eVehicleAdminStatusType NewAdminStatus)
 {
     _AdminStatusSchedule.Insert(NewAdminStatus);
 }
示例#7
0
        /// <summary>
        /// Create a new e-vehicle having the given identification.
        /// </summary>
        /// <param name="Id">The unique identification of the e-vehicle pool.</param>
        /// <param name="MaxAdminStatusListSize">The default size of the admin status list.</param>
        internal eVehicle(eVehicle_Id Id,
                          eMobilityProvider Provider,
                          Action <eVehicle> Configurator = null,
                          RemoteEVehicleCreatorDelegate RemoteEVehicleCreator = null,
                          eVehicleAdminStatusType AdminStatus = eVehicleAdminStatusType.Operational,
                          eVehicleStatusType Status           = eVehicleStatusType.Available,
                          UInt16 MaxAdminStatusListSize       = DefaultMaxAdminStatusListSize,
                          UInt16 MaxStatusListSize            = DefaultMaxStatusListSize)

            : base(Id)

        {
            #region Initial checks

            if (Provider == null)
            {
                throw new ArgumentNullException(nameof(Provider), "The e-mobility provider must not be null!");
            }

            #endregion

            #region Init data and properties

            this.Provider = Provider;

            this.Description = new I18NString();

            this._UserComment            = new I18NString();
            this._ServiceProviderComment = new I18NString();
            this.GeoLocation             = null;

            this._PaymentOptions = new ReactiveSet <PaymentOptions>();

            this._AdminStatusSchedule = new StatusSchedule <eVehicleAdminStatusType>(MaxAdminStatusListSize);
            this._AdminStatusSchedule.Insert(AdminStatus);

            this._StatusSchedule = new StatusSchedule <eVehicleStatusType>(MaxStatusListSize);
            this._StatusSchedule.Insert(Status);

            #endregion

            #region Init events


            #endregion

            #region Link events

            this._AdminStatusSchedule.OnStatusChanged += (Timestamp, EventTrackingId, StatusSchedule, OldStatus, NewStatus)
                                                         => UpdateAdminStatus(Timestamp, EventTrackingId, OldStatus, NewStatus);

            this._StatusSchedule.OnStatusChanged += (Timestamp, EventTrackingId, StatusSchedule, OldStatus, NewStatus)
                                                    => UpdateStatus(Timestamp, EventTrackingId, OldStatus, NewStatus);

            #endregion

            this.OnPropertyChanged += UpdateData;

            Configurator?.Invoke(this);

            this.RemoteEVehicle = RemoteEVehicleCreator?.Invoke(this);
        }