repo time
Dependencies: mbed MAX14720 MAX30205 USBDevice
HspGuiSourceV301/HSPGui/BioZChannel.cs@20:6d2af70c92ab, 2021-04-06 (annotated)
- Committer:
- darienf
- Date:
- Tue Apr 06 06:41:40 2021 +0000
- Revision:
- 20:6d2af70c92ab
another repo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
darienf | 20:6d2af70c92ab | 1 | /******************************************************************************* |
darienf | 20:6d2af70c92ab | 2 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All rights Reserved. |
darienf | 20:6d2af70c92ab | 3 | * |
darienf | 20:6d2af70c92ab | 4 | * This software is protected by copyright laws of the United States and |
darienf | 20:6d2af70c92ab | 5 | * of foreign countries. This material may also be protected by patent laws |
darienf | 20:6d2af70c92ab | 6 | * and technology transfer regulations of the United States and of foreign |
darienf | 20:6d2af70c92ab | 7 | * countries. This software is furnished under a license agreement and/or a |
darienf | 20:6d2af70c92ab | 8 | * nondisclosure agreement and may only be used or reproduced in accordance |
darienf | 20:6d2af70c92ab | 9 | * with the terms of those agreements. Dissemination of this information to |
darienf | 20:6d2af70c92ab | 10 | * any party or parties not specified in the license agreement and/or |
darienf | 20:6d2af70c92ab | 11 | * nondisclosure agreement is expressly prohibited. |
darienf | 20:6d2af70c92ab | 12 | * |
darienf | 20:6d2af70c92ab | 13 | * The above copyright notice and this permission notice shall be included |
darienf | 20:6d2af70c92ab | 14 | * in all copies or substantial portions of the Software. |
darienf | 20:6d2af70c92ab | 15 | * |
darienf | 20:6d2af70c92ab | 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
darienf | 20:6d2af70c92ab | 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
darienf | 20:6d2af70c92ab | 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
darienf | 20:6d2af70c92ab | 19 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
darienf | 20:6d2af70c92ab | 20 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
darienf | 20:6d2af70c92ab | 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
darienf | 20:6d2af70c92ab | 22 | * OTHER DEALINGS IN THE SOFTWARE. |
darienf | 20:6d2af70c92ab | 23 | * |
darienf | 20:6d2af70c92ab | 24 | * Except as contained in this notice, the name of Maxim Integrated |
darienf | 20:6d2af70c92ab | 25 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
darienf | 20:6d2af70c92ab | 26 | * Products, Inc. Branding Policy. |
darienf | 20:6d2af70c92ab | 27 | * |
darienf | 20:6d2af70c92ab | 28 | * The mere transfer of this software does not imply any licenses |
darienf | 20:6d2af70c92ab | 29 | * of trade secrets, proprietary technology, copyrights, patents, |
darienf | 20:6d2af70c92ab | 30 | * trademarks, maskwork rights, or any other form of intellectual |
darienf | 20:6d2af70c92ab | 31 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
darienf | 20:6d2af70c92ab | 32 | * ownership rights. |
darienf | 20:6d2af70c92ab | 33 | ******************************************************************************* |
darienf | 20:6d2af70c92ab | 34 | */ |
darienf | 20:6d2af70c92ab | 35 | |
darienf | 20:6d2af70c92ab | 36 | using System; |
darienf | 20:6d2af70c92ab | 37 | using System.Collections.Generic; |
darienf | 20:6d2af70c92ab | 38 | using System.Linq; |
darienf | 20:6d2af70c92ab | 39 | using System.Text; |
darienf | 20:6d2af70c92ab | 40 | |
darienf | 20:6d2af70c92ab | 41 | namespace HealthSensorPlatform |
darienf | 20:6d2af70c92ab | 42 | { |
darienf | 20:6d2af70c92ab | 43 | public partial class HspForm |
darienf | 20:6d2af70c92ab | 44 | { |
darienf | 20:6d2af70c92ab | 45 | List<RegisterField> bioZChannelField = new List<RegisterField>(); |
darienf | 20:6d2af70c92ab | 46 | |
darienf | 20:6d2af70c92ab | 47 | RegisterField bioZSampleRateField; // Needed for dynamic changing of options |
darienf | 20:6d2af70c92ab | 48 | RegisterField bioZDlpfField; |
darienf | 20:6d2af70c92ab | 49 | RegisterField bioZCgmagField; |
darienf | 20:6d2af70c92ab | 50 | |
darienf | 20:6d2af70c92ab | 51 | string[][] bioZSampleRateOptions = new string[][] |
darienf | 20:6d2af70c92ab | 52 | { |
darienf | 20:6d2af70c92ab | 53 | new string[] { "64 sps*", "32 sps" }, |
darienf | 20:6d2af70c92ab | 54 | new string[] { "62.5 sps*", "31.25 sps" }, |
darienf | 20:6d2af70c92ab | 55 | new string[] { "50 sps*", "25 sps" }, |
darienf | 20:6d2af70c92ab | 56 | new string[] { "49.95 sps*", "24.98 sps" } |
darienf | 20:6d2af70c92ab | 57 | }; |
darienf | 20:6d2af70c92ab | 58 | |
darienf | 20:6d2af70c92ab | 59 | string[][] bioZCgmagOptions = { new string[] { "Off*", "8 μA", "16 μA", "32 μA", "48 μA", "64 μA", "80 μA", "96 μA" }, |
darienf | 20:6d2af70c92ab | 60 | new string[] { "Off*", "8 μA", "16 μA", "32 μA", "48 μA", "64 μA", "80 μA" }, |
darienf | 20:6d2af70c92ab | 61 | new string[] { "Off*", "8 μA", "16 μA", "32 μA" }, |
darienf | 20:6d2af70c92ab | 62 | new string[] { "Off*", "8 μA", "16 μA" }, |
darienf | 20:6d2af70c92ab | 63 | new string[] { "Off*", "8 μA" } |
darienf | 20:6d2af70c92ab | 64 | }; |
darienf | 20:6d2af70c92ab | 65 | |
darienf | 20:6d2af70c92ab | 66 | string[][][] bioZDlpfOptions; |
darienf | 20:6d2af70c92ab | 67 | |
darienf | 20:6d2af70c92ab | 68 | void initalizeBioZConfigFields() |
darienf | 20:6d2af70c92ab | 69 | { |
darienf | 20:6d2af70c92ab | 70 | bioZDlpfOptions = new string[4][][]; |
darienf | 20:6d2af70c92ab | 71 | |
darienf | 20:6d2af70c92ab | 72 | for (int i = 0; i < 4; i++) |
darienf | 20:6d2af70c92ab | 73 | { |
darienf | 20:6d2af70c92ab | 74 | bioZDlpfOptions[i] = new string[2][]; |
darienf | 20:6d2af70c92ab | 75 | } |
darienf | 20:6d2af70c92ab | 76 | |
darienf | 20:6d2af70c92ab | 77 | // 32768 Hz |
darienf | 20:6d2af70c92ab | 78 | bioZDlpfOptions[0][0] = new string[] {"Bypass", "4.096 Hz*", "8.192 Hz", "16.384 Hz"}; |
darienf | 20:6d2af70c92ab | 79 | bioZDlpfOptions[0][1] = new string[] {"Bypass", "4.096 Hz*", "8.192 Hz"}; //, "4.096 Hz"}; |
darienf | 20:6d2af70c92ab | 80 | // 32000 Hz |
darienf | 20:6d2af70c92ab | 81 | bioZDlpfOptions[1][0] = new string[] {"Bypass", "4.0 Hz*", "8.0 Hz", "16.0 Hz"}; |
darienf | 20:6d2af70c92ab | 82 | bioZDlpfOptions[1][1] = new string[] {"Bypass", "4.0 Hz*", "8.0 Hz"}; //, "4.0 Hz"}; |
darienf | 20:6d2af70c92ab | 83 | // 32000 Hz |
darienf | 20:6d2af70c92ab | 84 | bioZDlpfOptions[2][0] = new string[] {"Bypass", "4.0 Hz*", "8.0 Hz", "16.0 Hz"}; |
darienf | 20:6d2af70c92ab | 85 | bioZDlpfOptions[2][1] = new string[] {"Bypass", "4.0 Hz*", "8.0 Hz"}; //, "4.0 Hz"}; |
darienf | 20:6d2af70c92ab | 86 | // 31968 Hz |
darienf | 20:6d2af70c92ab | 87 | bioZDlpfOptions[3][0] = new string[] {"Bypass", "3.996 Hz*", "7.992 Hz", "15.984 Hz"}; |
darienf | 20:6d2af70c92ab | 88 | bioZDlpfOptions[3][1] = new string[] {"Bypass", "3.996 Hz*", "7.992 Hz"}; //, "3.996 Hz"}; |
darienf | 20:6d2af70c92ab | 89 | |
darienf | 20:6d2af70c92ab | 90 | string[] aHpfOptions = { "250 Hz", "500 Hz", "1000 Hz*", "2000 Hz", "4000 Hz", "8000 Hz", "Bypass" }; |
darienf | 20:6d2af70c92ab | 91 | string[] gainOptions = { "20 V/V*", "40 V/V", "80 V/V", "160 V/V" }; |
darienf | 20:6d2af70c92ab | 92 | string[] dlpfOptions = { "Bypass", "4 Hz*", "8 Hz", "16 Hz" }; |
darienf | 20:6d2af70c92ab | 93 | string[] dhpfOptions = { "Bypass (DC)*", "0.05 Hz", "0.50 Hz" }; |
darienf | 20:6d2af70c92ab | 94 | |
darienf | 20:6d2af70c92ab | 95 | |
darienf | 20:6d2af70c92ab | 96 | string[] fcgenOptions = { "4*FMSTR (~128 kHz)", "2*FMSTR (~80 kHz) - offset", "FMSTR (~40 kHz) - offset", "FMSTR/2 (~18 kHz) - offset", |
darienf | 20:6d2af70c92ab | 97 | "FMSTR/4 (~8 kHz)", "FMSTR/8 (~4 kHz)", "FMSTR/16 (~2 kHz)", "FMSTR/32 (~1 kHz)", |
darienf | 20:6d2af70c92ab | 98 | "FMSTR/64 (~500 Hz)*", "FMSTR/128 (~250 Hz)", "FMSTR/256 (~125 Hz)"}; |
darienf | 20:6d2af70c92ab | 99 | string[] cgmonOptions = { "Disabled*", "Enabled" }; |
darienf | 20:6d2af70c92ab | 100 | string[] extRbiasOptions = { "Internal*", "External" }; |
darienf | 20:6d2af70c92ab | 101 | string[] cgModeOptions = { "Unchopped w/ LPF*", "Chopped w/o LPF", "Chopped w/ LPF", "Chopped w/ Resistive CM" }; |
darienf | 20:6d2af70c92ab | 102 | |
darienf | 20:6d2af70c92ab | 103 | string[] enBloffOptions = { "Disabled*", "Under Range", "Over Range", "Under and Over Range" }; |
darienf | 20:6d2af70c92ab | 104 | string[] hiITOptions = new string[256]; |
darienf | 20:6d2af70c92ab | 105 | string[] loITOptions = new string[256]; |
darienf | 20:6d2af70c92ab | 106 | |
darienf | 20:6d2af70c92ab | 107 | for (int i = 0; i < hiITOptions.Length; i++) |
darienf | 20:6d2af70c92ab | 108 | { |
darienf | 20:6d2af70c92ab | 109 | hiITOptions[i] = "±2048 * " + i; |
darienf | 20:6d2af70c92ab | 110 | loITOptions[i] = "±32 * " + i; |
darienf | 20:6d2af70c92ab | 111 | } |
darienf | 20:6d2af70c92ab | 112 | hiITOptions[255] += "*"; |
darienf | 20:6d2af70c92ab | 113 | loITOptions[255] += "*"; |
darienf | 20:6d2af70c92ab | 114 | |
darienf | 20:6d2af70c92ab | 115 | string[] phoffOptions = new string[16]; |
darienf | 20:6d2af70c92ab | 116 | for (int i = 0; i < phoffOptions.Length/4; i++) |
darienf | 20:6d2af70c92ab | 117 | { |
darienf | 20:6d2af70c92ab | 118 | phoffOptions[4 * i] = (11.25 * 4 * i).ToString() + "° (For all frequencies)"; |
darienf | 20:6d2af70c92ab | 119 | phoffOptions[4 * i + 1] = (11.25 * (4 * i + 1)).ToString() + "° (For <= 40kHz)"; |
darienf | 20:6d2af70c92ab | 120 | phoffOptions[4 * i + 2] = (11.25 * (4 * i + 2)).ToString() + "° (For <= 80kHz)"; |
darienf | 20:6d2af70c92ab | 121 | phoffOptions[4 * i + 3] = (11.25 * (4 * i + 3)).ToString() + "° (For <= 40kHz)"; |
darienf | 20:6d2af70c92ab | 122 | } |
darienf | 20:6d2af70c92ab | 123 | phoffOptions[0] += "*"; |
darienf | 20:6d2af70c92ab | 124 | |
darienf | 20:6d2af70c92ab | 125 | string[] enDcloffOptions = { "Disabled*", "ECGP/N", "BIP/N" }; |
darienf | 20:6d2af70c92ab | 126 | |
darienf | 20:6d2af70c92ab | 127 | bioZSampleRateField = new RegisterField { Name = "BIOZ_RATE", Register = 0x18, Index = 23, Width = 1, Descriptions = bioZSampleRateOptions[0], Label = lblBioZSampleRate, Control = cboBioZSampleRate, Device = max30001 }; |
darienf | 20:6d2af70c92ab | 128 | RegisterField aHpfField = new RegisterField { Name = "BIOZ_AHPF", Register = 0x18, Index = 20, Width = 3, Descriptions = aHpfOptions, Label = lblBioZAnalogHpf, Control = cboBioZAnalogHpf, Device = max30001 }; |
darienf | 20:6d2af70c92ab | 129 | RegisterField rbiasField = new RegisterField { Name = "\nEXT_RBIAS", Register = 0x18, Index = 19, Width = 1, Descriptions = extRbiasOptions, Label = lblBioZExternalResistorBiasEnable, Control = cboBioZExternalResistorBiasEnable, Device = max30001 }; |
darienf | 20:6d2af70c92ab | 130 | RegisterField gainField = new RegisterField { Name = "BIOZ_GAIN", Register = 0x18, Index = 16, Width = 2, Descriptions = gainOptions, Label = lblBioZChannelGain, Control = cboBioZChannelGain, Device = max30001 }; |
darienf | 20:6d2af70c92ab | 131 | RegisterField digitalHpfField = new RegisterField { Name = "BIOZ_DHPF", Register = 0x18, Index = 14, Width = 2, Descriptions = dhpfOptions, Label = lblBioZDigitalHpf, Control = cboBioZDigitalHpf, Device = max30001 }; |
darienf | 20:6d2af70c92ab | 132 | bioZDlpfField = new RegisterField { Name = "BIOZ_DLPF", Register = 0x18, Index = 12, Width = 2, Descriptions = dlpfOptions, Label = lblBioZDigitalLpf, Control = cboBioZDigitalLpf, Device = max30001 }; |
darienf | 20:6d2af70c92ab | 133 | RegisterField fcgenField = new RegisterField { Name = "BIOZ_FCGEN", Register = 0x18, Index = 8, Width = 4, Descriptions = fcgenOptions, Label = lblBioZCurrentGeneratorFrequency, Control = cboBioZCurrentGeneratorFrequency, Device = max30001 }; |
darienf | 20:6d2af70c92ab | 134 | RegisterField cgmonField = new RegisterField { Name = "BIOZ_CGMON", Register = 0x18, Index = 7, Width = 1, Descriptions = cgmonOptions, Label = lblBioZCurrentGeneratorMonitor, Control = cboBioZCurrentGeneratorMonitor, Device = max30001 }; |
darienf | 20:6d2af70c92ab | 135 | bioZCgmagField = new RegisterField { Name = "BIOZ_CGMAG", Register = 0x18, Index = 4, Width = 3, Descriptions = bioZCgmagOptions[0], Label = lblBioZCurrentGeneratorMagnitude, Control = cboBioZCurrentGeneratorMagnitude, Device = max30001 }; |
darienf | 20:6d2af70c92ab | 136 | RegisterField phoffField = new RegisterField { Name = "\nBIOZ_PHOFF", Register = 0x18, Index = 0, Width = 4, Descriptions = phoffOptions, Label = lblBioZModulationPhaseOffset, Control = cboBioZModulationPhaseOffset, Device = max30001 }; |
darienf | 20:6d2af70c92ab | 137 | bioZChannelField.Add(bioZSampleRateField); |
darienf | 20:6d2af70c92ab | 138 | bioZChannelField.Add(aHpfField); |
darienf | 20:6d2af70c92ab | 139 | bioZChannelField.Add(rbiasField); |
darienf | 20:6d2af70c92ab | 140 | bioZChannelField.Add(gainField); |
darienf | 20:6d2af70c92ab | 141 | bioZChannelField.Add(digitalHpfField); |
darienf | 20:6d2af70c92ab | 142 | bioZChannelField.Add(bioZDlpfField); |
darienf | 20:6d2af70c92ab | 143 | bioZChannelField.Add(fcgenField); |
darienf | 20:6d2af70c92ab | 144 | bioZChannelField.Add(cgmonField); |
darienf | 20:6d2af70c92ab | 145 | bioZChannelField.Add(bioZCgmagField); |
darienf | 20:6d2af70c92ab | 146 | bioZChannelField.Add(phoffField); |
darienf | 20:6d2af70c92ab | 147 | |
darienf | 20:6d2af70c92ab | 148 | RegisterField cgmodeField = new RegisterField { Name = "BMUX_CG_MODE", Register = 0x17, Index = 12, Width = 2, Descriptions = cgModeOptions, Label = lblBioZCurrentGeneratorMode, Control = cboBioZCurrentGeneratorMode, Device = max30001 }; |
darienf | 20:6d2af70c92ab | 149 | RegisterField enDcloffField = new RegisterField { Name = "EN_BLOFF", Register = 0x10, Index = 14, Width = 2, Descriptions = enBloffOptions, Label = lblBioZDigitalLeadOffDetectionEnable, Control = cboBioZDigitalLeadOffDetectionEnable, Device = max30001 }; |
darienf | 20:6d2af70c92ab | 150 | RegisterField bloffHiItField = new RegisterField { Name = "BLOFF_HI_IT", Register = 0x05, Index = 8, Width = 8, Descriptions = hiITOptions, Label = lblBioZACLeadOffOverRangeThreshold, Control = cboBioZACLeadOffOverRangeThreshold, Device = max30001 }; |
darienf | 20:6d2af70c92ab | 151 | RegisterField bloffLoItField = new RegisterField { Name = "BLOFF_LO_IT", Register = 0x05, Index = 0, Width = 8, Descriptions = loITOptions, Label = lblBioZACLeadOffUnderRangeThreshold, Control = cboBioZACLeadOffUnderRangeThreshold, Device = max30001 }; |
darienf | 20:6d2af70c92ab | 152 | bioZChannelField.Add(cgmodeField); |
darienf | 20:6d2af70c92ab | 153 | bioZChannelField.Add(enDcloffField); |
darienf | 20:6d2af70c92ab | 154 | bioZChannelField.Add(bloffHiItField); |
darienf | 20:6d2af70c92ab | 155 | bioZChannelField.Add(bloffLoItField); |
darienf | 20:6d2af70c92ab | 156 | } |
darienf | 20:6d2af70c92ab | 157 | |
darienf | 20:6d2af70c92ab | 158 | void BioZChannelUpdateRegisters() |
darienf | 20:6d2af70c92ab | 159 | { |
darienf | 20:6d2af70c92ab | 160 | internalUpdate = true; |
darienf | 20:6d2af70c92ab | 161 | ReadComboBoxesRegisters(bioZChannelField); |
darienf | 20:6d2af70c92ab | 162 | internalUpdate = false; |
darienf | 20:6d2af70c92ab | 163 | } |
darienf | 20:6d2af70c92ab | 164 | |
darienf | 20:6d2af70c92ab | 165 | private CustomControls.InitArgs.BIOZInitStart getBioZArgs() |
darienf | 20:6d2af70c92ab | 166 | { |
darienf | 20:6d2af70c92ab | 167 | CustomControls.InitArgs.BIOZInitStart biozArgs = new CustomControls.InitArgs.BIOZInitStart(); |
darienf | 20:6d2af70c92ab | 168 | |
darienf | 20:6d2af70c92ab | 169 | biozArgs.Openp = cboBioZBmuxOpenp.SelectedIndex; |
darienf | 20:6d2af70c92ab | 170 | biozArgs.Openn = cboBioZBmuxOpenn.SelectedIndex; |
darienf | 20:6d2af70c92ab | 171 | biozArgs.Calp_sel = cboBioZBmuxCalpSel.SelectedIndex; |
darienf | 20:6d2af70c92ab | 172 | biozArgs.Caln_sel = cboBioZBmuxCalnSel.SelectedIndex; |
darienf | 20:6d2af70c92ab | 173 | biozArgs.CG_mode = cboBioZCurrentGeneratorMode.SelectedIndex; |
darienf | 20:6d2af70c92ab | 174 | biozArgs.En_bioz = chkEnBioZ.Checked == true ? 1 : 0; |
darienf | 20:6d2af70c92ab | 175 | biozArgs.B_fit = 7; // comboBox39.SelectedIndex; |
darienf | 20:6d2af70c92ab | 176 | biozArgs.Rate = cboBioZSampleRate.SelectedIndex; |
darienf | 20:6d2af70c92ab | 177 | biozArgs.Ahpf = cboBioZAnalogHpf.SelectedIndex; |
darienf | 20:6d2af70c92ab | 178 | biozArgs.Ext_rbias = cboBioZExternalResistorBiasEnable.SelectedIndex; |
darienf | 20:6d2af70c92ab | 179 | biozArgs.Gain = cboBioZChannelGain.SelectedIndex; |
darienf | 20:6d2af70c92ab | 180 | biozArgs.Dhpf = cboBioZDigitalHpf.SelectedIndex; |
darienf | 20:6d2af70c92ab | 181 | biozArgs.Dlpf = cboBioZDigitalLpf.SelectedIndex; |
darienf | 20:6d2af70c92ab | 182 | biozArgs.Fcgen = cboBioZCurrentGeneratorFrequency.SelectedIndex; |
darienf | 20:6d2af70c92ab | 183 | biozArgs.Cgmon = cboBioZCurrentGeneratorMonitor.SelectedIndex; |
darienf | 20:6d2af70c92ab | 184 | biozArgs.Cgmag = cboBioZCurrentGeneratorMagnitude.SelectedIndex; |
darienf | 20:6d2af70c92ab | 185 | biozArgs.Phoff = cboBioZModulationPhaseOffset.SelectedIndex; |
darienf | 20:6d2af70c92ab | 186 | |
darienf | 20:6d2af70c92ab | 187 | return biozArgs; |
darienf | 20:6d2af70c92ab | 188 | } |
darienf | 20:6d2af70c92ab | 189 | |
darienf | 20:6d2af70c92ab | 190 | private void setBioZArgs(CustomControls.InitArgs.BIOZInitStart biozArgs) |
darienf | 20:6d2af70c92ab | 191 | { |
darienf | 20:6d2af70c92ab | 192 | cboBioZBmuxOpenp.SelectedIndex = biozArgs.Openp; |
darienf | 20:6d2af70c92ab | 193 | cboBioZBmuxOpenn.SelectedIndex = biozArgs.Openn; |
darienf | 20:6d2af70c92ab | 194 | cboBioZBmuxCalpSel.SelectedIndex = biozArgs.Calp_sel; |
darienf | 20:6d2af70c92ab | 195 | cboBioZBmuxCalnSel.SelectedIndex = biozArgs.Caln_sel; |
darienf | 20:6d2af70c92ab | 196 | cboBioZCurrentGeneratorMode.SelectedIndex = biozArgs.CG_mode; |
darienf | 20:6d2af70c92ab | 197 | //biozArgs.En_bioz = chkEnBioZ.Checked == true ? 1 : 0; |
darienf | 20:6d2af70c92ab | 198 | //biozArgs.B_fit = 7; // comboBox39.SelectedIndex; |
darienf | 20:6d2af70c92ab | 199 | cboBioZSampleRate.SelectedIndex = biozArgs.Rate; |
darienf | 20:6d2af70c92ab | 200 | cboBioZAnalogHpf.SelectedIndex = biozArgs.Ahpf; |
darienf | 20:6d2af70c92ab | 201 | cboBioZExternalResistorBiasEnable.SelectedIndex = biozArgs.Ext_rbias; |
darienf | 20:6d2af70c92ab | 202 | cboBioZChannelGain.SelectedIndex = biozArgs.Gain; |
darienf | 20:6d2af70c92ab | 203 | cboBioZDigitalHpf.SelectedIndex = biozArgs.Dhpf; |
darienf | 20:6d2af70c92ab | 204 | cboBioZDigitalLpf.SelectedIndex = biozArgs.Dlpf; |
darienf | 20:6d2af70c92ab | 205 | cboBioZCurrentGeneratorFrequency.SelectedIndex = biozArgs.Fcgen; |
darienf | 20:6d2af70c92ab | 206 | cboBioZCurrentGeneratorMonitor.SelectedIndex = biozArgs.Cgmon; |
darienf | 20:6d2af70c92ab | 207 | cboBioZCurrentGeneratorMagnitude.SelectedIndex = biozArgs.Cgmag; |
darienf | 20:6d2af70c92ab | 208 | cboBioZModulationPhaseOffset.SelectedIndex = biozArgs.Phoff; |
darienf | 20:6d2af70c92ab | 209 | } |
darienf | 20:6d2af70c92ab | 210 | |
darienf | 20:6d2af70c92ab | 211 | public string BioZSettingString() |
darienf | 20:6d2af70c92ab | 212 | { |
darienf | 20:6d2af70c92ab | 213 | StringBuilder sb = new StringBuilder(); |
darienf | 20:6d2af70c92ab | 214 | |
darienf | 20:6d2af70c92ab | 215 | foreach(RegisterField rf in bioZChannelField) |
darienf | 20:6d2af70c92ab | 216 | { |
darienf | 20:6d2af70c92ab | 217 | sb.Append(rf.Label.Text.Replace("\n", String.Empty)); |
darienf | 20:6d2af70c92ab | 218 | sb.Append(" = "); |
darienf | 20:6d2af70c92ab | 219 | sb.Append(((MaximStyle.MaximComboBox)rf.Control).SelectedItem); |
darienf | 20:6d2af70c92ab | 220 | sb.Append(", "); |
darienf | 20:6d2af70c92ab | 221 | } |
darienf | 20:6d2af70c92ab | 222 | |
darienf | 20:6d2af70c92ab | 223 | return sb.ToString(); |
darienf | 20:6d2af70c92ab | 224 | } |
darienf | 20:6d2af70c92ab | 225 | |
darienf | 20:6d2af70c92ab | 226 | public string EcgSettingString() |
darienf | 20:6d2af70c92ab | 227 | { |
darienf | 20:6d2af70c92ab | 228 | StringBuilder sb = new StringBuilder(); |
darienf | 20:6d2af70c92ab | 229 | |
darienf | 20:6d2af70c92ab | 230 | foreach (RegisterField rf in ecgChannelField) |
darienf | 20:6d2af70c92ab | 231 | { |
darienf | 20:6d2af70c92ab | 232 | sb.Append(rf.Label.Text.Replace("\n", String.Empty)); |
darienf | 20:6d2af70c92ab | 233 | sb.Append(" = "); |
darienf | 20:6d2af70c92ab | 234 | sb.Append(((MaximStyle.MaximComboBox)rf.Control).SelectedItem); |
darienf | 20:6d2af70c92ab | 235 | sb.Append(", "); |
darienf | 20:6d2af70c92ab | 236 | } |
darienf | 20:6d2af70c92ab | 237 | |
darienf | 20:6d2af70c92ab | 238 | return sb.ToString(); |
darienf | 20:6d2af70c92ab | 239 | } |
darienf | 20:6d2af70c92ab | 240 | |
darienf | 20:6d2af70c92ab | 241 | |
darienf | 20:6d2af70c92ab | 242 | private void cboBioZChannelGain_SelectedIndexChanged(object sender, EventArgs e) |
darienf | 20:6d2af70c92ab | 243 | { |
darienf | 20:6d2af70c92ab | 244 | MaximStyle.MaximComboBox cbox = (MaximStyle.MaximComboBox)sender; |
darienf | 20:6d2af70c92ab | 245 | |
darienf | 20:6d2af70c92ab | 246 | switch (cbox.SelectedIndex) |
darienf | 20:6d2af70c92ab | 247 | { |
darienf | 20:6d2af70c92ab | 248 | case 0: |
darienf | 20:6d2af70c92ab | 249 | ecgView1.GainBioZ = 20; |
darienf | 20:6d2af70c92ab | 250 | break; |
darienf | 20:6d2af70c92ab | 251 | case 1: |
darienf | 20:6d2af70c92ab | 252 | ecgView1.GainBioZ = 40; |
darienf | 20:6d2af70c92ab | 253 | break; |
darienf | 20:6d2af70c92ab | 254 | case 2: |
darienf | 20:6d2af70c92ab | 255 | ecgView1.GainBioZ = 80; |
darienf | 20:6d2af70c92ab | 256 | break; |
darienf | 20:6d2af70c92ab | 257 | case 3: |
darienf | 20:6d2af70c92ab | 258 | ecgView1.GainBioZ = 160; |
darienf | 20:6d2af70c92ab | 259 | break; |
darienf | 20:6d2af70c92ab | 260 | } |
darienf | 20:6d2af70c92ab | 261 | } |
darienf | 20:6d2af70c92ab | 262 | |
darienf | 20:6d2af70c92ab | 263 | private void cboBioZCurrentGeneratorMagnitude_SelectedIndexChanged(object sender, EventArgs e) |
darienf | 20:6d2af70c92ab | 264 | { |
darienf | 20:6d2af70c92ab | 265 | MaximStyle.MaximComboBox cbox = (MaximStyle.MaximComboBox)sender; |
darienf | 20:6d2af70c92ab | 266 | int[] currents = { 0, 8, 16, 32, 48, 64, 80, 96 }; |
darienf | 20:6d2af70c92ab | 267 | |
darienf | 20:6d2af70c92ab | 268 | // Equation for Hex code to current magnitude |
darienf | 20:6d2af70c92ab | 269 | ecgView1.CurrentBioZ = currents[cbox.SelectedIndex]; |
darienf | 20:6d2af70c92ab | 270 | } |
darienf | 20:6d2af70c92ab | 271 | |
darienf | 20:6d2af70c92ab | 272 | private void cboBioZSampleRate_SelectedIndexChanged(object sender, EventArgs e) |
darienf | 20:6d2af70c92ab | 273 | { |
darienf | 20:6d2af70c92ab | 274 | MaximStyle.MaximComboBox cbo = (MaximStyle.MaximComboBox)sender; |
darienf | 20:6d2af70c92ab | 275 | double[][] sampleRates = new double[][] |
darienf | 20:6d2af70c92ab | 276 | { |
darienf | 20:6d2af70c92ab | 277 | new double[] {64, 32}, |
darienf | 20:6d2af70c92ab | 278 | new double[] {62.5, 31.25}, |
darienf | 20:6d2af70c92ab | 279 | new double[] {50, 25}, |
darienf | 20:6d2af70c92ab | 280 | new double[] {49.95, 24.98} |
darienf | 20:6d2af70c92ab | 281 | }; |
darienf | 20:6d2af70c92ab | 282 | |
darienf | 20:6d2af70c92ab | 283 | if (connected && !internalUpdate) |
darienf | 20:6d2af70c92ab | 284 | writeComboBox(cbo); |
darienf | 20:6d2af70c92ab | 285 | |
darienf | 20:6d2af70c92ab | 286 | if (cboMasterClock.SelectedIndex > -1 && cbo.SelectedIndex > -1 && cboBioZDigitalLpf.SelectedIndex > -1) // All boxes are init |
darienf | 20:6d2af70c92ab | 287 | { |
darienf | 20:6d2af70c92ab | 288 | ecgView1.SampleRateBioZ = sampleRates[cboMasterClock.SelectedIndex][cbo.SelectedIndex]; |
darienf | 20:6d2af70c92ab | 289 | |
darienf | 20:6d2af70c92ab | 290 | cboBioZDigitalLpf.Items.Clear(); |
darienf | 20:6d2af70c92ab | 291 | bioZDlpfField.Descriptions = bioZDlpfOptions[cboMasterClock.SelectedIndex][cboBioZSampleRate.SelectedIndex]; |
darienf | 20:6d2af70c92ab | 292 | bioZDlpfField.Control = cboBioZDigitalLpf; // Trigger update of descriptions |
darienf | 20:6d2af70c92ab | 293 | |
darienf | 20:6d2af70c92ab | 294 | cboBioZDigitalLpf.SelectedIndex = bioZDlpfField.ReadField(); |
darienf | 20:6d2af70c92ab | 295 | |
darienf | 20:6d2af70c92ab | 296 | } |
darienf | 20:6d2af70c92ab | 297 | } |
darienf | 20:6d2af70c92ab | 298 | |
darienf | 20:6d2af70c92ab | 299 | private void cboBioZCurrentGeneratorFrequency_SelectedIndexChanged(object sender, EventArgs e) |
darienf | 20:6d2af70c92ab | 300 | { |
darienf | 20:6d2af70c92ab | 301 | string[] currentOptions; |
darienf | 20:6d2af70c92ab | 302 | switch (cboBioZCurrentGeneratorFrequency.SelectedIndex) |
darienf | 20:6d2af70c92ab | 303 | { |
darienf | 20:6d2af70c92ab | 304 | case 0: |
darienf | 20:6d2af70c92ab | 305 | case 1: |
darienf | 20:6d2af70c92ab | 306 | case 2: |
darienf | 20:6d2af70c92ab | 307 | case 3: |
darienf | 20:6d2af70c92ab | 308 | currentOptions = bioZCgmagOptions[0]; |
darienf | 20:6d2af70c92ab | 309 | break; |
darienf | 20:6d2af70c92ab | 310 | case 4: |
darienf | 20:6d2af70c92ab | 311 | currentOptions = bioZCgmagOptions[1]; |
darienf | 20:6d2af70c92ab | 312 | break; |
darienf | 20:6d2af70c92ab | 313 | case 5: |
darienf | 20:6d2af70c92ab | 314 | currentOptions = bioZCgmagOptions[2]; |
darienf | 20:6d2af70c92ab | 315 | break; |
darienf | 20:6d2af70c92ab | 316 | case 6: |
darienf | 20:6d2af70c92ab | 317 | currentOptions = bioZCgmagOptions[3]; |
darienf | 20:6d2af70c92ab | 318 | break; |
darienf | 20:6d2af70c92ab | 319 | default: |
darienf | 20:6d2af70c92ab | 320 | currentOptions = bioZCgmagOptions[4]; |
darienf | 20:6d2af70c92ab | 321 | break; |
darienf | 20:6d2af70c92ab | 322 | } |
darienf | 20:6d2af70c92ab | 323 | |
darienf | 20:6d2af70c92ab | 324 | if (cboBioZCurrentGeneratorMagnitude.SelectedIndex >= currentOptions.Length) // Force user selection to be valid |
darienf | 20:6d2af70c92ab | 325 | { |
darienf | 20:6d2af70c92ab | 326 | cboBioZCurrentGeneratorMagnitude.SelectedIndex = currentOptions.Length - 1; |
darienf | 20:6d2af70c92ab | 327 | } |
darienf | 20:6d2af70c92ab | 328 | bioZCgmagField.Descriptions = currentOptions; |
darienf | 20:6d2af70c92ab | 329 | bioZCgmagField.Control = cboBioZCurrentGeneratorMagnitude; // Repopulate drop down options |
darienf | 20:6d2af70c92ab | 330 | } |
darienf | 20:6d2af70c92ab | 331 | |
darienf | 20:6d2af70c92ab | 332 | private void cboBioZDigitalLeadOffDetectionEnable_SelectedIndexChanged(object sender, EventArgs e) |
darienf | 20:6d2af70c92ab | 333 | { |
darienf | 20:6d2af70c92ab | 334 | MaximStyle.MaximComboBox cbo = (MaximStyle.MaximComboBox)sender; |
darienf | 20:6d2af70c92ab | 335 | |
darienf | 20:6d2af70c92ab | 336 | if (cbo.SelectedIndex == 0) |
darienf | 20:6d2af70c92ab | 337 | ecgView1.EnableBioZOverUnderRange = false; |
darienf | 20:6d2af70c92ab | 338 | else |
darienf | 20:6d2af70c92ab | 339 | ecgView1.EnableBioZOverUnderRange = true; |
darienf | 20:6d2af70c92ab | 340 | } |
darienf | 20:6d2af70c92ab | 341 | |
darienf | 20:6d2af70c92ab | 342 | } |
darienf | 20:6d2af70c92ab | 343 | } |