Beispiel #1
0
        public void TestFilterAdd()
        {
            IReactiveSet <int> source = new ReactiveSet <int>();

            FilterSet <int> filtered = new FilterSet <int>(source, x => x > 4);

            source.Add(3);
            source.Add(4);
            source.Add(5);
            source.Add(6);

            Assert.IsFalse(filtered.IsSubscribed);

            List <int> ints = new List <int>();

            System.IDisposable disp = filtered.ObserveAdd().Subscribe(@event => { ints.Add(@event.Value); });

            CollectionAssert.AreEquivalent(ints, new [] { 5, 6 });

            Assert.IsTrue(filtered.IsSubscribed);

            source.Add(7);
            CollectionAssert.AreEquivalent(ints, new [] { 5, 6, 7 });

            disp.Dispose();

            Assert.IsFalse(filtered.IsSubscribed);
        }
Beispiel #2
0
        /// <summary>
        /// The Location object describes the location and its properties
        /// where a group of EVSEs that belong together are installed.
        /// </summary>
        /// <param name="Id">Uniquely identifies the location within the CPOs platform (and suboperator platforms).</param>
        /// <param name="Operator">Information of the evse operator.</param>
        /// <param name="SubOperator">Information of the evse suboperator if available.</param>
        public Location(Location_Id Id,
                        BusinessDetails Operator,
                        BusinessDetails SubOperator = null)

            : base(Id)

        {
            #region Initial checks

            if (Operator == null)
            {
                throw new ArgumentNullException("Operator", "The given parameter must not be null!");
            }

            #endregion

            #region Init data and properties

            this._Operator    = Operator;
            this._SubOperator = SubOperator;

            this._OpeningTimes       = Hours.TwentyFourSevenOpen();
            this._ChargingWhenClosed = true;
            this._Images             = new ReactiveSet <Image>();

            #endregion

            #region Init events

            //// 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

            //// ChargingStation events
            //this.OnEVSEAddition.           OnVoting       += (timestamp, station, evse, vote)      => ChargingPool.EVSEAddition.           SendVoting      (timestamp, station, evse, vote);
            //this.OnEVSEAddition.           OnNotification += (timestamp, station, evse)            => ChargingPool.EVSEAddition.           SendNotification(timestamp, station, evse);
            //
            //this.OnEVSERemoval.            OnVoting       += (timestamp, station, evse, vote)      => ChargingPool.EVSERemoval .           SendVoting      (timestamp, station, evse, vote);
            //this.OnEVSERemoval.            OnNotification += (timestamp, station, evse)            => ChargingPool.EVSERemoval .           SendNotification(timestamp, station, evse);
            //
            //// EVSE events
            //this.SocketOutletAddition.     OnVoting       += (timestamp, evse, outlet, vote)       => ChargingPool.SocketOutletAddition.   SendVoting      (timestamp, evse, outlet, vote);
            //this.SocketOutletAddition.     OnNotification += (timestamp, evse, outlet)             => ChargingPool.SocketOutletAddition.   SendNotification(timestamp, evse, outlet);
            //
            //this.SocketOutletRemoval.      OnVoting       += (timestamp, evse, outlet, vote)       => ChargingPool.SocketOutletRemoval.    SendVoting      (timestamp, evse, outlet, vote);
            //this.SocketOutletRemoval.      OnNotification += (timestamp, evse, outlet)             => ChargingPool.SocketOutletRemoval.    SendNotification(timestamp, evse, outlet);

            #endregion
        }
Beispiel #3
0
        public void TestAdd()
        {
            IReactiveSet <int> set = new ReactiveSet <int>();

            Assert.IsTrue(set.Add(2));
            Assert.IsFalse(set.Add(2));
            Assert.IsTrue(set.Add(4));

            Assert.AreEqual(2, set.Count);

            CollectionAssert.AreEquivalent(set, new[] { 2, 4 });
        }
Beispiel #4
0
        public void TestClear()
        {
            IReactiveSet <int> set = new ReactiveSet <int>();

            set.Add(2);
            set.Add(2);
            set.Add(4);

            set.Clear();

            Assert.AreEqual(0, set.Count);
            CollectionAssert.AreEquivalent(set, new int[] {});
        }
