diff --git a/OpenEphys.Onix1.Design/HeadstageRhs2116Dialog.Designer.cs b/OpenEphys.Onix1.Design/HeadstageRhs2116Dialog.Designer.cs index c4ddd0d5..fbcc7e24 100644 --- a/OpenEphys.Onix1.Design/HeadstageRhs2116Dialog.Designer.cs +++ b/OpenEphys.Onix1.Design/HeadstageRhs2116Dialog.Designer.cs @@ -44,14 +44,14 @@ private void InitializeComponent() this.flowLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // - // tabControl + // tabControlProperties // this.tabControl.Controls.Add(this.tabPageStimulusSequence); this.tabControl.Controls.Add(this.tabPageRhs2116); this.tabControl.Dock = System.Windows.Forms.DockStyle.Fill; this.tabControl.Location = new System.Drawing.Point(3, 2); this.tabControl.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.tabControl.Name = "tabControl"; + this.tabControl.Name = "tabControlProperties"; this.tabControl.SelectedIndex = 0; this.tabControl.Size = new System.Drawing.Size(1328, 741); this.tabControl.TabIndex = 0; diff --git a/OpenEphys.Onix1.Design/HeadstageRhs2116Dialog.cs b/OpenEphys.Onix1.Design/HeadstageRhs2116Dialog.cs index 12fdbfeb..354523a7 100644 --- a/OpenEphys.Onix1.Design/HeadstageRhs2116Dialog.cs +++ b/OpenEphys.Onix1.Design/HeadstageRhs2116Dialog.cs @@ -15,22 +15,16 @@ public partial class HeadstageRhs2116Dialog : Form internal readonly Rhs2116StimulusSequenceDialog StimulusSequenceDialog; internal readonly GenericDeviceDialog Rhs2116Dialog; - internal Rhs2116ProbeGroup ProbeGroup; - /// /// Initializes a new instance of a . /// - /// Current channel configuration settings for a . - /// Current stimulus sequence for a . + /// Current configuration settings for . /// Current configuration settings for a single . - public HeadstageRhs2116Dialog(Rhs2116ProbeGroup probeGroup, Rhs2116StimulusSequencePair sequence, - ConfigureRhs2116Pair rhs2116) + public HeadstageRhs2116Dialog(ConfigureRhs2116Trigger rhs2116Trigger, ConfigureRhs2116Pair rhs2116) { InitializeComponent(); - ProbeGroup = new Rhs2116ProbeGroup(probeGroup); - - StimulusSequenceDialog = new Rhs2116StimulusSequenceDialog(sequence, ProbeGroup); + StimulusSequenceDialog = new Rhs2116StimulusSequenceDialog(rhs2116Trigger); StimulusSequenceDialog.SetChildFormProperties(this).AddDialogToTab(tabPageStimulusSequence); this.AddMenuItemsFromDialogToFileOption(StimulusSequenceDialog); diff --git a/OpenEphys.Onix1.Design/HeadstageRhs2116Editor.cs b/OpenEphys.Onix1.Design/HeadstageRhs2116Editor.cs index 4d3fa3b7..3e6d5dbe 100644 --- a/OpenEphys.Onix1.Design/HeadstageRhs2116Editor.cs +++ b/OpenEphys.Onix1.Design/HeadstageRhs2116Editor.cs @@ -18,13 +18,11 @@ public override bool EditComponent(ITypeDescriptorContext context, object compon var editorState = (IWorkflowEditorState)provider.GetService(typeof(IWorkflowEditorState)); if (editorState != null && !editorState.WorkflowRunning && component is ConfigureHeadstageRhs2116 configureNode) { - using var editorDialog = new HeadstageRhs2116Dialog(configureNode.StimulusTrigger.ProbeGroup, - configureNode.StimulusTrigger.StimulusSequence, configureNode.Rhs2116Pair); + using var editorDialog = new HeadstageRhs2116Dialog(configureNode.StimulusTrigger, configureNode.Rhs2116Pair); if (editorDialog.ShowDialog() == DialogResult.OK) { - configureNode.StimulusTrigger.StimulusSequence = editorDialog.StimulusSequenceDialog.Sequence; - configureNode.StimulusTrigger.ProbeGroup = (Rhs2116ProbeGroup)editorDialog.StimulusSequenceDialog.ChannelDialog.ProbeGroup; + configureNode.StimulusTrigger = editorDialog.StimulusSequenceDialog.Trigger; DesignHelper.CopyProperties((ConfigureRhs2116Pair)editorDialog.Rhs2116Dialog.Device, configureNode.Rhs2116Pair, DesignHelper.PropertiesToIgnore); return true; diff --git a/OpenEphys.Onix1.Design/Rhs2116StimulusSequenceDialog.cs b/OpenEphys.Onix1.Design/Rhs2116StimulusSequenceDialog.cs index 07f43ebf..93636cfc 100644 --- a/OpenEphys.Onix1.Design/Rhs2116StimulusSequenceDialog.cs +++ b/OpenEphys.Onix1.Design/Rhs2116StimulusSequenceDialog.cs @@ -15,7 +15,9 @@ public partial class Rhs2116StimulusSequenceDialog : GenericStimulusSequenceDial const double SamplePeriodMilliSeconds = 1e3 / Rhs2116.SampleFrequencyHz; const int NumberOfChannels = 32; - internal Rhs2116StimulusSequencePair Sequence { get; set; } + internal Rhs2116StimulusSequencePair Sequence { get => Trigger.StimulusSequence; } + + internal ConfigureRhs2116Trigger Trigger { get; set; } readonly Rhs2116StimulusSequencePair SequenceCopy = new(); @@ -35,19 +37,18 @@ public partial class Rhs2116StimulusSequenceDialog : GenericStimulusSequenceDial /// Opens a dialog allowing for easy changing of stimulus sequence parameters, with /// visual feedback on what the resulting stimulus sequence looks like. /// - /// Stimulus sequence containing 32 channels of stimuli. - /// Probe group containing ProbeInterface specifications for 32 contacts. - public Rhs2116StimulusSequenceDialog(Rhs2116StimulusSequencePair sequence, Rhs2116ProbeGroup probeGroup) + /// Existing object. + public Rhs2116StimulusSequenceDialog(ConfigureRhs2116Trigger rhs2116Trigger) : base(NumberOfChannels, true, true) { - if (probeGroup.NumberOfContacts != NumberOfChannels) + if (rhs2116Trigger.ProbeGroup.NumberOfContacts != NumberOfChannels) { - throw new ArgumentException($"Probe group is not valid: {NumberOfChannels} channels were expected, there are {probeGroup.NumberOfContacts} instead."); + throw new ArgumentException($"Probe group is not valid: {NumberOfChannels} channels were expected, there are {rhs2116Trigger.ProbeGroup.NumberOfContacts} instead."); } InitializeComponent(); - Sequence = new Rhs2116StimulusSequencePair(sequence); + Trigger = new(rhs2116Trigger); dataGridViewStimulusTable.DataBindingComplete += DataBindingComplete; SetTableDataSource(); @@ -63,7 +64,7 @@ public Rhs2116StimulusSequenceDialog(Rhs2116StimulusSequencePair sequence, Rhs21 StepSize = Sequence.CurrentStepSize; - ChannelDialog = new(probeGroup); + ChannelDialog = new(rhs2116Trigger.ProbeGroup); ChannelDialog.SetChildFormProperties(this).AddDialogToPanel(panelProbe); this.AddMenuItemsFromDialogToFileOption(ChannelDialog, "Channel Configuration"); @@ -278,11 +279,6 @@ internal override PointPairList[] CreateStimulusWaveforms() internal override void SetStatusValidity() { - if (Sequence == null) - { - return; - } - if (Sequence.Valid && Sequence.FitsInHardware) { toolStripStatusIsValid.Image = Properties.Resources.StatusReadyImage; @@ -919,16 +915,16 @@ internal override void SerializeStimulusSequence(string fileName) internal override bool IsSequenceValid() { - return Sequence.Valid; + return Sequence.Valid && Sequence.FitsInHardware; } internal override void DeserializeStimulusSequence(string fileName) { - var sequence = DesignHelper.DeserializeString(File.ReadAllText(fileName)); + var newSequence = DesignHelper.DeserializeString(File.ReadAllText(fileName)); - if (sequence != null && sequence.Stimuli.Length == 32) + if (newSequence != null && newSequence.Stimuli.Length == 32) { - if (sequence == new Rhs2116StimulusSequencePair()) + if (newSequence == new Rhs2116StimulusSequencePair()) { var result = MessageBox.Show("The stimulus sequence loaded does not have any configuration settings applied. " + "This could be because the file did not have the correct format. If this sequence is loaded, it will clear out " + @@ -940,15 +936,15 @@ internal override void DeserializeStimulusSequence(string fileName) } } - Sequence = sequence; + Trigger.StimulusSequence = newSequence; - for (int i = 0; i < Sequence.Stimuli.Length; i++) + for (int i = 0; i < newSequence.Stimuli.Length; i++) { - RequestedAnodicAmplitudeuA[i] = Sequence.Stimuli[i].AnodicAmplitudeSteps * Sequence.CurrentStepSizeuA; - RequestedCathodicAmplitudeuA[i] = Sequence.Stimuli[i].CathodicAmplitudeSteps * Sequence.CurrentStepSizeuA; + RequestedAnodicAmplitudeuA[i] = newSequence.Stimuli[i].AnodicAmplitudeSteps * newSequence.CurrentStepSizeuA; + RequestedCathodicAmplitudeuA[i] = newSequence.Stimuli[i].CathodicAmplitudeSteps * newSequence.CurrentStepSizeuA; } - if (!Sequence.Valid) + if (!newSequence.Valid) { MessageBox.Show("Warning: Invalid stimuli found in the recently opened file. Check all values to ensure they are what is expected.", "Invalid Stimuli", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -962,10 +958,7 @@ internal override void DeserializeStimulusSequence(string fileName) internal override void SetTableDataSource() { - if (Sequence == null) - return; - - dataGridViewStimulusTable.DataSource = Sequence.Stimuli; + dataGridViewStimulusTable.DataSource = Trigger?.StimulusSequence.Stimuli; } private void DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) diff --git a/OpenEphys.Onix1.Design/Rhs2116StimulusSequenceEditor.cs b/OpenEphys.Onix1.Design/Rhs2116StimulusSequenceEditor.cs index c12bbb37..7c5a211a 100644 --- a/OpenEphys.Onix1.Design/Rhs2116StimulusSequenceEditor.cs +++ b/OpenEphys.Onix1.Design/Rhs2116StimulusSequenceEditor.cs @@ -18,12 +18,11 @@ public override bool EditComponent(ITypeDescriptorContext context, object compon var editorState = (IWorkflowEditorState)provider.GetService(typeof(IWorkflowEditorState)); if (editorState != null && !editorState.WorkflowRunning && component is ConfigureRhs2116Trigger configureNode) { - using var editorDialog = new Rhs2116StimulusSequenceDialog(configureNode.StimulusSequence, configureNode.ProbeGroup); + using var editorDialog = new Rhs2116StimulusSequenceDialog(configureNode); if (editorDialog.ShowDialog() == DialogResult.OK) { - configureNode.StimulusSequence = editorDialog.Sequence; - configureNode.ProbeGroup = (Rhs2116ProbeGroup)editorDialog.ChannelDialog.ProbeGroup; + DesignHelper.CopyProperties(editorDialog.Trigger, configureNode); return true; } diff --git a/OpenEphys.Onix1/ConfigureRhs2116Trigger.cs b/OpenEphys.Onix1/ConfigureRhs2116Trigger.cs index 7262fdbb..081c316a 100644 --- a/OpenEphys.Onix1/ConfigureRhs2116Trigger.cs +++ b/OpenEphys.Onix1/ConfigureRhs2116Trigger.cs @@ -33,6 +33,22 @@ public ConfigureRhs2116Trigger() { } + /// + /// Copy constructor for the class. + /// + /// Existing object. + public ConfigureRhs2116Trigger(ConfigureRhs2116Trigger rhs2116Trigger) + : this() + { + Enable = rhs2116Trigger.Enable; + DeviceAddress = rhs2116Trigger.DeviceAddress; + DeviceName = rhs2116Trigger.DeviceName; + TriggerSource = rhs2116Trigger.TriggerSource; + ProbeGroup = rhs2116Trigger.ProbeGroup; + Armed = rhs2116Trigger.Armed; + StimulusSequence = new(rhs2116Trigger.StimulusSequence); + } + /// /// Gets or sets the device enable state. ///