private void doListIDsByStatus()
        {
            m_UserStatusType = ConsoleUtils.ParseStatusType();
            Console.WriteLine("Vehicles in status: " + Converter.StringFromType(m_UserStatusType));
            Console.WriteLine();
            foreach (string idStr in r_GarageContainer.GetVehiclesIDsListByStatus(m_UserStatusType))
            {
                Console.WriteLine("ID: " + idStr);
            }

            Console.WriteLine("End of list.");
            Console.WriteLine();
        }
        public List <string> GetVehiclesIDsListByStatus(eVehicleStatusType i_Status)
        {
            List <string> result = new List <string>();

            foreach (GarageEntry garageEntry in r_Entries.Values)
            {
                if (garageEntry.Status == i_Status)
                {
                    result.Add(garageEntry.Vehicle.ID);
                }
            }

            return(result);
        }
        public List<string> GetVehiclesIDsListByStatus(eVehicleStatusType i_Status)
        {
            List<string> result = new List<string>();

            foreach (GarageEntry garageEntry in r_Entries.Values)
            {
                if (garageEntry.Status == i_Status)
                {
                    result.Add(garageEntry.Vehicle.ID);
                }
            }

            return result;
        }
Exemplo n.º 4
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 eVehicleStatus(eVehicle_Id Id,
                              eVehicleStatusType 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;
        }
Exemplo n.º 5
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;
        }
Exemplo n.º 6
0
        public static string StringFromType(eVehicleStatusType i_StatusType)
        {
            string result;

            switch (i_StatusType)
            {
            case eVehicleStatusType.Fixed:
                result = "Fixed. Ready for payment.";
                break;

            case eVehicleStatusType.Fixing:
                result = "Fixing is still in progress.";
                break;

            case eVehicleStatusType.Paid:
                result = "Vehicle is fixed and paid for.";
                break;

            default:
                throw new ArgumentException("Unknown vehicle status type");
            }

            return(result);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
        public static string StringFromType(eVehicleStatusType i_StatusType)
        {
            string result;

            switch (i_StatusType)
            {
                case eVehicleStatusType.Fixed:
                    result = "Fixed. Ready for payment.";
                    break;
                case eVehicleStatusType.Fixing:
                    result = "Fixing is still in progress.";
                    break;
                case eVehicleStatusType.Paid:
                    result = "Vehicle is fixed and paid for.";
                    break;
                default:
                    throw new ArgumentException("Unknown vehicle status type");
            }

            return result;
        }
Exemplo n.º 9
0
 internal GarageEntry(Contact i_Contact, Vehicle i_Vehicle)
 {
     r_Contact = i_Contact;
     r_Vehicle = i_Vehicle;
     m_Status = eVehicleStatusType.Fixing;
 }
        private void doListIDsByStatus()
        {
            m_UserStatusType = ConsoleUtils.ParseStatusType();
            Console.WriteLine("Vehicles in status: " + Converter.StringFromType(m_UserStatusType));
            Console.WriteLine();
            foreach (string idStr in r_GarageContainer.GetVehiclesIDsListByStatus(m_UserStatusType))
            {
                Console.WriteLine("ID: " + idStr);
            }

            Console.WriteLine("End of list.");
            Console.WriteLine();
        }
Exemplo n.º 11
0
 internal GarageEntry(Contact i_Contact, Vehicle i_Vehicle)
 {
     r_Contact = i_Contact;
     r_Vehicle = i_Vehicle;
     m_Status  = eVehicleStatusType.Fixing;
 }
Exemplo n.º 12
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);
        }