Example #1
0
 /// <summary>
 /// Tworzy obiekt oraz inicjalizuje podstawowe urzadzenia w ekspresie.
 /// </summary>
 public Devices()
 {
     this.Grinder = new Grinder();
     this.Head    = new Head();
     this.Pump    = new Pump(this.Head);
     this.Heater  = new Heater();
 }
Example #2
0
        public HeartContext()
        {
            worker.DoWork += worker_DoWork;
            worker.WorkerSupportsCancellation = true;

            Pump = new Com();
            //Pump = new RandomPump();
            //Pump = new FilePump();
            //Pump.Received += Pump_Received;

            Analyze = new ComDataAnalyze(Pump);
            Analyze.Analyzed += Analyze_Analyzed;

            Rate = new DifferenceHeartRate(this);
            Rate.RateAnalyzed += Rate_RateAnalyzed;

            AvgFilter = new AvgFilterProcess();
            //FirFilter = new MyFirFilterProcess();
            //FirFilter = new LowFirFilterProcess();
            FirFilter = new BandPassFirFilterProcess();
            BandStopFilter = new BandStopFirFilterProcess();
            MedianFilter = new MedianFilterProcess();

            Processes = new List<IProcess>()
            {
                AvgFilter,
                FirFilter,
                //BandStopFilter,
                MedianFilter,
            };
        }
 public CoffeeMachine(IGrinder grinder, IHeater heater, IPump pump, ITank tank)
 {
     this.grinder = grinder;
     this.heater  = heater;
     this.pump    = pump;
     this.tank    = tank;
 }
Example #4
0
 public CompressionCtrl(IPump pump, ITimer timer, IFeatures LED_Green, IFeatures LED_Red, IFeatures VibratingDevice)
 {
     timer_           = timer;
     pump_            = pump;
     LED_Green_       = LED_Green;
     LED_Red_         = LED_Red;
     VibratingDevice_ = VibratingDevice;
 }
Example #5
0
        public DataAnalyze(IPump pump)
        {
            Pump = pump;
            Pump.Received += Pump_Received;

            worker.DoWork += worker_DoWork;
            worker.WorkerSupportsCancellation = true;
        }
 public MyWashMachine(
     IEngine engine,
     IPump pump,
     IHeater heater)
 {
     this.engine = engine;
     this.pump   = pump;
     this.heater = heater;
 }
Example #7
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="inputCount">TBD</param>
        /// <param name="bufferSize">TBD</param>
        /// <param name="pump">TBD</param>
        protected InputBunch(int inputCount, int bufferSize, IPump pump)
        {
            _inputCount = inputCount;

            _states = new State[inputCount];
            _inputs = new BatchingInputBuffer[inputCount];
            for (var i = 0; i < inputCount; i++)
            {
                _inputs[i] = new AnonymousBatchingInputBuffer(bufferSize, pump, i, this);
            }

            AllOfMarkedInputs = new LambdaTransferState(
                isCompleted: () => _markedDepleted > 0,
                isReady: () => _markedPending == _markCount);

            AnyOfMarkedInputs = new LambdaTransferState(
                isCompleted: () => _markedDepleted == _markCount && _markedPending == 0,
                isReady: () => _markedPending > 0);

            // FIXME: Eliminate re-wraps
            SubReceive = new SubReceive(msg => msg.Match()
                                        .With <FanIn.OnSubscribe>(subscribe => _inputs[subscribe.Id].SubReceive.CurrentReceive(new Actors.OnSubscribe(subscribe.Subscription)))
                                        .With <FanIn.OnNext>(next =>
            {
                var id = next.Id;
                if (IsMarked(id) && !IsPending(id))
                {
                    _markedPending++;
                }
                Pending(id, on: true);
                _receivedInput = true;
                _inputs[id].SubReceive.CurrentReceive(new Actors.OnNext(next.Element));
            })
                                        .With <FanIn.OnComplete>(complete =>
            {
                var id = complete.Id;
                if (!IsPending(id))
                {
                    if (IsMarked(id) && !IsDepleted(id))
                    {
                        _markedDepleted++;
                    }
                    Depleted(id, on: true);
                    OnDepleted(id);
                }

                RegisterCompleted(id);
                _inputs[id].SubReceive.CurrentReceive(Actors.OnComplete.Instance);

                if (!_receivedInput && IsAllCompleted)
                {
                    OnCompleteWhenNoInput();
                }
            })
                                        .With <FanIn.OnError>(error => OnError(error.Id, error.Cause))
                                        .WasHandled);
        }
