示例#1
0
文件: BioFeedback.cs 项目: calum74/s2
 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);
     }
 }
示例#2
0
文件: Runner.cs 项目: calum74/s2
 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);
     }
 }
示例#3
0
文件: Runner.cs 项目: calum74/s2
        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();
            }
        }
示例#4
0
文件: BioFeedback.cs 项目: calum74/s2
 public void Run(IOpenChannel channel)
 {
     throw innerException;
 }
示例#5
0
文件: Scheduler.cs 项目: calum74/s2
 // If previous is null
 void Apply(IOpenChannel channel, Step step, Step previous)
 {
 }
示例#6
0
 void Start(IRunnable runnable, IOpenChannel channel)
 {
 }
示例#7
0
文件: ProgramStep.cs 项目: calum74/s2
 public void Run(IOpenChannel channel)
 {
     channel.Waveform = W;
 }
示例#8
0
文件: ProgramStep.cs 项目: calum74/s2
 public void Run(IOpenChannel channel)
 {
     channel.Amplitude = Amp;
 }
示例#9
0
文件: ProgramStep.cs 项目: calum74/s2
 public void Run(IOpenChannel channel)
 {
     channel.Frequency = Freq;
 }
示例#10
0
文件: ProgramStep.cs 项目: calum74/s2
 public void Run(IOpenChannel channel)
 {
 }
示例#11
0
文件: Channel.cs 项目: calum74/s2
 public CachedChannel(IOpenChannel channel)
 {
     UnderlyingChannel = channel;
 }