Esempio n. 1
0
        public SpecialHashSet(THost Host)
        {
            this._Host   = Host;
            this._Lookup = new Dictionary <TId, T>();

            this._Addition = new VotingNotificator <DateTime, THost, T, Boolean>(() => new VetoVote(), true);
            this._Removal  = new VotingNotificator <DateTime, THost, T, Boolean>(() => new VetoVote(), true);
        }
Esempio n. 2
0
        /// <summary>
        /// Create a new EV Roaming Network collection.
        /// </summary>
        public RoamingNetworks()
        {
            this._RoamingNetworks = new ConcurrentDictionary <RoamingNetwork_Id, RoamingNetwork>();

            #region Init events

            this.RoamingNetworkAddition = new VotingNotificator <RoamingNetworks, RoamingNetwork, Boolean>(() => new VetoVote(), true);
            this.RoamingNetworkRemoval  = new VotingNotificator <RoamingNetworks, RoamingNetwork, Boolean>(() => new VetoVote(), true);

            #endregion
        }
Esempio n. 3
0
        /// <summary>
        /// Create a new charging station group.
        /// </summary>
        /// <param name="Id">The unique identification of the charing station group.</param>
        /// <param name="Operator">The charging station operator of this charging station group.</param>
        /// <param name="Description">An optional (multi-language) description of this charging station group.</param>
        internal ChargingTariffGroup(ChargingTariffGroup_Id Id,
                                     ChargingStationOperator Operator,
                                     I18NString Description = null)

            : base(Id)

        {
            this.Operator    = Operator ?? throw new ArgumentNullException(nameof(Operator), "The charging station operator must not be null!");
            this.Description = Description ?? new I18NString();

            this._ChargingTariffs = new Dictionary <ChargingTariff_Id, ChargingTariff>();


            this.ChargingTariffAddition = new VotingNotificator <DateTime, ChargingTariffGroup, ChargingTariff, Boolean>(() => new VetoVote(), true);
            this.ChargingTariffRemoval  = new VotingNotificator <DateTime, ChargingTariffGroup, ChargingTariff, Boolean>(() => new VetoVote(), true);
        }