Example #8
0
 public override enExperimentStatus Configure(IExperiment parent, string resultsFilePath)
 {
     mPump           = Settings.Pumps[Settings.Pump];
     this.parent     = parent;
     ResultsFilePath = resultsFilePath;
     ResultsFileName = "SetPumpParam - " + Name + ".dat";
     status          = enExperimentStatus.Idle;
     return(status);
 }
Example #9
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="self">TBD</param>
        /// <param name="waitForUpstream">TBD</param>
        /// <exception cref="ArgumentException">
        /// This exception is thrown when the specified <paramref name="waitForUpstream"/> is less than one.
        /// </exception>
        public static void WaitForUpstream(this IPump self, int waitForUpstream)
        {
            if (waitForUpstream < 1)
            {
                throw new ArgumentException($"WaitForUpstream must be >= 1 (was {waitForUpstream})");
            }

            self.TransferState = new WaitingForUpstreamSubscription(waitForUpstream, new TransferPhase(self.TransferState, self.CurrentAction));
        }
Example #10
0
        public SimpleOutputs(IActorRef actor, IPump pump)
        {
            Actor = actor;
            Pump  = pump;

            SubReceive          = new SubReceive(WaitingExposedPublisher);
            NeedsDemand         = DefaultOutputTransferStates.NeedsDemand(this);
            NeedsDemandOrCancel = DefaultOutputTransferStates.NeedsDemandOrCancel(this);
        }
Example #11
0
        public AirCompressionMechanism(IPump pump, uint compressionTime, uint decompressionTime)
        {
            _pump = pump;

            _compressionTimer          = new Timer(compressionTime);
            _compressionTimer.Elapsed += CompressionCompleteTimeout;

            _decompressionTimer          = new Timer(decompressionTime);
            _decompressionTimer.Elapsed += DecompressionCompleteTimeout;
        }
Example #12
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="self">TBD</param>
 /// <param name="phase">TBD</param>
 public static void NextPhase(this IPump self, TransferPhase phase)
 {
     if (self.TransferState is WaitingForUpstreamSubscription)
     {
         var w = (WaitingForUpstreamSubscription)self.TransferState;
         self.TransferState = new WaitingForUpstreamSubscription(w.Remaining, phase);
     }
     else
     {
         self.TransferState = phase.Precondition;
         self.CurrentAction = phase.Action;
     }
 }
Example #13
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="self">TBD</param>
        /// <param name="waitForUpstream">TBD</param>
        /// <param name="andThen">TBD</param>
        /// <exception cref="ArgumentException">
        /// This exception is thrown when the specified <paramref name="waitForUpstream"/> is less than one.
        /// </exception>
        /// <exception cref="IllegalStateException">
        /// This exception is thrown when the initial state is not <see cref="NotInitialized.Instance"/>.
        /// </exception>
        public static void InitialPhase(this IPump self, int waitForUpstream, TransferPhase andThen)
        {
            if (waitForUpstream < 1)
            {
                throw new ArgumentException($"WaitForUpstream must be >= 1 (was {waitForUpstream})");
            }

            if (self.TransferState != NotInitialized.Instance)
            {
                throw new IllegalStateException($"Initial state expected NotInitialized, but got {self.TransferState}");
            }

            self.TransferState = new WaitingForUpstreamSubscription(waitForUpstream, andThen);
        }
Example #14
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="self">TBD</param>
        public static void GotUpstreamSubscription(this IPump self)
        {
            if (self.TransferState is WaitingForUpstreamSubscription)
            {
                var t = (WaitingForUpstreamSubscription)self.TransferState;
                if (t.Remaining == 1)
                {
                    self.TransferState = t.AndThen.Precondition;
                    self.CurrentAction = t.AndThen.Action;
                }
                else
                {
                    self.TransferState = new WaitingForUpstreamSubscription(t.Remaining - 1, t.AndThen);
                }
            }

            self.Pump();
        }
