public bool ScanNext(IOpenChannel channel, IBiofeedbackSource source, out Sample sample) { if (nextRead < samples.Count) { channel.Frequency = samples[nextRead].frequency; samples[nextRead].response = source.Read(); sample = samples[nextRead]; nextRead++; return(true); } else { sample = null; return(false); } }
public bool Next(IOpenChannel channel, out double freq, out Waveform waveform, out double amplitude, out TimeSpan eta) { if (commands.MoveNext()) { commands.Current.Cmd.Run(channel); freq = commands.Current.Frequency; eta = commands.Current.Remaining; waveform = commands.Current.Waveform; amplitude = commands.Current.Amplitude; Thread.Sleep(commands.Current.Cmd.Duration); return(true); } else { freq = 0; eta = default(TimeSpan); waveform = Waveform.Default; amplitude = 0; return(false); } }
void ThreadFn() { try { NativeMethods.PreventSleep(); if (openChannel is null) { openChannel = channel.TryOpen(); } if (openChannel is null) { state = RunState.Error; Progress(RunState.Error, 0, Waveform.Default, 0, eta); return; } State = RunState.Running; openChannel.Relay = true; double freq; Waveform waveform; double amplitude; while (runner.Next(openChannel, out freq, out waveform, out amplitude, out eta)) { Progress(RunState.Running, freq, waveform, amplitude, eta); if (source.Token.IsCancellationRequested) { openChannel.Relay = false; return; } } openChannel.Relay = false; Progress(RunState.Completed, freq, waveform, amplitude, eta); State = RunState.Completed; } catch (HardwareException ex) { hwex = ex; state = RunState.Error; Progress(RunState.Error, 0, Waveform.Default, 0, eta); } catch { // Shouldn't really get here :-( state = RunState.Error; Progress(RunState.Error, 0, Waveform.Default, 0, eta); } finally { try { openChannel?.Close(); } catch { } openChannel = null; NativeMethods.AllowSleep(); } }
public void Run(IOpenChannel channel) { throw innerException; }
// If previous is null void Apply(IOpenChannel channel, Step step, Step previous) { }
void Start(IRunnable runnable, IOpenChannel channel) { }
public void Run(IOpenChannel channel) { channel.Waveform = W; }
public void Run(IOpenChannel channel) { channel.Amplitude = Amp; }
public void Run(IOpenChannel channel) { channel.Frequency = Freq; }
public void Run(IOpenChannel channel) { }
public CachedChannel(IOpenChannel channel) { UnderlyingChannel = channel; }