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> /// Compares two e-vehicles for equality. /// </summary> /// <param name="eVehicle">A e-vehicle to compare with.</param> /// <returns>True if both match; False otherwise.</returns> public Boolean Equals(eVehicle eVehicle) { if ((Object)eVehicle == null) { return(false); } return(Id.Equals(eVehicle.Id)); }
/// <summary> /// Compares two instances of this object. /// </summary> /// <param name="eVehicle">A e-vehicle object to compare with.</param> public Int32 CompareTo(eVehicle eVehicle) { if ((Object)eVehicle == null) { throw new ArgumentNullException("The given e-vehicle must not be null!"); } return(Id.CompareTo(eVehicle.Id)); }
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> /// Update the current electric vehicle geo location. /// </summary> /// <param name="Timestamp">The timestamp when this change was detected.</param> /// <param name="EventTrackingId">An optional event tracking identification for correlating this request with other events.</param> /// <param name="eVehicle">The updated eVehicle.</param> /// <param name="OldGeoCoordinate">The old aggreagted charging station status.</param> /// <param name="NewGeoCoordinate">The new aggreagted charging station status.</param> internal async Task UpdateEVehicleGeoLocation(DateTime Timestamp, EventTracking_Id EventTrackingId, eVehicle eVehicle, Timestamped <GeoCoordinate> OldGeoCoordinate, Timestamped <GeoCoordinate> NewGeoCoordinate) { var OnEVehicleGeoLocationChangedLocal = OnEVehicleGeoLocationChanged; if (OnEVehicleGeoLocationChangedLocal != null) { await OnEVehicleGeoLocationChangedLocal(Timestamp, EventTrackingId, eVehicle, OldGeoCoordinate, NewGeoCoordinate); } }
/// <summary> /// Update the current eVehicle status. /// </summary> /// <param name="Timestamp">The timestamp when this change was detected.</param> /// <param name="EventTrackingId">An optional event tracking identification for correlating this request with other events.</param> /// <param name="eVehicle">The updated eVehicle.</param> /// <param name="OldStatus">The old aggreagted charging station status.</param> /// <param name="NewStatus">The new aggreagted charging station status.</param> internal async Task UpdateEVehicleStatus(DateTime Timestamp, EventTracking_Id EventTrackingId, eVehicle eVehicle, Timestamped <eVehicleStatusType> OldStatus, Timestamped <eVehicleStatusType> NewStatus) { var OnEVehicleStatusChangedLocal = OnEVehicleStatusChanged; if (OnEVehicleStatusChangedLocal != null) { await OnEVehicleStatusChangedLocal(Timestamp, EventTrackingId, eVehicle, OldStatus, NewStatus); } }
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); }
/// <summary> /// Update the data of an eVehicle. /// </summary> /// <param name="Timestamp">The timestamp when this change was detected.</param> /// <param name="EventTrackingId">An optional event tracking identification for correlating this request with other events.</param> /// <param name="eVehicle">The changed eVehicle.</param> /// <param name="PropertyName">The name of the changed property.</param> /// <param name="OldValue">The old value of the changed property.</param> /// <param name="NewValue">The new value of the changed property.</param> internal async Task UpdateEVehicleData(DateTime Timestamp, EventTracking_Id EventTrackingId, eVehicle eVehicle, String PropertyName, Object OldValue, Object NewValue) { var OnEVehicleDataChangedLocal = OnEVehicleDataChanged; if (OnEVehicleDataChangedLocal != null) { await OnEVehicleDataChangedLocal(Timestamp, EventTrackingId, eVehicle, PropertyName, OldValue, NewValue); } }
public Boolean TryGetEVehicleById(eVehicle_Id eVehicleId, out eVehicle eVehicle) => _eVehicles.TryGet(eVehicleId, out eVehicle);
/// <summary> /// Check if the given eVehicle is already present within the Charging Station Operator. /// </summary> /// <param name="eVehicle">A eVehicle.</param> public Boolean ContainseVehicle(eVehicle eVehicle) => _eVehicles.Contains(eVehicle);
/// <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); }
/// <summary> /// Take a snapshot of the current e-mobility station admin status. /// </summary> /// <param name="eVehicle">An e-mobility station.</param> public static eVehicleStatus Snapshot(eVehicle eVehicle) => new eVehicleStatus(eVehicle.Id, eVehicle.Status.Value, eVehicle.Status.Timestamp);