public ChannelSettings(IEnumerable <int> channels, ICytonChannelSettings settings) { InitializeComponent(); Text = Properties.Resources.ChannelConfig; ChannelsToSet = channels; var labelTitle = Properties.Resources.SetChannels; buttonSetChannels.Text = Properties.Resources.SetChannels; labelChannel.Text = $"{labelTitle} {string.Join(", ", channels)}"; comboBoxPowerDown.Items.Add(new ComboBoxItem($"{Properties.Resources.False} ({Properties.Resources.Default})", false)); comboBoxPowerDown.Items.Add(new ComboBoxItem(Properties.Resources.True, true)); comboBoxPowerDown.SelectedIndex = settings.PowerDown ? 1 : 0; comboBoxGain.Items.Add(new ComboBoxItem("1x", ChannelGain.x1)); comboBoxGain.Items.Add(new ComboBoxItem("2x", ChannelGain.x2)); comboBoxGain.Items.Add(new ComboBoxItem("4x", ChannelGain.x4)); comboBoxGain.Items.Add(new ComboBoxItem("6x", ChannelGain.x6)); comboBoxGain.Items.Add(new ComboBoxItem("8x", ChannelGain.x8)); comboBoxGain.Items.Add(new ComboBoxItem("12x", ChannelGain.x12)); comboBoxGain.Items.Add(new ComboBoxItem($"24x ({Properties.Resources.Default})", ChannelGain.x24)); comboBoxGain.SelectedIndex = (int)settings.Gain; comboBoxInputType.Items.Add(new ComboBoxItem($"{Properties.Resources.Normal} ({Properties.Resources.Default})", AdsChannelInputType.Normal)); comboBoxInputType.Items.Add(new ComboBoxItem(Properties.Resources.Shorted, AdsChannelInputType.Shorted)); comboBoxInputType.Items.Add(new ComboBoxItem(Properties.Resources.BiasMeasured, AdsChannelInputType.BiasMeas)); comboBoxInputType.Items.Add(new ComboBoxItem(Properties.Resources.Mvdd, AdsChannelInputType.Mvdd)); comboBoxInputType.Items.Add(new ComboBoxItem(Properties.Resources.Temporary, AdsChannelInputType.Temp)); comboBoxInputType.Items.Add(new ComboBoxItem(Properties.Resources.TestSignal, AdsChannelInputType.Testsig)); comboBoxInputType.Items.Add(new ComboBoxItem(Properties.Resources.BiasDrp, AdsChannelInputType.BiasDrp)); comboBoxInputType.Items.Add(new ComboBoxItem(Properties.Resources.BiasDrn, AdsChannelInputType.BiasDrn)); comboBoxInputType.SelectedIndex = (int)settings.InputType; comboBoxBias.Items.Add(new ComboBoxItem(Properties.Resources.RemoveFromBias, false)); comboBoxBias.Items.Add(new ComboBoxItem($"{Properties.Resources.IncludeInBias} ({Properties.Resources.Default})", true)); comboBoxBias.SelectedIndex = settings.Bias ? 1 : 0; comboBoxSrb2.Items.Add(new ComboBoxItem($"{Properties.Resources.Disconnect} SRB2", false)); comboBoxSrb2.Items.Add(new ComboBoxItem($"{Properties.Resources.Connect} to SRB2 ({Properties.Resources.Default})", true)); comboBoxSrb2.SelectedIndex = settings.Srb2 ? 1 : 0; }
/// <summary> /// Set Board Channels /// pass in channel settings for any board channel to set SRB1 and keep the other channel settings unchanged /// </summary> public async Task <bool> SetImpedanceModeAsync(IEnumerable <int> channels, ICytonChannelSettings settings) { if (await SettingsLock.WaitAsync(0)) { try { Log?.Invoke(this, new LogEventArgs(this, "SetImpedanceModeAsync", $"Setting board impedance {string.Join(",", channels)} to P {settings.LlofP} N {settings.LlofN}.", LogLevel.DEBUG)); string settingsString = ""; int setChannelCounter = 0; foreach (var nextChannel in channels) { setChannelCounter++; settingsString += $"z{nextChannel.ChannelSetCharacter()}{settings.LlofP.BoolCharacter()}{settings.LlofN.BoolCharacter()}Z"; if (setChannelCounter > 0) { var response = ConfigureBoard(settingsString); Log?.Invoke(this, new LogEventArgs(this, "SetImpedanceModeAsync", $"Response:{response}.", LogLevel.DEBUG)); settingsString = ""; setChannelCounter = 0; await Task.Delay(500); } } if (settingsString.Length > 0) { var response = ConfigureBoard(settingsString); Log?.Invoke(this, new LogEventArgs(this, "SetImpedanceModeAsync", $"Response:{response}.", LogLevel.DEBUG)); await Task.Delay(500); } return(true); } finally { SettingsLock.Release(); } } else { Log?.Invoke(this, new LogEventArgs(this, "SetImpedanceModeAsync", $"Another process is busy with the settings.", LogLevel.WARN)); return(false); } }
/// <summary> /// Set Board Channels /// </summary> public async Task <bool> SetBoardChannelAsync(IEnumerable <int> channels, ICytonChannelSettings settings) { if (await SettingsLock.WaitAsync(0)) { try { Log?.Invoke(this, new LogEventArgs(this, "SetBoardChannelAsync", $"Setting board channels {string.Join(",", channels)} to {settings}.", LogLevel.DEBUG)); string settingsString = ""; int setChannelCounter = 0; foreach (var nextChannel in channels) { setChannelCounter++; settingsString += $"x{nextChannel.ChannelSetCharacter()}{settings.PowerDown.BoolCharacter()}{(int)(settings.Gain)}{(int)(settings.InputType)}{settings.Bias.BoolCharacter()}{settings.Srb2.BoolCharacter()}0X"; if (setChannelCounter > 0) { var response = ConfigureBoard(settingsString); Log?.Invoke(this, new LogEventArgs(this, "SetBoardChannelAsync", $"Response:{response}.", LogLevel.DEBUG)); settingsString = ""; setChannelCounter = 0; await Task.Delay(500); } } if (settingsString.Length > 0) { var response = ConfigureBoard(settingsString); Log?.Invoke(this, new LogEventArgs(this, "SetBoardChannelAsync", $"Response:{response}.", LogLevel.DEBUG)); await Task.Delay(500); } return(true); } finally { SettingsLock.Release(); } } else { Log?.Invoke(this, new LogEventArgs(this, "SetBoardChannelAsync", $"Another process is busy with the settings.", LogLevel.WARN)); return(false); } }
public ImpedanceSettings(IEnumerable <int> channels, ICytonChannelSettings settings) { InitializeComponent(); ChannelsToSet = channels; Text = Properties.Resources.SetImpedance; var labelTitle = Properties.Resources.SetChannels; labelChannel.Text = $"{labelTitle} {string.Join(", ", channels)}"; buttonSetImpedance.Text = Properties.Resources.SetImpedance; comboBoxLlofP.Items.Add(new ComboBoxItem($"{Properties.Resources.TestSignalNotApplied} ({Properties.Resources.Default})", false)); comboBoxLlofP.Items.Add(new ComboBoxItem(Properties.Resources.TestSignalApplied, true)); comboBoxLlofP.SelectedIndex = settings.LlofP ? 1 : 0; comboBoxLlofN.Items.Add(new ComboBoxItem($"{Properties.Resources.TestSignalNotApplied} ({Properties.Resources.Default})", false)); comboBoxLlofN.Items.Add(new ComboBoxItem(Properties.Resources.TestSignalApplied, true)); comboBoxLlofN.SelectedIndex = settings.LlofN ? 1 : 0; }
/// <summary> /// Set SRB1 value for the board /// </summary> public async Task <bool> SetSrb1Async(ICytonChannelSettings settings, bool connect) { if (await SettingsLock.WaitAsync(0)) { try { Log?.Invoke(this, new LogEventArgs(this, "SetSrb1Async", $"{(connect ? "Connecting" : "Disconnecting")} SRB1 for {(settings.ChannelNumber < 9 ? "Cyton" : "Daisy")}.", LogLevel.DEBUG)); string settingsString = FormatSetSrb1String(settings, connect); var response = ConfigureBoard(settingsString); Log?.Invoke(this, new LogEventArgs(this, "SetSrb1Async", $"Response:{response}.", LogLevel.DEBUG)); if (settings.ChannelNumber <= 8) { StartSrb1CytonSet = connect; } else if (settings.ChannelNumber > 8) { StartSrb1DaisySet = connect; } return(true); } finally { SettingsLock.Release(); } } else { Log?.Invoke(this, new LogEventArgs(this, "SetSrb1Async", $"Another process is busy with the settings.", LogLevel.WARN)); return(false); } }
public void AddChannel(ICytonChannelSettings channel) { _Channels.Add(channel); }
/// <summary> /// Format the set SRB1 string /// </summary> private static string FormatSetSrb1String(ICytonChannelSettings settings, bool connect) { return($"x{settings.ChannelNumber.ChannelSetCharacter()}{settings.PowerDown.BoolCharacter()}{(int)(settings.Gain)}{(int)(settings.InputType)}{settings.Bias.BoolCharacter()}{settings.Srb2.BoolCharacter()}{(connect ? "1" : "0")}X"); }
public static string ChannelSettingsToString(this ICytonChannelSettings value) { return($"PwrDwn{value.PowerDown},Gain {value.Gain}, Input {value.InputType}, Bias {value.Bias}, SRB2 {value.Srb2}"); }