public void SetEVehicleAdminStatus(eVehicle_Id eVehicleId, IEnumerable <Timestamped <eVehicleAdminStatusType> > StatusList, ChangeMethods ChangeMethod = ChangeMethods.Replace) { eVehicle _eVehicle = null; if (TryGetEVehicleById(eVehicleId, out _eVehicle)) { _eVehicle.SetAdminStatus(StatusList, ChangeMethod); } //if (SendUpstream) //{ // // RoamingNetwork. // SendeVehicleAdminStatusDiff(new eVehicleAdminStatusDiff(DateTime.UtcNow, // ChargingStationOperatorId: Id, // ChargingStationOperatorName: Name, // NewStatus: new List<KeyValuePair<eVehicle_Id, eVehicleAdminStatusType>>(), // ChangedStatus: new List<KeyValuePair<eVehicle_Id, eVehicleAdminStatusType>>() { // new KeyValuePair<eVehicle_Id, eVehicleAdminStatusType>(eVehicleId, NewStatus.Value) // }, // RemovedIds: new List<eVehicle_Id>())); // //} }
/// <summary> /// An exception thrown whenever an electric vehicle already exists within the given e-mobility station. /// </summary> /// <param name="eMobilityStation">The e-mobility station.</param> /// <param name="eVehicleId">The electric vehicle identification.</param> public eVehicleAlreadyExistsInStation(eMobilityStation eMobilityStation, eVehicle_Id eVehicleId) : base(eMobilityStation.Provider, "The given electric vehicle identification '" + eVehicleId + "' already exists within the given '" + eMobilityStation.Id + "' e-mobility station!") { }
/// <summary> /// An exception thrown whenever an electric vehicle already exists within the given e-mobility provider. /// </summary> /// <param name="eMobilityProvider">The e-mobility provider.</param> /// <param name="eVehicleId">The electric vehicle identification.</param> public eVehicleAlreadyExists(eMobilityProvider eMobilityProvider, eVehicle_Id eVehicleId) : base(eMobilityProvider.RoamingNetwork, "The given electric vehicle identification '" + eVehicleId + "' already exists within the given '" + eMobilityProvider.Id + "' e-mobility provider!") { }
public void SetEVehicleAdminStatus(eVehicle_Id eVehicleId, eVehicleAdminStatusType NewStatus, DateTime Timestamp) { eVehicle _eVehicle = null; if (TryGetEVehicleById(eVehicleId, out _eVehicle)) { _eVehicle.SetAdminStatus(NewStatus, Timestamp); } }
public void SeteVehicleAdminStatus(eVehicle_Id eVehicleId, Timestamped <eVehicleAdminStatusType> NewStatus, Boolean SendUpstream = false) { eVehicle _eVehicle = null; if (TryGetEVehicleById(eVehicleId, out _eVehicle)) { _eVehicle.SetAdminStatus(NewStatus); } }
/// <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; }
public Boolean TryRemoveEVehicle(eVehicle_Id eVehicleId, out eVehicle eVehicle) { if (TryGetEVehicleById(eVehicleId, out eVehicle)) { if (eVehicleRemoval.SendVoting(DateTime.UtcNow, this, eVehicle)) { if (_eVehicles.TryRemove(eVehicleId, out eVehicle)) { eVehicleRemoval.SendNotification(DateTime.UtcNow, this, eVehicle); return(true); } } return(false); } return(true); }
public eVehicle RemoveEVehicle(eVehicle_Id eVehicleId) { eVehicle _eVehicle = null; if (TryGetEVehicleById(eVehicleId, out _eVehicle)) { if (eVehicleRemoval.SendVoting(DateTime.UtcNow, this, _eVehicle)) { if (_eVehicles.TryRemove(eVehicleId, out _eVehicle)) { eVehicleRemoval.SendNotification(DateTime.UtcNow, this, _eVehicle); return(_eVehicle); } } } return(null); }
public Boolean TryGetEVehicleById(eVehicle_Id eVehicleId, out eVehicle eVehicle) => _eVehicles.TryGet(eVehicleId, out eVehicle);
public eVehicle GetEVehicleById(eVehicle_Id eVehicleId) => _eVehicles.GetById(eVehicleId);
/// <summary> /// Check if the given eVehicle identification is already present within the Charging Station Operator. /// </summary> /// <param name="eVehicleId">The unique identification of the eVehicle.</param> public Boolean ContainseVehicle(eVehicle_Id eVehicleId) => _eVehicles.ContainsId(eVehicleId);
/// <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); }