void ProgressUpdated(RunState state, double frequency, Waveform w, double amplitude, TimeSpan timeleft) { if (state == RunState.Error) { Pause("Error - check hardware"); } if (!double.IsNaN(frequency)) { frequencyLabel.Text = $"{frequency:0.00} Hz"; } etaLabel.Text = $"{timeleft.Hours:00}:{timeleft.Minutes:00}:{timeleft.Seconds:00}"; if (!double.IsNaN(amplitude)) { amplitudeLabel.Text = $"{amplitude:0.00} V"; } if (w != Waveform.Default) { waveformLabel.Text = w.WaveformToString(); } if (state == RunState.Completed) { if (options.runInLoop) { runner.Start(runnable, channel, options); } else { Finished(); onFinished(); } } }
private async Task EnsureAllProjectsAreAllocated() { var projects = await projectRepo.GetAll(); if (projects != null) { var notAllocatedProjects = new List <Project>(projects) .Where(x => this.runners.Any(y => y.Name == x.Name) == false) .ToList(); foreach (var p in notAllocatedProjects) { Log.Information($"A new project is discovered named {p.Name}"); var newRunner = new BackgroundRunner(p.Name, new BuildAndDeployAction(), new BuildAndDeployActionPayload { ProjectId = p.Id, ProjectRepository = projectRepo, ServiceProvider = services, }); this.runners.Add(newRunner); newRunner.Start(); } } }
public void Start(IProgram runnable, IChannel channel, RunningOptions options) { this.options = options; this.runnable = runnable; this.channel = channel; var timeRemaining = runnable.Duration(options); etaLabel.Text = timeRemaining.ToString(); programLabel.Text = runnable.Name; generatorLabel.Text = channel.ToString(); amplitudeLabel.Text = $"10 V"; waveformLabel.Text = "Sine"; statusLabel.Text = "Running"; pauseButton.Text = "Pause"; pauseButton.Enabled = true; stopButton.Enabled = true; runner = new BackgroundRunner(); runner.Progress += new ProgressChanged((a, b, c, d, e) => this.BeginInvoke(new ProgressChanged(ProgressUpdated), a, b, c, d, e)); runner.Start(runnable, channel, options); }
public void Start(IChannel channel, IHeartRateMonitor hrm, BiofeedbackSettings settings, Action <Biofeedback.Sample[]> finished) { if (channel is null) { throw new ArgumentException(nameof(channel)); } if (hrm is null) { throw new ArgumentException(nameof(hrm)); } finishedAction = finished; bf = new Biofeedback(); if (channel is null) { throw new ArgumentException("Couldn't open a channel"); } source = new HrmSource(hrm); bf.Enqueue(settings.MinFrequency, settings.MaxFrequency, settings.StepSize); int frequencySteps = bf.TotalSteps; heatmapControl.NumberOfPoints = frequencySteps; heatmapControl.MinX = settings.MinFrequency; heatmapControl.MaxX = settings.MaxFrequency; statusLabel.Text = "Running"; pauseButton.Text = "Pause"; biofeedback = new Biofeedback(); biofeedback.Enqueue(settings.MinFrequency, settings.MaxFrequency, settings.StepSize); runner = new BackgroundRunner(); biofeedback.Source = source; biofeedback.OnProgress += new Biofeedback.Progress((f, r, s, t) => BeginInvoke(new Biofeedback.Progress(OnProgress), f, r, s, t)); biofeedback.OnFinished += new Biofeedback.Finished(r => BeginInvoke(new Biofeedback.Finished(OnFinished), new object[] { r })); runner.Progress += new ProgressChanged((s, t, w, a, e) => BeginInvoke(new ProgressChanged(OnGeneratorProgress), s, t, w, a, e)); var options = new RunningOptions(); runner.Start(biofeedback, channel, options); }