private void SetSampleRate(SampleRateEnum rate) { if (_requesting) { return; } _requesting = true; var eEGExampleViewModel = this.DataContext as EEGExampleViewModel; if (eEGExampleViewModel == null) { _requesting = false; return; } var aresult = eEGExampleViewModel.SetSampleRate(rate); eEGExampleViewModel = null; if (aresult == null) { _requesting = false; return; } aresult.ContinueWith(result => { _requesting = false; ShowSetSampleResult(result.Result, rate); }, TaskScheduler.FromCurrentSynchronizationContext()); }
/// <summary> /// Called whenever sample rate is changed. You must also /// change the UI state to ensure it matches the state set /// here /// </summary> /// <param name="newSampleRate"></param> private void SetSampleRate(SampleRateEnum newSampleRate) { SampleRate = newSampleRate; switch (newSampleRate) { case SampleRateEnum.Fast_1KHz: AcqTimer.Interval = 50; Hardware.SetSampleRate(QA350.SampleRate.Fast); Label_2p5sps.Visible = false; Label_1ksps.Visible = true; break; case SampleRateEnum.Slow_2p5Hz: AcqTimer.Interval = 405; Hardware.SetSampleRate(QA350.SampleRate.Slow); Label_2p5sps.Visible = true; Label_1ksps.Visible = false; break; default: break; } ResetStats(); }
public BrainState(bool isStart) { IsStart = isStart; SampleRate = SampleRateEnum.SPS_250; TrapOption = TrapSettingEnum.NoTrap; EnableFilter = false; SamplePacketOrder = 0; }
internal Task <CommandError> SetSampleRate(SampleRateEnum rate) { if (_devCtl != null && _currentState.SampleRate != rate) { return(_devCtl.SetSampleRate(rate)); } return(null); }
/// <summary> /// Called when user changes logging state in the menu /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void loggingToolStripMenuItem_Click(object sender, EventArgs e) { ToolStripMenuItem mi = (ToolStripMenuItem)sender; if (mi.Checked == false) { SaveFileDialog sfd = new SaveFileDialog(); sfd.InitialDirectory = Constants.DataFilePath; sfd.Filter = "Log Files|*.log"; if (sfd.ShowDialog() == DialogResult.OK) { mi.Checked = true; LoggingEnabled = true; LogFile = sfd.FileName; if (SlowUpdateBtn.On) { SampleRate = SampleRateEnum.Slow_2p5Hz; } else if (FastUpdateBtn.On) { SampleRate = SampleRateEnum.Fast_1KHz; } if (mi == logToBinaryFileToolStripMenuItem) { logToTextFileToolStripMenuItem.Enabled = false; logToTextAtArbitraryIntervalToolStripMenuItem.Enabled = false; new Task(LoggingThreadBinary).Start(); } else if (mi == logToTextFileToolStripMenuItem) { logToBinaryFileToolStripMenuItem.Enabled = false; logToTextAtArbitraryIntervalToolStripMenuItem.Enabled = false; new Task(LoggingThreadText).Start(); } else if (mi == logToTextAtArbitraryIntervalToolStripMenuItem) { logToBinaryFileToolStripMenuItem.Enabled = false; logToTextFileToolStripMenuItem.Enabled = false; new Task(LoggingThreadTextArbitraryInterval).Start(); } // While logging, the logging speed cannot be changed and the DC/RMS setting cannot be changed DcModeBtn.Enabled = false; RmsModeBtn.Enabled = false; SlowUpdateBtn.Enabled = false; FastUpdateBtn.Enabled = false; SetRelBtn.Enabled = false; } } else { LoggingEnabled = false; LoggingDone(); } }
private void ShowSetSampleResult(CommandError result, SampleRateEnum rate) { var r = result; if (r != CommandError.Success) { ViewWinUtils.ShowDefaultDialog($"Set Sample Rate {rate} failed: {r}"); } }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.CacheFileSoundFlags = ((Flags)(binaryReader.ReadInt16())); this.SoundClass = ((SoundClassEnum)(binaryReader.ReadByte())); this.SampleRate = ((SampleRateEnum)(binaryReader.ReadByte())); this.Encoding = ((EncodingEnum)(binaryReader.ReadByte())); this.Compression = ((CompressionEnum)(binaryReader.ReadByte())); this.PlaybackIndex = binaryReader.ReadInt16(); this.FirstPitchRangeIndex = binaryReader.ReadInt16(); this.PitchRangeCount = binaryReader.ReadByte(); this.ScaleIndex = binaryReader.ReadByte(); this.PromotionIndex = binaryReader.ReadByte(); this.CustomPlaybackIndex = binaryReader.ReadByte(); this.ExtraInfoIndex = binaryReader.ReadInt16(); this.MaximumPlayTime = binaryReader.ReadInt32(); return(pointerQueue); }
private static async Task SendSampleData(int sampleTimeTick, SampleRateEnum rate, Socket socket, CancellationToken ctsToken) { byte size = 2 + ChannelCount * 3; var buf = bmgr.TakeBuffer(size); //_r.NextBytes(buf); var passTimes = BrainDevState.PassTimeMs(rate, sampleTimeTick); const float max = 4.5f / 24; buf[0] = (byte)DevCommandFuncId.StartStop; buf[1] = _brainState.SamplePacketOrder++; for (int i = 0; i < ChannelCount; i++) { var sampleValue = Math.Sin(passTimes * 2 / 1000f * Math.PI + i * simalatedDelta) * max; var(b0, b1, b2) = BitDataConverter.ConvertTo(sampleValue, 4.5f, 24); buf[2 + i * 3] = b0; buf[2 + 1 + i * 3] = b1; buf[2 + 2 + i * 3] = b2; } await SendWithHeadTail(socket, buf, size, ctsToken); bmgr.ReturnBuffer(buf); }
public static float PassTimeMs(SampleRateEnum sampleRate, int passTimeTick) { var count = 1f; switch (sampleRate) { case SampleRateEnum.SPS_250: //every 1000ms sample 250 times count = passTimeTick * BrainDevState.SmapleDeltaTime_250; break; case SampleRateEnum.SPS_500: count = passTimeTick * BrainDevState.SmapleDeltaTime_500; break; case SampleRateEnum.SPS_1k: count = passTimeTick * BrainDevState.SmapleDeltaTime_1k; break; case SampleRateEnum.SPS_2k: count = passTimeTick * BrainDevState.SmapleDeltaTime_2k; break; } return(count); }
public static int SampleCountPer20ms(SampleRateEnum sampleRate) { var count = 1; switch (sampleRate) { case SampleRateEnum.SPS_250: //every 1000ms sample 250 times count = BrainDevState.SampleCount_250; //20ms -> sample counts break; case SampleRateEnum.SPS_500: count = BrainDevState.SampleCount_500; //20ms -> sample counts break; case SampleRateEnum.SPS_1k: count = BrainDevState.SampleCount_1k; //20ms -> sample counts break; case SampleRateEnum.SPS_2k: count = BrainDevState.SampleCount_2k; //20ms -> sample counts break; } return(count); }
public static int SampleCountPer1Sec(SampleRateEnum sampleRate) { var count = 1; switch (sampleRate) { case SampleRateEnum.SPS_250: count = BrainDevState.SampleCountRate250; break; case SampleRateEnum.SPS_500: count = BrainDevState.SampleCountRate500; break; case SampleRateEnum.SPS_1k: count = BrainDevState.SampleCountRate1k; break; case SampleRateEnum.SPS_2k: count = BrainDevState.SampleCountRate2k; break; } return(count); }
public async Task <CommandError> SetSampleRate(SampleRateEnum sampleRate) { return(await ExecCmd(DevCommandEnum.SetSampleRate, sampleRate)); }