Esempio n. 4
0
        /// <summary>
        /// Create a new charging station group.
        /// </summary>
        /// <param name="Id">The unique identification of the charing station group.</param>
        /// <param name="Operator">The charging station operator of this charging station group.</param>
        /// <param name="Name">The offical (multi-language) name of this charging station group.</param>
        /// <param name="Description">An optional (multi-language) description of this charging station group.</param>
        ///
        /// <param name="Members">An enumeration of charging stations member building this charging station group.</param>
        /// <param name="MemberIds">An enumeration of charging station identifications which are building this charging station group.</param>
        /// <param name="AutoIncludeStations">A delegate deciding whether to include new charging stations automatically into this group.</param>
        ///
        /// <param name="StatusAggregationDelegate">A delegate called to aggregate the dynamic status of all subordinated charging stations.</param>
        /// <param name="MaxGroupStatusListSize">The default size of the charging station group status list.</param>
        /// <param name="MaxGroupAdminStatusListSize">The default size of the charging station group admin status list.</param>
        internal ChargingStationGroup(ChargingStationGroup_Id Id,
                                      ChargingStationOperator Operator,
                                      I18NString Name,
                                      I18NString Description = null,

                                      Brand Brand           = null,
                                      Priority?Priority     = null,
                                      ChargingTariff Tariff = null,
                                      IEnumerable <DataLicense> DataLicenses = null,

                                      IEnumerable <ChargingStation> Members               = null,
                                      IEnumerable <ChargingStation_Id> MemberIds          = null,
                                      Func <ChargingStation, Boolean> AutoIncludeStations = null,

                                      Func <ChargingStationStatusReport, ChargingStationGroupStatusTypes> StatusAggregationDelegate = null,
                                      UInt16 MaxGroupStatusListSize      = DefaultMaxGroupStatusListSize,
                                      UInt16 MaxGroupAdminStatusListSize = DefaultMaxGroupAdminStatusListSize)

            : base(Id)

        {
            #region Initial checks

            if (Operator == null)
            {
                throw new ArgumentNullException(nameof(Operator), "The charging station operator must not be null!");
            }

            if (IEnumerableExtensions.IsNullOrEmpty(Name))
            {
                throw new ArgumentNullException(nameof(Name), "The name of the charging station group must not be null or empty!");
            }

            #endregion

            #region Init data and properties

            this.Operator    = Operator;
            this.Name        = Name;
            this.Description = Description ?? new I18NString();

            this.Brand        = Brand;
            this.Priority     = Priority;
            this.Tariff       = Tariff;
            this.DataLicenses = DataLicenses?.Any() == true ? new ReactiveSet <DataLicense>(DataLicenses) : new ReactiveSet <DataLicense>();

            this._AllowedMemberIds   = MemberIds != null ? new HashSet <ChargingStation_Id>(MemberIds) : new HashSet <ChargingStation_Id>();
            this.AutoIncludeStations = AutoIncludeStations ?? (MemberIds == null ? (Func <ChargingStation, Boolean>)(station => true) : station => false);
            this._ChargingStations   = new ConcurrentDictionary <ChargingStation_Id, ChargingStation>();

            this.StatusAggregationDelegate = StatusAggregationDelegate;

            this._AdminStatusSchedule = new StatusSchedule <ChargingStationGroupAdminStatusTypes>(MaxGroupAdminStatusListSize);
            this._AdminStatusSchedule.Insert(ChargingStationGroupAdminStatusTypes.Unknown);

            this._StatusSchedule = new StatusSchedule <ChargingStationGroupStatusTypes>     (MaxGroupStatusListSize);
            this._StatusSchedule.Insert(ChargingStationGroupStatusTypes.Unknown);

            #endregion

            #region Init events

            // ChargingStationGroup events
            this.ChargingStationAddition = new VotingNotificator <DateTime, ChargingStationGroup, ChargingStation, Boolean>(() => new VetoVote(), true);
            this.ChargingStationRemoval  = new VotingNotificator <DateTime, ChargingStationGroup, ChargingStation, Boolean>(() => new VetoVote(), true);

            // ChargingStation events
            this.EVSEAddition = new VotingNotificator <DateTime, ChargingStation, EVSE, Boolean>(() => new VetoVote(), true);
            this.EVSERemoval  = new VotingNotificator <DateTime, ChargingStation, EVSE, Boolean>(() => new VetoVote(), true);

            // EVSE events

            #endregion

            #region Link events

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

            // ChargingStationGroup events
            //this.OnChargingStationAddition.OnVoting       += (timestamp, evseoperator, pool, vote) => EVSEOperator.ChargingStationAddition.SendVoting      (timestamp, evseoperator, pool, vote);
            //this.OnChargingStationAddition.OnNotification += (timestamp, evseoperator, pool)       => EVSEOperator.ChargingStationAddition.SendNotification(timestamp, evseoperator, pool);
            //
            //this.OnChargingStationRemoval. OnVoting       += (timestamp, evseoperator, pool, vote) => EVSEOperator.ChargingStationRemoval. SendVoting      (timestamp, evseoperator, pool, vote);
            //this.OnChargingStationRemoval. OnNotification += (timestamp, evseoperator, pool)       => EVSEOperator.ChargingStationRemoval. SendNotification(timestamp, evseoperator, pool);

            // ChargingStation events
            this.OnEVSEAddition.OnVoting       += (timestamp, station, evse, vote) => Operator.EVSEAddition.SendVoting(timestamp, station, evse, vote);
            this.OnEVSEAddition.OnNotification += (timestamp, station, evse) => Operator.EVSEAddition.SendNotification(timestamp, station, evse);

            this.OnEVSERemoval.OnVoting       += (timestamp, station, evse, vote) => Operator.EVSERemoval.SendVoting(timestamp, station, evse, vote);
            this.OnEVSERemoval.OnNotification += (timestamp, station, evse) => Operator.EVSERemoval.SendNotification(timestamp, station, evse);

            #endregion


            if (Members?.Any() == true)
            {
                Members.ForEach(station => Add(station));
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Create a new group/pool of charging stations having the given identification.
        /// </summary>
        /// <param name="Id">The unique identification of the charing pool.</param>
        /// <param name="EVSEOperator">The parent EVSE operator.</param>
        /// <param name="MaxPoolStatusListSize">The default size of the charging pool (aggregated charging station) status list.</param>
        /// <param name="MaxPoolAdminStatusListSize">The default size of the charging pool admin status list.</param>
        internal ChargingStationGroup(ChargingStationGroup_Id Id,
                                      EVSEOperator EVSEOperator,
                                      UInt16 MaxPoolStatusListSize      = DefaultMaxPoolStatusListSize,
                                      UInt16 MaxPoolAdminStatusListSize = DefaultMaxPoolAdminStatusListSize)

            : base(Id)

        {
            #region Initial checks

            if (EVSEOperator == null)
            {
                throw new ArgumentNullException("EVSEOperator", "The EVSE operator must not be null!");
            }

            #endregion

            #region Init data and properties

            this._EVSEOperator = EVSEOperator;

            //this._ChargingStations           = new ConcurrentDictionary<ChargingStation_Id, ChargingStation>();

            this.Name        = new I18NString();
            this.Description = new I18NString();

            this._AdminStatusSchedule = new StatusSchedule <ChargingStationGroupAdminStatusType>(MaxPoolAdminStatusListSize);
            this._AdminStatusSchedule.Insert(ChargingStationGroupAdminStatusType.Unspecified);

            this._AllowedChargingStationIds = new HashSet <ChargingStation_Id>();

            #endregion

            #region Init events

            // ChargingStationGroup events
            this.ChargingStationAddition = new VotingNotificator <DateTime, ChargingStationGroup, ChargingStation, Boolean>(() => new VetoVote(), true);
            this.ChargingStationRemoval  = new VotingNotificator <DateTime, ChargingStationGroup, ChargingStation, Boolean>(() => new VetoVote(), true);

            // ChargingStation events
            this.EVSEAddition = new VotingNotificator <DateTime, ChargingStation, EVSE, Boolean>(() => new VetoVote(), true);
            this.EVSERemoval  = new VotingNotificator <DateTime, ChargingStation, EVSE, Boolean>(() => new VetoVote(), true);

            // EVSE events
            this.SocketOutletAddition = new VotingNotificator <DateTime, EVSE, SocketOutlet, Boolean>(() => new VetoVote(), true);
            this.SocketOutletRemoval  = new VotingNotificator <DateTime, EVSE, SocketOutlet, Boolean>(() => new VetoVote(), true);

            #endregion

            #region Link events

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

            // ChargingStationGroup events
            //this.OnChargingStationAddition.OnVoting       += (timestamp, evseoperator, pool, vote) => EVSEOperator.ChargingStationAddition.SendVoting      (timestamp, evseoperator, pool, vote);
            //this.OnChargingStationAddition.OnNotification += (timestamp, evseoperator, pool)       => EVSEOperator.ChargingStationAddition.SendNotification(timestamp, evseoperator, pool);
            //
            //this.OnChargingStationRemoval. OnVoting       += (timestamp, evseoperator, pool, vote) => EVSEOperator.ChargingStationRemoval. SendVoting      (timestamp, evseoperator, pool, vote);
            //this.OnChargingStationRemoval. OnNotification += (timestamp, evseoperator, pool)       => EVSEOperator.ChargingStationRemoval. SendNotification(timestamp, evseoperator, pool);

            // ChargingStation events
            this.OnEVSEAddition.OnVoting       += (timestamp, station, evse, vote) => EVSEOperator.EVSEAddition.SendVoting(timestamp, station, evse, vote);
            this.OnEVSEAddition.OnNotification += (timestamp, station, evse) => EVSEOperator.EVSEAddition.SendNotification(timestamp, station, evse);

            this.OnEVSERemoval.OnVoting       += (timestamp, station, evse, vote) => EVSEOperator.EVSERemoval.SendVoting(timestamp, station, evse, vote);
            this.OnEVSERemoval.OnNotification += (timestamp, station, evse) => EVSEOperator.EVSERemoval.SendNotification(timestamp, station, evse);

            // EVSE events
            this.SocketOutletAddition.OnVoting       += (timestamp, evse, outlet, vote) => EVSEOperator.SocketOutletAddition.SendVoting(timestamp, evse, outlet, vote);
            this.SocketOutletAddition.OnNotification += (timestamp, evse, outlet) => EVSEOperator.SocketOutletAddition.SendNotification(timestamp, evse, outlet);

            this.SocketOutletRemoval.OnVoting       += (timestamp, evse, outlet, vote) => EVSEOperator.SocketOutletRemoval.SendVoting(timestamp, evse, outlet, vote);
            this.SocketOutletRemoval.OnNotification += (timestamp, evse, outlet) => EVSEOperator.SocketOutletRemoval.SendNotification(timestamp, evse, outlet);

            #endregion
        }
Esempio n. 6
0
        /// <summary>
        /// Create a new Electric Vehicle Supply Equipment (EVSE) having the given EVSE identification.
        /// </summary>
        /// <param name="Id">The unique identification of this EVSE.</param>
        /// <param name="ChargingStation">The parent charging station.</param>
        /// <param name="MaxStatusListSize">The maximum size of the EVSE status list.</param>
        /// <param name="MaxAdminStatusListSize">The maximum size of the EVSE admin status list.</param>
        internal NetworkEVSEStub(EVSE_Id Id,
                                 ANetworkChargingStation ChargingStation,
                                 UInt16 MaxStatusListSize      = DefaultMaxEVSEStatusListSize,
                                 UInt16 MaxAdminStatusListSize = DefaultMaxAdminStatusListSize)

            : base(Id)

        {
            #region Initial checks

            if (ChargingStation == null)
            {
                throw new ArgumentNullException("ChargingStation", "The charging station must not be null!");
            }

            #endregion

            #region Init data and properties

            this._ANetworkChargingStation = ChargingStation;

            this._Description   = new I18NString();
            this._ChargingModes = new ReactiveSet <ChargingModes>();
            this._SocketOutlets = new ReactiveSet <SocketOutlet>();

            this._StatusSchedule = new StatusSchedule <EVSEStatusTypes>(MaxStatusListSize);
            this._StatusSchedule.Insert(EVSEStatusTypes.OutOfService);

            this._AdminStatusSchedule = new StatusSchedule <EVSEAdminStatusTypes>(MaxStatusListSize);
            this._AdminStatusSchedule.Insert(EVSEAdminStatusTypes.OutOfService);

            #endregion

            #region Init events

            this.SocketOutletAddition = new VotingNotificator <DateTime, IRemoteEVSE, SocketOutlet, Boolean>(() => new VetoVote(), true);
            this.SocketOutletRemoval  = new VotingNotificator <DateTime, IRemoteEVSE, SocketOutlet, Boolean>(() => new VetoVote(), true);

            #endregion

            #region Link events

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

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


            //this.SocketOutletAddition.OnVoting        += (timestamp, evse, outlet, vote)
            //                                              => ChargingStation.SocketOutletAddition.SendVoting      (timestamp, evse, outlet, vote);
            //
            //this.SocketOutletAddition.OnNotification  += (timestamp, evse, outlet)
            //                                              => ChargingStation.SocketOutletAddition.SendNotification(timestamp, evse, outlet);
            //
            //this.SocketOutletRemoval. OnVoting        += (timestamp, evse, outlet, vote)
            //                                              => ChargingStation.SocketOutletRemoval. SendVoting      (timestamp, evse, outlet, vote);
            //
            //this.SocketOutletRemoval. OnNotification  += (timestamp, evse, outlet)
            //                                              => ChargingStation.SocketOutletRemoval. SendNotification(timestamp, evse, outlet);

            #endregion


            //this.OnStatusChanged += async (Timestamp,
            //                               EventTrackingId,
            //                               IRemoteEVSE,
            //                               OldStatus,
            //                               NewStatus) => {

            //    if (OldStatus.Value == EVSEStatusTypes.Reserved &&
            //        NewStatus.Value != EVSEStatusTypes.Reserved &&
            //        _Reservation != null)
            //    {

            //        CancelReservation(_Reservation.Id,
            //                          ChargingReservationCancellationReason.Aborted).Wait();

            //    }

            //};
        }