Beispiel #5
0
        public void TestAdd()
        {
            IReactiveSet <int> source = new ReactiveSet <int>();

            source.Add(3);

            ReactiveSetView <int> view = new ReactiveSetView <int>(source);

            Assert.AreEqual(1, view.Count);
            Assert.AreEqual(3, view[0]);

            source.Add(4);
            Assert.AreEqual(4, view[1]);
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            var set = new ReactiveSet <int>(new[] { 1 });

            var buffered = set.Buffer(3);

            buffered.ToImmutableSets().Select(x => string.Join(", ", x)).Subscribe(Console.WriteLine);

            set.Add(4);
            set.Add(8);
            set.Add(12);
            set.Add(16);

            Console.Read();
        }
Beispiel #7
0
        public void TestRemove()
        {
            IReactiveSet <int> set = new ReactiveSet <int>();

            set.Add(2);
            set.Add(2);
            set.Add(4);

            Assert.IsFalse(set.Remove(5));
            Assert.IsTrue(set.Remove(2));


            Assert.AreEqual(1, set.Count);
            CollectionAssert.AreEquivalent(set, new[] { 4 });
        }
Beispiel #8
0
        /// <summary>
        /// The EVSE object describes the part that controls the power supply to a single EV in a single session.
        /// </summary>
        /// <param name="Id">Uniquely identifies the EVSE within the CPOs platform (and suboperator platforms).</param>
        /// <param name="Location">The charging location object that contains this EVSE.</param>
        internal EVSE(EVSE_Id Id,
                      Location Location)

            : base(Id)

        {
            #region Initial checks

            if (Location == null)
            {
                throw new ArgumentNullException("Location", "The given parameter must not be null!");
            }

            #endregion

            #region Init data and properties

            this._Location = Location;

            this._Status             = EVSEStatusType.Unknown;
            this._StatusSchedule     = new ReactiveSet <EVSEStatusSchedule>();
            this._Capabilities       = new ReactiveSet <CapabilityType>();
            this._Connectors         = new ReactiveSet <Connector>();
            this._Directions         = new I18NString();
            this._ParkingRestriction = new ReactiveSet <ParkingRestrictionType>();
            this._Images             = new ReactiveSet <Image>();

            #endregion

            #region Init events

            //// 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

            //// EVSE events
            //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
        }
Beispiel #9
0
        /// <summary>
        /// Create a new parking space having the given identification.
        /// </summary>
        /// <param name="Id">The unique identification of the parking space.</param>
        public ParkingSpace(ParkingSpace_Id Id)
            : base(Id)
        {
            #region Initial checks

            if (Id == null)
            {
                throw new ArgumentNullException(nameof(Id), "The unique identification of the parking space must not be null!");
            }

            #endregion

            #region Init data and properties

            this._Name             = new I18NString(Languages.eng, Id.ToString());
            this._Description      = new I18NString();
            this._Geometry         = new List <GeoCoordinate>();
            this._ChargingStations = new ReactiveSet <ChargingStation>();

            #endregion
        }
Beispiel #10
0
        public void TestAddObservable()
        {
            IReactiveSet <int> set = new ReactiveSet <int>();

            int?lastAdded = null;

            set.ObserveAdd().Subscribe(@event => lastAdded = @event.Value);

            Assert.IsTrue(set.Add(2));

            Assert.AreEqual(2, lastAdded);

            lastAdded = null;

            Assert.IsFalse(set.Add(2));

            Assert.IsNull(lastAdded);

            Assert.IsTrue(set.Add(4));

            Assert.AreEqual(4, lastAdded);
        }
Beispiel #11
0
        public void TestRemoveObservable()
        {
            IReactiveSet <int> set = new ReactiveSet <int>();

            int?lastRemoved = null;

            set.ObserveRemove().Subscribe(@event => lastRemoved = @event.Value);

            set.Add(2);
            set.Add(3);
            set.Add(4);

            set.Remove(3);
            Assert.AreEqual(3, lastRemoved);

            lastRemoved = null;

            set.Remove(3);

            Assert.IsNull(lastRemoved);

            set.Remove(4);
            Assert.AreEqual(4, lastRemoved);
        }