Example #15
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="self">TBD</param>
        public static void Pump(this IPump self)
        {
            try
            {
                while (self.TransferState.IsExecutable)
                {
                    self.CurrentAction();
                }
            }
            catch (Exception e)
            {
                self.PumpFailed(e);
            }

            if (self.IsPumpFinished)
            {
                self.PumpFinished();
            }
        }
Example #16
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="maxBufferSize">TBD</param>
        /// <param name="initialBufferSize">TBD</param>
        /// <param name="self">TBD</param>
        /// <param name="pump">TBD</param>
        /// <param name="afterShutdown">TBD</param>
        /// <exception cref="IllegalStateException">
        /// This exception is thrown when the first message isn't of type <see cref="ExposedPublisher"/>.
        /// </exception>
        public FanoutOutputs(int maxBufferSize, int initialBufferSize, IActorRef self, IPump pump, Action afterShutdown = null)
        {
            _self               = self;
            _pump               = pump;
            _afterShutdown      = afterShutdown;
            MaxBufferSize       = maxBufferSize;
            InitialBufferSize   = initialBufferSize;
            NeedsDemand         = DefaultOutputTransferStates.NeedsDemand(this);
            NeedsDemandOrCancel = DefaultOutputTransferStates.NeedsDemandOrCancel(this);
            SubReceive          = new SubReceive(message =>
            {
                if (!(message is ExposedPublisher publisher))
                {
                    throw new IllegalStateException($"The first message must be ExposedPublisher but was {message}");
                }

                ExposedPublisher = publisher.Publisher;
                SubReceive.Become(DownstreamRunning);
                return(true);
            });
        }
Example #17
0
        protected BatchingInputBuffer(int count, IPump pump)
        {
            if (count <= 0)
            {
                throw new ArgumentException("Buffer Count must be > 0");
            }
            if ((count & (count - 1)) != 0)
            {
                throw new ArgumentException("Buffer Count must be power of two");
            }
            // TODO: buffer and batch sizing heuristics

            Count = count;
            Pump  = pump;

            _indexMask      = count - 1;
            _inputBuffer    = new object[count];
            _batchRemaining = RequestBatchSize;
            SubReceive      = new SubReceive(WaitingForUpstream);

            NeedsInput           = DefaultInputTransferStates.NeedsInput(this);
            NeedsInputOrComplete = DefaultInputTransferStates.NeedsInputOrComplete(this);
        }
Example #18
0
 public AirCompressionCtrl(IPump pump)
 {
     _pump = pump;
     IsPumped = false;
 }
Example #19
0
 public CompressionCtrl(IPump pump, ITimer timer)
 {
     _pump = pump;
     _timer = timer;
 }
Example #20
0
 public Pipeline(IPump <T> pump, IDataSink <T> sink, string pipelineName = "")
 {
     _pump         = pump;
     _sink         = sink;
     _pipelineName = pipelineName;
 }
Example #21
0
 public CompressionCtrl(IPump pump, ITimer timer)
 {
     _pump  = pump;
     _timer = timer;
 }
Example #22
0
 public SubstreamOutput(SubstreamKey key, IActorRef actor, IPump pump, ICancelable subscriptionTimeout) : base(actor, pump)
 {
     Key = key;
     SubscriptionTimeout = subscriptionTimeout;
     _subscription       = new SubstreamSubscription(actor, key);
 }
Example #23
0
 public Pump(IPump hardware)
 {
     _hardware = hardware;
 }
Example #24
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="self">TBD</param>
 /// <returns>TBD</returns>
 public static bool IsPumpFinished(this IPump self) => self.TransferState.IsCompleted;
