repo time

Dependencies:   mbed MAX14720 MAX30205 USBDevice

Committer:
darienf
Date:
Tue Apr 06 06:41:40 2021 +0000
Revision:
20:6d2af70c92ab
another repo

Who changed what in which revision?

UserRevisionLine numberNew 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;
darienf 20:6d2af70c92ab 38 using System.Collections.Generic;
darienf 20:6d2af70c92ab 39 using System.ComponentModel;
darienf 20:6d2af70c92ab 40 using System.Data;
darienf 20:6d2af70c92ab 41 using System.Drawing;
darienf 20:6d2af70c92ab 42 using System.Linq;
darienf 20:6d2af70c92ab 43 using System.Text;
darienf 20:6d2af70c92ab 44 using System.Windows.Forms;
darienf 20:6d2af70c92ab 45 using HealthSensorPlatform.CustomControls;
darienf 20:6d2af70c92ab 46 using HealthSensorPlatform;
darienf 20:6d2af70c92ab 47
darienf 20:6d2af70c92ab 48
darienf 20:6d2af70c92ab 49 namespace HealthSensorPlatform
darienf 20:6d2af70c92ab 50 {
darienf 20:6d2af70c92ab 51 // Code for ECG Input Mux Tab
darienf 20:6d2af70c92ab 52 public partial class HspForm
darienf 20:6d2af70c92ab 53 {
darienf 20:6d2af70c92ab 54 List<RegisterField> ecgInputMuxField = new List<RegisterField>();
darienf 20:6d2af70c92ab 55
darienf 20:6d2af70c92ab 56 // Needed for dynamic changing of options
darienf 20:6d2af70c92ab 57 RegisterField ecgCalFiftyField;
darienf 20:6d2af70c92ab 58
darienf 20:6d2af70c92ab 59
darienf 20:6d2af70c92ab 60 public int[] sw = new int[15];
darienf 20:6d2af70c92ab 61
darienf 20:6d2af70c92ab 62 void initalizeECGInputMuxFields()
darienf 20:6d2af70c92ab 63 {
darienf 20:6d2af70c92ab 64 string[] enDcloffOptions = { "Disabled*", "ECG Ch.", "BioZ Ch." };
darienf 20:6d2af70c92ab 65 string[] dcloffIpolOptions = { "P: Pull Up, N: Pull Down*", "P: Pull Down, N: Pull Up" };
darienf 20:6d2af70c92ab 66 string[] dcloffImagOptions = { "0nA/Disabled*", "5nA", "10nA", "20nA", "50nA", "100nA" };
darienf 20:6d2af70c92ab 67 string[] dcloffVthOptions = { "VMID ±300mV*", "VMID ±400mV", "VMID ±450mV", "VMID ±500mV" };
darienf 20:6d2af70c92ab 68
darienf 20:6d2af70c92ab 69 string[] enUlpLonOptions = { "Disabled", "ECG Ch.", "BioZ Ch." };
darienf 20:6d2af70c92ab 70
darienf 20:6d2af70c92ab 71 string[] emuxOpenpOptions = { "Connected", "Isolated*" };
darienf 20:6d2af70c92ab 72 string[] emuxOpennOptions = { "Connected", "Isolated*" };
darienf 20:6d2af70c92ab 73 string[] emuxPolOptions = { "Non-Inverted*", "Inverted" };
darienf 20:6d2af70c92ab 74
darienf 20:6d2af70c92ab 75 string[] enRbiasOptions = { "Disabled*", "ECG Bias", "BIOZ Bias" };
darienf 20:6d2af70c92ab 76 string[] rBiasvOptions = { "50MΩ", "100MΩ*", "200MΩ" };
darienf 20:6d2af70c92ab 77 string[] rBiaspOptions = { "Disconnected*", "Connected" };
darienf 20:6d2af70c92ab 78 string[] rBiasnOptions = { "Disconnected*", "Connected" };
darienf 20:6d2af70c92ab 79
darienf 20:6d2af70c92ab 80 string[] calEnVcalOptions = { "Disabled*", "Enabled" };
darienf 20:6d2af70c92ab 81 string[] calVmodeOptions = { "Unipolar*", "Bipolar" };
darienf 20:6d2af70c92ab 82 string[] calVmagOptions = { "0.25mV*", "0.50mV" };
darienf 20:6d2af70c92ab 83 string[] calFcalOptions = { "FMSTR/128 (~256Hz)", "FMSTR/512 (~64Hz)", "FMSTR/2048 (~16Hz)", "FMSTR/8192 (~4Hz)",
darienf 20:6d2af70c92ab 84 "FMSTR/2^15 (~1Hz)*", "FMSTR/2^17 (~1/4Hz)", "FMSTR/2^19 (~1/16Hz)", "FMSTR/2^21 (~1/64Hz)" };
darienf 20:6d2af70c92ab 85 string[] calFiftyOptions = { "Time High", "50%*" };
darienf 20:6d2af70c92ab 86 string[] calThighOptions = new string[2048/8]; // Assume FMSTR = 32768 Hz
darienf 20:6d2af70c92ab 87 for (int i = 0; i < 2048/8; i++)
darienf 20:6d2af70c92ab 88 {
darienf 20:6d2af70c92ab 89 calThighOptions[i] = (30.52 * i * 8).ToString("F0") + " μs";
darienf 20:6d2af70c92ab 90 }
darienf 20:6d2af70c92ab 91 calThighOptions[0] += "*"; // Default
darienf 20:6d2af70c92ab 92
darienf 20:6d2af70c92ab 93 string[] calPSelOptions = { "None*", "VMID", "VCALP", "VCALN" };
darienf 20:6d2af70c92ab 94 string[] calNSelOptions = calPSelOptions;
darienf 20:6d2af70c92ab 95
darienf 20:6d2af70c92ab 96 RegisterField enDcloffField = new RegisterField { Name = "\nEN_DCLOFF", Register = 0x10, Index = 12, Width = 2, Descriptions = enDcloffOptions, Label = lblEnDcloff, Control = cboEnDcloff , Device = max30001};
darienf 20:6d2af70c92ab 97 RegisterField dcloffIpolField = new RegisterField { Name = "DCLOFF_IPOL", Register = 0x10, Index = 11, Width = 1, Descriptions = dcloffIpolOptions, Label = lblDcloffIpol, Control = cboDcloffIpol, Device = max30001 };
darienf 20:6d2af70c92ab 98 RegisterField dcloffImagField = new RegisterField { Name = "DCLOFF_IMAG", Register = 0x10, Index = 8, Width = 3, Descriptions = dcloffImagOptions, Label = lblDcloffImag, Control = cboDcloffImag, Device = max30001 };
darienf 20:6d2af70c92ab 99 RegisterField dcloffVthField = new RegisterField { Name = "DCLOFF_VTH", Register = 0x10, Index = 6, Width = 2, Descriptions = dcloffVthOptions, Label = lblDcloffVth, Control = cboDcloffVth, Device = max30001};
darienf 20:6d2af70c92ab 100 ecgInputMuxField.Add(enDcloffField);
darienf 20:6d2af70c92ab 101 ecgInputMuxField.Add(dcloffIpolField);
darienf 20:6d2af70c92ab 102 ecgInputMuxField.Add(dcloffImagField);
darienf 20:6d2af70c92ab 103 ecgInputMuxField.Add(dcloffVthField);
darienf 20:6d2af70c92ab 104
darienf 20:6d2af70c92ab 105 RegisterField enUlpLonField = new RegisterField { Name = "\nEN_ULP_LON", Register = 0x10, Index = 22, Width = 2, Descriptions = enDcloffOptions, Label = lblEmuxEnUlpLon, Control = cboEmuxEnUlpLon, Device = max30001};
darienf 20:6d2af70c92ab 106 ecgInputMuxField.Add(enUlpLonField);
darienf 20:6d2af70c92ab 107
darienf 20:6d2af70c92ab 108
darienf 20:6d2af70c92ab 109 RegisterField emuxOpenpField = new RegisterField { Name = "EMUX_OPENP", Register = 0x14, Index = 21, Width = 1, Descriptions = emuxOpenpOptions, Label = lblEmuxOpenp, Control = cboEmuxOpenp, Device = max30001 };
darienf 20:6d2af70c92ab 110 RegisterField emuxOpennField = new RegisterField { Name = "EMUX_OPENN", Register = 0x14, Index = 20, Width = 1, Descriptions = emuxOpennOptions, Label = lblEmuxOpenn, Control = cboEmuxOpenn, Device = max30001 };
darienf 20:6d2af70c92ab 111 RegisterField emuxPolField = new RegisterField { Name = "EMUX_POL", Register = 0x14, Index = 23, Width = 1, Descriptions = emuxPolOptions, Label = lblEmuxPol, Control = cboEmuxPol, Device = max30001 };
darienf 20:6d2af70c92ab 112 ecgInputMuxField.Add(emuxOpenpField);
darienf 20:6d2af70c92ab 113 ecgInputMuxField.Add(emuxOpennField);
darienf 20:6d2af70c92ab 114 ecgInputMuxField.Add(emuxPolField);
darienf 20:6d2af70c92ab 115
darienf 20:6d2af70c92ab 116 RegisterField enRbiasField = new RegisterField { Name = "\nEN_RBIAS", Register = 0x10, Index = 4, Width = 2, Descriptions = enDcloffOptions, Label = lblEnRbias, Control = cboEnRbias, Device = max30001 };
darienf 20:6d2af70c92ab 117 RegisterField rBiasvField = new RegisterField { Name = "RBIASV", Register = 0x10, Index = 2, Width = 2, Descriptions = rBiasvOptions, Label = lblRbiasv, Control = cboRbiasv, Device = max30001 };
darienf 20:6d2af70c92ab 118 RegisterField rBiaspField = new RegisterField { Name = "RBIASP", Register = 0x10, Index = 1, Width = 1, Descriptions = rBiaspOptions, Label = lblRbiasp, Control = cboRbiasp, Device = max30001 };
darienf 20:6d2af70c92ab 119 RegisterField rBiasnField = new RegisterField { Name = "RBIASN", Register = 0x10, Index = 0, Width = 1, Descriptions = rBiasnOptions, Label = lblRbiasn, Control = cboRbiasn, Device = max30001 };
darienf 20:6d2af70c92ab 120 ecgInputMuxField.Add(enRbiasField);
darienf 20:6d2af70c92ab 121 ecgInputMuxField.Add(rBiasvField);
darienf 20:6d2af70c92ab 122 ecgInputMuxField.Add(rBiaspField);
darienf 20:6d2af70c92ab 123 ecgInputMuxField.Add(rBiasnField);
darienf 20:6d2af70c92ab 124
darienf 20:6d2af70c92ab 125 RegisterField calEnVcalField = new RegisterField { Name = "CAL_EN_VCAL", Register = 0x12, Index = 22, Width = 1, Descriptions = calEnVcalOptions, Label = lblCalEnVcal, Control = cboCalEnVcal, Device = max30001 };
darienf 20:6d2af70c92ab 126 RegisterField calVmodeField = new RegisterField { Name = "CAL_VMODE", Register = 0x12, Index = 21, Width = 1, Descriptions = calVmodeOptions, Label = lblCalVMode, Control = cboCalVmode, Device = max30001 };
darienf 20:6d2af70c92ab 127 RegisterField calVmagField = new RegisterField { Name = "CAL_VMAG", Register = 0x12, Index = 20, Width = 1, Descriptions = calVmagOptions, Label = lblCalVmag, Control = cboCalVmag, Device = max30001 };
darienf 20:6d2af70c92ab 128 RegisterField calFcalField = new RegisterField { Name = "CAL_FCAL", Register = 0x12, Index = 12, Width = 3, Descriptions = calFcalOptions, Label = lblCalFreq, Control = cboCalFcal, Device = max30001 };
darienf 20:6d2af70c92ab 129 ecgCalFiftyField = new RegisterField { Name = "CAL_FIFTY", Register = 0x12, Index = 11, Width = 1, Descriptions = calFiftyOptions, Label = lblCalFifty, Control = cboCalFifty, Device = max30001 };
darienf 20:6d2af70c92ab 130 RegisterField calThighField = new RegisterField { Name = "CAL_THIGH", Register = 0x12, Index = 3, Width = 8, Descriptions = calThighOptions, Label = lblCalTHigh, Control = cboCalThigh, Device = max30001 };
darienf 20:6d2af70c92ab 131 // Decreasing GUI options from 2048 to 256
darienf 20:6d2af70c92ab 132 //RegisterField calThighField = new RegisterField { Name = "CAL_THIGH", Register = 0x12, Index = 0, Width = 10, Descriptions = calThighOptions, Label = lblCalTHigh };
darienf 20:6d2af70c92ab 133 ecgInputMuxField.Add(calEnVcalField);
darienf 20:6d2af70c92ab 134 ecgInputMuxField.Add(calVmodeField);
darienf 20:6d2af70c92ab 135 ecgInputMuxField.Add(calVmagField);
darienf 20:6d2af70c92ab 136 ecgInputMuxField.Add(calFcalField);
darienf 20:6d2af70c92ab 137 ecgInputMuxField.Add(ecgCalFiftyField);
darienf 20:6d2af70c92ab 138 ecgInputMuxField.Add(calThighField);
darienf 20:6d2af70c92ab 139
darienf 20:6d2af70c92ab 140 RegisterField calPSelField = new RegisterField { Name = "EMUX_CALP_SEL", Register = 0x14, Index = 18, Width = 2, Descriptions = calPSelOptions, Label = lblEmuxCalPSel, Control = cboEmuxCalPSel, Device = max30001 };
darienf 20:6d2af70c92ab 141 RegisterField calNSelField = new RegisterField { Name = "EMUX_CALN_SEL", Register = 0x14, Index = 16, Width = 2, Descriptions = calNSelOptions, Label = lblEmuxCalNSel, Control = cboEmuxCalNSel, Device = max30001 };
darienf 20:6d2af70c92ab 142 ecgInputMuxField.Add(calPSelField);
darienf 20:6d2af70c92ab 143 ecgInputMuxField.Add(calNSelField);
darienf 20:6d2af70c92ab 144 }
darienf 20:6d2af70c92ab 145
darienf 20:6d2af70c92ab 146 void ECGInputMuxUpdateRegisters()
darienf 20:6d2af70c92ab 147 {
darienf 20:6d2af70c92ab 148 internalUpdate = true;
darienf 20:6d2af70c92ab 149 ReadComboBoxesRegisters(ecgInputMuxField);
darienf 20:6d2af70c92ab 150 internalUpdate = false;
darienf 20:6d2af70c92ab 151 }
darienf 20:6d2af70c92ab 152
darienf 20:6d2af70c92ab 153 private void cboCalFifty_SelectedIndexChanged(object sender, EventArgs e)
darienf 20:6d2af70c92ab 154 {
darienf 20:6d2af70c92ab 155 if (cboCalFifty.SelectedIndex == 1)
darienf 20:6d2af70c92ab 156 {
darienf 20:6d2af70c92ab 157 cboCalThigh.Enabled = false;
darienf 20:6d2af70c92ab 158 }
darienf 20:6d2af70c92ab 159 else
darienf 20:6d2af70c92ab 160 {
darienf 20:6d2af70c92ab 161 cboCalThigh.Enabled = true;
darienf 20:6d2af70c92ab 162 }
darienf 20:6d2af70c92ab 163 }
darienf 20:6d2af70c92ab 164
darienf 20:6d2af70c92ab 165 private void cboEnDcloff_SelectedIndexChanged(object sender, EventArgs e)
darienf 20:6d2af70c92ab 166 {
darienf 20:6d2af70c92ab 167 MaximStyle.MaximComboBox cbo = (MaximStyle.MaximComboBox)sender;
darienf 20:6d2af70c92ab 168
darienf 20:6d2af70c92ab 169 if (cbo.SelectedIndex == 0)
darienf 20:6d2af70c92ab 170 {
darienf 20:6d2af70c92ab 171 ecgView1.EnableDCLeadOff = false;
darienf 20:6d2af70c92ab 172 }
darienf 20:6d2af70c92ab 173 else
darienf 20:6d2af70c92ab 174 {
darienf 20:6d2af70c92ab 175 ecgView1.EnableDCLeadOff = true;
darienf 20:6d2af70c92ab 176 if (cbo.SelectedIndex == 1)
darienf 20:6d2af70c92ab 177 ecgView1.EnableEcgDCLeadOff = true;
darienf 20:6d2af70c92ab 178 else
darienf 20:6d2af70c92ab 179 ecgView1.EnableEcgDCLeadOff = false;
darienf 20:6d2af70c92ab 180 }
darienf 20:6d2af70c92ab 181
darienf 20:6d2af70c92ab 182 redrawEcgMuxImage();
darienf 20:6d2af70c92ab 183 }
darienf 20:6d2af70c92ab 184
darienf 20:6d2af70c92ab 185 private void cboDcloffIpol_SelectedIndexChanged(object sender, EventArgs e)
darienf 20:6d2af70c92ab 186 {
darienf 20:6d2af70c92ab 187 redrawEcgMuxImage();
darienf 20:6d2af70c92ab 188 }
darienf 20:6d2af70c92ab 189
darienf 20:6d2af70c92ab 190 private void cboEmuxEnUlpLon_SelectedIndexChanged(object sender, EventArgs e)
darienf 20:6d2af70c92ab 191 {
darienf 20:6d2af70c92ab 192 redrawEcgMuxImage();
darienf 20:6d2af70c92ab 193 }
darienf 20:6d2af70c92ab 194
darienf 20:6d2af70c92ab 195 private void cboEmuxOpenp_SelectedIndexChanged(object sender, EventArgs e)
darienf 20:6d2af70c92ab 196 {
darienf 20:6d2af70c92ab 197 redrawEcgMuxImage();
darienf 20:6d2af70c92ab 198 }
darienf 20:6d2af70c92ab 199
darienf 20:6d2af70c92ab 200 private void cboEmuxOpenn_SelectedIndexChanged(object sender, EventArgs e)
darienf 20:6d2af70c92ab 201 {
darienf 20:6d2af70c92ab 202 redrawEcgMuxImage();
darienf 20:6d2af70c92ab 203 }
darienf 20:6d2af70c92ab 204
darienf 20:6d2af70c92ab 205 private void cboEmuxPol_SelectedIndexChanged(object sender, EventArgs e)
darienf 20:6d2af70c92ab 206 {
darienf 20:6d2af70c92ab 207 redrawEcgMuxImage();
darienf 20:6d2af70c92ab 208 }
darienf 20:6d2af70c92ab 209
darienf 20:6d2af70c92ab 210 private void cboEnRbias_SelectedIndexChanged(object sender, EventArgs e)
darienf 20:6d2af70c92ab 211 {
darienf 20:6d2af70c92ab 212 redrawEcgMuxImage();
darienf 20:6d2af70c92ab 213 }
darienf 20:6d2af70c92ab 214
darienf 20:6d2af70c92ab 215 private void cboRbiasp_SelectedIndexChanged(object sender, EventArgs e)
darienf 20:6d2af70c92ab 216 {
darienf 20:6d2af70c92ab 217 redrawEcgMuxImage();
darienf 20:6d2af70c92ab 218 }
darienf 20:6d2af70c92ab 219
darienf 20:6d2af70c92ab 220 private void cboRbiasn_SelectedIndexChanged(object sender, EventArgs e)
darienf 20:6d2af70c92ab 221 {
darienf 20:6d2af70c92ab 222 redrawEcgMuxImage();
darienf 20:6d2af70c92ab 223 }
darienf 20:6d2af70c92ab 224
darienf 20:6d2af70c92ab 225 private void cboCalEnVcal_SelectedIndexChanged(object sender, EventArgs e)
darienf 20:6d2af70c92ab 226 {
darienf 20:6d2af70c92ab 227 redrawEcgMuxImage();
darienf 20:6d2af70c92ab 228 }
darienf 20:6d2af70c92ab 229
darienf 20:6d2af70c92ab 230 private void cboEmuxCalPSel_SelectedIndexChanged(object sender, EventArgs e)
darienf 20:6d2af70c92ab 231 {
darienf 20:6d2af70c92ab 232 redrawEcgMuxImage();
darienf 20:6d2af70c92ab 233 }
darienf 20:6d2af70c92ab 234
darienf 20:6d2af70c92ab 235 private void cboEmuxCalNSel_SelectedIndexChanged(object sender, EventArgs e)
darienf 20:6d2af70c92ab 236 {
darienf 20:6d2af70c92ab 237 redrawEcgMuxImage();
darienf 20:6d2af70c92ab 238 }
darienf 20:6d2af70c92ab 239
darienf 20:6d2af70c92ab 240 private void redrawEcgMuxImage()
darienf 20:6d2af70c92ab 241 {
darienf 20:6d2af70c92ab 242 processSwitchState();
darienf 20:6d2af70c92ab 243
darienf 20:6d2af70c92ab 244 redrawSwitches();
darienf 20:6d2af70c92ab 245 }
darienf 20:6d2af70c92ab 246
darienf 20:6d2af70c92ab 247 private void processSwitchState()
darienf 20:6d2af70c92ab 248 {
darienf 20:6d2af70c92ab 249 //Logic for panel 1
darienf 20:6d2af70c92ab 250 if (cboEnDcloff.SelectedIndex == 1)
darienf 20:6d2af70c92ab 251 {
darienf 20:6d2af70c92ab 252 if (cboDcloffIpol.SelectedIndex == 0)
darienf 20:6d2af70c92ab 253 {
darienf 20:6d2af70c92ab 254 sw[1] = 0;
darienf 20:6d2af70c92ab 255 sw[2] = 1;
darienf 20:6d2af70c92ab 256 sw[10] = 1;
darienf 20:6d2af70c92ab 257 sw[11] = 0;
darienf 20:6d2af70c92ab 258 }
darienf 20:6d2af70c92ab 259 else
darienf 20:6d2af70c92ab 260 {
darienf 20:6d2af70c92ab 261 sw[1] = 1;
darienf 20:6d2af70c92ab 262 sw[2] = 0;
darienf 20:6d2af70c92ab 263 sw[10] = 0;
darienf 20:6d2af70c92ab 264 sw[11] = 1;
darienf 20:6d2af70c92ab 265 }
darienf 20:6d2af70c92ab 266 }
darienf 20:6d2af70c92ab 267 else
darienf 20:6d2af70c92ab 268 {
darienf 20:6d2af70c92ab 269 sw[1] = 0;
darienf 20:6d2af70c92ab 270 sw[2] = 0;
darienf 20:6d2af70c92ab 271 sw[10] = 0;
darienf 20:6d2af70c92ab 272 sw[11] = 0;
darienf 20:6d2af70c92ab 273 }
darienf 20:6d2af70c92ab 274 //Logic for panel 2
darienf 20:6d2af70c92ab 275 if (cboEmuxEnUlpLon.SelectedIndex == 1)
darienf 20:6d2af70c92ab 276 {
darienf 20:6d2af70c92ab 277 sw[3] = 1;
darienf 20:6d2af70c92ab 278 sw[12] = 1;
darienf 20:6d2af70c92ab 279 }
darienf 20:6d2af70c92ab 280 else
darienf 20:6d2af70c92ab 281 {
darienf 20:6d2af70c92ab 282 sw[3] = 0;
darienf 20:6d2af70c92ab 283 sw[12] = 0;
darienf 20:6d2af70c92ab 284 }
darienf 20:6d2af70c92ab 285 //Logic for panel 3
darienf 20:6d2af70c92ab 286 if (cboEmuxPol.SelectedIndex == 0)
darienf 20:6d2af70c92ab 287 {
darienf 20:6d2af70c92ab 288 sw[7] = 0;
darienf 20:6d2af70c92ab 289 sw[8] = 0;
darienf 20:6d2af70c92ab 290 if (cboEmuxOpenp.SelectedIndex == 0)
darienf 20:6d2af70c92ab 291 {
darienf 20:6d2af70c92ab 292 sw[6] = 1;
darienf 20:6d2af70c92ab 293 }
darienf 20:6d2af70c92ab 294 else
darienf 20:6d2af70c92ab 295 {
darienf 20:6d2af70c92ab 296 sw[6] = 0;
darienf 20:6d2af70c92ab 297 }
darienf 20:6d2af70c92ab 298 if (cboEmuxOpenn.SelectedIndex == 0)
darienf 20:6d2af70c92ab 299 {
darienf 20:6d2af70c92ab 300 sw[9] = 1;
darienf 20:6d2af70c92ab 301 }
darienf 20:6d2af70c92ab 302 else
darienf 20:6d2af70c92ab 303 {
darienf 20:6d2af70c92ab 304 sw[9] = 0;
darienf 20:6d2af70c92ab 305 }
darienf 20:6d2af70c92ab 306 }
darienf 20:6d2af70c92ab 307 else
darienf 20:6d2af70c92ab 308 {
darienf 20:6d2af70c92ab 309 sw[6] = 0;
darienf 20:6d2af70c92ab 310 sw[9] = 0;
darienf 20:6d2af70c92ab 311 if (cboEmuxOpenp.SelectedIndex == 0)
darienf 20:6d2af70c92ab 312 {
darienf 20:6d2af70c92ab 313 sw[7] = 1;
darienf 20:6d2af70c92ab 314 }
darienf 20:6d2af70c92ab 315 else
darienf 20:6d2af70c92ab 316 {
darienf 20:6d2af70c92ab 317 sw[7] = 0;
darienf 20:6d2af70c92ab 318 }
darienf 20:6d2af70c92ab 319 if (cboEmuxOpenn.SelectedIndex == 0)
darienf 20:6d2af70c92ab 320 {
darienf 20:6d2af70c92ab 321 sw[8] = 1;
darienf 20:6d2af70c92ab 322 }
darienf 20:6d2af70c92ab 323 else
darienf 20:6d2af70c92ab 324 {
darienf 20:6d2af70c92ab 325 sw[8] = 0;
darienf 20:6d2af70c92ab 326 }
darienf 20:6d2af70c92ab 327 }
darienf 20:6d2af70c92ab 328 //Logic for panel 4
darienf 20:6d2af70c92ab 329 if (cboEnRbias.SelectedIndex == 1)
darienf 20:6d2af70c92ab 330 {
darienf 20:6d2af70c92ab 331 if (cboRbiasp.SelectedIndex == 1)
darienf 20:6d2af70c92ab 332 sw[4] = 1;
darienf 20:6d2af70c92ab 333 else
darienf 20:6d2af70c92ab 334 sw[4] = 0;
darienf 20:6d2af70c92ab 335 if (cboRbiasn.SelectedIndex == 1)
darienf 20:6d2af70c92ab 336 sw[13] = 1;
darienf 20:6d2af70c92ab 337 else
darienf 20:6d2af70c92ab 338 sw[13] = 0;
darienf 20:6d2af70c92ab 339 }
darienf 20:6d2af70c92ab 340 else
darienf 20:6d2af70c92ab 341 {
darienf 20:6d2af70c92ab 342 sw[4] = 0;
darienf 20:6d2af70c92ab 343 sw[13] = 0;
darienf 20:6d2af70c92ab 344 }
darienf 20:6d2af70c92ab 345 //Logic 5
darienf 20:6d2af70c92ab 346 if (cboCalEnVcal.SelectedIndex == 1)
darienf 20:6d2af70c92ab 347 {
darienf 20:6d2af70c92ab 348 if (cboEmuxCalPSel.SelectedIndex == 1 | cboEmuxCalPSel.SelectedIndex == 2 |
darienf 20:6d2af70c92ab 349 cboEmuxCalPSel.SelectedIndex == 3)
darienf 20:6d2af70c92ab 350 sw[5] = 1;
darienf 20:6d2af70c92ab 351 else
darienf 20:6d2af70c92ab 352 {
darienf 20:6d2af70c92ab 353 sw[5] = 0;
darienf 20:6d2af70c92ab 354 }
darienf 20:6d2af70c92ab 355 if (cboEmuxCalNSel.SelectedIndex == 1 | cboEmuxCalNSel.SelectedIndex == 2 |
darienf 20:6d2af70c92ab 356 cboEmuxCalNSel.SelectedIndex == 3)
darienf 20:6d2af70c92ab 357 sw[14] = 1;
darienf 20:6d2af70c92ab 358 else
darienf 20:6d2af70c92ab 359 {
darienf 20:6d2af70c92ab 360 sw[14] = 0;
darienf 20:6d2af70c92ab 361 }
darienf 20:6d2af70c92ab 362 }
darienf 20:6d2af70c92ab 363 else
darienf 20:6d2af70c92ab 364 {
darienf 20:6d2af70c92ab 365 sw[5] = 0;
darienf 20:6d2af70c92ab 366 sw[14] = 0;
darienf 20:6d2af70c92ab 367 }
darienf 20:6d2af70c92ab 368 }
darienf 20:6d2af70c92ab 369
darienf 20:6d2af70c92ab 370 private void redrawSwitches()
darienf 20:6d2af70c92ab 371 {
darienf 20:6d2af70c92ab 372 // Dispose all Images
darienf 20:6d2af70c92ab 373 if (picSw1.Image != null)
darienf 20:6d2af70c92ab 374 picSw1.Image.Dispose();
darienf 20:6d2af70c92ab 375 if (picSw2.Image != null)
darienf 20:6d2af70c92ab 376 picSw2.Image.Dispose();
darienf 20:6d2af70c92ab 377 if (picSw3.Image != null)
darienf 20:6d2af70c92ab 378 picSw3.Image.Dispose();
darienf 20:6d2af70c92ab 379 if (picSw4.Image != null)
darienf 20:6d2af70c92ab 380 picSw4.Image.Dispose();
darienf 20:6d2af70c92ab 381 if (picSw5.Image != null)
darienf 20:6d2af70c92ab 382 picSw5.Image.Dispose();
darienf 20:6d2af70c92ab 383 if (picSw6.Image != null)
darienf 20:6d2af70c92ab 384 picSw6.Image.Dispose();
darienf 20:6d2af70c92ab 385 if (picSw7.Image != null)
darienf 20:6d2af70c92ab 386 picSw7.Image.Dispose();
darienf 20:6d2af70c92ab 387 if (picSw8.Image != null)
darienf 20:6d2af70c92ab 388 picSw8.Image.Dispose();
darienf 20:6d2af70c92ab 389 if (picSw9.Image != null)
darienf 20:6d2af70c92ab 390 picSw9.Image.Dispose();
darienf 20:6d2af70c92ab 391 if (picSw10.Image != null)
darienf 20:6d2af70c92ab 392 picSw10.Image.Dispose();
darienf 20:6d2af70c92ab 393 if (picSw11.Image != null)
darienf 20:6d2af70c92ab 394 picSw11.Image.Dispose();
darienf 20:6d2af70c92ab 395 if (picSw12.Image != null)
darienf 20:6d2af70c92ab 396 picSw12.Image.Dispose();
darienf 20:6d2af70c92ab 397 if (picSw13.Image != null)
darienf 20:6d2af70c92ab 398 picSw13.Image.Dispose();
darienf 20:6d2af70c92ab 399 if (picSw14.Image != null)
darienf 20:6d2af70c92ab 400 picSw14.Image.Dispose();
darienf 20:6d2af70c92ab 401
darienf 20:6d2af70c92ab 402 if (sw[1] == 1)
darienf 20:6d2af70c92ab 403 picSw1.Image = Properties.Resources.sw1;
darienf 20:6d2af70c92ab 404 else
darienf 20:6d2af70c92ab 405 picSw1.Image = null;
darienf 20:6d2af70c92ab 406 if (sw[2] == 1)
darienf 20:6d2af70c92ab 407 picSw2.Image = Properties.Resources.sw2;
darienf 20:6d2af70c92ab 408 else
darienf 20:6d2af70c92ab 409 picSw2.Image = null;
darienf 20:6d2af70c92ab 410 if (sw[3] == 1)
darienf 20:6d2af70c92ab 411 picSw3.Image = Properties.Resources.sw3;
darienf 20:6d2af70c92ab 412 else
darienf 20:6d2af70c92ab 413 picSw3.Image = null;
darienf 20:6d2af70c92ab 414 if (sw[4] == 1)
darienf 20:6d2af70c92ab 415 picSw4.Image = Properties.Resources.sw4;
darienf 20:6d2af70c92ab 416 else
darienf 20:6d2af70c92ab 417 picSw4.Image = null;
darienf 20:6d2af70c92ab 418 if (sw[5] == 1)
darienf 20:6d2af70c92ab 419 picSw5.Image = Properties.Resources.sw5;
darienf 20:6d2af70c92ab 420 else
darienf 20:6d2af70c92ab 421 picSw5.Image = null;
darienf 20:6d2af70c92ab 422 if (sw[6] == 1)
darienf 20:6d2af70c92ab 423 picSw6.Image = Properties.Resources.sw6;
darienf 20:6d2af70c92ab 424 else
darienf 20:6d2af70c92ab 425 picSw6.Image = null;
darienf 20:6d2af70c92ab 426 if (sw[7] == 1)
darienf 20:6d2af70c92ab 427 picSw7.Image = Properties.Resources.sw7;
darienf 20:6d2af70c92ab 428 else
darienf 20:6d2af70c92ab 429 picSw7.Image = null;
darienf 20:6d2af70c92ab 430 if (sw[8] == 1)
darienf 20:6d2af70c92ab 431 picSw8.Image = Properties.Resources.sw8;
darienf 20:6d2af70c92ab 432 else
darienf 20:6d2af70c92ab 433 picSw8.Image = null;
darienf 20:6d2af70c92ab 434 if (sw[9] == 1)
darienf 20:6d2af70c92ab 435 picSw9.Image = Properties.Resources.sw9;
darienf 20:6d2af70c92ab 436 else
darienf 20:6d2af70c92ab 437 picSw9.Image = null;
darienf 20:6d2af70c92ab 438 if (sw[10] == 1)
darienf 20:6d2af70c92ab 439 picSw10.Image = Properties.Resources.sw10;
darienf 20:6d2af70c92ab 440 else
darienf 20:6d2af70c92ab 441 picSw10.Image = null;
darienf 20:6d2af70c92ab 442 if (sw[11] == 1)
darienf 20:6d2af70c92ab 443 picSw11.Image = Properties.Resources.sw11;
darienf 20:6d2af70c92ab 444 else
darienf 20:6d2af70c92ab 445 picSw11.Image = null;
darienf 20:6d2af70c92ab 446 if (sw[12] == 1)
darienf 20:6d2af70c92ab 447 picSw12.Image = Properties.Resources.sw12;
darienf 20:6d2af70c92ab 448 else
darienf 20:6d2af70c92ab 449 picSw12.Image = null;
darienf 20:6d2af70c92ab 450 if (sw[13] == 1)
darienf 20:6d2af70c92ab 451 picSw13.Image = Properties.Resources.sw13;
darienf 20:6d2af70c92ab 452 else
darienf 20:6d2af70c92ab 453 picSw13.Image = null;
darienf 20:6d2af70c92ab 454 if (sw[14] == 1)
darienf 20:6d2af70c92ab 455 picSw14.Image = Properties.Resources.sw14;
darienf 20:6d2af70c92ab 456 else
darienf 20:6d2af70c92ab 457 picSw14.Image = null;
darienf 20:6d2af70c92ab 458 }
darienf 20:6d2af70c92ab 459
darienf 20:6d2af70c92ab 460
darienf 20:6d2af70c92ab 461 private InitArgs.EcgInitStart getEcgArgs()
darienf 20:6d2af70c92ab 462 {
darienf 20:6d2af70c92ab 463 InitArgs.EcgInitStart initArgs = new CustomControls.InitArgs.EcgInitStart();
darienf 20:6d2af70c92ab 464
darienf 20:6d2af70c92ab 465 initArgs.Openp = cboEmuxOpenp.SelectedIndex;
darienf 20:6d2af70c92ab 466 initArgs.Openn = cboEmuxOpenn.SelectedIndex;
darienf 20:6d2af70c92ab 467 initArgs.Pol = cboEmuxPol.SelectedIndex;
darienf 20:6d2af70c92ab 468 initArgs.Calp_sel = cboEmuxCalPSel.SelectedIndex;
darienf 20:6d2af70c92ab 469 initArgs.Caln_sel = cboEmuxCalNSel.SelectedIndex;
darienf 20:6d2af70c92ab 470 //initArgs.En_ecg = cboECGChannelEnable.SelectedIndex;
darienf 20:6d2af70c92ab 471 initArgs.En_ecg = chkEnECG.Checked ? 1 : 0;
darienf 20:6d2af70c92ab 472 initArgs.E_fit = 15;//0x1F; // TODO
darienf 20:6d2af70c92ab 473 initArgs.Rate = cboSampleRate.SelectedIndex;
darienf 20:6d2af70c92ab 474 initArgs.Gain = cboChannelGain.SelectedIndex;
darienf 20:6d2af70c92ab 475 initArgs.Dhpf = cboDhpf.SelectedIndex;
darienf 20:6d2af70c92ab 476 initArgs.Dlpf = cboDlpf.SelectedIndex;
darienf 20:6d2af70c92ab 477
darienf 20:6d2af70c92ab 478 return initArgs;
darienf 20:6d2af70c92ab 479 }
darienf 20:6d2af70c92ab 480
darienf 20:6d2af70c92ab 481 private void setEcgArgs(InitArgs.EcgInitStart initArgs)
darienf 20:6d2af70c92ab 482 {
darienf 20:6d2af70c92ab 483 cboEmuxOpenp.SelectedIndex = initArgs.Openp;
darienf 20:6d2af70c92ab 484 cboEmuxOpenn.SelectedIndex = initArgs.Openn;
darienf 20:6d2af70c92ab 485 cboEmuxPol.SelectedIndex = initArgs.Pol;
darienf 20:6d2af70c92ab 486 cboEmuxCalPSel.SelectedIndex = initArgs.Calp_sel;
darienf 20:6d2af70c92ab 487 cboEmuxCalNSel.SelectedIndex = initArgs.Caln_sel;
darienf 20:6d2af70c92ab 488 //initArgs.En_ecg = cboECGChannelEnable.SelectedIndex;
darienf 20:6d2af70c92ab 489 //initArgs.En_ecg = chkEnECG.Checked == true ? 1 : 0;
darienf 20:6d2af70c92ab 490 //initArgs.E_fit = 15;//0x1F;
darienf 20:6d2af70c92ab 491 cboSampleRate.SelectedIndex = initArgs.Rate;
darienf 20:6d2af70c92ab 492 cboChannelGain.SelectedIndex = initArgs.Gain;
darienf 20:6d2af70c92ab 493 cboDhpf.SelectedIndex = initArgs.Dhpf;
darienf 20:6d2af70c92ab 494 cboDlpf.SelectedIndex = initArgs.Dlpf;
darienf 20:6d2af70c92ab 495 }
darienf 20:6d2af70c92ab 496
darienf 20:6d2af70c92ab 497 private InitArgs.FMSTRInitStart getFMSTRArgs()
darienf 20:6d2af70c92ab 498 {
darienf 20:6d2af70c92ab 499 InitArgs.FMSTRInitStart initArgs = new InitArgs.FMSTRInitStart();
darienf 20:6d2af70c92ab 500
darienf 20:6d2af70c92ab 501 initArgs.En_rbias = cboEnRbias.SelectedIndex;
darienf 20:6d2af70c92ab 502 initArgs.Rbiasv = cboRbiasv.SelectedIndex;
darienf 20:6d2af70c92ab 503 initArgs.Rbiasp = cboRbiasp.SelectedIndex;
darienf 20:6d2af70c92ab 504 initArgs.Rbiasn = cboRbiasn.SelectedIndex;
darienf 20:6d2af70c92ab 505 initArgs.Fmstr = cboMasterClock.SelectedIndex;
darienf 20:6d2af70c92ab 506
darienf 20:6d2af70c92ab 507 return initArgs;
darienf 20:6d2af70c92ab 508 }
darienf 20:6d2af70c92ab 509
darienf 20:6d2af70c92ab 510 private void setFMSTRArgs(InitArgs.FMSTRInitStart initArgs)
darienf 20:6d2af70c92ab 511 {
darienf 20:6d2af70c92ab 512 cboEnRbias.SelectedIndex = initArgs.En_rbias;
darienf 20:6d2af70c92ab 513 cboRbiasv.SelectedIndex = initArgs.Rbiasv;
darienf 20:6d2af70c92ab 514 cboRbiasp.SelectedIndex = initArgs.Rbiasp;
darienf 20:6d2af70c92ab 515 cboRbiasn.SelectedIndex = initArgs.Rbiasn;
darienf 20:6d2af70c92ab 516 cboMasterClock.SelectedIndex = initArgs.Fmstr;
darienf 20:6d2af70c92ab 517 }
darienf 20:6d2af70c92ab 518
darienf 20:6d2af70c92ab 519 }
darienf 20:6d2af70c92ab 520 }