public EVSEAlreadyExistsInGroup(EVSEGroup EVSEGroup, EVSE_Id EVSEId) : base(EVSEGroup.Operator, "The given EVSE identification '" + EVSEId + "' already exists within the given '" + EVSEGroup.Id + "' charging group!") { }
/// <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; }
/// <summary> /// Create a new EVSE admin status. /// </summary> /// <param name="Id">The unique identification of the EVSE.</param> /// <param name="StatusSchedule">The timestamped admin status of the EVSE.</param> /// <param name="CustomData">An optional dictionary of customer-specific data.</param> public EVSEAdminStatusSchedule(EVSE_Id Id, IEnumerable <Timestamped <EVSEAdminStatusTypes> > StatusSchedule, IReadOnlyDictionary <String, Object> CustomData = null) : base(CustomData) { this.Id = Id; this.StatusSchedule = StatusSchedule; }
/// <summary> /// Create a new EVSE status. /// </summary> /// <param name="Id">The unique identification of the EVSE.</param> /// <param name="Status">The current timestamped status of the EVSE.</param> /// <param name="CustomData">An optional dictionary of customer-specific data.</param> public EVSEStatus(EVSE_Id Id, Timestamped <EVSEStatusTypes> Status, IReadOnlyDictionary <String, Object> CustomData = null) : base(CustomData) { this.Id = Id; this.Status = Status; }
/// <summary> /// Create a ChargingStationId based on the given EVSE identification. /// </summary> /// <param name="EVSEId">An EVSEId.</param> /// <param name="RemoveLastStar">Generate a charging station identification by removing the last star part.</param> public static ChargingStation_Id Create(EVSE_Id EVSEId, Boolean RemoveLastStar = true) { var _Suffix = EVSEId.Suffix; if (RemoveLastStar) { var _HasAStar = EVSEId.Suffix.LastIndexOf("*"); if (_HasAStar > 0) { _Suffix = _Suffix.Substring(0, _HasAStar); } } return(Parse(EVSEId.OperatorId, _Suffix.ToUpper())); //var _Array = new String[] { // EVSEId.OperatorId.CountryCode.Alpha2Code, // EVSEId.OperatorId.Suffix // }.Concat(EVSEId.ToString().Substring(2 + EVSEId.OperatorId.Suffix.Length).ToUpper().Split('*', '-')).ToArray(); //if (EVSEId.Format == OperatorIdFormats.ISO || EVSEId.Format == OperatorIdFormats.ISO_STAR) //{ // if (_Array[2].StartsWith("E", StringComparison.Ordinal)) // _Array[2] = "S" + _Array[2].Substring(1); //} //else //{ // if (!_Array[2].StartsWith("S", StringComparison.Ordinal)) // _Array[2] = "S" + _Array[2]; //} //// e.g. "DE*822*E123456" //if (_Array.Length == 3) //{ // if (EVSEId.ToString().Contains('-')) // return Parse(_Array.AggregateWith("-")); // return Parse(_Array.AggregateWith("*")); //} //// e.g. "DE*822*E123456*1" => "DE*822*S123456" //if (EVSEId.ToString().Contains('-')) // return Parse(_Array.Take(_Array.Length - 1).AggregateWith("-")); //if (_Array[0].StartsWith("+")) // return Parse(_Array.Take(1).Select(item => Country.ParseTelefonCode(item.Substring(1)).Alpha2Code).Concat(_Array.Skip(1).Take(_Array.Length - 1)).AggregateWith("*")); //else // return Parse(_Array.Take(_Array.Length - 1).AggregateWith("*")); }
public RedirectedEVSEs Add(EVSE_Id EVSEId, RoamingNetwork_Id RoamingNetwork_From, RoamingNetwork_Id RoamingNetwork_To) { if (!_RedirectedEVSEList.ContainsKey(EVSEId)) { _RedirectedEVSEList.Add(EVSEId, new Tuple <RoamingNetwork_Id, RoamingNetwork_Id>(RoamingNetwork_From, RoamingNetwork_To)); } return(this); }
/// <summary> /// Create a new EVSE status. /// </summary> /// <param name="Id">The unique identification of the EVSE.</param> /// <param name="Status">The current status of the EVSE.</param> /// <param name="Timestamp">The timestamp of the status change of the EVSE.</param> /// <param name="CustomData">An optional dictionary of customer-specific data.</param> public EVSEStatus(EVSE_Id Id, EVSEStatusTypes Status, DateTime Timestamp, IReadOnlyDictionary <String, Object> CustomData = null) : this(Id, new Timestamped <EVSEStatusTypes>(Timestamp, Status), CustomData) { }
/// <summary> /// Create a new EVSE identification /// based on the given charging station identification. /// </summary> /// <param name="ChargingStationId">A charging station identification.</param> /// <param name="AdditionalSuffix">An additional EVSE suffix.</param> public static EVSE_Id CreateEVSEId(this ChargingStation_Id ChargingStationId, String AdditionalSuffix) { var Suffix = ChargingStationId.Suffix; if (Suffix.StartsWith("TATION", StringComparison.Ordinal)) { Suffix = "VSE" + Suffix.Substring(6); } return(EVSE_Id.Parse(ChargingStationId.OperatorId, Suffix + AdditionalSuffix ?? "")); }
/// <summary> /// Create a charging reservation. /// </summary> public ChargingReservation(ChargingReservation_Id ReservationId, DateTime Timestamp, DateTime StartTime, TimeSpan Duration, DateTime EndTime, TimeSpan ConsumedReservationTime, ChargingReservationLevel ReservationLevel, EVSP_Id ProviderId = null, eMA_Id eMAId = null, RoamingNetwork RoamingNetwork = null, ChargingPool_Id ChargingPoolId = null, ChargingStation_Id ChargingStationId = null, EVSE_Id EVSEId = null, ChargingProduct_Id ChargingProductId = null, IEnumerable <Auth_Token> AuthTokens = null, IEnumerable <eMA_Id> eMAIds = null, IEnumerable <UInt32> PINs = null) { #region Initial checks if (ReservationId == null) { throw new ArgumentNullException(nameof(ReservationId), "The given charging reservation identification must not be null!"); } #endregion this._ReservationId = ReservationId; this._Timestamp = Timestamp.ToUniversalTime(); this._StartTime = StartTime.ToUniversalTime(); this._Duration = Duration; this._EndTime = StartTime.ToUniversalTime() + Duration; this._ConsumedReservationTime = ConsumedReservationTime; this._ReservationLevel = ReservationLevel; this._ProviderId = ProviderId; this._eMAId = eMAId; this._RoamingNetwork = RoamingNetwork; this._ChargingPoolId = ChargingPoolId; this._ChargingStationId = ChargingStationId; this._EVSEId = EVSEId; this._ChargingProductId = ChargingProductId; this._AuthTokens = AuthTokens != null ? new HashSet <Auth_Token>(AuthTokens) : new HashSet <Auth_Token>(); this._eMAIds = eMAIds != null ? new HashSet <eMA_Id> (eMAIds) : new HashSet <eMA_Id>(); this._PINs = PINs != null ? new HashSet <UInt32> (PINs) : new HashSet <UInt32>(); }
/// <summary> /// Create a ChargingStationId based on the given EVSE identification. /// </summary> /// <param name="EVSEId">An EVSEId.</param> public static ChargingStation_Id Create(EVSE_Id EVSEId) { #region Initial checks if (EVSEId == null) { throw new ArgumentException("The parameter must not be null or empty!", "EVSEId"); } #endregion var _Array = EVSEId.OriginId.Split('*', '-'); if (EVSEId.Format == IdFormatType.NEW) { if (_Array[2].StartsWith("E")) { _Array[2] = "S" + _Array[2].Substring(1); } } else { if (!_Array[2].StartsWith("S")) { _Array[2] = "S" + _Array[2]; } } // e.g. "DE*822*E123456" if (_Array.Length == 3) { if (EVSEId.OriginId.Contains('-')) { return(ChargingStation_Id.Parse(_Array.AggregateWith("-"))); } return(ChargingStation_Id.Parse(_Array.AggregateWith("*"))); } // e.g. "DE*822*E123456*1" => "DE*822*S123456" if (EVSEId.OriginId.Contains('-')) { return(ChargingStation_Id.Parse(_Array.Take(_Array.Length - 1).AggregateWith("-"))); } return(ChargingStation_Id.Parse(_Array.Take(_Array.Length - 1).AggregateWith("*"))); }
/// <summary> /// Check if the given enumeration of EVSEs and their current status /// contains the given pair of EVSE identification and status. /// </summary> /// <param name="EVSEStatus">An enumeration of EVSEs and their current status.</param> /// <param name="Id">An EVSE identification.</param> /// <param name="Status">An EVSE status.</param> public static Boolean Contains(this IEnumerable <EVSEStatus> EVSEStatus, EVSE_Id Id, EVSEStatusTypes Status) { foreach (var status in EVSEStatus) { if (status.Id == Id && status.Status == Status) { return(true); } } return(false); }
/// <summary> /// Check if the given enumeration of EVSEs and their current status /// contains the given pair of EVSE identification and status. /// </summary> /// <param name="AdminStatus">An enumeration of EVSEs and their current status.</param> /// <param name="Id">An EVSE identification.</param> /// <param name="Status">An EVSE status.</param> public static Boolean Contains(this IEnumerable <EVSEAdminStatus> AdminStatus, EVSE_Id Id, EVSEAdminStatusTypes Status) { foreach (var adminstatus in AdminStatus) { if (adminstatus.Id == Id && adminstatus.Status == Status) { return(true); } } return(false); }
/// <summary> /// Create a new EVSE status. /// </summary> /// <param name="Id">The unique identification of the EVSE.</param> /// <param name="Status">The current status of the EVSE.</param> /// <param name="Timestamp">The timestamp of the current status of the EVSE.</param> public EVSEStatus(EVSE_Id Id, EVSEStatusType Status, DateTime Timestamp) { #region Initial checks if (Id == null) { throw new ArgumentNullException(nameof(Id), "The given unique identification of an EVSE must not be null!"); } #endregion this._Id = Id; this._Status = Status; this._Timestamp = Timestamp; }
/// <summary> /// Create a new EVSE status change. /// </summary> /// <param name="Id">The unique identification of the EVSE.</param> /// <param name="OldStatus">The old status of the EVSE.</param> /// <param name="NewStatus">The new status of the EVSE.</param> public EVSEStatusChange(EVSE_Id Id, Timestamped <EVSEStatusType> OldStatus, Timestamped <EVSEStatusType> NewStatus) { #region Initial checks if (Id == null) { throw new ArgumentNullException(nameof(Id), "The given unique identification of an EVSE must not be null!"); } #endregion this._Id = Id; this._OldStatus = OldStatus; this._NewStatus = NewStatus; }
/// <summary> /// Create a charging reservation. /// </summary> public ChargingReservation(DateTime Timestamp, DateTime StartTime, TimeSpan Duration, DateTime EndTime, ChargingReservationLevel ReservationLevel, EVSP_Id ProviderId = null, eMA_Id eMAId = null, RoamingNetwork RoamingNetwork = null, ChargingPool_Id ChargingPoolId = null, ChargingStation_Id ChargingStationId = null, EVSE_Id EVSEId = null, ChargingProduct_Id ChargingProductId = null, IEnumerable <Auth_Token> AuthTokens = null, IEnumerable <eMA_Id> eMAIds = null, IEnumerable <UInt32> PINs = null) : this(ChargingReservation_Id.New, Timestamp, StartTime, Duration, EndTime, TimeSpan.FromSeconds(0), ReservationLevel, ProviderId, eMAId, RoamingNetwork, ChargingPoolId, ChargingStationId, EVSEId, ChargingProductId, AuthTokens, eMAIds, PINs) { }
public SignedMeteringValue(DateTime Timestamp, Double MeterValue, EnergyMeter_Id MeterId, EVSE_Id EVSEId, AAuthentication UserId, PgpPublicKey PublicKey, String lastSignature = "", String Signature = "") { this.Timestamp = Timestamp; this.MeterValue = MeterValue; this.MeterId = MeterId; this.EVSEId = EVSEId; this.UserId = UserId; this.PublicKey = PublicKey; this.lastSignature = lastSignature != null?lastSignature.Trim() : ""; this.Signature = Signature != null?Signature.Trim() : ""; if (UserId == null) { new ArgumentNullException(nameof(UserId), "A signed meter value must have some kind of user identification!"); } }
/// <summary> /// Check if the given EVSE identification is member of this EVSE group. /// </summary> /// <param name="EVSEId">The unique identification of an EVSE.</param> public Boolean ContainsEVSEId(EVSE_Id EVSEId) => _EVSEs.ContainsKey(EVSEId);
/// <summary> /// Create a ChargingStationId based on the given EVSEIds. /// </summary> /// <param name="EVSEIds">An enumeration of EVSEIds.</param> public static ChargingStation_Id?Create(IEnumerable <EVSE_Id> EVSEIds, String HelperId = "", Byte Length = 15, Func <String, String> Mapper = null) { #region Initial checks if (EVSEIds == null) { return(null); } var _EVSEIds = EVSEIds.ToArray(); if (_EVSEIds.Length == 0) { return(null); } #endregion #region A single EVSE Id... // It is just a single EVSE Id... if (_EVSEIds.Length == 1) { return(Create(_EVSEIds[0])); } #endregion // Multiple OperatorIds which do not match! if (_EVSEIds.Select(evse => evse.OperatorId.ToString()).Distinct().Count() > 1) { return(null); } #region EVSEIdSuffix contains '*'... if (_EVSEIds.Any(EVSEId => EVSEId.Suffix.Contains('*') || EVSEId.Suffix.Contains('-'))) { var EVSEIdPrefixStrings = _EVSEIds. Select(EVSEId => EVSEId.Suffix.Split(StarSplitter, StringSplitOptions.RemoveEmptyEntries)). Select(SuffixElements => SuffixElements.Take(SuffixElements.Length - 1).AggregateWith("*", "")). Where(NewSuffix => NewSuffix != ""). Distinct(). ToArray(); if (EVSEIdPrefixStrings.Length != 1) { return(null); } return(Parse(_EVSEIds[0].OperatorId, EVSEIdPrefixStrings[0])); } #endregion #region ...or use longest prefix... else { var _Array = _EVSEIds.Select(evse => evse.ToString()).ToArray(); var _MinLength = (Int32)_Array.Select(v => v.Length).Min(); var _Prefix = ""; for (var i = 0; i < _MinLength; i++) { if (_Array.All(v => v[i] == _Array[0][i])) { _Prefix += _Array[0][i]; } } if (((UInt64)_Prefix.Length) > _EVSEIds[0].OperatorId.Length + 1) { var TmpEVSEId = EVSE_Id.Parse(_Prefix); if (TmpEVSEId.Format == OperatorIdFormats.ISO) { if (((UInt64)_Prefix.Length) > _EVSEIds[0].OperatorId.Length + 2) { _Prefix = TmpEVSEId.Suffix; //TmpEVSEId.OperatorId + "*S" + TmpEVSEId.Suffix; } else { return(null); } } return(Parse(_EVSEIds[0].OperatorId, _Prefix)); } } #endregion #region ...or generate a hash of the EVSEIds! if (Length < 12) { Length = 12; } if (Length > 50) { Length = 50; } var Suffíx = new SHA1CryptoServiceProvider(). ComputeHash(Encoding.UTF8.GetBytes(EVSEIds.Select(evseid => evseid.ToString()). AggregateWith(HelperId ?? ","))). ToHexString(). SubstringMax(Length). ToUpper(); return(Parse(_EVSEIds[0].OperatorId, Mapper != null ? Mapper(Suffíx) : Suffíx)); #endregion }
/// <summary> /// Create a ChargingStationId based on the given EVSEIds. /// </summary> /// <param name="EVSEIds">An enumeration of EVSEIds.</param> public static ChargingStation_Id Create(IEnumerable <EVSE_Id> EVSEIds) { #region Initial checks if (EVSEIds == null) { return(null); } var _EVSEIds = EVSEIds.ToArray(); if (_EVSEIds.Length == 0) { return(null); } // It is just a single EVSE Id... if (_EVSEIds.Length == 1) { return(Create(_EVSEIds[0])); } #endregion #region Multiple EVSE Ids... String[] EVSEIdPrefixStrings = null; #region EVSEIdSuffix contains '*' or '-'... if (_EVSEIds.Any(EVSEId => EVSEId.Suffix.Contains('*') || EVSEId.Suffix.Contains('-'))) { EVSEIdPrefixStrings = _EVSEIds. Select(EVSEId => EVSEId.OriginId.Split('*', '-')). Select(EVSEIdElements => { if (EVSEIdElements.Length < 4) { return new String[] { "" } } ; if (_EVSEIds[0].Format == IdFormatType.NEW) { if (EVSEIdElements[2].StartsWith("E")) { EVSEIdElements[2] = "S" + EVSEIdElements[2].Substring(1); } } return(EVSEIdElements); }). Select(EVSEIdElements => EVSEIdElements. Take(EVSEIdElements.Length - 1). AggregateWith("*", "")). Where(v => v != ""). Distinct(). ToArray(); } #endregion #region ...or use longest prefix! else { var _Array = _EVSEIds.Select(EVSEId => EVSEId.OriginId).ToArray(); var _MinLength = _Array.Select(v => v.Length).Min(); var _Prefix = ""; for (var i = 0; i < _MinLength; i++) { if (_Array.All(v => v[i] == _Array[0][i])) { _Prefix += _Array[0][i]; } } if (_Prefix.Length > _EVSEIds[0].OperatorId.OriginId.Length + 1) { var TmpEVSEId = EVSE_Id.Parse(_Prefix); if (TmpEVSEId.Format == IdFormatType.NEW) { if (_Prefix.Length > _EVSEIds[0].OperatorId.OriginId.Length + 2) { _Prefix = TmpEVSEId.OperatorId.OriginId + "*S" + TmpEVSEId.Suffix; } else { return(null); } } EVSEIdPrefixStrings = new String[1] { _Prefix }; } else { return(null); } } #endregion if (EVSEIdPrefixStrings.Length == 1) { var Id = EVSEIdPrefixStrings.First(); if (Id.Contains('-')) { Id = Id.Replace("-", "*"); } var IdElements = Id.Split(new String[] { "*" }, StringSplitOptions.None); return(ChargingStation_Id.Parse(IdElements[0] + "*" + IdElements[1] + "*S" + IdElements.Skip(2).Aggregate("*"))); } #endregion return(null); }
public Boolean TryGet(EVSE_Id EVSEId, out Tuple <RoamingNetwork_Id, RoamingNetwork_Id> Redirection) { return(_RedirectedEVSEList.TryGetValue(EVSEId, out Redirection)); }
public static ChargingLocation FromEVSEId(EVSE_Id EVSEId) => new ChargingLocation(EVSEId: EVSEId);
public EVSEGroup Add(EVSE_Id EVSEId) { _AllowedMemberIds.Add(EVSEId); return(this); }
public EVSEAlreadyExistsInStation(EVSE_Id EVSE_Id, ChargingStation_Id ChargingStation_Id) : base("The given EVSE identification '" + EVSE_Id + "' already exists within the given '" + ChargingStation_Id + "' charging station!") { }
/// <summary> /// Check if the given EVSE identification is member of this charging station group. /// </summary> /// <param name="EVSEId">The unique identification of an EVSE.</param> public Boolean ContainsEVSEId(EVSE_Id EVSEId) => ChargingStations.Any(ChargingStation => ChargingStation.EVSEIds.Contains(EVSEId));