Example #25
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="outputCount">TBD</param>
        /// <param name="impl">TBD</param>
        /// <param name="pump">TBD</param>
        public OutputBunch(int outputCount, IActorRef impl, IPump pump)
        {
            _outputCount = outputCount;
            _outputs     = new FanoutOutputs[outputCount];
            for (var i = 0; i < outputCount; i++)
            {
                _outputs[i] = new FanoutOutputs(i, impl, pump);
            }

            _marked    = new bool[outputCount];
            _pending   = new bool[outputCount];
            _cancelled = new bool[outputCount];
            _completed = new bool[outputCount];
            _errored   = new bool[outputCount];

            AllOfMarkedOutputs = new LambdaTransferState(
                isCompleted: () => _markedCanceled > 0 || _markedCount == 0,
                isReady: () => _markedPending == _markedCount);

            AnyOfMarkedOutputs = new LambdaTransferState(
                isCompleted: () => _markedCanceled == _markedCount,
                isReady: () => _markedPending > 0);

            // FIXME: Eliminate re-wraps
            SubReceive = new SubReceive(message => message.Match()
                                        .With <FanOut.ExposedPublishers <T> >(exposed =>
            {
                var publishers = exposed.Publishers.GetEnumerator();
                var outputs    = _outputs.AsEnumerable().GetEnumerator();

                while (publishers.MoveNext() && outputs.MoveNext())
                {
                    outputs.Current.SubReceive.CurrentReceive(new ExposedPublisher(publishers.Current));
                }
            })
                                        .With <FanOut.SubstreamRequestMore>(more =>
            {
                if (more.Demand < 1)
                {
                    // According to Reactive Streams Spec 3.9, with non-positive demand must yield onError
                    Error(more.Id, ReactiveStreamsCompliance.NumberOfElementsInRequestMustBePositiveException);
                }
                else
                {
                    if (_marked[more.Id] && !_pending[more.Id])
                    {
                        _markedPending += 1;
                    }
                    _pending[more.Id] = true;
                    _outputs[more.Id].SubReceive.CurrentReceive(new RequestMore(null, more.Demand));
                }
            })
                                        .With <FanOut.SubstreamCancel>(cancel =>
            {
                if (_unmarkCancelled)
                {
                    UnmarkOutput(cancel.Id);
                }

                if (_marked[cancel.Id] && !_cancelled[cancel.Id])
                {
                    _markedCanceled += 1;
                }

                _cancelled[cancel.Id] = true;
                OnCancel(cancel.Id);
                _outputs[cancel.Id].SubReceive.CurrentReceive(new Cancel(null));
            })
                                        .With <FanOut.SubstreamSubscribePending>(pending => _outputs[pending.Id].SubReceive.CurrentReceive(SubscribePending.Instance))
                                        .WasHandled);
        }
Example #26
0
 public FanoutOutputs(int id, IActorRef actor, IPump pump) : base(actor, pump)
 {
     _id = id;
 }
Example #27
0
 public AirCompressionCtrl(IPump pump)
 {
     _pump    = pump;
     IsPumped = false;
 }
Example #28
0
 public CoroutineRunner(IEnumerator routine, IPump pump)
 {
     _pump            = pump;
     _currentNode     = new EnumeratorNode(routine);
     _pump.NextFrame += OnNextFrame;
 }
Example #29
0
 public AnonymousBatchingInputBuffer(int count, IPump pump, int id, InputBunch inputBunch) : base(count, pump)
 {
     _id         = id;
     _inputBunch = inputBunch;
 }
Example #30
0
 public CoffeeMaker(IHeater heater, IPump pump)
 {
     _heater = heater;
     _pump   = pump;
 }
Example #31
0
 public ComDataAnalyze(IPump pump)
     : base(pump)
 {
 }
Example #32
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="self">TBD</param>
 /// <exception cref="IllegalStateException">
 /// This exception is thrown when the pump has not been initialized with a phase.
 /// </exception>
 public static void Init(this IPump self)
 {
     self.TransferState = NotInitialized.Instance;
     self.CurrentAction = () => { throw new IllegalStateException("Pump has not been initialized with a phase"); };
 }
Example #33
0
 public static void AssignEventPump(IPump pump)
 {
     _pump?.Dispose();
     _pump = pump;
 }