Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
ECGChannel.cs
00001 /******************************************************************************* 00002 * Copyright (C) 2016 Maxim Integrated Products, Inc., All rights Reserved. 00003 * 00004 * This software is protected by copyright laws of the United States and 00005 * of foreign countries. This material may also be protected by patent laws 00006 * and technology transfer regulations of the United States and of foreign 00007 * countries. This software is furnished under a license agreement and/or a 00008 * nondisclosure agreement and may only be used or reproduced in accordance 00009 * with the terms of those agreements. Dissemination of this information to 00010 * any party or parties not specified in the license agreement and/or 00011 * nondisclosure agreement is expressly prohibited. 00012 * 00013 * The above copyright notice and this permission notice shall be included 00014 * in all copies or substantial portions of the Software. 00015 * 00016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00017 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00018 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00019 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES 00020 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00021 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00022 * OTHER DEALINGS IN THE SOFTWARE. 00023 * 00024 * Except as contained in this notice, the name of Maxim Integrated 00025 * Products, Inc. shall not be used except as stated in the Maxim Integrated 00026 * Products, Inc. Branding Policy. 00027 * 00028 * The mere transfer of this software does not imply any licenses 00029 * of trade secrets, proprietary technology, copyrights, patents, 00030 * trademarks, maskwork rights, or any other form of intellectual 00031 * property whatsoever. Maxim Integrated Products, Inc. retains all 00032 * ownership rights. 00033 ******************************************************************************* 00034 */ 00035 00036 using System; 00037 using System.Collections.Generic; 00038 using System.ComponentModel; 00039 using System.Data; 00040 using System.Drawing; 00041 using System.Linq; 00042 using System.Text; 00043 using System.Windows.Forms; 00044 00045 namespace HealthSensorPlatform 00046 { 00047 // Code for ECG Configuration Tab 00048 public partial class HspForm 00049 { 00050 List<RegisterField> ecgChannelField = new List<RegisterField>(); 00051 List<RegisterField> ecgGlobalField = new List<RegisterField>(); 00052 List<RegisterField> rToRField = new List<RegisterField>(); 00053 00054 List<RegisterField> channelEnableField = new List<RegisterField>(); 00055 00056 // Needed for dynamic changing of options 00057 RegisterField ecgSampleRateField; 00058 RegisterField ecgDlpfField; 00059 00060 string[][] ecgSampleRateOptions = new string[][] 00061 { 00062 new string[] { "512 sps", "256 sps", "128 sps*" }, 00063 new string[] { "500 sps", "250 sps", "125 sps*" }, 00064 new string[] { "N/A", "N/A", "200 sps*" }, 00065 new string[] { "N/A", "N/A", "199.8 sps*" } 00066 }; 00067 00068 double[][] ecgSampleRates = new double[][] 00069 { 00070 new double[] {512, 256, 128, 128}, 00071 new double[] {500, 250, 125, 125}, 00072 new double[] {200, 200, 200, 200}, 00073 new double[] {199.8, 199.8, 199.8, 199.8} // using 200, the error is 0.1% 00074 }; 00075 00076 string[][][] ecgDlpfOptions; 00077 00078 00079 void initalizeECGConfigFields() 00080 { 00081 ecgDlpfOptions = new string[4][][]; 00082 00083 for (int i = 0; i < 4; i++) 00084 { 00085 ecgDlpfOptions[i] = new string[4][]; 00086 } 00087 00088 // 32768 Hz 00089 ecgDlpfOptions[0][0] = new string[] {"Bypass (00)", "40.96 Hz (01)*", "102.4 Hz (10)", "153.6 Hz (11)"}; 00090 ecgDlpfOptions[0][1] = new string[] {"Bypass (00)", "40.96 Hz (01)*", "102.4 Hz (10)"};//, "40.96 Hz (11)"}; 00091 ecgDlpfOptions[0][2] = new string[] {"Bypass (00)", "40.96 Hz (01)*"}; //, "40.96 Hz (10)", "40.96 Hz (11)"}; 00092 ecgDlpfOptions[0][3] = new string[] {"Bypass (00)", "40.96 Hz (01)*"}; //, "40.96 Hz (10)", "40.96 Hz (11)"}; 00093 // 32000 Hz 00094 ecgDlpfOptions[1][0] = new string[] { "Bypass (00)", "40.00 Hz (01)*", "100.0 Hz (10)", "150.0 Hz (11)"}; 00095 ecgDlpfOptions[1][1] = new string[] {"Bypass (00)", "40.00 Hz (01)*", "100.0 Hz (10)"}; //, "40.00 Hz (11)"}; 00096 ecgDlpfOptions[1][2] = new string[] {"Bypass (00)", "40.00 Hz (01)*"}; //, "40.00 Hz (10)", "40.00 Hz (11)"}; 00097 ecgDlpfOptions[1][3] = new string[] {"Bypass (00)", "40.00 Hz (01)*"}; //, "40.00 Hz (10)", "40.00 Hz (11)"}; 00098 //32000 Hz 00099 ecgDlpfOptions[2][0] = new string[] { "Bypass", "40.00 Hz"}; //, "40.00 Hz", "40.00 Hz" }; 00100 ecgDlpfOptions[2][1] = new string[] { "Bypass", "40.00 Hz"}; //, "40.00 Hz", "40.00 Hz" }; 00101 ecgDlpfOptions[2][2] = new string[] { "Bypass", "40.00 Hz"}; //, "40.00 Hz", "40.00 Hz" }; 00102 ecgDlpfOptions[2][3] = new string[] { "Bypass", "40.00 Hz"}; //, "40.00 Hz", "40.00 Hz" }; 00103 // 31968 Hz 00104 ecgDlpfOptions[3][0] = new string[] { "Bypass (00)", "39.96 Hz (01)" }; //, "39.96 Hz (10)", "39.96 Hz (11)" }; 00105 ecgDlpfOptions[3][1] = new string[] { "Bypass", "39.96 Hz"}; //, "39.96 Hz", "39.96 Hz" }; 00106 ecgDlpfOptions[3][2] = new string[] { "Bypass", "39.96 Hz"};//, "39.96 Hz", "39.96 Hz" }; 00107 ecgDlpfOptions[3][3] = new string[] { "Bypass", "39.96 Hz"};//, "39.96 Hz", "39.96 Hz" }; 00108 00109 string[] fastOptions = { "Normal*", "Manual Fast Recovery", "Automatic Fast Recovery" }; 00110 string[] fastThOptions = new string[64]; 00111 for (int i = 0; i < 64; i++) 00112 { 00113 fastThOptions[i] = i.ToString() + " * 2048 LSB"; 00114 } 00115 fastThOptions[0x3F] += "*"; // Default option 00116 00117 string[] channelGainOptions = { "20 V/V*", "40 V/V", "80 V/V", "160 V/V" }; 00118 00119 //string[] sampleRateOptions = { "512 sps", "256 sps", "128 sps*"}; // Assume FMSTR = 32768 Hz 00120 00121 string[] dlpfOptions = { "Bypass", "40.96 Hz*", "102.4 Hz", "153.6 Hz" }; 00122 string[] dhpfOptions = { "Bypass", "0.50 Hz*" }; 00123 00124 RegisterField fastField = new RegisterField { Name = "FAST", Register = 5, Index = 22, Width = 2, Descriptions = fastOptions, Label = lblFast, Control = cboFast, Device = max30001}; 00125 RegisterField fastThField = new RegisterField { Name = "FAST_TH", Register = 5, Index = 16, Width = 6, Descriptions = fastThOptions, Label = lblFastTh, Control = cboFastTh, Device = max30001}; 00126 ecgChannelField.Add(fastField); 00127 ecgChannelField.Add(fastThField); 00128 00129 RegisterField channelGainField = new RegisterField { Name = "ECG_GAIN", Register = 0x15, Index = 16, Width = 2, Descriptions = channelGainOptions, Label = lblChannelGain, Control = cboChannelGain, Device = max30001}; 00130 ecgChannelField.Add(channelGainField); 00131 00132 ecgSampleRateField = new RegisterField { Name = "ECG_RATE", Register = 0x15, Index = 22, Width = 2, Descriptions = ecgSampleRateOptions[0], Label = lblSampleRate, Control = cboSampleRate, Device = max30001}; 00133 ecgChannelField.Add(ecgSampleRateField); 00134 00135 ecgDlpfField = new RegisterField { Name = "ECG_DLPF", Register = 0x15, Index = 12, Width = 2, Descriptions = dlpfOptions, Label = lblDlpf, Control = cboDlpf, Device = max30001}; 00136 RegisterField dhpfField = new RegisterField { Name = "ECG_DHPF", Register = 0x15, Index = 14, Width = 1, Descriptions = dhpfOptions, Label = lblDhpf, Control = cboDhpf, Device = max30001}; 00137 ecgChannelField.Add(ecgDlpfField); 00138 ecgChannelField.Add(dhpfField); 00139 } 00140 00141 void initalizeECGGlobalControls() 00142 { 00143 string[] fmstrDescription = { "32768 Hz (00)*", "32000 Hz (01)", "32000 Hz (10)", "31968 Hz (11)" }; 00144 string[] enECGDescription = { "Disabled*", "Enabled" }; 00145 00146 RegisterField fmstrField = new RegisterField { Name = "FMSTR", Register = 0x10, Index = 20, Width = 2, Descriptions = fmstrDescription, Control = cboMasterClock, Device = max30001}; 00147 ecgGlobalField.Add(fmstrField); 00148 00149 //RegisterField enECGField = new RegisterField { Name = "EN_ECG", Register = 0x10, Index = 19, Width = 1, Descriptions = enECGDescription, Label = lblECGChannelEnable }; 00150 //enECGField.Control = cboECGChannelEnable; 00151 //ecgGlobalField.Add(enECGField); 00152 RegisterField enECGField = new RegisterField { Name = "EN_ECG", Register = 0x10, Index = 19, Width = 1, Control = chkEnECG, Device = max30001}; 00153 RegisterField enBioZField = new RegisterField { Name = "EN_BIOZ", Register = 0x10, Index = 18, Width = 1, Control = chkEnBioZ, Device = max30001}; 00154 RegisterField enPaceField = new RegisterField { Name = "EN_PACE", Register = 0x10, Index = 17, Width = 1, Control = chkEnPace, Device = max30001}; 00155 RegisterField enRtorField = new RegisterField { Name = "EN_RTOR", Register = 0x1d, Index = 15, Width = 1, Control = chkEnRtor, Device = max30001}; 00156 channelEnableField.Add(enECGField); 00157 channelEnableField.Add(enBioZField); 00158 channelEnableField.Add(enPaceField); 00159 channelEnableField.Add(enRtorField); 00160 } 00161 00162 void initalizeRToRFields() 00163 { 00164 string[] wndwOptions = {"6 * 8ms", "8 * 8ms", "10 * 8ms", "12 * 8ms*", "14 * 8ms", "16 * 8ms", "18 * 8ms", "20 * 8ms", 00165 "22 * 8ms", "24 * 8ms", "26 * 8ms", "28 * 8ms"}; 00166 string[] gainOptions = { "1", "2", "4", "8", "16", "32", "64", "128", "256", "512", "1024", "2048", "4096", "8192", "16384", "Auto-Scale*" }; 00167 string[] enableOptions = { "Disable*", "Enable" }; 00168 string[] pavgOptions = { "2", "4", "8*", "16" }; 00169 string[] ptsfOptions = { "1/16", "2/16", "3/16", "4/16*", "5/16", "6/16", "7/16", "8/16", 00170 "9/16", "10/16", "11/16", "12/16", "13/16", "14/16", "15/16", "16/16"}; 00171 string[] hoffOptions = new string[64]; 00172 for(int i = 0; i < 64; i ++) 00173 { 00174 hoffOptions[i] = i.ToString(); 00175 if (i == 32) 00176 hoffOptions[i] += "*"; 00177 } 00178 string[] ravgOptions = { "2", "4", "8*", "16" }; 00179 string[] rhsfOptions = { "0/8", "1/8", "2/8", "3/8", "4/8*", "5/8", "6/8", "7/8" }; 00180 00181 RegisterField wndwField = new RegisterField { Name = "RTOR_WNDW", Register = 0x1d, Index = 20, Width = 4, Descriptions = wndwOptions, Control = cboRRWndw, Label = lblRRWndw, Device = max30001 }; 00182 RegisterField gainField = new RegisterField { Name = "RTOR_GAIN", Register = 0x1d, Index = 16, Width = 4, Descriptions = gainOptions, Control = cboRRGain, Label = lblRRGain, Device = max30001 }; 00183 RegisterField enableField = new RegisterField { Name = "EN_RTOR", Register = 0x1d, Index = 15, Width = 1, Descriptions = enableOptions, Control = cboEnRToR, Label = lblEnRToR, Device = max30001 }; 00184 RegisterField pavgField = new RegisterField { Name = "RTOR_PAVG", Register = 0x1d, Index = 12, Width = 2, Descriptions = pavgOptions, Control = cboRRPavg, Label = lblRRPavg, Device = max30001 }; 00185 RegisterField ptsfField = new RegisterField { Name = "RTOR_PTSF", Register = 0x1d, Index = 8, Width = 4, Descriptions = ptsfOptions, Control = cboRRPtsf, Label = lblRRPtsf, Device = max30001}; 00186 RegisterField hoffField = new RegisterField { Name = "RTOR_HOFF", Register = 0x1e, Index = 16, Width = 6, Descriptions = hoffOptions, Control = cboRRHoff, Label = lblRRHoff, Device = max30001 }; 00187 RegisterField ravgField = new RegisterField { Name = "RTOR_RAVG", Register = 0x1e, Index = 12, Width = 2, Descriptions = ravgOptions, Control = cboRRRavg, Label = lblRRRavg, Device = max30001 }; 00188 RegisterField rhsfField = new RegisterField { Name = "RTOR_RHSF", Register = 0x1e, Index = 8, Width = 3, Descriptions = rhsfOptions, Control = cboRRRhsf, Label = lblRRRhsf, Device = max30001 }; 00189 00190 rToRField.Add(wndwField); 00191 rToRField.Add(gainField); 00192 rToRField.Add(enableField); 00193 rToRField.Add(pavgField); 00194 rToRField.Add(ptsfField); 00195 rToRField.Add(hoffField); 00196 rToRField.Add(ravgField); 00197 rToRField.Add(rhsfField); 00198 } 00199 00200 /// <summary> 00201 /// Read register values and update GUI accordingly 00202 /// </summary> 00203 void ECGChannelUpdateRegisters() 00204 { 00205 internalUpdate = true; 00206 ReadComboBoxesRegisters(ecgChannelField); 00207 ReadComboBoxesRegisters(rToRField); 00208 internalUpdate = false; 00209 } 00210 00211 /// <summary> 00212 /// Read and update all the MAX30001 global GUI settings (enable bits and clock) 00213 /// </summary> 00214 void ECGGlobalUpdateRegisters() 00215 { 00216 internalUpdate = true; 00217 ReadComboBoxesRegisters(ecgGlobalField); 00218 ReadCheckBoxRegisters(channelEnableField); 00219 channelEnableMask(chkEnECG); 00220 internalUpdate = false; 00221 00222 // Update EcgView to maintain consistent state 00223 ecgView1.EnableBioZ = chkEnBioZ.Checked; 00224 ecgView1.EnableECG = chkEnECG.Checked; 00225 ecgView1.EnablePace = chkEnPace.Checked; 00226 ecgView1.EnableRToR = chkEnRtor.Checked; 00227 } 00228 00229 /// <summary> 00230 /// Mask enable bits for features which depend on EN_ECG = 1 and EN_BIOZ = 1 00231 /// </summary> 00232 /// <param name="enEcg">Checkbox representing EN_ECG bit</param> 00233 void channelEnableMask(MaximStyle.MaximCheckBox enEcg) 00234 { 00235 if (enEcg.Checked == false) 00236 { 00237 chkEnRtor.Enabled = false; 00238 chkEnPace.Enabled = false; 00239 } 00240 else 00241 { 00242 chkEnRtor.Enabled = true; 00243 if (max30001Model.PartID == Model.MAX30001Model.Part.MAX30001) 00244 chkEnPace.Enabled = true; 00245 } 00246 00247 /*if (chkEnBioZ.Checked == false) 00248 { 00249 chkEnPace.Enabled = false; 00250 } 00251 else 00252 { 00253 chkEnPace.Enabled = true; 00254 }*/ 00255 00256 } 00257 00258 void ReadComboBoxesRegisters(List<RegisterField> fields) 00259 { 00260 int bitValue; 00261 MaximStyle.MaximComboBox cbox; 00262 00263 foreach (RegisterField rf in fields) 00264 { 00265 cbox = (MaximStyle.MaximComboBox)rf.Control; 00266 00267 if (rf.AutoUpdate == true) 00268 { 00269 //for (int i = 0; i < 3; i++) 00270 //{ 00271 // try 00272 // { 00273 bitValue = rf.ReadField(); 00274 00275 00276 if (bitValue < cbox.Items.Count && cbox.Items.Count != 0) // Bit setting matches combobox setting 00277 { 00278 cbox.SelectedItem = rf.Descriptions[bitValue]; 00279 } 00280 else // Bit setting value outside of combobox item range 00281 { 00282 cbox.Text = "0b" + Convert.ToString(bitValue, 2); 00283 } 00284 00285 // } 00286 // catch (System.TimeoutException) 00287 // { 00288 // if (i == 2) 00289 // throw; 00290 // } 00291 //} 00292 00293 } 00294 } 00295 00296 } 00297 00298 void ReadComboBoxesRegister(RegisterField rf) 00299 { 00300 int bitValue; 00301 MaximStyle.MaximComboBox cbox; 00302 00303 cbox = (MaximStyle.MaximComboBox)rf.Control; 00304 00305 if (rf.AutoUpdate == true) 00306 { 00307 bitValue = rf.ReadField(); 00308 00309 if (bitValue < cbox.Items.Count && cbox.Items.Count != 0) // Bit setting matches combobox setting 00310 { 00311 cbox.SelectedItem = rf.Descriptions[bitValue]; 00312 } 00313 else // Bit setting value outside of combobox item range 00314 { 00315 cbox.Text = "0b" + Convert.ToString(bitValue, 2); 00316 } 00317 } 00318 } 00319 00320 void ReadCheckBoxRegisters(List<RegisterField> fields) 00321 { 00322 int bitValue; 00323 MaximStyle.MaximCheckBox chk; 00324 00325 foreach (RegisterField rf in fields) 00326 { 00327 chk = (MaximStyle.MaximCheckBox)rf.Control; 00328 00329 if (rf.AutoUpdate == true) 00330 { 00331 bitValue = rf.ReadField(); 00332 00333 if (bitValue == 0) 00334 chk.Checked = false; 00335 else 00336 chk.Checked = true; 00337 } 00338 } 00339 } 00340 00341 /// <summary> 00342 /// Get bit value from register 00343 /// </summary> 00344 /// <param name="field"></param> 00345 /// <returns></returns> 00346 /*int BitValue(RegisterField field) 00347 { 00348 int registerData; 00349 00350 registerData = max30001.ReadReg((byte)field.Register); 00351 00352 return (registerData >> field.Index) & ((1 << field.Width) - 1); 00353 }*/ 00354 00355 /// <summary> 00356 /// Add tool tips to combo boxes and event to write registers 00357 /// </summary> 00358 /// <param name="list"></param> 00359 void initalizeToolTipEvents(List<RegisterField> list) 00360 { 00361 MaximStyle.MaximComboBox cbox; 00362 Label lbl; 00363 StringBuilder strBuilder = new StringBuilder(); 00364 00365 foreach (RegisterField field in list) 00366 { 00367 cbox = (MaximStyle.MaximComboBox)field.Control; 00368 lbl = field.Label; 00369 00370 // Tool Tip String 00371 strBuilder.Append("Bit "); 00372 strBuilder.Append(field.Name.Replace("\n", String.Empty)); 00373 strBuilder.Append(" in Register 0x"); 00374 strBuilder.Append(field.Register.ToString("X2")); 00375 toolTip1.SetToolTip(cbox, strBuilder.ToString()); 00376 if (lbl != null) 00377 toolTip1.SetToolTip(lbl, strBuilder.ToString()); 00378 strBuilder.Clear(); 00379 00380 // Event to Write Registers 00381 if (cbox != cboMasterClock && cbox != cboSampleRate && cbox != cboBioZSampleRate) // cboMasterClock has a special handler to support repopulation of comboboxes 00382 cbox.SelectedIndexChanged += new System.EventHandler(cboECGChannel_SelectedIndexChanged); 00383 } 00384 } 00385 00386 /// <summary> 00387 /// Write corresponding register of cbox 00388 /// </summary> 00389 /// <param name="cbox"></param> 00390 void writeComboBox(MaximStyle.MaximComboBox cbox) 00391 { 00392 List<RegisterField>[] fieldLists = { ecgChannelField, ecgInputMuxField, ecgGlobalField, rToRField, bioZChannelField, bioZInputMuxField, bioZLoadField, paceChannelField}; 00393 RegisterField field = null; 00394 //int val; 00395 00396 foreach (List<RegisterField> list in fieldLists) 00397 { 00398 foreach (RegisterField f in list) 00399 { 00400 if (f.Control == cbox) 00401 { 00402 field = f; 00403 break; 00404 } 00405 } 00406 00407 if (field != null) 00408 break; 00409 } 00410 00411 field.WriteField((((MaximStyle.MaximComboBox)field.Control).SelectedIndex)); 00412 } 00413 00414 void writeCheckBox(MaximStyle.MaximCheckBox chk) 00415 { 00416 List<RegisterField>[] fieldLists = { channelEnableField }; 00417 RegisterField field = null; 00418 //int val; 00419 00420 foreach (List<RegisterField> list in fieldLists) 00421 { 00422 foreach (RegisterField f in list) 00423 { 00424 if (f.Control == chk) 00425 { 00426 field = f; 00427 break; 00428 } 00429 } 00430 00431 if (field != null) 00432 break; 00433 } 00434 00435 field.WriteField(((MaximStyle.MaximCheckBox)field.Control).Checked == true ? 1 : 0); 00436 } 00437 00438 /// <summary> 00439 /// Event to handle when a new item is selected in the comboboxes for ECG Channel tabs 00440 /// </summary> 00441 /// <param name="sender"></param> 00442 /// <param name="e"></param> 00443 private void cboECGChannel_SelectedIndexChanged(object sender, EventArgs e) 00444 { 00445 MaximStyle.MaximComboBox cbox = (MaximStyle.MaximComboBox)sender; 00446 00447 if (connected && !internalUpdate) 00448 writeComboBox(cbox); 00449 } 00450 00451 /// <summary> 00452 /// Update sample rate for ECG View 00453 /// </summary> 00454 /// <param name="sender"></param> 00455 /// <param name="e"></param> 00456 private void cboSampleRate_SelectedIndexChanged(object sender, EventArgs e) 00457 { 00458 MaximStyle.MaximComboBox cbox = (MaximStyle.MaximComboBox)sender; 00459 00460 if (connected && !internalUpdate) 00461 writeComboBox(cbox); 00462 00463 if (cboMasterClock.SelectedIndex > -1) 00464 { 00465 // Set sample rate based on clock 00466 ecgView1.SampleRateEcg = ecgSampleRates[cboMasterClock.SelectedIndex][cbox.SelectedIndex]; 00467 00468 // Set digital low pass filter 00469 cboDlpf.Items.Clear(); 00470 ecgDlpfField.Descriptions = ecgDlpfOptions[cboMasterClock.SelectedIndex][cboSampleRate.SelectedIndex]; 00471 ecgDlpfField.Control = cboDlpf; // Trigger updating of descriptions 00472 00473 //internalUpdate = true; 00474 if (connected) 00475 cboDlpf.SelectedIndex = ecgDlpfField.ReadField(); 00476 //internalUpdate = false; 00477 //ReadComboBoxesRegisters(cboDlpf); 00478 } 00479 00480 } 00481 00482 private void cboChannelGain_SelectedIndexChanged(object sender, EventArgs e) 00483 { 00484 MaximStyle.MaximComboBox cbox = (MaximStyle.MaximComboBox)sender; 00485 00486 switch (cbox.SelectedIndex) 00487 { 00488 case 0: 00489 ecgView1.GainECG = 20; 00490 break; 00491 case 1: 00492 ecgView1.GainECG = 40; 00493 break; 00494 case 2: 00495 ecgView1.GainECG = 80; 00496 break; 00497 case 3: 00498 ecgView1.GainECG = 160; 00499 break; 00500 } 00501 } 00502 00503 private void chkChannelEnable_CheckedChanged(object sender, EventArgs e) 00504 { 00505 MaximStyle.MaximCheckBox chk = (MaximStyle.MaximCheckBox)sender; 00506 00507 // Write bit 00508 if (connected && !internalUpdate) 00509 { 00510 writeCheckBox(chk); 00511 00512 // Do not allow user to change masked enable bits 00513 channelEnableMask(chkEnECG); 00514 00515 // Tell ECG View the status 00516 if (chk == chkEnECG) 00517 { 00518 ecgView1.EnableECG = chk.Checked; 00519 } 00520 else if (chk == chkEnBioZ) 00521 { 00522 ecgView1.EnableBioZ = chk.Checked; 00523 } 00524 else if (chk == chkEnPace) 00525 { 00526 ecgView1.EnablePace = chk.Checked; 00527 } 00528 else if (chk == chkEnRtor) 00529 { 00530 ecgView1.EnableRToR = chk.Checked; 00531 } 00532 00533 // Read all enable bits 00534 internalUpdate = true; 00535 ReadCheckBoxRegisters(channelEnableField); 00536 internalUpdate = false; 00537 } 00538 } 00539 00540 private void cboMasterClock_SelectedIndexChanged(object sender, EventArgs e) 00541 { 00542 MaximStyle.MaximComboBox cbo = (MaximStyle.MaximComboBox)sender; 00543 int[] clock = { 32768, 32000, 32000, 31968 }; 00544 00545 if (connected && !internalUpdate) 00546 writeComboBox(cbo); 00547 00548 ecgView1.FrequencyMasterField = cbo.SelectedIndex; 00549 //ecgView1.TimeResolution = 1.0/(2*clock[cbo.SelectedIndex]); 00550 00551 ecgSampleRateField.Descriptions = ecgSampleRateOptions[cbo.SelectedIndex]; 00552 ecgSampleRateField.Control = cboSampleRate; // Trigger updating of descriptions 00553 00554 cboBioZSampleRate.Items.Clear(); 00555 bioZSampleRateField.Descriptions = bioZSampleRateOptions[cbo.SelectedIndex]; 00556 bioZSampleRateField.Control = cboBioZSampleRate; // Trigger updating of descriptions 00557 00558 // Trigger update of current selection to new description 00559 internalUpdate = true; 00560 if (connected) 00561 { 00562 cboSampleRate.SelectedIndex = ecgSampleRateField.ReadField(); 00563 cboDlpf.SelectedIndex = ecgDlpfField.ReadField(); 00564 cboBioZSampleRate.SelectedIndex = bioZSampleRateField.ReadField(); 00565 cboBioZDigitalLpf.SelectedIndex = bioZDlpfField.ReadField(); 00566 } 00567 internalUpdate = false; 00568 } 00569 00570 private void cboRRWndw_SelectedIndexChanged(object sender, EventArgs e) 00571 { 00572 MaximStyle.MaximComboBox cbo = (MaximStyle.MaximComboBox)sender; 00573 ecgView1.RToRWindowField = cbo.SelectedIndex; 00574 } 00575 00576 private CustomControls.InitArgs.RToRInitStart getRToRArgs() 00577 { 00578 CustomControls.InitArgs.RToRInitStart initArgs = new CustomControls.InitArgs.RToRInitStart(); 00579 00580 initArgs.Wndw = cboRRWndw.SelectedIndex; 00581 initArgs.Gain = cboRRGain.SelectedIndex; 00582 initArgs.En_rtor = chkEnRtor.Checked == true ? 1 : 0; 00583 initArgs.Pavg = cboRRPavg.SelectedIndex; 00584 initArgs.Ptsf = cboRRPtsf.SelectedIndex; 00585 initArgs.Hoff = cboRRHoff.SelectedIndex; 00586 initArgs.Ravg = cboRRRavg.SelectedIndex; 00587 initArgs.Rhsf = cboRRRhsf.SelectedIndex; 00588 initArgs.Clr_rrint = 1; // Default from Jerry's GUI 00589 00590 return initArgs; 00591 } 00592 00593 private void setRToRArgs(CustomControls.InitArgs.RToRInitStart initArgs) 00594 { 00595 cboRRWndw.SelectedIndex = initArgs.Wndw; 00596 cboRRGain.SelectedIndex = initArgs.Gain; 00597 //initArgs.En_rtor = chkEnRtor.Checked == true ? 1 : 0; //cboEnRToR.SelectedIndex; 00598 cboRRPavg.SelectedIndex = initArgs.Pavg; 00599 cboRRPtsf.SelectedIndex = initArgs.Ptsf; 00600 cboRRHoff.SelectedIndex = initArgs.Hoff; 00601 cboRRRavg.SelectedIndex = initArgs.Ravg; 00602 cboRRRhsf.SelectedIndex = initArgs.Rhsf; 00603 //initArgs.Clr_rrint = 2; // Default from Jerry's GUI 00604 } 00605 00606 } 00607 }
Generated on Tue Jul 12 2022 21:52:37 by
1.7.2