Beispiel #12
0
        /// <summary>
        /// Create a new e-mobility station having the given identification.
        /// </summary>
        /// <param name="Id">The unique identification of the e-mobility station pool.</param>
        /// <param name="MaxAdminStatusListSize">The default size of the admin status list.</param>
        internal eMobilityStation(eMobilityStation_Id Id,
                                  eMobilityProvider Provider,
                                  Action <eMobilityStation> Configurator = null,
                                  RemoteEMobilityStationCreatorDelegate RemoteeMobilityStationCreator = null,
                                  eMobilityStationAdminStatusType AdminStatus = eMobilityStationAdminStatusType.Operational,
                                  UInt16 MaxAdminStatusListSize = DefaultMaxAdminStatusListSize)

            : 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.Name        = new I18NString();
            this.Description = new I18NString();

            this._UserComment            = new I18NString();
            this._ServiceProviderComment = new I18NString();
            //this.GeoLocation                 = new GeoCoordinate();

            this._ParkingSpaces = new List <ParkingSpace>();

            this._PaymentOptions = new ReactiveSet <PaymentOptions>();

            this._AdminStatusSchedule = new StatusSchedule <eMobilityStationAdminStatusType>(MaxAdminStatusListSize);
            this._AdminStatusSchedule.Insert(AdminStatus);

            #endregion

            #region Init events


            #endregion

            #region Link events

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

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

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

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

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

            #endregion

            this.OnPropertyChanged += UpdateData;

            Configurator?.Invoke(this);

            this.RemoteeMobilityStation = RemoteeMobilityStationCreator?.Invoke(this);
        }
Beispiel #13
0
        public static JProperty ToJSON(this ReactiveSet <AuthenticationModes> AuthenticationModes, String JPropertyKey)

        => AuthenticationModes != null
                   ? new JProperty(JPropertyKey,
                                   new JArray(AuthenticationModes.SafeSelect(mode => mode.ToJSON())))
                   : null;
Beispiel #14
0
        public void TestChainDispose()
        {
            IReactiveSet <int> source    = new ReactiveSet <int>();
            FilterSet <int>    filtered  = new FilterSet <int>(source, x => x >= 4);
            FilterSet <int>    filtered2 = new FilterSet <int>(filtered, x => x <= 20);
            FilterSet <int>    filtered3 = new FilterSet <int>(filtered2, x => x % 2 == 0);

            source.Add(3);
            source.Add(5);
            source.Add(10);
            source.Add(99);

            Assert.IsFalse(filtered.IsSubscribed);
            Assert.IsFalse(filtered2.IsSubscribed);
            Assert.IsFalse(filtered3.IsSubscribed);

            var view = new ReactiveSetView <int>(filtered3);

            Assert.IsTrue(filtered.IsSubscribed);
            Assert.IsTrue(filtered2.IsSubscribed);
            Assert.IsTrue(filtered3.IsSubscribed);

            Assert.AreEqual(1, view.Count);
            Assert.AreEqual(10, view[0]);

            source.Add(13);

            Assert.AreEqual(1, view.Count);
            Assert.AreEqual(10, view[0]);

            source.Add(16);

            Assert.AreEqual(2, view.Count);
            Assert.AreEqual(10, view[0]);
            Assert.AreEqual(16, view[1]);

            view.Dispose();

            Assert.IsFalse(filtered.IsSubscribed);
            Assert.IsFalse(filtered2.IsSubscribed);
            Assert.IsFalse(filtered3.IsSubscribed);

            view = new ReactiveSetView <int>(filtered2);
            var view2 = new ReactiveSetView <int>(filtered);

            Assert.IsTrue(filtered.IsSubscribed);
            Assert.IsTrue(filtered2.IsSubscribed);
            Assert.IsFalse(filtered3.IsSubscribed);

            CollectionAssert.AreEquivalent(view, new int[] { 5, 10, 13, 16 });
            CollectionAssert.AreEquivalent(view2, new int[] { 5, 10, 13, 16, 99 });
            view.Dispose();

            Assert.IsTrue(filtered.IsSubscribed);
            Assert.IsFalse(filtered2.IsSubscribed);
            Assert.IsFalse(filtered3.IsSubscribed);

            view2.Dispose();

            Assert.IsFalse(filtered.IsSubscribed);
            Assert.IsFalse(filtered2.IsSubscribed);
            Assert.IsFalse(filtered3.IsSubscribed);
        }
Beispiel #15
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();

            //    }

            //};
        }
Beispiel #16
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);
        }