/// <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(); }
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; }
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; }
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; }
/// <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); }
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); }
/// <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)); }
public SimpleOutputs(IActorRef actor, IPump pump) { Actor = actor; Pump = pump; SubReceive = new SubReceive(WaitingExposedPublisher); NeedsDemand = DefaultOutputTransferStates.NeedsDemand(this); NeedsDemandOrCancel = DefaultOutputTransferStates.NeedsDemandOrCancel(this); }
public AirCompressionMechanism(IPump pump, uint compressionTime, uint decompressionTime) { _pump = pump; _compressionTimer = new Timer(compressionTime); _compressionTimer.Elapsed += CompressionCompleteTimeout; _decompressionTimer = new Timer(decompressionTime); _decompressionTimer.Elapsed += DecompressionCompleteTimeout; }
/// <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; } }
/// <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); }
/// <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(); }
/// <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(); } }
/// <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); }); }
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); }
public AirCompressionCtrl(IPump pump) { _pump = pump; IsPumped = false; }
public CompressionCtrl(IPump pump, ITimer timer) { _pump = pump; _timer = timer; }
public Pipeline(IPump <T> pump, IDataSink <T> sink, string pipelineName = "") { _pump = pump; _sink = sink; _pipelineName = pipelineName; }
public SubstreamOutput(SubstreamKey key, IActorRef actor, IPump pump, ICancelable subscriptionTimeout) : base(actor, pump) { Key = key; SubscriptionTimeout = subscriptionTimeout; _subscription = new SubstreamSubscription(actor, key); }
public Pump(IPump hardware) { _hardware = hardware; }
/// <summary> /// TBD /// </summary> /// <param name="self">TBD</param> /// <returns>TBD</returns> public static bool IsPumpFinished(this IPump self) => self.TransferState.IsCompleted;
/// <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); }
public FanoutOutputs(int id, IActorRef actor, IPump pump) : base(actor, pump) { _id = id; }
public CoroutineRunner(IEnumerator routine, IPump pump) { _pump = pump; _currentNode = new EnumeratorNode(routine); _pump.NextFrame += OnNextFrame; }
public AnonymousBatchingInputBuffer(int count, IPump pump, int id, InputBunch inputBunch) : base(count, pump) { _id = id; _inputBunch = inputBunch; }
public CoffeeMaker(IHeater heater, IPump pump) { _heater = heater; _pump = pump; }
public ComDataAnalyze(IPump pump) : base(pump) { }
/// <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"); }; }
public static void AssignEventPump(IPump pump) { _pump?.Dispose(); _pump = pump; }