This is the latest working repository used in our demo video for the Maxim to display temperature readings on Bluetooth
hspguisourcev301/HspGuiSourceV301/HSPGui/Form1.cs@3:36de8b9e4b1a, 2021-04-10 (annotated)
- Committer:
- darienf
- Date:
- Sat Apr 10 03:05:42 2021 +0000
- Revision:
- 3:36de8b9e4b1a
ayoooo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
darienf | 3:36de8b9e4b1a | 1 | /******************************************************************************* |
darienf | 3:36de8b9e4b1a | 2 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All rights Reserved. |
darienf | 3:36de8b9e4b1a | 3 | * |
darienf | 3:36de8b9e4b1a | 4 | * This software is protected by copyright laws of the United States and |
darienf | 3:36de8b9e4b1a | 5 | * of foreign countries. This material may also be protected by patent laws |
darienf | 3:36de8b9e4b1a | 6 | * and technology transfer regulations of the United States and of foreign |
darienf | 3:36de8b9e4b1a | 7 | * countries. This software is furnished under a license agreement and/or a |
darienf | 3:36de8b9e4b1a | 8 | * nondisclosure agreement and may only be used or reproduced in accordance |
darienf | 3:36de8b9e4b1a | 9 | * with the terms of those agreements. Dissemination of this information to |
darienf | 3:36de8b9e4b1a | 10 | * any party or parties not specified in the license agreement and/or |
darienf | 3:36de8b9e4b1a | 11 | * nondisclosure agreement is expressly prohibited. |
darienf | 3:36de8b9e4b1a | 12 | * |
darienf | 3:36de8b9e4b1a | 13 | * The above copyright notice and this permission notice shall be included |
darienf | 3:36de8b9e4b1a | 14 | * in all copies or substantial portions of the Software. |
darienf | 3:36de8b9e4b1a | 15 | * |
darienf | 3:36de8b9e4b1a | 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
darienf | 3:36de8b9e4b1a | 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
darienf | 3:36de8b9e4b1a | 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
darienf | 3:36de8b9e4b1a | 19 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
darienf | 3:36de8b9e4b1a | 20 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
darienf | 3:36de8b9e4b1a | 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
darienf | 3:36de8b9e4b1a | 22 | * OTHER DEALINGS IN THE SOFTWARE. |
darienf | 3:36de8b9e4b1a | 23 | * |
darienf | 3:36de8b9e4b1a | 24 | * Except as contained in this notice, the name of Maxim Integrated |
darienf | 3:36de8b9e4b1a | 25 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
darienf | 3:36de8b9e4b1a | 26 | * Products, Inc. Branding Policy. |
darienf | 3:36de8b9e4b1a | 27 | * |
darienf | 3:36de8b9e4b1a | 28 | * The mere transfer of this software does not imply any licenses |
darienf | 3:36de8b9e4b1a | 29 | * of trade secrets, proprietary technology, copyrights, patents, |
darienf | 3:36de8b9e4b1a | 30 | * trademarks, maskwork rights, or any other form of intellectual |
darienf | 3:36de8b9e4b1a | 31 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
darienf | 3:36de8b9e4b1a | 32 | * ownership rights. |
darienf | 3:36de8b9e4b1a | 33 | ******************************************************************************* |
darienf | 3:36de8b9e4b1a | 34 | */ |
darienf | 3:36de8b9e4b1a | 35 | |
darienf | 3:36de8b9e4b1a | 36 | using System; |
darienf | 3:36de8b9e4b1a | 37 | using System.Collections.Generic; |
darienf | 3:36de8b9e4b1a | 38 | using System.ComponentModel; |
darienf | 3:36de8b9e4b1a | 39 | using System.Data; |
darienf | 3:36de8b9e4b1a | 40 | using System.Drawing; |
darienf | 3:36de8b9e4b1a | 41 | using System.Linq; |
darienf | 3:36de8b9e4b1a | 42 | using System.Text; |
darienf | 3:36de8b9e4b1a | 43 | |
darienf | 3:36de8b9e4b1a | 44 | using System.Windows.Forms; |
darienf | 3:36de8b9e4b1a | 45 | using Microsoft.Win32; |
darienf | 3:36de8b9e4b1a | 46 | using Microsoft.Win32.SafeHandles; |
darienf | 3:36de8b9e4b1a | 47 | using System.Globalization; |
darienf | 3:36de8b9e4b1a | 48 | using System.Threading; |
darienf | 3:36de8b9e4b1a | 49 | using System.Management; |
darienf | 3:36de8b9e4b1a | 50 | using System.Diagnostics; |
darienf | 3:36de8b9e4b1a | 51 | using System.IO; |
darienf | 3:36de8b9e4b1a | 52 | using System.Collections.Specialized; |
darienf | 3:36de8b9e4b1a | 53 | |
darienf | 3:36de8b9e4b1a | 54 | using HealthSensorPlatform.DeviceDescriptions; |
darienf | 3:36de8b9e4b1a | 55 | using HealthSensorPlatform.CustomControls; |
darienf | 3:36de8b9e4b1a | 56 | using HealthSensorPlatform.View; |
darienf | 3:36de8b9e4b1a | 57 | using HealthSensorPlatform.Presenter; |
darienf | 3:36de8b9e4b1a | 58 | using HealthSensorPlatform.Model; |
darienf | 3:36de8b9e4b1a | 59 | |
darienf | 3:36de8b9e4b1a | 60 | using MAX30205EVKit.Presenter; |
darienf | 3:36de8b9e4b1a | 61 | |
darienf | 3:36de8b9e4b1a | 62 | using Maxim.MAX30101GUI; |
darienf | 3:36de8b9e4b1a | 63 | using Maxim.Utility; |
darienf | 3:36de8b9e4b1a | 64 | |
darienf | 3:36de8b9e4b1a | 65 | using MaximStyle; |
darienf | 3:36de8b9e4b1a | 66 | |
darienf | 3:36de8b9e4b1a | 67 | namespace HealthSensorPlatform |
darienf | 3:36de8b9e4b1a | 68 | { |
darienf | 3:36de8b9e4b1a | 69 | |
darienf | 3:36de8b9e4b1a | 70 | public partial class HspForm : Form, IFormView, IHspSetting |
darienf | 3:36de8b9e4b1a | 71 | { |
darienf | 3:36de8b9e4b1a | 72 | /* Constants */ |
darienf | 3:36de8b9e4b1a | 73 | //Software Version |
darienf | 3:36de8b9e4b1a | 74 | internal const int MAJORVERSION = 3; |
darienf | 3:36de8b9e4b1a | 75 | internal const int MINORVERSION = 0; |
darienf | 3:36de8b9e4b1a | 76 | internal const int PATCHVERSION = 1; |
darienf | 3:36de8b9e4b1a | 77 | const string VersionSuffix = ""; |
darienf | 3:36de8b9e4b1a | 78 | |
darienf | 3:36de8b9e4b1a | 79 | const string PartNumber = "MAXREFDES100"; |
darienf | 3:36de8b9e4b1a | 80 | |
darienf | 3:36de8b9e4b1a | 81 | const string readVersionCommand = "/System/ReadVer\r\n"; |
darienf | 3:36de8b9e4b1a | 82 | const string readFlashIDCommand = "/S25FS512/ReadId\r\n"; |
darienf | 3:36de8b9e4b1a | 83 | const string firmwareKey = "HSP FW Version"; |
darienf | 3:36de8b9e4b1a | 84 | |
darienf | 3:36de8b9e4b1a | 85 | /* Fields */ |
darienf | 3:36de8b9e4b1a | 86 | SplashScreen splashScreen = new SplashScreen(); |
darienf | 3:36de8b9e4b1a | 87 | FormConnection connectionDialog = new FormConnection(); |
darienf | 3:36de8b9e4b1a | 88 | string port; |
darienf | 3:36de8b9e4b1a | 89 | bool connected = false; |
darienf | 3:36de8b9e4b1a | 90 | bool internalUpdate = false; // Used to prevent events from triggering |
darienf | 3:36de8b9e4b1a | 91 | bool streaming = false; // Disable GUI features while streaming is enabled |
darienf | 3:36de8b9e4b1a | 92 | |
darienf | 3:36de8b9e4b1a | 93 | static ManagementEventWatcher watcher; |
darienf | 3:36de8b9e4b1a | 94 | |
darienf | 3:36de8b9e4b1a | 95 | /* // TODO: Do not remember what this is for, can remove |
darienf | 3:36de8b9e4b1a | 96 | MaximStyle.MaximNumericUpDown[] ud_cmd = new MaximStyle.MaximNumericUpDown[3]; |
darienf | 3:36de8b9e4b1a | 97 | MaximStyle.MaximNumericUpDown[] ud_data = new MaximStyle.MaximNumericUpDown[8]; |
darienf | 3:36de8b9e4b1a | 98 | Panel[] p_cmd = new Panel[3]; |
darienf | 3:36de8b9e4b1a | 99 | Panel[] p_data = new Panel[8]; |
darienf | 3:36de8b9e4b1a | 100 | */ |
darienf | 3:36de8b9e4b1a | 101 | |
darienf | 3:36de8b9e4b1a | 102 | IDeviceView[] deviceViews; |
darienf | 3:36de8b9e4b1a | 103 | Maxim.CustomControls.RegisterView[] registerViews; |
darienf | 3:36de8b9e4b1a | 104 | TabPage[] max30001TabPages; |
darienf | 3:36de8b9e4b1a | 105 | |
darienf | 3:36de8b9e4b1a | 106 | RPCSupport.RPCClient rpcClient; |
darienf | 3:36de8b9e4b1a | 107 | RPCSupport.Devices.I2cDevice i2cDevice; |
darienf | 3:36de8b9e4b1a | 108 | RPCSupport.Devices.SpiDevice spiDevice; |
darienf | 3:36de8b9e4b1a | 109 | RPCSupport.Devices.MAX30101 max30101; |
darienf | 3:36de8b9e4b1a | 110 | RPCSupport.Devices.MAX30205 max30205; |
darienf | 3:36de8b9e4b1a | 111 | RPCSupport.Devices.LIS2HD lis2hd; |
darienf | 3:36de8b9e4b1a | 112 | RPCSupport.Devices.MAX30001 max30001; |
darienf | 3:36de8b9e4b1a | 113 | RPCSupport.DataLogging.DataLogging logging; |
darienf | 3:36de8b9e4b1a | 114 | |
darienf | 3:36de8b9e4b1a | 115 | ListDictionary registerViewDict; |
darienf | 3:36de8b9e4b1a | 116 | |
darienf | 3:36de8b9e4b1a | 117 | //FileLogPresenter fileLogPresenter; |
darienf | 3:36de8b9e4b1a | 118 | RawFileLogPresenter rawFileLogPresenter; |
darienf | 3:36de8b9e4b1a | 119 | OpticalFileLogPresenter opticalFileLogPresenter; |
darienf | 3:36de8b9e4b1a | 120 | TemperaturePresenter temperaturePresenter; |
darienf | 3:36de8b9e4b1a | 121 | |
darienf | 3:36de8b9e4b1a | 122 | Model.MAX30001Model max30001Model; |
darienf | 3:36de8b9e4b1a | 123 | |
darienf | 3:36de8b9e4b1a | 124 | public event EventHandler<EnableEventArgs> FileLogEnable; |
darienf | 3:36de8b9e4b1a | 125 | public event EventHandler<EnableEventArgs> OpticalFileLogEnable; |
darienf | 3:36de8b9e4b1a | 126 | public event EventHandler<EventArgs> RegisterExport; |
darienf | 3:36de8b9e4b1a | 127 | public event EventHandler<EventArgs> RegisterImport; |
darienf | 3:36de8b9e4b1a | 128 | |
darienf | 3:36de8b9e4b1a | 129 | public event EventHandler<EventArgs> Connected; |
darienf | 3:36de8b9e4b1a | 130 | |
darienf | 3:36de8b9e4b1a | 131 | /* Constructor */ |
darienf | 3:36de8b9e4b1a | 132 | /// <summary> |
darienf | 3:36de8b9e4b1a | 133 | /// |
darienf | 3:36de8b9e4b1a | 134 | /// </summary> |
darienf | 3:36de8b9e4b1a | 135 | public HspForm() |
darienf | 3:36de8b9e4b1a | 136 | { |
darienf | 3:36de8b9e4b1a | 137 | InitializeComponent(); |
darienf | 3:36de8b9e4b1a | 138 | |
darienf | 3:36de8b9e4b1a | 139 | InitSplashScreen(); |
darienf | 3:36de8b9e4b1a | 140 | |
darienf | 3:36de8b9e4b1a | 141 | //initialize text in status bar |
darienf | 3:36de8b9e4b1a | 142 | ss_Status.Items[0].Text = ""; |
darienf | 3:36de8b9e4b1a | 143 | ss_Status.Items[1].Text = ""; |
darienf | 3:36de8b9e4b1a | 144 | |
darienf | 3:36de8b9e4b1a | 145 | deviceViews = new IDeviceView[] { |
darienf | 3:36de8b9e4b1a | 146 | opticalView1, |
darienf | 3:36de8b9e4b1a | 147 | temperatureView1, |
darienf | 3:36de8b9e4b1a | 148 | ecgView1, |
darienf | 3:36de8b9e4b1a | 149 | dataLoggingView1, |
darienf | 3:36de8b9e4b1a | 150 | rvLIS2HD, |
darienf | 3:36de8b9e4b1a | 151 | rvMAX14720, |
darienf | 3:36de8b9e4b1a | 152 | rvMAX30001, |
darienf | 3:36de8b9e4b1a | 153 | rvMAX30101, |
darienf | 3:36de8b9e4b1a | 154 | rvMAX30205, |
darienf | 3:36de8b9e4b1a | 155 | rvMAX30205_U18 |
darienf | 3:36de8b9e4b1a | 156 | }; |
darienf | 3:36de8b9e4b1a | 157 | |
darienf | 3:36de8b9e4b1a | 158 | registerViews = new Maxim.CustomControls.RegisterView[] { |
darienf | 3:36de8b9e4b1a | 159 | rvMAX30101, |
darienf | 3:36de8b9e4b1a | 160 | rvMAX30205, |
darienf | 3:36de8b9e4b1a | 161 | rvMAX30205_U18, |
darienf | 3:36de8b9e4b1a | 162 | rvLIS2HD, |
darienf | 3:36de8b9e4b1a | 163 | rvMAX30001, |
darienf | 3:36de8b9e4b1a | 164 | rvMAX14720 |
darienf | 3:36de8b9e4b1a | 165 | }; |
darienf | 3:36de8b9e4b1a | 166 | |
darienf | 3:36de8b9e4b1a | 167 | max30001TabPages = new TabPage[] { tpMAX30001BioZInputMux, tpBioZChannel, tpMAX30001BioZLoad, tpMAX30001Pace }; |
darienf | 3:36de8b9e4b1a | 168 | |
darienf | 3:36de8b9e4b1a | 169 | registerViewDict = new ListDictionary(); |
darienf | 3:36de8b9e4b1a | 170 | |
darienf | 3:36de8b9e4b1a | 171 | InitRpcClient(); |
darienf | 3:36de8b9e4b1a | 172 | |
darienf | 3:36de8b9e4b1a | 173 | InitRpcDevices(); |
darienf | 3:36de8b9e4b1a | 174 | PrimitivesViewInit(); |
darienf | 3:36de8b9e4b1a | 175 | RegistersTabInit(); |
darienf | 3:36de8b9e4b1a | 176 | LoggingViewInit(); |
darienf | 3:36de8b9e4b1a | 177 | TemperatureViewInit(); |
darienf | 3:36de8b9e4b1a | 178 | OpticalViewInit(); |
darienf | 3:36de8b9e4b1a | 179 | |
darienf | 3:36de8b9e4b1a | 180 | BlockDiagramsInit(); |
darienf | 3:36de8b9e4b1a | 181 | ECGPlotsViewInit(); |
darienf | 3:36de8b9e4b1a | 182 | |
darienf | 3:36de8b9e4b1a | 183 | InitalizeUSBDetection(); |
darienf | 3:36de8b9e4b1a | 184 | |
darienf | 3:36de8b9e4b1a | 185 | FileLoggingInit(); |
darienf | 3:36de8b9e4b1a | 186 | |
darienf | 3:36de8b9e4b1a | 187 | RegisterExportInit(); |
darienf | 3:36de8b9e4b1a | 188 | |
darienf | 3:36de8b9e4b1a | 189 | SetupSwitchPictureBoxes(); |
darienf | 3:36de8b9e4b1a | 190 | } |
darienf | 3:36de8b9e4b1a | 191 | |
darienf | 3:36de8b9e4b1a | 192 | private void SetupSwitchPictureBoxes() |
darienf | 3:36de8b9e4b1a | 193 | { |
darienf | 3:36de8b9e4b1a | 194 | //ECGMux Tab |
darienf | 3:36de8b9e4b1a | 195 | picECGLeadConfig.Controls.Add(picSw1); |
darienf | 3:36de8b9e4b1a | 196 | picSw1.Controls.Add(picSw2); |
darienf | 3:36de8b9e4b1a | 197 | picSw2.Controls.Add(picSw3); |
darienf | 3:36de8b9e4b1a | 198 | picSw3.Controls.Add(picSw4); |
darienf | 3:36de8b9e4b1a | 199 | picSw4.Controls.Add(picSw5); |
darienf | 3:36de8b9e4b1a | 200 | picSw5.Controls.Add(picSw6); |
darienf | 3:36de8b9e4b1a | 201 | picSw6.Controls.Add(picSw7); |
darienf | 3:36de8b9e4b1a | 202 | picSw7.Controls.Add(picSw8); |
darienf | 3:36de8b9e4b1a | 203 | picSw8.Controls.Add(picSw9); |
darienf | 3:36de8b9e4b1a | 204 | picSw9.Controls.Add(picSw10); |
darienf | 3:36de8b9e4b1a | 205 | picSw10.Controls.Add(picSw11); |
darienf | 3:36de8b9e4b1a | 206 | picSw11.Controls.Add(picSw12); |
darienf | 3:36de8b9e4b1a | 207 | picSw12.Controls.Add(picSw13); |
darienf | 3:36de8b9e4b1a | 208 | picSw13.Controls.Add(picSw14); |
darienf | 3:36de8b9e4b1a | 209 | |
darienf | 3:36de8b9e4b1a | 210 | //BioZMux Tab |
darienf | 3:36de8b9e4b1a | 211 | pictureBox2.Controls.Add(picLoff1); |
darienf | 3:36de8b9e4b1a | 212 | picLoff1.Controls.Add(picLoff2); |
darienf | 3:36de8b9e4b1a | 213 | picLoff2.Controls.Add(picLeadOn); |
darienf | 3:36de8b9e4b1a | 214 | picLeadOn.Controls.Add(picBioZsw1); |
darienf | 3:36de8b9e4b1a | 215 | picBioZsw1.Controls.Add(picBioZsw2); |
darienf | 3:36de8b9e4b1a | 216 | picBioZsw2.Controls.Add(picLeadBias1); |
darienf | 3:36de8b9e4b1a | 217 | picLeadBias1.Controls.Add(picLeadBias2); |
darienf | 3:36de8b9e4b1a | 218 | picLeadBias2.Controls.Add(picBioZCal1); |
darienf | 3:36de8b9e4b1a | 219 | picBioZCal1.Controls.Add(picBioZCal2); |
darienf | 3:36de8b9e4b1a | 220 | |
darienf | 3:36de8b9e4b1a | 221 | //BioZLoad Tab |
darienf | 3:36de8b9e4b1a | 222 | picBioZLoad.Controls.Add(picBioZLresload); |
darienf | 3:36de8b9e4b1a | 223 | picBioZLresload.Controls.Add(picBioZLloff1); |
darienf | 3:36de8b9e4b1a | 224 | picBioZLloff1.Controls.Add(picBioZLloff2); |
darienf | 3:36de8b9e4b1a | 225 | picBioZLloff2.Controls.Add(picBioZLlon); |
darienf | 3:36de8b9e4b1a | 226 | picBioZLlon.Controls.Add(picBioZLsw1); |
darienf | 3:36de8b9e4b1a | 227 | picBioZLsw1.Controls.Add(picBioZLsw2); |
darienf | 3:36de8b9e4b1a | 228 | picBioZLsw2.Controls.Add(picBioZLlb1); |
darienf | 3:36de8b9e4b1a | 229 | picBioZLlb1.Controls.Add(picBioZLlb2); |
darienf | 3:36de8b9e4b1a | 230 | picBioZLlb2.Controls.Add(picBioZLcal1); |
darienf | 3:36de8b9e4b1a | 231 | picBioZLcal1.Controls.Add(picBioZLcal2); |
darienf | 3:36de8b9e4b1a | 232 | |
darienf | 3:36de8b9e4b1a | 233 | |
darienf | 3:36de8b9e4b1a | 234 | } |
darienf | 3:36de8b9e4b1a | 235 | |
darienf | 3:36de8b9e4b1a | 236 | /* Delegates */ |
darienf | 3:36de8b9e4b1a | 237 | delegate void guiDisconnectedCallBack(); |
darienf | 3:36de8b9e4b1a | 238 | |
darienf | 3:36de8b9e4b1a | 239 | public void MessageInfo(string message) |
darienf | 3:36de8b9e4b1a | 240 | { |
darienf | 3:36de8b9e4b1a | 241 | ss_Status.MessagesLabel.Text = message; |
darienf | 3:36de8b9e4b1a | 242 | } |
darienf | 3:36de8b9e4b1a | 243 | |
darienf | 3:36de8b9e4b1a | 244 | public void MessageBoxShow(string message) |
darienf | 3:36de8b9e4b1a | 245 | { |
darienf | 3:36de8b9e4b1a | 246 | MessageBox.Show(message); |
darienf | 3:36de8b9e4b1a | 247 | } |
darienf | 3:36de8b9e4b1a | 248 | |
darienf | 3:36de8b9e4b1a | 249 | public void MessageBoxShow(string message, string title) |
darienf | 3:36de8b9e4b1a | 250 | { |
darienf | 3:36de8b9e4b1a | 251 | MessageBox.Show(message, title); |
darienf | 3:36de8b9e4b1a | 252 | } |
darienf | 3:36de8b9e4b1a | 253 | |
darienf | 3:36de8b9e4b1a | 254 | |
darienf | 3:36de8b9e4b1a | 255 | /// <summary> |
darienf | 3:36de8b9e4b1a | 256 | /// http://stackoverflow.com/questions/286184/how-to-capture-a-serial-port-that-disappears-because-the-usb-cable-gets-unplugge |
darienf | 3:36de8b9e4b1a | 257 | /// </summary> |
darienf | 3:36de8b9e4b1a | 258 | private void InitalizeUSBDetection() |
darienf | 3:36de8b9e4b1a | 259 | { |
darienf | 3:36de8b9e4b1a | 260 | WqlEventQuery query; |
darienf | 3:36de8b9e4b1a | 261 | ManagementScope scope; |
darienf | 3:36de8b9e4b1a | 262 | |
darienf | 3:36de8b9e4b1a | 263 | scope = new ManagementScope("root\\CIMV2"); |
darienf | 3:36de8b9e4b1a | 264 | scope.Options.EnablePrivileges = true; |
darienf | 3:36de8b9e4b1a | 265 | |
darienf | 3:36de8b9e4b1a | 266 | query = new WqlEventQuery(); |
darienf | 3:36de8b9e4b1a | 267 | query.EventClassName = "__InstanceDeletionEvent"; // "__InstanceCreationEvent" can be used for insertion |
darienf | 3:36de8b9e4b1a | 268 | query.WithinInterval = new TimeSpan(0, 0, 3); |
darienf | 3:36de8b9e4b1a | 269 | query.Condition = @"TargetInstance ISA 'Win32_USBControllerdevice'"; |
darienf | 3:36de8b9e4b1a | 270 | watcher = new ManagementEventWatcher(scope, query); |
darienf | 3:36de8b9e4b1a | 271 | watcher.EventArrived += new EventArrivedEventHandler(USBRemovedHandler); |
darienf | 3:36de8b9e4b1a | 272 | watcher.Start(); |
darienf | 3:36de8b9e4b1a | 273 | } |
darienf | 3:36de8b9e4b1a | 274 | |
darienf | 3:36de8b9e4b1a | 275 | /// <summary> |
darienf | 3:36de8b9e4b1a | 276 | /// http://stackoverflow.com/questions/286184/how-to-capture-a-serial-port-that-disappears-because-the-usb-cable-gets-unplugge |
darienf | 3:36de8b9e4b1a | 277 | /// </summary> |
darienf | 3:36de8b9e4b1a | 278 | /// <param name="sender"></param> |
darienf | 3:36de8b9e4b1a | 279 | /// <param name="e"></param> |
darienf | 3:36de8b9e4b1a | 280 | private void USBRemovedHandler(object sender, EventArrivedEventArgs e) |
darienf | 3:36de8b9e4b1a | 281 | { |
darienf | 3:36de8b9e4b1a | 282 | PropertyData targetInstanceData = e.NewEvent.Properties["TargetInstance"]; |
darienf | 3:36de8b9e4b1a | 283 | |
darienf | 3:36de8b9e4b1a | 284 | if (targetInstanceData != null) |
darienf | 3:36de8b9e4b1a | 285 | { |
darienf | 3:36de8b9e4b1a | 286 | ManagementBaseObject targetInstanceObject = (ManagementBaseObject)targetInstanceData.Value; |
darienf | 3:36de8b9e4b1a | 287 | if (targetInstanceData != null) |
darienf | 3:36de8b9e4b1a | 288 | { |
darienf | 3:36de8b9e4b1a | 289 | string dependent = targetInstanceObject.Properties["Dependent"].Value.ToString(); |
darienf | 3:36de8b9e4b1a | 290 | string deviceId = dependent.Substring(dependent.IndexOf("DeviceID=") + 10); |
darienf | 3:36de8b9e4b1a | 291 | |
darienf | 3:36de8b9e4b1a | 292 | if (deviceId.StartsWith("USB\\\\VID_0B6A&PID_003C") // FW 1.5 |
darienf | 3:36de8b9e4b1a | 293 | || deviceId.StartsWith("USB\\\\VID_1F00&PID_2012\\\\0123456789") |
darienf | 3:36de8b9e4b1a | 294 | || deviceId.StartsWith("USB\\\\VID_0B6A&PID_0100")) // FW 2.0 mbed |
darienf | 3:36de8b9e4b1a | 295 | { |
darienf | 3:36de8b9e4b1a | 296 | // device is disconnected |
darienf | 3:36de8b9e4b1a | 297 | guiDisconnected(); |
darienf | 3:36de8b9e4b1a | 298 | try |
darienf | 3:36de8b9e4b1a | 299 | { |
darienf | 3:36de8b9e4b1a | 300 | rpcClient.Disconnect(); |
darienf | 3:36de8b9e4b1a | 301 | } |
darienf | 3:36de8b9e4b1a | 302 | catch (System.IO.IOException) |
darienf | 3:36de8b9e4b1a | 303 | { |
darienf | 3:36de8b9e4b1a | 304 | |
darienf | 3:36de8b9e4b1a | 305 | } |
darienf | 3:36de8b9e4b1a | 306 | catch (NullReferenceException) |
darienf | 3:36de8b9e4b1a | 307 | { |
darienf | 3:36de8b9e4b1a | 308 | // Disconnecting when it doesn't exist |
darienf | 3:36de8b9e4b1a | 309 | // Occurs when you pull the USB while on the com port selection window |
darienf | 3:36de8b9e4b1a | 310 | } |
darienf | 3:36de8b9e4b1a | 311 | } |
darienf | 3:36de8b9e4b1a | 312 | } |
darienf | 3:36de8b9e4b1a | 313 | |
darienf | 3:36de8b9e4b1a | 314 | } |
darienf | 3:36de8b9e4b1a | 315 | |
darienf | 3:36de8b9e4b1a | 316 | } |
darienf | 3:36de8b9e4b1a | 317 | |
darienf | 3:36de8b9e4b1a | 318 | private void InitSplashScreen() |
darienf | 3:36de8b9e4b1a | 319 | { |
darienf | 3:36de8b9e4b1a | 320 | splashScreen.maximSplashScreen1.CopyrightString = "©2016 Maxim Integrated Products, Inc."; |
darienf | 3:36de8b9e4b1a | 321 | splashScreen.maximSplashScreen1.VersionString = "Version " + MAJORVERSION.ToString() + "." + MINORVERSION.ToString() + "." + PATCHVERSION.ToString() + VersionSuffix; |
darienf | 3:36de8b9e4b1a | 322 | splashScreen.maximSplashScreen1.ApplicationName = this.Text; |
darienf | 3:36de8b9e4b1a | 323 | //splashScreen.maximSplashScreen1.Checked = Properties.Settings.Default.DisableSplash; |
darienf | 3:36de8b9e4b1a | 324 | } |
darienf | 3:36de8b9e4b1a | 325 | |
darienf | 3:36de8b9e4b1a | 326 | void comPortConnect() |
darienf | 3:36de8b9e4b1a | 327 | { |
darienf | 3:36de8b9e4b1a | 328 | bool tryPreviousComPort = true; |
darienf | 3:36de8b9e4b1a | 329 | |
darienf | 3:36de8b9e4b1a | 330 | connectionDialog.Reset(); |
darienf | 3:36de8b9e4b1a | 331 | connectionDialog.ScanPorts(); |
darienf | 3:36de8b9e4b1a | 332 | |
darienf | 3:36de8b9e4b1a | 333 | while (true) |
darienf | 3:36de8b9e4b1a | 334 | { |
darienf | 3:36de8b9e4b1a | 335 | // Try to connect to the previous port, if we have not tried before |
darienf | 3:36de8b9e4b1a | 336 | // and it the port string is not an empty string ("") |
darienf | 3:36de8b9e4b1a | 337 | if (tryPreviousComPort == true |
darienf | 3:36de8b9e4b1a | 338 | && String.Compare(Properties.Settings.Default.ComPort, "") != 0) |
darienf | 3:36de8b9e4b1a | 339 | { |
darienf | 3:36de8b9e4b1a | 340 | tryPreviousComPort = false; |
darienf | 3:36de8b9e4b1a | 341 | } |
darienf | 3:36de8b9e4b1a | 342 | else |
darienf | 3:36de8b9e4b1a | 343 | { |
darienf | 3:36de8b9e4b1a | 344 | connectionDialog.ShowDialog(); |
darienf | 3:36de8b9e4b1a | 345 | } |
darienf | 3:36de8b9e4b1a | 346 | |
darienf | 3:36de8b9e4b1a | 347 | // Break out of loop if user canceled |
darienf | 3:36de8b9e4b1a | 348 | if (connectionDialog.Canceled == true) |
darienf | 3:36de8b9e4b1a | 349 | { |
darienf | 3:36de8b9e4b1a | 350 | guiDisconnected(); |
darienf | 3:36de8b9e4b1a | 351 | break; |
darienf | 3:36de8b9e4b1a | 352 | } |
darienf | 3:36de8b9e4b1a | 353 | |
darienf | 3:36de8b9e4b1a | 354 | // Get the port from the dialog form, returns default property |
darienf | 3:36de8b9e4b1a | 355 | // for first use |
darienf | 3:36de8b9e4b1a | 356 | port = connectionDialog.Port; |
darienf | 3:36de8b9e4b1a | 357 | if (String.Compare(port, "") == 0) |
darienf | 3:36de8b9e4b1a | 358 | continue; |
darienf | 3:36de8b9e4b1a | 359 | |
darienf | 3:36de8b9e4b1a | 360 | |
darienf | 3:36de8b9e4b1a | 361 | // Connect to port |
darienf | 3:36de8b9e4b1a | 362 | try |
darienf | 3:36de8b9e4b1a | 363 | { |
darienf | 3:36de8b9e4b1a | 364 | rpcClient.Connect(port); |
darienf | 3:36de8b9e4b1a | 365 | if (rpcClient.IsConnected() == true) |
darienf | 3:36de8b9e4b1a | 366 | { |
darienf | 3:36de8b9e4b1a | 367 | guiConnected(); |
darienf | 3:36de8b9e4b1a | 368 | break; |
darienf | 3:36de8b9e4b1a | 369 | } |
darienf | 3:36de8b9e4b1a | 370 | else // Connected to COM port, but cannot query STM32_HV |
darienf | 3:36de8b9e4b1a | 371 | { |
darienf | 3:36de8b9e4b1a | 372 | MessageBox.Show("Device not found on selected port", "Connection Issue"); |
darienf | 3:36de8b9e4b1a | 373 | guiDisconnected(); |
darienf | 3:36de8b9e4b1a | 374 | } |
darienf | 3:36de8b9e4b1a | 375 | } |
darienf | 3:36de8b9e4b1a | 376 | catch (TimeoutException) |
darienf | 3:36de8b9e4b1a | 377 | { |
darienf | 3:36de8b9e4b1a | 378 | guiDisconnected(); |
darienf | 3:36de8b9e4b1a | 379 | rpcClient.Disconnect(); |
darienf | 3:36de8b9e4b1a | 380 | MessageBox.Show("Unable to communicate with device, communication timed out.\nVerified selected port is correct.", |
darienf | 3:36de8b9e4b1a | 381 | "Connection Issue"); |
darienf | 3:36de8b9e4b1a | 382 | } |
darienf | 3:36de8b9e4b1a | 383 | catch (System.IO.IOException) |
darienf | 3:36de8b9e4b1a | 384 | { |
darienf | 3:36de8b9e4b1a | 385 | guiDisconnected(); |
darienf | 3:36de8b9e4b1a | 386 | MessageBox.Show("Select a valid COM port. Unable to connect with device.\n\nVerify the " + PartNumber + " board is plugged in and turned on. Turn on by pressing the button on the board for 3 seconds until the red LED starts blinking.", |
darienf | 3:36de8b9e4b1a | 387 | "Connection Issue"); |
darienf | 3:36de8b9e4b1a | 388 | } |
darienf | 3:36de8b9e4b1a | 389 | catch (UnauthorizedAccessException) |
darienf | 3:36de8b9e4b1a | 390 | { |
darienf | 3:36de8b9e4b1a | 391 | // Port does not exist |
darienf | 3:36de8b9e4b1a | 392 | } |
darienf | 3:36de8b9e4b1a | 393 | } |
darienf | 3:36de8b9e4b1a | 394 | } |
darienf | 3:36de8b9e4b1a | 395 | |
darienf | 3:36de8b9e4b1a | 396 | bool checkFirmware() |
darienf | 3:36de8b9e4b1a | 397 | { |
darienf | 3:36de8b9e4b1a | 398 | string reply; |
darienf | 3:36de8b9e4b1a | 399 | |
darienf | 3:36de8b9e4b1a | 400 | reply = rpcClient.RawRpcCall(readVersionCommand, true); |
darienf | 3:36de8b9e4b1a | 401 | |
darienf | 3:36de8b9e4b1a | 402 | return reply.StartsWith(firmwareKey); |
darienf | 3:36de8b9e4b1a | 403 | } |
darienf | 3:36de8b9e4b1a | 404 | |
darienf | 3:36de8b9e4b1a | 405 | void guiConnected() |
darienf | 3:36de8b9e4b1a | 406 | { |
darienf | 3:36de8b9e4b1a | 407 | ss_Status.Items[1].Text = rpcClient.Version();//rpcClient.RawRpcCall(readVersionCommand, true); // TODO this should be moved into the RPCSupport as a virtual system device |
darienf | 3:36de8b9e4b1a | 408 | ss_Status.Items[2].Text = "Hardware Connected (" + port + ")"; |
darienf | 3:36de8b9e4b1a | 409 | |
darienf | 3:36de8b9e4b1a | 410 | connected = true; |
darienf | 3:36de8b9e4b1a | 411 | |
darienf | 3:36de8b9e4b1a | 412 | //connectionToolStripMenuItem.Enabled = false; |
darienf | 3:36de8b9e4b1a | 413 | //disconnectToolStripMenuItem.Enabled = true; |
darienf | 3:36de8b9e4b1a | 414 | |
darienf | 3:36de8b9e4b1a | 415 | connectionToolStripMenuItem.Checked = true; |
darienf | 3:36de8b9e4b1a | 416 | disconnectToolStripMenuItem.Checked = false; |
darienf | 3:36de8b9e4b1a | 417 | |
darienf | 3:36de8b9e4b1a | 418 | // Enable Communication for each Device View |
darienf | 3:36de8b9e4b1a | 419 | foreach (IDeviceView device in deviceViews) |
darienf | 3:36de8b9e4b1a | 420 | { |
darienf | 3:36de8b9e4b1a | 421 | device.Connected = true; |
darienf | 3:36de8b9e4b1a | 422 | } |
darienf | 3:36de8b9e4b1a | 423 | |
darienf | 3:36de8b9e4b1a | 424 | // TODO Ask F/W team if this is needed |
darienf | 3:36de8b9e4b1a | 425 | rpcClient.MAX30001.WriteReg(0x02, 0x3); |
darienf | 3:36de8b9e4b1a | 426 | rpcClient.MAX30001.WriteReg(0x03, 0x3); |
darienf | 3:36de8b9e4b1a | 427 | |
darienf | 3:36de8b9e4b1a | 428 | max30001Model = new Model.MAX30001Model(max30001); |
darienf | 3:36de8b9e4b1a | 429 | partIDInit(); |
darienf | 3:36de8b9e4b1a | 430 | |
darienf | 3:36de8b9e4b1a | 431 | dataLoggingView1.Enabled = checkFlashID(); |
darienf | 3:36de8b9e4b1a | 432 | |
darienf | 3:36de8b9e4b1a | 433 | // Read device registers |
darienf | 3:36de8b9e4b1a | 434 | UpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 435 | |
darienf | 3:36de8b9e4b1a | 436 | if (Connected != null) |
darienf | 3:36de8b9e4b1a | 437 | Connected(this, new EventArgs()); |
darienf | 3:36de8b9e4b1a | 438 | } |
darienf | 3:36de8b9e4b1a | 439 | |
darienf | 3:36de8b9e4b1a | 440 | |
darienf | 3:36de8b9e4b1a | 441 | void guiDisconnected() |
darienf | 3:36de8b9e4b1a | 442 | { |
darienf | 3:36de8b9e4b1a | 443 | if (this.ss_Status.InvokeRequired) |
darienf | 3:36de8b9e4b1a | 444 | { |
darienf | 3:36de8b9e4b1a | 445 | guiDisconnectedCallBack d = new guiDisconnectedCallBack(guiDisconnected); |
darienf | 3:36de8b9e4b1a | 446 | this.Invoke(d); |
darienf | 3:36de8b9e4b1a | 447 | } |
darienf | 3:36de8b9e4b1a | 448 | else |
darienf | 3:36de8b9e4b1a | 449 | { |
darienf | 3:36de8b9e4b1a | 450 | ss_Status.Items[1].Text = ""; |
darienf | 3:36de8b9e4b1a | 451 | ss_Status.Items[2].Text = "Hardware Not Connected"; |
darienf | 3:36de8b9e4b1a | 452 | //UpdateConnection(null, false);; |
darienf | 3:36de8b9e4b1a | 453 | connected = false; |
darienf | 3:36de8b9e4b1a | 454 | |
darienf | 3:36de8b9e4b1a | 455 | //connectionToolStripMenuItem.Enabled = true; |
darienf | 3:36de8b9e4b1a | 456 | //disconnectToolStripMenuItem.Enabled = false; |
darienf | 3:36de8b9e4b1a | 457 | |
darienf | 3:36de8b9e4b1a | 458 | connectionToolStripMenuItem.Checked = false; |
darienf | 3:36de8b9e4b1a | 459 | disconnectToolStripMenuItem.Checked = true; |
darienf | 3:36de8b9e4b1a | 460 | |
darienf | 3:36de8b9e4b1a | 461 | foreach (IDeviceView device in deviceViews) |
darienf | 3:36de8b9e4b1a | 462 | { |
darienf | 3:36de8b9e4b1a | 463 | device.Connected = false; |
darienf | 3:36de8b9e4b1a | 464 | } |
darienf | 3:36de8b9e4b1a | 465 | } |
darienf | 3:36de8b9e4b1a | 466 | } |
darienf | 3:36de8b9e4b1a | 467 | |
darienf | 3:36de8b9e4b1a | 468 | void InitRpcClient() |
darienf | 3:36de8b9e4b1a | 469 | { |
darienf | 3:36de8b9e4b1a | 470 | rpcClient = new RPCSupport.RPCClient(RPCSupport.RPCClient.ePipeline.eSerialWrap); |
darienf | 3:36de8b9e4b1a | 471 | rpcClient.InitPipeline(); |
darienf | 3:36de8b9e4b1a | 472 | } |
darienf | 3:36de8b9e4b1a | 473 | |
darienf | 3:36de8b9e4b1a | 474 | void InitRpcDevices() |
darienf | 3:36de8b9e4b1a | 475 | { |
darienf | 3:36de8b9e4b1a | 476 | i2cDevice = rpcClient.Init_I2cDevice(); |
darienf | 3:36de8b9e4b1a | 477 | spiDevice = rpcClient.Init_SpiDevice(); |
darienf | 3:36de8b9e4b1a | 478 | max30101 = rpcClient.Init_MAX30101(0xAE); |
darienf | 3:36de8b9e4b1a | 479 | max30205 = rpcClient.Init_MAX30205(0x32); |
darienf | 3:36de8b9e4b1a | 480 | lis2hd = rpcClient.Init_LIS2HD(0x50); |
darienf | 3:36de8b9e4b1a | 481 | max30001 = rpcClient.Init_MAX30001(); |
darienf | 3:36de8b9e4b1a | 482 | logging = rpcClient.Init_Logging(); |
darienf | 3:36de8b9e4b1a | 483 | } |
darienf | 3:36de8b9e4b1a | 484 | |
darienf | 3:36de8b9e4b1a | 485 | private void Form_Load(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 486 | { |
darienf | 3:36de8b9e4b1a | 487 | if (splashScreen.SplashDisabled() == false) |
darienf | 3:36de8b9e4b1a | 488 | splashScreen.ShowDialog(); |
darienf | 3:36de8b9e4b1a | 489 | |
darienf | 3:36de8b9e4b1a | 490 | while (splashScreen.Visible == true) |
darienf | 3:36de8b9e4b1a | 491 | Thread.Sleep(100); |
darienf | 3:36de8b9e4b1a | 492 | |
darienf | 3:36de8b9e4b1a | 493 | comPortConnect(); |
darienf | 3:36de8b9e4b1a | 494 | } |
darienf | 3:36de8b9e4b1a | 495 | |
darienf | 3:36de8b9e4b1a | 496 | void PrimitivesViewInit() |
darienf | 3:36de8b9e4b1a | 497 | { |
darienf | 3:36de8b9e4b1a | 498 | primitivesView1.rpcClient = rpcClient; |
darienf | 3:36de8b9e4b1a | 499 | primitivesView1.i2cDevice = i2cDevice; |
darienf | 3:36de8b9e4b1a | 500 | primitivesView1.spiDevice = spiDevice; |
darienf | 3:36de8b9e4b1a | 501 | primitivesView1.max30101 = max30101; |
darienf | 3:36de8b9e4b1a | 502 | primitivesView1.max30205 = max30205; |
darienf | 3:36de8b9e4b1a | 503 | primitivesView1.max30001 = max30001; |
darienf | 3:36de8b9e4b1a | 504 | primitivesView1.lis2hd = lis2hd; |
darienf | 3:36de8b9e4b1a | 505 | |
darienf | 3:36de8b9e4b1a | 506 | maximTabControl1.HideTab("tpPrimitives"); |
darienf | 3:36de8b9e4b1a | 507 | } |
darienf | 3:36de8b9e4b1a | 508 | |
darienf | 3:36de8b9e4b1a | 509 | void OpticalViewInit() |
darienf | 3:36de8b9e4b1a | 510 | { |
darienf | 3:36de8b9e4b1a | 511 | opticalView1.RPCClient = rpcClient; |
darienf | 3:36de8b9e4b1a | 512 | //opticalView1.StreamingStartStop += new OpticalView.StreamingStartStopEventHandler(opticalView_StreamingStartStop); |
darienf | 3:36de8b9e4b1a | 513 | opticalView1.StreamingStartStop += new EventHandler<StreamingStartStopEventArgs>(opticalView_StreamingStartStop); |
darienf | 3:36de8b9e4b1a | 514 | dataLoggingView1.LoggingParametersChanged += new DataLoggingView.LoggingParametersHandler(dataLoggingFlashReadEventHandler); |
darienf | 3:36de8b9e4b1a | 515 | |
darienf | 3:36de8b9e4b1a | 516 | MaximSKAlgorithmClass algorithm = new MaximSKAlgorithmClass(); |
darienf | 3:36de8b9e4b1a | 517 | OpticalAlgorithmPresenter presenter = new OpticalAlgorithmPresenter(rpcClient, algorithm, opticalView1); |
darienf | 3:36de8b9e4b1a | 518 | } |
darienf | 3:36de8b9e4b1a | 519 | |
darienf | 3:36de8b9e4b1a | 520 | void ECGPlotsViewInit() |
darienf | 3:36de8b9e4b1a | 521 | { |
darienf | 3:36de8b9e4b1a | 522 | ecgView1.RPCClient = rpcClient; |
darienf | 3:36de8b9e4b1a | 523 | |
darienf | 3:36de8b9e4b1a | 524 | //cboEnRToR.SelectedIndexChanged += new EventHandler(cboStreaming_SelectedIndexChanged); |
darienf | 3:36de8b9e4b1a | 525 | //cboECGChannelEnable.SelectedIndexChanged += new EventHandler(cboStreaming_SelectedIndexChanged); |
darienf | 3:36de8b9e4b1a | 526 | |
darienf | 3:36de8b9e4b1a | 527 | ecgView1.GetEcgInitArgsPointer = new CustomControls.EcgView.GetEcgInitArgs(getEcgArgs); |
darienf | 3:36de8b9e4b1a | 528 | ecgView1.GetRToRInitArgsPointer = new CustomControls.EcgView.GetRToRInitArgs(getRToRArgs); |
darienf | 3:36de8b9e4b1a | 529 | ecgView1.GetBioZInitArgsPointer = new CustomControls.EcgView.GetBioZInitArgs(getBioZArgs); |
darienf | 3:36de8b9e4b1a | 530 | ecgView1.GetPaceInitArgsPointer = new CustomControls.EcgView.GetPaceInitArgs(getPaceArgs); |
darienf | 3:36de8b9e4b1a | 531 | |
darienf | 3:36de8b9e4b1a | 532 | ecgView1.StreamingStartStop += new EventHandler<StreamingStartStopEventArgs>(ecgView_StreamingStartStop); |
darienf | 3:36de8b9e4b1a | 533 | |
darienf | 3:36de8b9e4b1a | 534 | ecgView1.HspSetting = this; |
darienf | 3:36de8b9e4b1a | 535 | |
darienf | 3:36de8b9e4b1a | 536 | StreamPresenter streamPresenter = new StreamPresenter(rpcClient, ecgView1, this); |
darienf | 3:36de8b9e4b1a | 537 | } |
darienf | 3:36de8b9e4b1a | 538 | |
darienf | 3:36de8b9e4b1a | 539 | void LoggingViewInit() |
darienf | 3:36de8b9e4b1a | 540 | { |
darienf | 3:36de8b9e4b1a | 541 | dataLoggingView1.RPCClient = rpcClient; |
darienf | 3:36de8b9e4b1a | 542 | |
darienf | 3:36de8b9e4b1a | 543 | dataLoggingView1.GetEcgInitArgsPointer = new CustomControls.DataLoggingView.GetEcgInitArgs(getEcgArgs); |
darienf | 3:36de8b9e4b1a | 544 | dataLoggingView1.GetRToRInitArgsPointer = new CustomControls.DataLoggingView.GetRToRInitArgs(getRToRArgs); |
darienf | 3:36de8b9e4b1a | 545 | dataLoggingView1.GetBioZInitArgsPointer = new CustomControls.DataLoggingView.GetBioZInitArgs(getBioZArgs); |
darienf | 3:36de8b9e4b1a | 546 | dataLoggingView1.GetPaceInitArgsPointer = new CustomControls.DataLoggingView.GetPaceInitArgs(getPaceArgs); |
darienf | 3:36de8b9e4b1a | 547 | dataLoggingView1.GetFMSTRInitArgsPointer = new CustomControls.DataLoggingView.GetFMSTRInitArgs(getFMSTRArgs); |
darienf | 3:36de8b9e4b1a | 548 | dataLoggingView1.GetHRModeInitArgsPointer = new CustomControls.DataLoggingView.GetHRModeInitArgs(opticalView1.GetHRModeArgs); |
darienf | 3:36de8b9e4b1a | 549 | dataLoggingView1.GetSpO2HRModeInitArgsPointer = new CustomControls.DataLoggingView.GetSpO2HRModeInitArgs(opticalView1.GetSpO2HRModeArgs); |
darienf | 3:36de8b9e4b1a | 550 | dataLoggingView1.GetMultiModeInitArgsPointer = new CustomControls.DataLoggingView.GetMultiModeInitArgs(opticalView1.GetMultiModeArgs); |
darienf | 3:36de8b9e4b1a | 551 | |
darienf | 3:36de8b9e4b1a | 552 | Model.DataLogModel dataLogModel = new Model.DataLogModel(rpcClient); |
darienf | 3:36de8b9e4b1a | 553 | DataLogPresenter dataLogPresenter = new DataLogPresenter(this, ecgView1, opticalView1, dataLogModel, dataLoggingView1, new RawFileLogView(), new RawFileLogView(), new RawFileLogView(), |
darienf | 3:36de8b9e4b1a | 554 | new RawFileLogView(), new RawFileLogView(), new RawFileLogView(), new RawFileLogView(), new RawFileLogView(), new RawFileLogView()); |
darienf | 3:36de8b9e4b1a | 555 | } |
darienf | 3:36de8b9e4b1a | 556 | |
darienf | 3:36de8b9e4b1a | 557 | void FileLoggingInit() |
darienf | 3:36de8b9e4b1a | 558 | { |
darienf | 3:36de8b9e4b1a | 559 | IRawFileLogView ecgFileLog = new RawFileLogView(); |
darienf | 3:36de8b9e4b1a | 560 | IRawFileLogView bioZFileLog = new RawFileLogView(); |
darienf | 3:36de8b9e4b1a | 561 | |
darienf | 3:36de8b9e4b1a | 562 | //fileLogPresenter = new FileLogPresenter(ecgFileLog, bioZFileLog, this, rpcClient, ecgView1); |
darienf | 3:36de8b9e4b1a | 563 | //ecgView1.EcgLog = ecgFileLog; |
darienf | 3:36de8b9e4b1a | 564 | //ecgView1.BioZLog = bioZFileLog; |
darienf | 3:36de8b9e4b1a | 565 | |
darienf | 3:36de8b9e4b1a | 566 | IRawFileLogView ecgRawFileLog = new RawFileLogView(); |
darienf | 3:36de8b9e4b1a | 567 | IRawFileLogView paceRawFileLog = new RawFileLogView(); |
darienf | 3:36de8b9e4b1a | 568 | IRawFileLogView rToRFileLog = new RawFileLogView(); |
darienf | 3:36de8b9e4b1a | 569 | IRawFileLogView bioZRawFileLog = new RawFileLogView(); |
darienf | 3:36de8b9e4b1a | 570 | rawFileLogPresenter = new RawFileLogPresenter(ecgRawFileLog, bioZRawFileLog, rToRFileLog, paceRawFileLog, this, rpcClient, ecgView1, dataLoggingView1); |
darienf | 3:36de8b9e4b1a | 571 | |
darienf | 3:36de8b9e4b1a | 572 | IRawFileLogView opticalFileLog = new RawFileLogView(); |
darienf | 3:36de8b9e4b1a | 573 | IRawFileLogView accelFileLog = new RawFileLogView(); |
darienf | 3:36de8b9e4b1a | 574 | |
darienf | 3:36de8b9e4b1a | 575 | opticalFileLogPresenter = new OpticalFileLogPresenter(rpcClient, this, opticalView1, opticalFileLog, accelFileLog); |
darienf | 3:36de8b9e4b1a | 576 | |
darienf | 3:36de8b9e4b1a | 577 | } |
darienf | 3:36de8b9e4b1a | 578 | |
darienf | 3:36de8b9e4b1a | 579 | void RegisterExportInit() |
darienf | 3:36de8b9e4b1a | 580 | { |
darienf | 3:36de8b9e4b1a | 581 | RegisterExportPresenter registerExportPresenter; |
darienf | 3:36de8b9e4b1a | 582 | RegisterExportForm exportForm = new RegisterExportForm(); |
darienf | 3:36de8b9e4b1a | 583 | List<Maxim.CustomControls.RegisterView> registerViewList = new List<Maxim.CustomControls.RegisterView>(); |
darienf | 3:36de8b9e4b1a | 584 | |
darienf | 3:36de8b9e4b1a | 585 | registerViewList.AddRange(registerViews); |
darienf | 3:36de8b9e4b1a | 586 | |
darienf | 3:36de8b9e4b1a | 587 | registerExportPresenter = new RegisterExportPresenter(this, exportForm, registerViewList); |
darienf | 3:36de8b9e4b1a | 588 | } |
darienf | 3:36de8b9e4b1a | 589 | |
darienf | 3:36de8b9e4b1a | 590 | private void txt_Status_TextChanged(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 591 | { |
darienf | 3:36de8b9e4b1a | 592 | //Scroll to the bottom of the textbox when text is added |
darienf | 3:36de8b9e4b1a | 593 | txt_Status.SelectionStart = txt_Status.Text.Length; |
darienf | 3:36de8b9e4b1a | 594 | txt_Status.ScrollToCaret(); |
darienf | 3:36de8b9e4b1a | 595 | txt_Status.Refresh(); |
darienf | 3:36de8b9e4b1a | 596 | } |
darienf | 3:36de8b9e4b1a | 597 | |
darienf | 3:36de8b9e4b1a | 598 | private void btn_Clear_Click(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 599 | { |
darienf | 3:36de8b9e4b1a | 600 | //clear the status box |
darienf | 3:36de8b9e4b1a | 601 | txt_Status.Text = ""; |
darienf | 3:36de8b9e4b1a | 602 | } |
darienf | 3:36de8b9e4b1a | 603 | |
darienf | 3:36de8b9e4b1a | 604 | private void rvLIS2HDInit() |
darienf | 3:36de8b9e4b1a | 605 | { |
darienf | 3:36de8b9e4b1a | 606 | Maxim.CustomControls.LIS2DHInfo lis2DHInfo = new Maxim.CustomControls.LIS2DHInfo(); |
darienf | 3:36de8b9e4b1a | 607 | Maxim.CustomControls.DeviceController controller = new Maxim.CustomControls.DeviceController(); |
darienf | 3:36de8b9e4b1a | 608 | controller.SetRegisterInfo(lis2DHInfo); |
darienf | 3:36de8b9e4b1a | 609 | controller.SetInterface(rpcClient); |
darienf | 3:36de8b9e4b1a | 610 | rvLIS2HD.SetController(controller); |
darienf | 3:36de8b9e4b1a | 611 | //rvLIS2HD.ReadAll(); |
darienf | 3:36de8b9e4b1a | 612 | rvLIS2HD.DisplayRegisters(); |
darienf | 3:36de8b9e4b1a | 613 | rvLIS2HD.DeviceName = "LIS2DH"; |
darienf | 3:36de8b9e4b1a | 614 | |
darienf | 3:36de8b9e4b1a | 615 | |
darienf | 3:36de8b9e4b1a | 616 | //registerInfoData[0] = lis2DHInfo.Info; |
darienf | 3:36de8b9e4b1a | 617 | } |
darienf | 3:36de8b9e4b1a | 618 | |
darienf | 3:36de8b9e4b1a | 619 | private void rvMAX30101Init() |
darienf | 3:36de8b9e4b1a | 620 | { |
darienf | 3:36de8b9e4b1a | 621 | Maxim.CustomControls.MAX30101Info max30101Info = new Maxim.CustomControls.MAX30101Info(); |
darienf | 3:36de8b9e4b1a | 622 | Maxim.CustomControls.DeviceController controller = new Maxim.CustomControls.DeviceController(); |
darienf | 3:36de8b9e4b1a | 623 | controller.SetRegisterInfo(max30101Info); |
darienf | 3:36de8b9e4b1a | 624 | controller.SetInterface(rpcClient); |
darienf | 3:36de8b9e4b1a | 625 | rvMAX30101.SetController(controller); |
darienf | 3:36de8b9e4b1a | 626 | //rvMAX30101.ReadAll(); |
darienf | 3:36de8b9e4b1a | 627 | rvMAX30101.DisplayRegisters(); |
darienf | 3:36de8b9e4b1a | 628 | rvMAX30101.DeviceName = "MAX30101"; |
darienf | 3:36de8b9e4b1a | 629 | |
darienf | 3:36de8b9e4b1a | 630 | |
darienf | 3:36de8b9e4b1a | 631 | //registerInfoData[1] = max30101Info.Info; |
darienf | 3:36de8b9e4b1a | 632 | } |
darienf | 3:36de8b9e4b1a | 633 | |
darienf | 3:36de8b9e4b1a | 634 | private void rvMAX30205Init() |
darienf | 3:36de8b9e4b1a | 635 | { |
darienf | 3:36de8b9e4b1a | 636 | Maxim.CustomControls.MAX30205Info max30205Info = new Maxim.CustomControls.MAX30205Info(0x92); |
darienf | 3:36de8b9e4b1a | 637 | Maxim.CustomControls.DeviceController controller = new Maxim.CustomControls.DeviceController(); |
darienf | 3:36de8b9e4b1a | 638 | controller.SetRegisterInfo(max30205Info); |
darienf | 3:36de8b9e4b1a | 639 | controller.SetInterface(rpcClient); |
darienf | 3:36de8b9e4b1a | 640 | rvMAX30205.SetController(controller); |
darienf | 3:36de8b9e4b1a | 641 | //rvMAX30205.ReadAll(); |
darienf | 3:36de8b9e4b1a | 642 | rvMAX30205.DisplayRegisters(); |
darienf | 3:36de8b9e4b1a | 643 | rvMAX30205.DeviceName = "MAX30205 (Top)"; |
darienf | 3:36de8b9e4b1a | 644 | |
darienf | 3:36de8b9e4b1a | 645 | |
darienf | 3:36de8b9e4b1a | 646 | //registerInfoData[2] = max30205Info.Info; |
darienf | 3:36de8b9e4b1a | 647 | } |
darienf | 3:36de8b9e4b1a | 648 | |
darienf | 3:36de8b9e4b1a | 649 | private void rvMAX30205_U18Init() |
darienf | 3:36de8b9e4b1a | 650 | { |
darienf | 3:36de8b9e4b1a | 651 | Maxim.CustomControls.MAX30205Info max30205Info = new Maxim.CustomControls.MAX30205Info(); |
darienf | 3:36de8b9e4b1a | 652 | Maxim.CustomControls.DeviceController controller = new Maxim.CustomControls.DeviceController(); |
darienf | 3:36de8b9e4b1a | 653 | controller.SetRegisterInfo(max30205Info); |
darienf | 3:36de8b9e4b1a | 654 | controller.SetInterface(rpcClient); |
darienf | 3:36de8b9e4b1a | 655 | rvMAX30205_U18.SetController(controller); |
darienf | 3:36de8b9e4b1a | 656 | //rvMAX30205_U18.ReadAll(); |
darienf | 3:36de8b9e4b1a | 657 | rvMAX30205_U18.DisplayRegisters(); |
darienf | 3:36de8b9e4b1a | 658 | rvMAX30205_U18.DeviceName = "MAX30205 (Bottom)"; |
darienf | 3:36de8b9e4b1a | 659 | |
darienf | 3:36de8b9e4b1a | 660 | |
darienf | 3:36de8b9e4b1a | 661 | //registerInfoData[3] = max30205Info.Info; |
darienf | 3:36de8b9e4b1a | 662 | } |
darienf | 3:36de8b9e4b1a | 663 | |
darienf | 3:36de8b9e4b1a | 664 | private void rvMAX30001Init() |
darienf | 3:36de8b9e4b1a | 665 | { |
darienf | 3:36de8b9e4b1a | 666 | Maxim.CustomControls.MAX30001Info max30001Info = new Maxim.CustomControls.MAX30001Info(); |
darienf | 3:36de8b9e4b1a | 667 | Maxim.CustomControls.DeviceController controller = new Maxim.CustomControls.DeviceController(); |
darienf | 3:36de8b9e4b1a | 668 | controller.SetRegisterInfo(max30001Info); |
darienf | 3:36de8b9e4b1a | 669 | controller.SetInterface(rpcClient); |
darienf | 3:36de8b9e4b1a | 670 | rvMAX30001.SetController(controller); |
darienf | 3:36de8b9e4b1a | 671 | //rvMAX30001.ReadAll(); |
darienf | 3:36de8b9e4b1a | 672 | rvMAX30001.DisplayRegisters(); |
darienf | 3:36de8b9e4b1a | 673 | rvMAX30001.DeviceName = "MAX30001"; |
darienf | 3:36de8b9e4b1a | 674 | |
darienf | 3:36de8b9e4b1a | 675 | |
darienf | 3:36de8b9e4b1a | 676 | //registerInfoData[4] = max30001Info.Info; |
darienf | 3:36de8b9e4b1a | 677 | } |
darienf | 3:36de8b9e4b1a | 678 | |
darienf | 3:36de8b9e4b1a | 679 | private void rvMAX30003Init() |
darienf | 3:36de8b9e4b1a | 680 | { |
darienf | 3:36de8b9e4b1a | 681 | Maxim.CustomControls.MAX30003Info max30003Info = new Maxim.CustomControls.MAX30003Info(); |
darienf | 3:36de8b9e4b1a | 682 | Maxim.CustomControls.DeviceController controller = new Maxim.CustomControls.DeviceController(); |
darienf | 3:36de8b9e4b1a | 683 | controller.SetRegisterInfo(max30003Info); |
darienf | 3:36de8b9e4b1a | 684 | controller.SetInterface(rpcClient); |
darienf | 3:36de8b9e4b1a | 685 | rvMAX30001.SetController(controller); |
darienf | 3:36de8b9e4b1a | 686 | //rvMAX30001.ReadAll(); |
darienf | 3:36de8b9e4b1a | 687 | rvMAX30001.DisplayRegisters(); |
darienf | 3:36de8b9e4b1a | 688 | rvMAX30001.DeviceName = "MAX30003"; |
darienf | 3:36de8b9e4b1a | 689 | } |
darienf | 3:36de8b9e4b1a | 690 | |
darienf | 3:36de8b9e4b1a | 691 | private void rvMAX14720Init() |
darienf | 3:36de8b9e4b1a | 692 | { |
darienf | 3:36de8b9e4b1a | 693 | Maxim.CustomControls.MAX14720Info max14720Info = new Maxim.CustomControls.MAX14720Info(); |
darienf | 3:36de8b9e4b1a | 694 | Maxim.CustomControls.DeviceController controller = new Maxim.CustomControls.DeviceController(); |
darienf | 3:36de8b9e4b1a | 695 | controller.SetRegisterInfo(max14720Info); |
darienf | 3:36de8b9e4b1a | 696 | controller.SetInterface(rpcClient); |
darienf | 3:36de8b9e4b1a | 697 | rvMAX14720.SetController(controller); |
darienf | 3:36de8b9e4b1a | 698 | //rvMAX14720.ReadAll(); |
darienf | 3:36de8b9e4b1a | 699 | rvMAX14720.DisplayRegisters(); |
darienf | 3:36de8b9e4b1a | 700 | rvMAX14720.DeviceName = "MAX14720"; |
darienf | 3:36de8b9e4b1a | 701 | |
darienf | 3:36de8b9e4b1a | 702 | //registerInfoData[5] = max14720Info.Info; |
darienf | 3:36de8b9e4b1a | 703 | } |
darienf | 3:36de8b9e4b1a | 704 | |
darienf | 3:36de8b9e4b1a | 705 | private void partIDInit() |
darienf | 3:36de8b9e4b1a | 706 | { |
darienf | 3:36de8b9e4b1a | 707 | //rvMAX30001.Clear(); |
darienf | 3:36de8b9e4b1a | 708 | tabPageEnable(null, false); |
darienf | 3:36de8b9e4b1a | 709 | switch (max30001Model.PartID) |
darienf | 3:36de8b9e4b1a | 710 | { |
darienf | 3:36de8b9e4b1a | 711 | case Model.MAX30001Model.Part.MAX30003: |
darienf | 3:36de8b9e4b1a | 712 | // General GUI |
darienf | 3:36de8b9e4b1a | 713 | bioZMilliohmScaleToolStripMenuItem.Enabled = false; |
darienf | 3:36de8b9e4b1a | 714 | registerNamesToolStripMenuItem.Text = "Show MAX30003 Register Names"; |
darienf | 3:36de8b9e4b1a | 715 | paceFileLogToolStripMenuItem.Enabled = false; |
darienf | 3:36de8b9e4b1a | 716 | bioZFileLogToolStripMenuItem.Enabled = false; |
darienf | 3:36de8b9e4b1a | 717 | |
darienf | 3:36de8b9e4b1a | 718 | // Block Diagram |
darienf | 3:36de8b9e4b1a | 719 | picBlockDiagram.Image = global::HealthSensorPlatform.Properties.Resources.system_block_diagram_max30003; |
darienf | 3:36de8b9e4b1a | 720 | linkBioZChannel.Visible = false; |
darienf | 3:36de8b9e4b1a | 721 | linkBioZMux.Visible = false; |
darienf | 3:36de8b9e4b1a | 722 | linkBioZLoad.Visible = false; |
darienf | 3:36de8b9e4b1a | 723 | linkPaceChannel.Visible = false; |
darienf | 3:36de8b9e4b1a | 724 | linkLabelQuickBioimpedance.Visible = false; |
darienf | 3:36de8b9e4b1a | 725 | linkLabelQuickRespiration.Visible = false; |
darienf | 3:36de8b9e4b1a | 726 | |
darienf | 3:36de8b9e4b1a | 727 | // Global Panel |
darienf | 3:36de8b9e4b1a | 728 | chkEnBioZ.Enabled = false; |
darienf | 3:36de8b9e4b1a | 729 | chkEnPace.Enabled = false; |
darienf | 3:36de8b9e4b1a | 730 | grpGlobalControls.Text = "MAX30003 Global Controls"; |
darienf | 3:36de8b9e4b1a | 731 | |
darienf | 3:36de8b9e4b1a | 732 | // Tabs - not working |
darienf | 3:36de8b9e4b1a | 733 | tabPageEnable(null, true); |
darienf | 3:36de8b9e4b1a | 734 | |
darienf | 3:36de8b9e4b1a | 735 | // Plots |
darienf | 3:36de8b9e4b1a | 736 | ecgView1.BioZFunction(false); |
darienf | 3:36de8b9e4b1a | 737 | |
darienf | 3:36de8b9e4b1a | 738 | // Data Logging Tab |
darienf | 3:36de8b9e4b1a | 739 | dataLoggingView1.PaceFunction(false); |
darienf | 3:36de8b9e4b1a | 740 | dataLoggingView1.BioZFunction(false); |
darienf | 3:36de8b9e4b1a | 741 | |
darienf | 3:36de8b9e4b1a | 742 | //Register Tabs |
darienf | 3:36de8b9e4b1a | 743 | for(int i = 0; i < cboRegisterTabDevice.Items.Count; i++) |
darienf | 3:36de8b9e4b1a | 744 | { |
darienf | 3:36de8b9e4b1a | 745 | if ((string)cboRegisterTabDevice.Items[i] == "MAX30001") |
darienf | 3:36de8b9e4b1a | 746 | { |
darienf | 3:36de8b9e4b1a | 747 | cboRegisterTabDevice.Items[i] = "MAX30003"; |
darienf | 3:36de8b9e4b1a | 748 | } |
darienf | 3:36de8b9e4b1a | 749 | |
darienf | 3:36de8b9e4b1a | 750 | } |
darienf | 3:36de8b9e4b1a | 751 | rvMAX30003Init(); |
darienf | 3:36de8b9e4b1a | 752 | |
darienf | 3:36de8b9e4b1a | 753 | break; |
darienf | 3:36de8b9e4b1a | 754 | case Model.MAX30001Model.Part.MAX30001: |
darienf | 3:36de8b9e4b1a | 755 | // Defaults |
darienf | 3:36de8b9e4b1a | 756 | // General GUI |
darienf | 3:36de8b9e4b1a | 757 | bioZMilliohmScaleToolStripMenuItem.Enabled = true; |
darienf | 3:36de8b9e4b1a | 758 | registerNamesToolStripMenuItem.Text = "Show MAX30001 Register Names"; |
darienf | 3:36de8b9e4b1a | 759 | paceFileLogToolStripMenuItem.Enabled = true; |
darienf | 3:36de8b9e4b1a | 760 | bioZFileLogToolStripMenuItem.Enabled = true; |
darienf | 3:36de8b9e4b1a | 761 | |
darienf | 3:36de8b9e4b1a | 762 | // Block Diagram |
darienf | 3:36de8b9e4b1a | 763 | picBlockDiagram.Image = global::HealthSensorPlatform.Properties.Resources.system_block_diagram; |
darienf | 3:36de8b9e4b1a | 764 | linkBioZChannel.Visible = true; |
darienf | 3:36de8b9e4b1a | 765 | linkBioZMux.Visible = true; |
darienf | 3:36de8b9e4b1a | 766 | linkBioZLoad.Visible = true; |
darienf | 3:36de8b9e4b1a | 767 | linkPaceChannel.Visible = true; |
darienf | 3:36de8b9e4b1a | 768 | linkLabelQuickBioimpedance.Visible = true; |
darienf | 3:36de8b9e4b1a | 769 | linkLabelQuickRespiration.Visible = true; |
darienf | 3:36de8b9e4b1a | 770 | |
darienf | 3:36de8b9e4b1a | 771 | // Global Panel |
darienf | 3:36de8b9e4b1a | 772 | grpGlobalControls.Text = "MAX30001 Global Controls"; |
darienf | 3:36de8b9e4b1a | 773 | chkEnBioZ.Enabled = true; |
darienf | 3:36de8b9e4b1a | 774 | chkEnECG.Enabled = true; |
darienf | 3:36de8b9e4b1a | 775 | chkEnPace.Enabled = true; |
darienf | 3:36de8b9e4b1a | 776 | chkEnRtor.Enabled = true; |
darienf | 3:36de8b9e4b1a | 777 | |
darienf | 3:36de8b9e4b1a | 778 | // Tabs - not working |
darienf | 3:36de8b9e4b1a | 779 | tabPageEnable(null, true); |
darienf | 3:36de8b9e4b1a | 780 | |
darienf | 3:36de8b9e4b1a | 781 | // Plots |
darienf | 3:36de8b9e4b1a | 782 | ecgView1.BioZFunction(true); |
darienf | 3:36de8b9e4b1a | 783 | |
darienf | 3:36de8b9e4b1a | 784 | // Data Logging Tab |
darienf | 3:36de8b9e4b1a | 785 | dataLoggingView1.PaceFunction(true); |
darienf | 3:36de8b9e4b1a | 786 | dataLoggingView1.BioZFunction(true); |
darienf | 3:36de8b9e4b1a | 787 | |
darienf | 3:36de8b9e4b1a | 788 | //Register Tabs |
darienf | 3:36de8b9e4b1a | 789 | for (int i = 0; i < cboRegisterTabDevice.Items.Count; i++) |
darienf | 3:36de8b9e4b1a | 790 | { |
darienf | 3:36de8b9e4b1a | 791 | if ((string)cboRegisterTabDevice.Items[i] == "MAX30003") |
darienf | 3:36de8b9e4b1a | 792 | { |
darienf | 3:36de8b9e4b1a | 793 | cboRegisterTabDevice.Items[i] = "MAX30001"; |
darienf | 3:36de8b9e4b1a | 794 | } |
darienf | 3:36de8b9e4b1a | 795 | |
darienf | 3:36de8b9e4b1a | 796 | } |
darienf | 3:36de8b9e4b1a | 797 | rvMAX30001Init(); |
darienf | 3:36de8b9e4b1a | 798 | break; |
darienf | 3:36de8b9e4b1a | 799 | } |
darienf | 3:36de8b9e4b1a | 800 | } |
darienf | 3:36de8b9e4b1a | 801 | |
darienf | 3:36de8b9e4b1a | 802 | private bool checkFlashID() |
darienf | 3:36de8b9e4b1a | 803 | { |
darienf | 3:36de8b9e4b1a | 804 | string reply; |
darienf | 3:36de8b9e4b1a | 805 | |
darienf | 3:36de8b9e4b1a | 806 | reply = rpcClient.RawRpcCall(readFlashIDCommand, true); |
darienf | 3:36de8b9e4b1a | 807 | |
darienf | 3:36de8b9e4b1a | 808 | return (reply.StartsWith("00010219")); |
darienf | 3:36de8b9e4b1a | 809 | } |
darienf | 3:36de8b9e4b1a | 810 | |
darienf | 3:36de8b9e4b1a | 811 | private void tabPageEnable(TabPage exception, bool enable) |
darienf | 3:36de8b9e4b1a | 812 | { |
darienf | 3:36de8b9e4b1a | 813 | if (enable) |
darienf | 3:36de8b9e4b1a | 814 | { |
darienf | 3:36de8b9e4b1a | 815 | if (max30001Model.PartID == MAX30001Model.Part.MAX30003) |
darienf | 3:36de8b9e4b1a | 816 | { |
darienf | 3:36de8b9e4b1a | 817 | foreach (TabPage tp in maximTabControl1.TabPages) |
darienf | 3:36de8b9e4b1a | 818 | { |
darienf | 3:36de8b9e4b1a | 819 | if (!max30001TabPages.Contains(tp)) |
darienf | 3:36de8b9e4b1a | 820 | tp.Enabled = true; |
darienf | 3:36de8b9e4b1a | 821 | } |
darienf | 3:36de8b9e4b1a | 822 | } |
darienf | 3:36de8b9e4b1a | 823 | else |
darienf | 3:36de8b9e4b1a | 824 | { |
darienf | 3:36de8b9e4b1a | 825 | foreach (TabPage tp in maximTabControl1.TabPages) |
darienf | 3:36de8b9e4b1a | 826 | { |
darienf | 3:36de8b9e4b1a | 827 | tp.Enabled = true; |
darienf | 3:36de8b9e4b1a | 828 | } |
darienf | 3:36de8b9e4b1a | 829 | } |
darienf | 3:36de8b9e4b1a | 830 | } |
darienf | 3:36de8b9e4b1a | 831 | else |
darienf | 3:36de8b9e4b1a | 832 | { |
darienf | 3:36de8b9e4b1a | 833 | foreach (TabPage tp in maximTabControl1.TabPages) |
darienf | 3:36de8b9e4b1a | 834 | { |
darienf | 3:36de8b9e4b1a | 835 | if (tp != exception) |
darienf | 3:36de8b9e4b1a | 836 | tp.Enabled = false; |
darienf | 3:36de8b9e4b1a | 837 | } |
darienf | 3:36de8b9e4b1a | 838 | } |
darienf | 3:36de8b9e4b1a | 839 | |
darienf | 3:36de8b9e4b1a | 840 | maximTabControl1.Invalidate(); |
darienf | 3:36de8b9e4b1a | 841 | } |
darienf | 3:36de8b9e4b1a | 842 | |
darienf | 3:36de8b9e4b1a | 843 | private void aboutToolStripMenuItem_Click(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 844 | { |
darienf | 3:36de8b9e4b1a | 845 | splashScreen = new SplashScreen(120); |
darienf | 3:36de8b9e4b1a | 846 | InitSplashScreen(); |
darienf | 3:36de8b9e4b1a | 847 | splashScreen.Show(); |
darienf | 3:36de8b9e4b1a | 848 | splashScreen.ShowOKButton(); |
darienf | 3:36de8b9e4b1a | 849 | } |
darienf | 3:36de8b9e4b1a | 850 | |
darienf | 3:36de8b9e4b1a | 851 | private void exitToolStripMenuItem_Click(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 852 | { |
darienf | 3:36de8b9e4b1a | 853 | Application.Exit(); |
darienf | 3:36de8b9e4b1a | 854 | } |
darienf | 3:36de8b9e4b1a | 855 | |
darienf | 3:36de8b9e4b1a | 856 | private void maximTabControl1_SelectedIndexChanged(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 857 | { |
darienf | 3:36de8b9e4b1a | 858 | |
darienf | 3:36de8b9e4b1a | 859 | temperatureView1.TimerState(false); |
darienf | 3:36de8b9e4b1a | 860 | //ecgView1.Stream = false; // Disconnect plotting event for flash log data loading |
darienf | 3:36de8b9e4b1a | 861 | |
darienf | 3:36de8b9e4b1a | 862 | if (maximTabControl1.SelectedTab == tpBlockDiagram) |
darienf | 3:36de8b9e4b1a | 863 | { |
darienf | 3:36de8b9e4b1a | 864 | updateBlockDiagramLayout(); |
darienf | 3:36de8b9e4b1a | 865 | } |
darienf | 3:36de8b9e4b1a | 866 | else if (maximTabControl1.SelectedTab == tpTemperature) |
darienf | 3:36de8b9e4b1a | 867 | { |
darienf | 3:36de8b9e4b1a | 868 | if (connected) |
darienf | 3:36de8b9e4b1a | 869 | { |
darienf | 3:36de8b9e4b1a | 870 | // TODO |
darienf | 3:36de8b9e4b1a | 871 | /* |
darienf | 3:36de8b9e4b1a | 872 | temperatureView1.TimerState(true); |
darienf | 3:36de8b9e4b1a | 873 | temperatureView1.UpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 874 | temperatureView1.ReadTemperature(); |
darienf | 3:36de8b9e4b1a | 875 | */ |
darienf | 3:36de8b9e4b1a | 876 | temperatureView1.TimerState(true); |
darienf | 3:36de8b9e4b1a | 877 | temperaturePresenter.OnReadAll(this, new EventArgs()); |
darienf | 3:36de8b9e4b1a | 878 | } |
darienf | 3:36de8b9e4b1a | 879 | } |
darienf | 3:36de8b9e4b1a | 880 | else if (maximTabControl1.SelectedTab == tpMAX30001EcgChannel) |
darienf | 3:36de8b9e4b1a | 881 | { |
darienf | 3:36de8b9e4b1a | 882 | if (connected) |
darienf | 3:36de8b9e4b1a | 883 | { |
darienf | 3:36de8b9e4b1a | 884 | ECGChannelUpdateRegisters(); // and R to R |
darienf | 3:36de8b9e4b1a | 885 | ECGGlobalUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 886 | } |
darienf | 3:36de8b9e4b1a | 887 | |
darienf | 3:36de8b9e4b1a | 888 | pnlMAX30001Global.Parent = tpMAX30001EcgChannel; |
darienf | 3:36de8b9e4b1a | 889 | } |
darienf | 3:36de8b9e4b1a | 890 | else if (maximTabControl1.SelectedTab == tpMAX30001InputMux) |
darienf | 3:36de8b9e4b1a | 891 | { |
darienf | 3:36de8b9e4b1a | 892 | if (connected) |
darienf | 3:36de8b9e4b1a | 893 | { |
darienf | 3:36de8b9e4b1a | 894 | ECGInputMuxUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 895 | ECGGlobalUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 896 | } |
darienf | 3:36de8b9e4b1a | 897 | |
darienf | 3:36de8b9e4b1a | 898 | pnlMAX30001Global.Parent = tpMAX30001InputMux; |
darienf | 3:36de8b9e4b1a | 899 | } |
darienf | 3:36de8b9e4b1a | 900 | else if (maximTabControl1.SelectedTab == tpMAX30001Plots) |
darienf | 3:36de8b9e4b1a | 901 | { |
darienf | 3:36de8b9e4b1a | 902 | pnlMAX30001Global.Parent = tpMAX30001Plots; |
darienf | 3:36de8b9e4b1a | 903 | //ecgView1.Stream = true; |
darienf | 3:36de8b9e4b1a | 904 | //pnlMAX30001Global.BringToFront(); |
darienf | 3:36de8b9e4b1a | 905 | if (connected) |
darienf | 3:36de8b9e4b1a | 906 | { |
darienf | 3:36de8b9e4b1a | 907 | ECGGlobalUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 908 | } |
darienf | 3:36de8b9e4b1a | 909 | } |
darienf | 3:36de8b9e4b1a | 910 | else if (maximTabControl1.SelectedTab == tpBioZChannel) |
darienf | 3:36de8b9e4b1a | 911 | { |
darienf | 3:36de8b9e4b1a | 912 | if (connected) |
darienf | 3:36de8b9e4b1a | 913 | { |
darienf | 3:36de8b9e4b1a | 914 | BioZChannelUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 915 | ECGGlobalUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 916 | } |
darienf | 3:36de8b9e4b1a | 917 | pnlMAX30001Global.Parent = tpBioZChannel; |
darienf | 3:36de8b9e4b1a | 918 | } |
darienf | 3:36de8b9e4b1a | 919 | else if (maximTabControl1.SelectedTab == tpMAX30001BioZInputMux) |
darienf | 3:36de8b9e4b1a | 920 | { |
darienf | 3:36de8b9e4b1a | 921 | if (connected) |
darienf | 3:36de8b9e4b1a | 922 | { |
darienf | 3:36de8b9e4b1a | 923 | BioZInputMuxUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 924 | ECGGlobalUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 925 | } |
darienf | 3:36de8b9e4b1a | 926 | pnlMAX30001Global.Parent = tpMAX30001BioZInputMux; |
darienf | 3:36de8b9e4b1a | 927 | } |
darienf | 3:36de8b9e4b1a | 928 | else if (maximTabControl1.SelectedTab == tpMAX30001BioZLoad) |
darienf | 3:36de8b9e4b1a | 929 | { |
darienf | 3:36de8b9e4b1a | 930 | if (connected) |
darienf | 3:36de8b9e4b1a | 931 | { |
darienf | 3:36de8b9e4b1a | 932 | BioZLoadUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 933 | ECGGlobalUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 934 | } |
darienf | 3:36de8b9e4b1a | 935 | UpdateBioZLoadSwitches(); |
darienf | 3:36de8b9e4b1a | 936 | pnlMAX30001Global.Parent = tpMAX30001BioZLoad; |
darienf | 3:36de8b9e4b1a | 937 | } |
darienf | 3:36de8b9e4b1a | 938 | else if (maximTabControl1.SelectedTab == tpMAX30001Pace) |
darienf | 3:36de8b9e4b1a | 939 | { |
darienf | 3:36de8b9e4b1a | 940 | if (connected) |
darienf | 3:36de8b9e4b1a | 941 | { |
darienf | 3:36de8b9e4b1a | 942 | PaceChannelUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 943 | ECGGlobalUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 944 | } |
darienf | 3:36de8b9e4b1a | 945 | pnlMAX30001Global.Parent = tpMAX30001Pace; |
darienf | 3:36de8b9e4b1a | 946 | } |
darienf | 3:36de8b9e4b1a | 947 | else if (maximTabControl1.SelectedTab == tpFlashLog) |
darienf | 3:36de8b9e4b1a | 948 | { |
darienf | 3:36de8b9e4b1a | 949 | if (connected) |
darienf | 3:36de8b9e4b1a | 950 | { |
darienf | 3:36de8b9e4b1a | 951 | dataLoggingView1.UpdateArgs(); |
darienf | 3:36de8b9e4b1a | 952 | } |
darienf | 3:36de8b9e4b1a | 953 | } |
darienf | 3:36de8b9e4b1a | 954 | else if (maximTabControl1.SelectedTab == tpRegisters) |
darienf | 3:36de8b9e4b1a | 955 | { |
darienf | 3:36de8b9e4b1a | 956 | if (connected) |
darienf | 3:36de8b9e4b1a | 957 | { |
darienf | 3:36de8b9e4b1a | 958 | ((Maxim.CustomControls.RegisterView)registerViewDict[(string)(cboRegisterTabDevice.SelectedItem)]).ReadAll(); |
darienf | 3:36de8b9e4b1a | 959 | } |
darienf | 3:36de8b9e4b1a | 960 | } |
darienf | 3:36de8b9e4b1a | 961 | |
darienf | 3:36de8b9e4b1a | 962 | if (maximTabControl1.SelectedTab != null) // Support dynamic adding/removing of tabs |
darienf | 3:36de8b9e4b1a | 963 | pnlMAX30001Global.Location = new Point(0, maximTabControl1.SelectedTab.Size.Height - pnlMAX30001Global.Size.Height); |
darienf | 3:36de8b9e4b1a | 964 | |
darienf | 3:36de8b9e4b1a | 965 | ss_Status.MessagesLabel.Text = ""; // Clear any message from previous tabs |
darienf | 3:36de8b9e4b1a | 966 | } |
darienf | 3:36de8b9e4b1a | 967 | |
darienf | 3:36de8b9e4b1a | 968 | /// <summary> |
darienf | 3:36de8b9e4b1a | 969 | /// Read all registers, used for first connect |
darienf | 3:36de8b9e4b1a | 970 | /// </summary> |
darienf | 3:36de8b9e4b1a | 971 | public void UpdateRegisters() |
darienf | 3:36de8b9e4b1a | 972 | { |
darienf | 3:36de8b9e4b1a | 973 | ECGChannelUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 974 | ECGInputMuxUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 975 | ECGGlobalUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 976 | BioZChannelUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 977 | BioZInputMuxUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 978 | BioZLoadUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 979 | PaceChannelUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 980 | |
darienf | 3:36de8b9e4b1a | 981 | //rvLIS2HD.ReadAll(); |
darienf | 3:36de8b9e4b1a | 982 | //rvMAX14720.ReadAll(); |
darienf | 3:36de8b9e4b1a | 983 | //rvMAX30001.ReadAll(); |
darienf | 3:36de8b9e4b1a | 984 | //rvMAX30101.ReadAll(); |
darienf | 3:36de8b9e4b1a | 985 | //rvMAX30205.ReadAll(); |
darienf | 3:36de8b9e4b1a | 986 | //rvMAX30205_U18.ReadAll(); |
darienf | 3:36de8b9e4b1a | 987 | } |
darienf | 3:36de8b9e4b1a | 988 | |
darienf | 3:36de8b9e4b1a | 989 | #region Temperature Tab |
darienf | 3:36de8b9e4b1a | 990 | private void TemperatureViewInit() |
darienf | 3:36de8b9e4b1a | 991 | { |
darienf | 3:36de8b9e4b1a | 992 | MAX30205Model max30205_1 = new MAX30205Model(rpcClient.I2cDevice, 0x92); |
darienf | 3:36de8b9e4b1a | 993 | MAX30205Model max30205_2 = new MAX30205Model(rpcClient.I2cDevice, 0x90); |
darienf | 3:36de8b9e4b1a | 994 | |
darienf | 3:36de8b9e4b1a | 995 | temperaturePresenter = new MAX30205EVKit.Presenter.TemperaturePresenter(new MAX30205Model[] { max30205_1, max30205_2 }, temperatureView1, temperatureView1); |
darienf | 3:36de8b9e4b1a | 996 | //temperatureView1.max30205_1 = max30205; |
darienf | 3:36de8b9e4b1a | 997 | //temperatureView1.i2cDevice = i2cDevice; |
darienf | 3:36de8b9e4b1a | 998 | } |
darienf | 3:36de8b9e4b1a | 999 | #endregion |
darienf | 3:36de8b9e4b1a | 1000 | |
darienf | 3:36de8b9e4b1a | 1001 | #region Register Tab |
darienf | 3:36de8b9e4b1a | 1002 | private void RegistersTabInit() |
darienf | 3:36de8b9e4b1a | 1003 | { |
darienf | 3:36de8b9e4b1a | 1004 | pnlRegMAX30101.Visible = true; |
darienf | 3:36de8b9e4b1a | 1005 | pnlRegMAX30101.Visible = false; |
darienf | 3:36de8b9e4b1a | 1006 | pnlRegMAX30205.Visible = false; |
darienf | 3:36de8b9e4b1a | 1007 | pnlRegMAX14720.Visible = false; |
darienf | 3:36de8b9e4b1a | 1008 | |
darienf | 3:36de8b9e4b1a | 1009 | rvLIS2HDInit(); |
darienf | 3:36de8b9e4b1a | 1010 | rvMAX30001Init(); |
darienf | 3:36de8b9e4b1a | 1011 | rvMAX30101Init(); |
darienf | 3:36de8b9e4b1a | 1012 | rvMAX30205Init(); |
darienf | 3:36de8b9e4b1a | 1013 | rvMAX30205_U18Init(); |
darienf | 3:36de8b9e4b1a | 1014 | rvMAX14720Init(); |
darienf | 3:36de8b9e4b1a | 1015 | registerViewDict.Add(rvLIS2HD.DeviceName, rvLIS2HD); |
darienf | 3:36de8b9e4b1a | 1016 | registerViewDict.Add(rvMAX30001.DeviceName, rvMAX30001); |
darienf | 3:36de8b9e4b1a | 1017 | registerViewDict.Add("MAX30003", rvMAX30001); |
darienf | 3:36de8b9e4b1a | 1018 | registerViewDict.Add(rvMAX30101.DeviceName, rvMAX30101); |
darienf | 3:36de8b9e4b1a | 1019 | registerViewDict.Add(rvMAX30205.DeviceName, rvMAX30205); |
darienf | 3:36de8b9e4b1a | 1020 | registerViewDict.Add(rvMAX30205_U18.DeviceName, rvMAX30205_U18); |
darienf | 3:36de8b9e4b1a | 1021 | registerViewDict.Add(rvMAX14720.DeviceName, rvMAX14720); |
darienf | 3:36de8b9e4b1a | 1022 | |
darienf | 3:36de8b9e4b1a | 1023 | cboRegisterTabDevice.Items.Clear(); |
darienf | 3:36de8b9e4b1a | 1024 | foreach (Maxim.CustomControls.RegisterView rv in registerViews) |
darienf | 3:36de8b9e4b1a | 1025 | cboRegisterTabDevice.Items.Add(rv.DeviceName); |
darienf | 3:36de8b9e4b1a | 1026 | |
darienf | 3:36de8b9e4b1a | 1027 | cboRegisterTabDevice.SelectedIndex = 0; |
darienf | 3:36de8b9e4b1a | 1028 | |
darienf | 3:36de8b9e4b1a | 1029 | // Update status message when write is complete. Clear status message when entering the register data cell |
darienf | 3:36de8b9e4b1a | 1030 | foreach (Maxim.CustomControls.RegisterView rv in registerViews) |
darienf | 3:36de8b9e4b1a | 1031 | { |
darienf | 3:36de8b9e4b1a | 1032 | rv.CellBeginEdit += new Maxim.CustomControls.RegisterView.CellBeginEditHandler(registerView_CellBeginEdit); |
darienf | 3:36de8b9e4b1a | 1033 | rv.RegisterWriteComplete += new Maxim.CustomControls.RegisterView.RegisterWriteCompleteHandler(registerView_WriteComplete); |
darienf | 3:36de8b9e4b1a | 1034 | } |
darienf | 3:36de8b9e4b1a | 1035 | |
darienf | 3:36de8b9e4b1a | 1036 | } |
darienf | 3:36de8b9e4b1a | 1037 | |
darienf | 3:36de8b9e4b1a | 1038 | private void cboRegisterTabDevice_SelectedIndexChanged(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 1039 | { |
darienf | 3:36de8b9e4b1a | 1040 | MaximStyle.MaximComboBox cbo = (MaximStyle.MaximComboBox)sender; |
darienf | 3:36de8b9e4b1a | 1041 | |
darienf | 3:36de8b9e4b1a | 1042 | if (cbo.Text.CompareTo(rvMAX30001.DeviceName) == 0) |
darienf | 3:36de8b9e4b1a | 1043 | { |
darienf | 3:36de8b9e4b1a | 1044 | pnlRegMAX30001.Visible = true; |
darienf | 3:36de8b9e4b1a | 1045 | pnlRegMAX30101.Visible = false; |
darienf | 3:36de8b9e4b1a | 1046 | pnlRegMAX30205.Visible = false; |
darienf | 3:36de8b9e4b1a | 1047 | pnlRegMAX30205_U18.Visible = false; |
darienf | 3:36de8b9e4b1a | 1048 | pnlRegLIS2HD.Visible = false; |
darienf | 3:36de8b9e4b1a | 1049 | pnlRegMAX14720.Visible = false; |
darienf | 3:36de8b9e4b1a | 1050 | rvMAX30001.ReadAll(); |
darienf | 3:36de8b9e4b1a | 1051 | } |
darienf | 3:36de8b9e4b1a | 1052 | else if (cbo.Text.CompareTo(rvMAX30101.DeviceName) == 0) |
darienf | 3:36de8b9e4b1a | 1053 | { |
darienf | 3:36de8b9e4b1a | 1054 | pnlRegMAX30001.Visible = false; |
darienf | 3:36de8b9e4b1a | 1055 | pnlRegMAX30101.Visible = true; |
darienf | 3:36de8b9e4b1a | 1056 | pnlRegMAX30205.Visible = false; |
darienf | 3:36de8b9e4b1a | 1057 | pnlRegMAX30205_U18.Visible = false; |
darienf | 3:36de8b9e4b1a | 1058 | pnlRegLIS2HD.Visible = false; |
darienf | 3:36de8b9e4b1a | 1059 | pnlRegMAX14720.Visible = false; |
darienf | 3:36de8b9e4b1a | 1060 | rvMAX30101.ReadAll(); |
darienf | 3:36de8b9e4b1a | 1061 | } |
darienf | 3:36de8b9e4b1a | 1062 | else if (cbo.Text.CompareTo(rvMAX30205.DeviceName) == 0) |
darienf | 3:36de8b9e4b1a | 1063 | { |
darienf | 3:36de8b9e4b1a | 1064 | pnlRegMAX30001.Visible = false; |
darienf | 3:36de8b9e4b1a | 1065 | pnlRegMAX30101.Visible = false; |
darienf | 3:36de8b9e4b1a | 1066 | pnlRegMAX30205.Visible = true; |
darienf | 3:36de8b9e4b1a | 1067 | pnlRegMAX30205_U18.Visible = false; |
darienf | 3:36de8b9e4b1a | 1068 | pnlRegLIS2HD.Visible = false; |
darienf | 3:36de8b9e4b1a | 1069 | pnlRegMAX14720.Visible = false; |
darienf | 3:36de8b9e4b1a | 1070 | rvMAX30205.ReadAll(); |
darienf | 3:36de8b9e4b1a | 1071 | } |
darienf | 3:36de8b9e4b1a | 1072 | else if (cbo.Text.CompareTo(rvMAX30205_U18.DeviceName) == 0) |
darienf | 3:36de8b9e4b1a | 1073 | { |
darienf | 3:36de8b9e4b1a | 1074 | pnlRegMAX30001.Visible = false; |
darienf | 3:36de8b9e4b1a | 1075 | pnlRegMAX30101.Visible = false; |
darienf | 3:36de8b9e4b1a | 1076 | pnlRegMAX30205.Visible = true; |
darienf | 3:36de8b9e4b1a | 1077 | pnlRegMAX30205_U18.Visible = true; |
darienf | 3:36de8b9e4b1a | 1078 | pnlRegLIS2HD.Visible = false; |
darienf | 3:36de8b9e4b1a | 1079 | pnlRegMAX14720.Visible = false; |
darienf | 3:36de8b9e4b1a | 1080 | rvMAX30205_U18.ReadAll(); |
darienf | 3:36de8b9e4b1a | 1081 | } |
darienf | 3:36de8b9e4b1a | 1082 | else if (cbo.Text.CompareTo(rvLIS2HD.DeviceName) == 0) |
darienf | 3:36de8b9e4b1a | 1083 | { |
darienf | 3:36de8b9e4b1a | 1084 | pnlRegMAX30001.Visible = false; |
darienf | 3:36de8b9e4b1a | 1085 | pnlRegMAX30101.Visible = false; |
darienf | 3:36de8b9e4b1a | 1086 | pnlRegMAX30205.Visible = false; |
darienf | 3:36de8b9e4b1a | 1087 | pnlRegMAX30205_U18.Visible = false; |
darienf | 3:36de8b9e4b1a | 1088 | pnlRegLIS2HD.Visible = true; |
darienf | 3:36de8b9e4b1a | 1089 | pnlRegMAX14720.Visible = false; |
darienf | 3:36de8b9e4b1a | 1090 | rvLIS2HD.ReadAll(); |
darienf | 3:36de8b9e4b1a | 1091 | } |
darienf | 3:36de8b9e4b1a | 1092 | else if (cbo.Text.CompareTo(rvMAX14720.DeviceName) == 0) |
darienf | 3:36de8b9e4b1a | 1093 | { |
darienf | 3:36de8b9e4b1a | 1094 | pnlRegMAX30001.Visible = false; |
darienf | 3:36de8b9e4b1a | 1095 | pnlRegMAX30101.Visible = false; |
darienf | 3:36de8b9e4b1a | 1096 | pnlRegMAX30205.Visible = false; |
darienf | 3:36de8b9e4b1a | 1097 | pnlRegMAX30205_U18.Visible = false; |
darienf | 3:36de8b9e4b1a | 1098 | pnlRegLIS2HD.Visible = false; |
darienf | 3:36de8b9e4b1a | 1099 | pnlRegMAX14720.Visible = true; |
darienf | 3:36de8b9e4b1a | 1100 | rvMAX14720.ReadAll(); |
darienf | 3:36de8b9e4b1a | 1101 | } |
darienf | 3:36de8b9e4b1a | 1102 | } |
darienf | 3:36de8b9e4b1a | 1103 | #endregion |
darienf | 3:36de8b9e4b1a | 1104 | |
darienf | 3:36de8b9e4b1a | 1105 | #region Optical Tab |
darienf | 3:36de8b9e4b1a | 1106 | private void opticalView_StreamingStartStop(object sender, StreamingStartStopEventArgs e) |
darienf | 3:36de8b9e4b1a | 1107 | { |
darienf | 3:36de8b9e4b1a | 1108 | /* Disable user selection to Tabs when Streaming is enabled */ |
darienf | 3:36de8b9e4b1a | 1109 | streaming = e.state; |
darienf | 3:36de8b9e4b1a | 1110 | if (e.state == true) |
darienf | 3:36de8b9e4b1a | 1111 | { |
darienf | 3:36de8b9e4b1a | 1112 | tabPageEnable(tpOpticalSensor, false); |
darienf | 3:36de8b9e4b1a | 1113 | } |
darienf | 3:36de8b9e4b1a | 1114 | else |
darienf | 3:36de8b9e4b1a | 1115 | { |
darienf | 3:36de8b9e4b1a | 1116 | tabPageEnable(tpOpticalSensor, true); |
darienf | 3:36de8b9e4b1a | 1117 | } |
darienf | 3:36de8b9e4b1a | 1118 | maximTabControl1.Invalidate(); // Redraw the tabs |
darienf | 3:36de8b9e4b1a | 1119 | } |
darienf | 3:36de8b9e4b1a | 1120 | #endregion |
darienf | 3:36de8b9e4b1a | 1121 | |
darienf | 3:36de8b9e4b1a | 1122 | #region Block Diagrams |
darienf | 3:36de8b9e4b1a | 1123 | private void BlockDiagramsInit() |
darienf | 3:36de8b9e4b1a | 1124 | { |
darienf | 3:36de8b9e4b1a | 1125 | initalizeECGConfigFields(); |
darienf | 3:36de8b9e4b1a | 1126 | initalizeECGInputMuxFields(); |
darienf | 3:36de8b9e4b1a | 1127 | initalizeRToRFields(); |
darienf | 3:36de8b9e4b1a | 1128 | initalizeECGGlobalControls(); |
darienf | 3:36de8b9e4b1a | 1129 | initalizeBioZConfigFields(); |
darienf | 3:36de8b9e4b1a | 1130 | initalizeBioZInputMuxFields(); |
darienf | 3:36de8b9e4b1a | 1131 | initalizeBioZLoadFields(); |
darienf | 3:36de8b9e4b1a | 1132 | initalizePaceChannelFields(); |
darienf | 3:36de8b9e4b1a | 1133 | |
darienf | 3:36de8b9e4b1a | 1134 | // Set ECG Gain setting for chart Y-scale purposes |
darienf | 3:36de8b9e4b1a | 1135 | cboChannelGain.SelectedIndexChanged += new EventHandler(cboChannelGain_SelectedIndexChanged); |
darienf | 3:36de8b9e4b1a | 1136 | |
darienf | 3:36de8b9e4b1a | 1137 | //cboECGChannelEnable.SelectedIndex = 0; // Default is disabled |
darienf | 3:36de8b9e4b1a | 1138 | |
darienf | 3:36de8b9e4b1a | 1139 | initalizeToolTipEvents(ecgChannelField); |
darienf | 3:36de8b9e4b1a | 1140 | initalizeToolTipEvents(rToRField); |
darienf | 3:36de8b9e4b1a | 1141 | initalizeToolTipEvents(ecgInputMuxField); |
darienf | 3:36de8b9e4b1a | 1142 | initalizeToolTipEvents(ecgGlobalField); |
darienf | 3:36de8b9e4b1a | 1143 | initalizeToolTipEvents(bioZChannelField); |
darienf | 3:36de8b9e4b1a | 1144 | initalizeToolTipEvents(bioZInputMuxField); |
darienf | 3:36de8b9e4b1a | 1145 | initalizeToolTipEvents(bioZLoadField); |
darienf | 3:36de8b9e4b1a | 1146 | initalizeToolTipEvents(paceChannelField); |
darienf | 3:36de8b9e4b1a | 1147 | |
darienf | 3:36de8b9e4b1a | 1148 | // Force panel load for location placement in case of window resize |
darienf | 3:36de8b9e4b1a | 1149 | // on a tab where the panel is not shown otherwise it will show in a strange location |
darienf | 3:36de8b9e4b1a | 1150 | pnlMAX30001Global.Parent = tpMAX30001EcgChannel; |
darienf | 3:36de8b9e4b1a | 1151 | } |
darienf | 3:36de8b9e4b1a | 1152 | |
darienf | 3:36de8b9e4b1a | 1153 | #endregion |
darienf | 3:36de8b9e4b1a | 1154 | |
darienf | 3:36de8b9e4b1a | 1155 | #region Streaming |
darienf | 3:36de8b9e4b1a | 1156 | private void ecgView_StreamingStartStop(object sender, StreamingStartStopEventArgs e) |
darienf | 3:36de8b9e4b1a | 1157 | { |
darienf | 3:36de8b9e4b1a | 1158 | streaming = e.state; |
darienf | 3:36de8b9e4b1a | 1159 | /* Disable user selection to Tabs when Streaming is enabled */ |
darienf | 3:36de8b9e4b1a | 1160 | if (e.state == true) |
darienf | 3:36de8b9e4b1a | 1161 | { |
darienf | 3:36de8b9e4b1a | 1162 | tabPageEnable(tpMAX30001Plots, false); |
darienf | 3:36de8b9e4b1a | 1163 | |
darienf | 3:36de8b9e4b1a | 1164 | grpChannelPlotEnable.Enabled = false; |
darienf | 3:36de8b9e4b1a | 1165 | grpGlobalControls.Enabled = false; |
darienf | 3:36de8b9e4b1a | 1166 | menuStrip1.Enabled = false; |
darienf | 3:36de8b9e4b1a | 1167 | } |
darienf | 3:36de8b9e4b1a | 1168 | else |
darienf | 3:36de8b9e4b1a | 1169 | { |
darienf | 3:36de8b9e4b1a | 1170 | if (connected) |
darienf | 3:36de8b9e4b1a | 1171 | { |
darienf | 3:36de8b9e4b1a | 1172 | // Rewrite enable bits for global controls to allow GUI to maintain consistent state |
darienf | 3:36de8b9e4b1a | 1173 | foreach (RegisterField field in channelEnableField) |
darienf | 3:36de8b9e4b1a | 1174 | { |
darienf | 3:36de8b9e4b1a | 1175 | MaximCheckBox chk = (MaximStyle.MaximCheckBox)field.Control; |
darienf | 3:36de8b9e4b1a | 1176 | |
darienf | 3:36de8b9e4b1a | 1177 | if (chk.Checked) |
darienf | 3:36de8b9e4b1a | 1178 | writeCheckBox(chk); |
darienf | 3:36de8b9e4b1a | 1179 | } |
darienf | 3:36de8b9e4b1a | 1180 | |
darienf | 3:36de8b9e4b1a | 1181 | if (cboEnRbias.SelectedIndex != 0) |
darienf | 3:36de8b9e4b1a | 1182 | writeComboBox(cboEnRbias); |
darienf | 3:36de8b9e4b1a | 1183 | else if (cboBioZEnRbias.SelectedIndex != 0) |
darienf | 3:36de8b9e4b1a | 1184 | writeComboBox(cboBioZEnRbias); |
darienf | 3:36de8b9e4b1a | 1185 | |
darienf | 3:36de8b9e4b1a | 1186 | if (cboEnDcloff.SelectedIndex != 0) |
darienf | 3:36de8b9e4b1a | 1187 | writeComboBox(cboEnDcloff); |
darienf | 3:36de8b9e4b1a | 1188 | else if (cboBioZEnDcloff.SelectedIndex != 0) |
darienf | 3:36de8b9e4b1a | 1189 | writeComboBox(cboBioZEnDcloff); |
darienf | 3:36de8b9e4b1a | 1190 | |
darienf | 3:36de8b9e4b1a | 1191 | if (cboBioZDigitalLeadOffDetectionEnable.SelectedIndex != 0) |
darienf | 3:36de8b9e4b1a | 1192 | writeComboBox(cboBioZDigitalLeadOffDetectionEnable); |
darienf | 3:36de8b9e4b1a | 1193 | |
darienf | 3:36de8b9e4b1a | 1194 | if (cboEmuxEnUlpLon.SelectedIndex != 0) |
darienf | 3:36de8b9e4b1a | 1195 | writeComboBox(cboEmuxEnUlpLon); |
darienf | 3:36de8b9e4b1a | 1196 | else if (cboBmuxEnUlpLon.SelectedIndex != 0) |
darienf | 3:36de8b9e4b1a | 1197 | writeComboBox(cboBmuxEnUlpLon); |
darienf | 3:36de8b9e4b1a | 1198 | |
darienf | 3:36de8b9e4b1a | 1199 | } |
darienf | 3:36de8b9e4b1a | 1200 | |
darienf | 3:36de8b9e4b1a | 1201 | tabPageEnable(tpMAX30001Plots, true); |
darienf | 3:36de8b9e4b1a | 1202 | |
darienf | 3:36de8b9e4b1a | 1203 | grpChannelPlotEnable.Enabled = true; |
darienf | 3:36de8b9e4b1a | 1204 | grpGlobalControls.Enabled = true; |
darienf | 3:36de8b9e4b1a | 1205 | menuStrip1.Enabled = true; |
darienf | 3:36de8b9e4b1a | 1206 | } |
darienf | 3:36de8b9e4b1a | 1207 | |
darienf | 3:36de8b9e4b1a | 1208 | maximTabControl1.Invalidate(); // Redraw the tabs |
darienf | 3:36de8b9e4b1a | 1209 | } |
darienf | 3:36de8b9e4b1a | 1210 | #endregion |
darienf | 3:36de8b9e4b1a | 1211 | |
darienf | 3:36de8b9e4b1a | 1212 | #region Data Logging |
darienf | 3:36de8b9e4b1a | 1213 | // When Data Logging reads the flash, update the values on the other tabs to match what is in the flash |
darienf | 3:36de8b9e4b1a | 1214 | // The data logging tab will generate an event and run this method |
darienf | 3:36de8b9e4b1a | 1215 | private void dataLoggingFlashReadEventHandler(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 1216 | { |
darienf | 3:36de8b9e4b1a | 1217 | DataLoggingView dlView = (DataLoggingView)sender; |
darienf | 3:36de8b9e4b1a | 1218 | |
darienf | 3:36de8b9e4b1a | 1219 | if (dlView.EnableOpticalHR) |
darienf | 3:36de8b9e4b1a | 1220 | { |
darienf | 3:36de8b9e4b1a | 1221 | opticalView1.SetHRModeArgs(dlView.HRModeArgs); |
darienf | 3:36de8b9e4b1a | 1222 | } |
darienf | 3:36de8b9e4b1a | 1223 | else if (dlView.EnableOpticalSpO2) |
darienf | 3:36de8b9e4b1a | 1224 | { |
darienf | 3:36de8b9e4b1a | 1225 | opticalView1.SetSpO2HRModeArgs(dlView.SpO2HRModeArgs); |
darienf | 3:36de8b9e4b1a | 1226 | } |
darienf | 3:36de8b9e4b1a | 1227 | else if (dlView.EnableOpticalMulti) |
darienf | 3:36de8b9e4b1a | 1228 | { |
darienf | 3:36de8b9e4b1a | 1229 | opticalView1.SetMultiModeArgs(dlView.MultiModeArgs); |
darienf | 3:36de8b9e4b1a | 1230 | } |
darienf | 3:36de8b9e4b1a | 1231 | |
darienf | 3:36de8b9e4b1a | 1232 | if (dlView.EnableEcg) |
darienf | 3:36de8b9e4b1a | 1233 | { |
darienf | 3:36de8b9e4b1a | 1234 | setEcgArgs(dlView.EcgArgs); |
darienf | 3:36de8b9e4b1a | 1235 | } |
darienf | 3:36de8b9e4b1a | 1236 | |
darienf | 3:36de8b9e4b1a | 1237 | if (dlView.EnableBioz) |
darienf | 3:36de8b9e4b1a | 1238 | { |
darienf | 3:36de8b9e4b1a | 1239 | setBioZArgs(dlView.BioZArgs); |
darienf | 3:36de8b9e4b1a | 1240 | } |
darienf | 3:36de8b9e4b1a | 1241 | |
darienf | 3:36de8b9e4b1a | 1242 | if (dlView.EnableRToR) |
darienf | 3:36de8b9e4b1a | 1243 | { |
darienf | 3:36de8b9e4b1a | 1244 | setRToRArgs(dlView.RToRArgs); |
darienf | 3:36de8b9e4b1a | 1245 | } |
darienf | 3:36de8b9e4b1a | 1246 | |
darienf | 3:36de8b9e4b1a | 1247 | if (dlView.EnablePace) |
darienf | 3:36de8b9e4b1a | 1248 | { |
darienf | 3:36de8b9e4b1a | 1249 | setPaceArgs(dlView.PaceArgs); |
darienf | 3:36de8b9e4b1a | 1250 | } |
darienf | 3:36de8b9e4b1a | 1251 | } |
darienf | 3:36de8b9e4b1a | 1252 | #endregion |
darienf | 3:36de8b9e4b1a | 1253 | |
darienf | 3:36de8b9e4b1a | 1254 | private void connectionToolStripMenuItem_Click(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 1255 | { |
darienf | 3:36de8b9e4b1a | 1256 | if (connectionToolStripMenuItem.Checked) |
darienf | 3:36de8b9e4b1a | 1257 | { |
darienf | 3:36de8b9e4b1a | 1258 | connectionToolStripMenuItem.Checked = true; |
darienf | 3:36de8b9e4b1a | 1259 | return; |
darienf | 3:36de8b9e4b1a | 1260 | } |
darienf | 3:36de8b9e4b1a | 1261 | |
darienf | 3:36de8b9e4b1a | 1262 | if (!connected) |
darienf | 3:36de8b9e4b1a | 1263 | { |
darienf | 3:36de8b9e4b1a | 1264 | comPortConnect(); |
darienf | 3:36de8b9e4b1a | 1265 | } |
darienf | 3:36de8b9e4b1a | 1266 | } |
darienf | 3:36de8b9e4b1a | 1267 | |
darienf | 3:36de8b9e4b1a | 1268 | private void disconnectToolStripMenuItem_Click(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 1269 | { |
darienf | 3:36de8b9e4b1a | 1270 | if (disconnectToolStripMenuItem.Checked) |
darienf | 3:36de8b9e4b1a | 1271 | { |
darienf | 3:36de8b9e4b1a | 1272 | disconnectToolStripMenuItem.Checked = true; |
darienf | 3:36de8b9e4b1a | 1273 | return; |
darienf | 3:36de8b9e4b1a | 1274 | } |
darienf | 3:36de8b9e4b1a | 1275 | |
darienf | 3:36de8b9e4b1a | 1276 | if (connected) |
darienf | 3:36de8b9e4b1a | 1277 | { |
darienf | 3:36de8b9e4b1a | 1278 | guiDisconnected(); |
darienf | 3:36de8b9e4b1a | 1279 | rpcClient.Disconnect(); |
darienf | 3:36de8b9e4b1a | 1280 | } |
darienf | 3:36de8b9e4b1a | 1281 | } |
darienf | 3:36de8b9e4b1a | 1282 | |
darienf | 3:36de8b9e4b1a | 1283 | /// <summary> |
darienf | 3:36de8b9e4b1a | 1284 | /// Stop streaming before exiting HSP |
darienf | 3:36de8b9e4b1a | 1285 | /// </summary> |
darienf | 3:36de8b9e4b1a | 1286 | /// <param name="sender"></param> |
darienf | 3:36de8b9e4b1a | 1287 | /// <param name="e"></param> |
darienf | 3:36de8b9e4b1a | 1288 | private void HspForm_FormClosing(object sender, FormClosingEventArgs e) |
darienf | 3:36de8b9e4b1a | 1289 | { |
darienf | 3:36de8b9e4b1a | 1290 | try |
darienf | 3:36de8b9e4b1a | 1291 | { |
darienf | 3:36de8b9e4b1a | 1292 | if (connected) |
darienf | 3:36de8b9e4b1a | 1293 | { |
darienf | 3:36de8b9e4b1a | 1294 | opticalView1.Close(); // Stop streaming |
darienf | 3:36de8b9e4b1a | 1295 | ecgView1.Close(); |
darienf | 3:36de8b9e4b1a | 1296 | } |
darienf | 3:36de8b9e4b1a | 1297 | } |
darienf | 3:36de8b9e4b1a | 1298 | catch (Exception) |
darienf | 3:36de8b9e4b1a | 1299 | { |
darienf | 3:36de8b9e4b1a | 1300 | // We are exiting the GUI, we can ignore all exceptions |
darienf | 3:36de8b9e4b1a | 1301 | // Adding this for the case where the user unplugs HSP and quickly tries to close |
darienf | 3:36de8b9e4b1a | 1302 | // before the operating system reports USB removed |
darienf | 3:36de8b9e4b1a | 1303 | // Occurs while streaming ECG because we re-write the interrupt registers on stream stop |
darienf | 3:36de8b9e4b1a | 1304 | return; |
darienf | 3:36de8b9e4b1a | 1305 | } |
darienf | 3:36de8b9e4b1a | 1306 | } |
darienf | 3:36de8b9e4b1a | 1307 | |
darienf | 3:36de8b9e4b1a | 1308 | private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) |
darienf | 3:36de8b9e4b1a | 1309 | { |
darienf | 3:36de8b9e4b1a | 1310 | maximTabControl1.SelectedTab = tpMAX30001InputMux; |
darienf | 3:36de8b9e4b1a | 1311 | } |
darienf | 3:36de8b9e4b1a | 1312 | |
darienf | 3:36de8b9e4b1a | 1313 | private void linkLabel2_Click(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 1314 | { |
darienf | 3:36de8b9e4b1a | 1315 | maximTabControl1.SelectedTab = tpMAX30001BioZInputMux; |
darienf | 3:36de8b9e4b1a | 1316 | } |
darienf | 3:36de8b9e4b1a | 1317 | |
darienf | 3:36de8b9e4b1a | 1318 | private void linkLabelBioZLoad_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) |
darienf | 3:36de8b9e4b1a | 1319 | { |
darienf | 3:36de8b9e4b1a | 1320 | maximTabControl1.SelectedTab = tpMAX30001BioZLoad; |
darienf | 3:36de8b9e4b1a | 1321 | } |
darienf | 3:36de8b9e4b1a | 1322 | |
darienf | 3:36de8b9e4b1a | 1323 | private void linkLabelQuickOpticalSpO2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) |
darienf | 3:36de8b9e4b1a | 1324 | { |
darienf | 3:36de8b9e4b1a | 1325 | if (connected) |
darienf | 3:36de8b9e4b1a | 1326 | { |
darienf | 3:36de8b9e4b1a | 1327 | opticalView1.OpticalSensorDefaults(); |
darienf | 3:36de8b9e4b1a | 1328 | maximTabControl1.SelectedTab = tpOpticalSensor; |
darienf | 3:36de8b9e4b1a | 1329 | } |
darienf | 3:36de8b9e4b1a | 1330 | } |
darienf | 3:36de8b9e4b1a | 1331 | |
darienf | 3:36de8b9e4b1a | 1332 | private void linkLabelQuickTemperature_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) |
darienf | 3:36de8b9e4b1a | 1333 | { |
darienf | 3:36de8b9e4b1a | 1334 | if (connected) |
darienf | 3:36de8b9e4b1a | 1335 | { |
darienf | 3:36de8b9e4b1a | 1336 | temperaturePresenter.WriteRegister(0, 1, 0); |
darienf | 3:36de8b9e4b1a | 1337 | temperaturePresenter.WriteRegister(1, 1, 0); |
darienf | 3:36de8b9e4b1a | 1338 | maximTabControl1.SelectedTab = tpTemperature; |
darienf | 3:36de8b9e4b1a | 1339 | } |
darienf | 3:36de8b9e4b1a | 1340 | } |
darienf | 3:36de8b9e4b1a | 1341 | |
darienf | 3:36de8b9e4b1a | 1342 | private void linkLabelQuickEcg_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) |
darienf | 3:36de8b9e4b1a | 1343 | { |
darienf | 3:36de8b9e4b1a | 1344 | if (connected) |
darienf | 3:36de8b9e4b1a | 1345 | { |
darienf | 3:36de8b9e4b1a | 1346 | // SW_RST |
darienf | 3:36de8b9e4b1a | 1347 | max30001Model.Write(0x08, 1); |
darienf | 3:36de8b9e4b1a | 1348 | max30001Model.Write(0x08, 0); |
darienf | 3:36de8b9e4b1a | 1349 | // CNFG_GEN |
darienf | 3:36de8b9e4b1a | 1350 | max30001Model.Write(0x10, 0x080017); |
darienf | 3:36de8b9e4b1a | 1351 | // CNFG_EMUX |
darienf | 3:36de8b9e4b1a | 1352 | max30001Model.Write(0x14, 0x000000); |
darienf | 3:36de8b9e4b1a | 1353 | // CNFG_RTOR1 |
darienf | 3:36de8b9e4b1a | 1354 | max30001Model.Write(0x1d, 0x3FA300); |
darienf | 3:36de8b9e4b1a | 1355 | |
darienf | 3:36de8b9e4b1a | 1356 | ECGChannelUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 1357 | ECGInputMuxUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 1358 | |
darienf | 3:36de8b9e4b1a | 1359 | maximTabControl1.SelectedTab = tpMAX30001Plots; |
darienf | 3:36de8b9e4b1a | 1360 | } |
darienf | 3:36de8b9e4b1a | 1361 | } |
darienf | 3:36de8b9e4b1a | 1362 | |
darienf | 3:36de8b9e4b1a | 1363 | private void linkLabelQuickBioimpedance_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) |
darienf | 3:36de8b9e4b1a | 1364 | { |
darienf | 3:36de8b9e4b1a | 1365 | if (connected) |
darienf | 3:36de8b9e4b1a | 1366 | { |
darienf | 3:36de8b9e4b1a | 1367 | // SW_RST |
darienf | 3:36de8b9e4b1a | 1368 | max30001Model.Write(0x08, 1); |
darienf | 3:36de8b9e4b1a | 1369 | max30001Model.Write(0x08, 0); |
darienf | 3:36de8b9e4b1a | 1370 | // CNFG_GEN |
darienf | 3:36de8b9e4b1a | 1371 | max30001Model.Write(0x10, 0x040027); |
darienf | 3:36de8b9e4b1a | 1372 | // CNFG_BMUX |
darienf | 3:36de8b9e4b1a | 1373 | max30001Model.Write(0x17, 0x000040); |
darienf | 3:36de8b9e4b1a | 1374 | // CNFG_BIOZ |
darienf | 3:36de8b9e4b1a | 1375 | max30001Model.Write(0x18, 0x601430); |
darienf | 3:36de8b9e4b1a | 1376 | |
darienf | 3:36de8b9e4b1a | 1377 | ECGChannelUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 1378 | ECGInputMuxUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 1379 | BioZChannelUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 1380 | BioZInputMuxUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 1381 | |
darienf | 3:36de8b9e4b1a | 1382 | bioZMilliohmScaleToolStripMenuItem.Checked = false; |
darienf | 3:36de8b9e4b1a | 1383 | ecgView1.BioZMilliOhmRange = false; |
darienf | 3:36de8b9e4b1a | 1384 | |
darienf | 3:36de8b9e4b1a | 1385 | maximTabControl1.SelectedTab = tpMAX30001Plots; |
darienf | 3:36de8b9e4b1a | 1386 | } |
darienf | 3:36de8b9e4b1a | 1387 | } |
darienf | 3:36de8b9e4b1a | 1388 | |
darienf | 3:36de8b9e4b1a | 1389 | private void linkLabelQuickRespiration_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) |
darienf | 3:36de8b9e4b1a | 1390 | { |
darienf | 3:36de8b9e4b1a | 1391 | if (connected) |
darienf | 3:36de8b9e4b1a | 1392 | { |
darienf | 3:36de8b9e4b1a | 1393 | // SW_RST |
darienf | 3:36de8b9e4b1a | 1394 | max30001Model.Write(0x08, 1); |
darienf | 3:36de8b9e4b1a | 1395 | max30001Model.Write(0x08, 0); |
darienf | 3:36de8b9e4b1a | 1396 | // CNFG_GEN |
darienf | 3:36de8b9e4b1a | 1397 | max30001Model.Write(0x10, 0x040027); |
darienf | 3:36de8b9e4b1a | 1398 | // CNFG_BMUX |
darienf | 3:36de8b9e4b1a | 1399 | max30001Model.Write(0x17, 0x000040); |
darienf | 3:36de8b9e4b1a | 1400 | // CNFG_BIOZ |
darienf | 3:36de8b9e4b1a | 1401 | max30001Model.Write(0x18, 0x201050); |
darienf | 3:36de8b9e4b1a | 1402 | |
darienf | 3:36de8b9e4b1a | 1403 | ECGChannelUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 1404 | ECGInputMuxUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 1405 | BioZChannelUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 1406 | BioZInputMuxUpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 1407 | |
darienf | 3:36de8b9e4b1a | 1408 | bioZMilliohmScaleToolStripMenuItem.Checked = true; |
darienf | 3:36de8b9e4b1a | 1409 | ecgView1.BioZMilliOhmRange = true; |
darienf | 3:36de8b9e4b1a | 1410 | |
darienf | 3:36de8b9e4b1a | 1411 | maximTabControl1.SelectedTab = tpMAX30001Plots; |
darienf | 3:36de8b9e4b1a | 1412 | } |
darienf | 3:36de8b9e4b1a | 1413 | } |
darienf | 3:36de8b9e4b1a | 1414 | |
darienf | 3:36de8b9e4b1a | 1415 | private void btnSwRst_Click(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 1416 | { |
darienf | 3:36de8b9e4b1a | 1417 | if (!connected) |
darienf | 3:36de8b9e4b1a | 1418 | return; |
darienf | 3:36de8b9e4b1a | 1419 | |
darienf | 3:36de8b9e4b1a | 1420 | max30001.WriteReg(0x08, 0x01); |
darienf | 3:36de8b9e4b1a | 1421 | max30001.WriteReg(0x08, 0x00); |
darienf | 3:36de8b9e4b1a | 1422 | |
darienf | 3:36de8b9e4b1a | 1423 | UpdateRegisters(); |
darienf | 3:36de8b9e4b1a | 1424 | } |
darienf | 3:36de8b9e4b1a | 1425 | |
darienf | 3:36de8b9e4b1a | 1426 | private void btnSynch_Click(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 1427 | { |
darienf | 3:36de8b9e4b1a | 1428 | if (!connected) |
darienf | 3:36de8b9e4b1a | 1429 | return; |
darienf | 3:36de8b9e4b1a | 1430 | |
darienf | 3:36de8b9e4b1a | 1431 | max30001.WriteReg(0x09, 0x01); |
darienf | 3:36de8b9e4b1a | 1432 | max30001.WriteReg(0x09, 0x00); |
darienf | 3:36de8b9e4b1a | 1433 | } |
darienf | 3:36de8b9e4b1a | 1434 | |
darienf | 3:36de8b9e4b1a | 1435 | private void btnFifoRst_Click(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 1436 | { |
darienf | 3:36de8b9e4b1a | 1437 | if (!connected) |
darienf | 3:36de8b9e4b1a | 1438 | return; |
darienf | 3:36de8b9e4b1a | 1439 | |
darienf | 3:36de8b9e4b1a | 1440 | max30001.WriteReg(0x0A, 0x01); |
darienf | 3:36de8b9e4b1a | 1441 | max30001.WriteReg(0x0A, 0x00); |
darienf | 3:36de8b9e4b1a | 1442 | } |
darienf | 3:36de8b9e4b1a | 1443 | |
darienf | 3:36de8b9e4b1a | 1444 | private void registerNamesToolStripMenuItem_Click(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 1445 | { |
darienf | 3:36de8b9e4b1a | 1446 | List<RegisterField>[] fields = new List<RegisterField>[]{ ecgChannelField, ecgInputMuxField, ecgGlobalField, rToRField, bioZChannelField, bioZInputMuxField, bioZLoadField, paceChannelField }; |
darienf | 3:36de8b9e4b1a | 1447 | ToolStripMenuItem tsi = (ToolStripMenuItem)sender; |
darienf | 3:36de8b9e4b1a | 1448 | |
darienf | 3:36de8b9e4b1a | 1449 | if (tsi.Checked == true) |
darienf | 3:36de8b9e4b1a | 1450 | { |
darienf | 3:36de8b9e4b1a | 1451 | // Combo Boxes |
darienf | 3:36de8b9e4b1a | 1452 | foreach (List<RegisterField> listRegisterField in fields) |
darienf | 3:36de8b9e4b1a | 1453 | { |
darienf | 3:36de8b9e4b1a | 1454 | foreach(RegisterField rf in listRegisterField) |
darienf | 3:36de8b9e4b1a | 1455 | { |
darienf | 3:36de8b9e4b1a | 1456 | if (rf.Label != null) |
darienf | 3:36de8b9e4b1a | 1457 | rf.Label.Text = rf.Name; |
darienf | 3:36de8b9e4b1a | 1458 | } |
darienf | 3:36de8b9e4b1a | 1459 | } |
darienf | 3:36de8b9e4b1a | 1460 | |
darienf | 3:36de8b9e4b1a | 1461 | // Check Boxes |
darienf | 3:36de8b9e4b1a | 1462 | foreach (RegisterField rf in channelEnableField) |
darienf | 3:36de8b9e4b1a | 1463 | { |
darienf | 3:36de8b9e4b1a | 1464 | rf.LabelDescription = rf.Control.Text; |
darienf | 3:36de8b9e4b1a | 1465 | rf.Control.Text = rf.Name; |
darienf | 3:36de8b9e4b1a | 1466 | } |
darienf | 3:36de8b9e4b1a | 1467 | |
darienf | 3:36de8b9e4b1a | 1468 | string calHighRegName = "CAL_THIGH"; |
darienf | 3:36de8b9e4b1a | 1469 | cboCalFifty.Items[0] = calHighRegName; |
darienf | 3:36de8b9e4b1a | 1470 | cboBioZCalFifty.Items[0] = calHighRegName; |
darienf | 3:36de8b9e4b1a | 1471 | if (cboCalFifty.SelectedIndex == 0) |
darienf | 3:36de8b9e4b1a | 1472 | { |
darienf | 3:36de8b9e4b1a | 1473 | cboCalFifty.SelectedIndex = ecgCalFiftyField.ReadField(); |
darienf | 3:36de8b9e4b1a | 1474 | cboBioZCalFifty.SelectedIndex = biozCalFiftyField.ReadField(); |
darienf | 3:36de8b9e4b1a | 1475 | } |
darienf | 3:36de8b9e4b1a | 1476 | |
darienf | 3:36de8b9e4b1a | 1477 | } |
darienf | 3:36de8b9e4b1a | 1478 | else |
darienf | 3:36de8b9e4b1a | 1479 | { |
darienf | 3:36de8b9e4b1a | 1480 | // Combo Boxes |
darienf | 3:36de8b9e4b1a | 1481 | foreach (List<RegisterField> listRegisterField in fields) |
darienf | 3:36de8b9e4b1a | 1482 | { |
darienf | 3:36de8b9e4b1a | 1483 | foreach (RegisterField rf in listRegisterField) |
darienf | 3:36de8b9e4b1a | 1484 | { |
darienf | 3:36de8b9e4b1a | 1485 | if (rf.Label != null) |
darienf | 3:36de8b9e4b1a | 1486 | rf.Label.Text = rf.LabelDescription; |
darienf | 3:36de8b9e4b1a | 1487 | } |
darienf | 3:36de8b9e4b1a | 1488 | } |
darienf | 3:36de8b9e4b1a | 1489 | |
darienf | 3:36de8b9e4b1a | 1490 | // Check Boxes |
darienf | 3:36de8b9e4b1a | 1491 | foreach (RegisterField rf in channelEnableField) |
darienf | 3:36de8b9e4b1a | 1492 | { |
darienf | 3:36de8b9e4b1a | 1493 | rf.Control.Text = rf.LabelDescription; |
darienf | 3:36de8b9e4b1a | 1494 | } |
darienf | 3:36de8b9e4b1a | 1495 | |
darienf | 3:36de8b9e4b1a | 1496 | string calHighRegName = "Time High"; |
darienf | 3:36de8b9e4b1a | 1497 | cboCalFifty.Items[0] = calHighRegName; |
darienf | 3:36de8b9e4b1a | 1498 | cboBioZCalFifty.Items[0] = calHighRegName; |
darienf | 3:36de8b9e4b1a | 1499 | if (cboCalFifty.SelectedIndex == 0) |
darienf | 3:36de8b9e4b1a | 1500 | { |
darienf | 3:36de8b9e4b1a | 1501 | cboCalFifty.SelectedIndex = ecgCalFiftyField.ReadField(); |
darienf | 3:36de8b9e4b1a | 1502 | cboBioZCalFifty.SelectedIndex = biozCalFiftyField.ReadField(); |
darienf | 3:36de8b9e4b1a | 1503 | } |
darienf | 3:36de8b9e4b1a | 1504 | } |
darienf | 3:36de8b9e4b1a | 1505 | } |
darienf | 3:36de8b9e4b1a | 1506 | |
darienf | 3:36de8b9e4b1a | 1507 | /// <summary> |
darienf | 3:36de8b9e4b1a | 1508 | /// Prevent tab changes while streaming |
darienf | 3:36de8b9e4b1a | 1509 | /// </summary> |
darienf | 3:36de8b9e4b1a | 1510 | /// <param name="sender"></param> |
darienf | 3:36de8b9e4b1a | 1511 | /// <param name="e"></param> |
darienf | 3:36de8b9e4b1a | 1512 | private void maximTabControl1_Selecting(object sender, TabControlCancelEventArgs e) |
darienf | 3:36de8b9e4b1a | 1513 | { |
darienf | 3:36de8b9e4b1a | 1514 | if (streaming && connected) |
darienf | 3:36de8b9e4b1a | 1515 | e.Cancel = true; |
darienf | 3:36de8b9e4b1a | 1516 | } |
darienf | 3:36de8b9e4b1a | 1517 | |
darienf | 3:36de8b9e4b1a | 1518 | private void showAdvancedTabToolStripMenuItem_Click(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 1519 | { |
darienf | 3:36de8b9e4b1a | 1520 | if (showAdvancedTabToolStripMenuItem.Checked) |
darienf | 3:36de8b9e4b1a | 1521 | { |
darienf | 3:36de8b9e4b1a | 1522 | maximTabControl1.UnhideTab("tpPrimitives"); |
darienf | 3:36de8b9e4b1a | 1523 | } |
darienf | 3:36de8b9e4b1a | 1524 | else |
darienf | 3:36de8b9e4b1a | 1525 | { |
darienf | 3:36de8b9e4b1a | 1526 | maximTabControl1.HideTab("tpPrimitives"); |
darienf | 3:36de8b9e4b1a | 1527 | } |
darienf | 3:36de8b9e4b1a | 1528 | } |
darienf | 3:36de8b9e4b1a | 1529 | |
darienf | 3:36de8b9e4b1a | 1530 | private void registerView_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) |
darienf | 3:36de8b9e4b1a | 1531 | { |
darienf | 3:36de8b9e4b1a | 1532 | ss_Status.MessagesLabel.Text = ""; |
darienf | 3:36de8b9e4b1a | 1533 | } |
darienf | 3:36de8b9e4b1a | 1534 | |
darienf | 3:36de8b9e4b1a | 1535 | private void registerView_WriteComplete(object sender, Maxim.CustomControls.RegisterView.RegisterArgs e) |
darienf | 3:36de8b9e4b1a | 1536 | { |
darienf | 3:36de8b9e4b1a | 1537 | ss_Status.MessagesLabel.Text = "Write Reg " + e.Register.ToString("X2") + "h Complete"; |
darienf | 3:36de8b9e4b1a | 1538 | } |
darienf | 3:36de8b9e4b1a | 1539 | |
darienf | 3:36de8b9e4b1a | 1540 | private void bioZMilliohmScaleToolStripMenuItem_Click(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 1541 | { |
darienf | 3:36de8b9e4b1a | 1542 | // Set the BioZ chart to be in units of milliohms or ohms |
darienf | 3:36de8b9e4b1a | 1543 | ecgView1.BioZMilliOhmRange = bioZMilliohmScaleToolStripMenuItem.Checked; |
darienf | 3:36de8b9e4b1a | 1544 | } |
darienf | 3:36de8b9e4b1a | 1545 | |
darienf | 3:36de8b9e4b1a | 1546 | public void LogFileItem(StreamType stream, bool state) |
darienf | 3:36de8b9e4b1a | 1547 | { |
darienf | 3:36de8b9e4b1a | 1548 | switch(stream) |
darienf | 3:36de8b9e4b1a | 1549 | { |
darienf | 3:36de8b9e4b1a | 1550 | case StreamType.Ecg: |
darienf | 3:36de8b9e4b1a | 1551 | eCGFileLogToolStripMenuItem.Checked = state; |
darienf | 3:36de8b9e4b1a | 1552 | break; |
darienf | 3:36de8b9e4b1a | 1553 | case StreamType.RToR: |
darienf | 3:36de8b9e4b1a | 1554 | rToRFileLogToolStripMenuItem.Checked = state; |
darienf | 3:36de8b9e4b1a | 1555 | break; |
darienf | 3:36de8b9e4b1a | 1556 | case StreamType.Pace: |
darienf | 3:36de8b9e4b1a | 1557 | paceFileLogToolStripMenuItem.Checked = state; |
darienf | 3:36de8b9e4b1a | 1558 | break; |
darienf | 3:36de8b9e4b1a | 1559 | case StreamType.BioZ: |
darienf | 3:36de8b9e4b1a | 1560 | bioZFileLogToolStripMenuItem.Checked = state; |
darienf | 3:36de8b9e4b1a | 1561 | break; |
darienf | 3:36de8b9e4b1a | 1562 | case StreamType.Optical: |
darienf | 3:36de8b9e4b1a | 1563 | opticalAccelerometerFileLogToolStripMenuItem.Checked = state; |
darienf | 3:36de8b9e4b1a | 1564 | break; |
darienf | 3:36de8b9e4b1a | 1565 | |
darienf | 3:36de8b9e4b1a | 1566 | // TODO other stream types |
darienf | 3:36de8b9e4b1a | 1567 | } |
darienf | 3:36de8b9e4b1a | 1568 | } |
darienf | 3:36de8b9e4b1a | 1569 | |
darienf | 3:36de8b9e4b1a | 1570 | public void OpticalLogFileItem(bool state) |
darienf | 3:36de8b9e4b1a | 1571 | { |
darienf | 3:36de8b9e4b1a | 1572 | opticalAccelerometerFileLogToolStripMenuItem.Checked = state; |
darienf | 3:36de8b9e4b1a | 1573 | } |
darienf | 3:36de8b9e4b1a | 1574 | |
darienf | 3:36de8b9e4b1a | 1575 | public void EcgLogFileItem(bool state) |
darienf | 3:36de8b9e4b1a | 1576 | { |
darienf | 3:36de8b9e4b1a | 1577 | eCGFileLogToolStripMenuItem.Checked = state; |
darienf | 3:36de8b9e4b1a | 1578 | } |
darienf | 3:36de8b9e4b1a | 1579 | |
darienf | 3:36de8b9e4b1a | 1580 | public void BioZLogFileItem(bool state) |
darienf | 3:36de8b9e4b1a | 1581 | { |
darienf | 3:36de8b9e4b1a | 1582 | bioZFileLogToolStripMenuItem.Checked = state; |
darienf | 3:36de8b9e4b1a | 1583 | } |
darienf | 3:36de8b9e4b1a | 1584 | |
darienf | 3:36de8b9e4b1a | 1585 | public void RtoRLogFileItem(bool state) |
darienf | 3:36de8b9e4b1a | 1586 | { |
darienf | 3:36de8b9e4b1a | 1587 | rToRFileLogToolStripMenuItem.Checked = state; |
darienf | 3:36de8b9e4b1a | 1588 | } |
darienf | 3:36de8b9e4b1a | 1589 | |
darienf | 3:36de8b9e4b1a | 1590 | public void PaceLogFileItem(bool state) |
darienf | 3:36de8b9e4b1a | 1591 | { |
darienf | 3:36de8b9e4b1a | 1592 | paceFileLogToolStripMenuItem.Checked = state; |
darienf | 3:36de8b9e4b1a | 1593 | } |
darienf | 3:36de8b9e4b1a | 1594 | |
darienf | 3:36de8b9e4b1a | 1595 | private void eCGBioZFileLogToolStripMenuItem_Click(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 1596 | { |
darienf | 3:36de8b9e4b1a | 1597 | if (FileLogEnable != null) |
darienf | 3:36de8b9e4b1a | 1598 | FileLogEnable(this, new EnableEventArgs(StreamType.Ecg, !eCGBioZFileLogToolStripMenuItem.Checked)); |
darienf | 3:36de8b9e4b1a | 1599 | } |
darienf | 3:36de8b9e4b1a | 1600 | |
darienf | 3:36de8b9e4b1a | 1601 | private void eCGFileLogToolStripMenuItem_Click(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 1602 | { |
darienf | 3:36de8b9e4b1a | 1603 | if (FileLogEnable != null) |
darienf | 3:36de8b9e4b1a | 1604 | FileLogEnable(this, new EnableEventArgs(StreamType.Ecg, !eCGFileLogToolStripMenuItem.Checked)); |
darienf | 3:36de8b9e4b1a | 1605 | } |
darienf | 3:36de8b9e4b1a | 1606 | |
darienf | 3:36de8b9e4b1a | 1607 | private void rToRFileLogToolStripMenuItem_Click(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 1608 | { |
darienf | 3:36de8b9e4b1a | 1609 | if (FileLogEnable != null) |
darienf | 3:36de8b9e4b1a | 1610 | FileLogEnable(this, new EnableEventArgs(StreamType.RToR, !rToRFileLogToolStripMenuItem.Checked)); |
darienf | 3:36de8b9e4b1a | 1611 | } |
darienf | 3:36de8b9e4b1a | 1612 | |
darienf | 3:36de8b9e4b1a | 1613 | private void paceFileLogToolStripMenuItem_Click(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 1614 | { |
darienf | 3:36de8b9e4b1a | 1615 | if (FileLogEnable != null) |
darienf | 3:36de8b9e4b1a | 1616 | FileLogEnable(this, new EnableEventArgs(StreamType.Pace, !paceFileLogToolStripMenuItem.Checked)); |
darienf | 3:36de8b9e4b1a | 1617 | } |
darienf | 3:36de8b9e4b1a | 1618 | |
darienf | 3:36de8b9e4b1a | 1619 | private void bioZFileLogToolStripMenuItem_Click(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 1620 | { |
darienf | 3:36de8b9e4b1a | 1621 | if (FileLogEnable != null) |
darienf | 3:36de8b9e4b1a | 1622 | FileLogEnable(this, new EnableEventArgs(StreamType.BioZ, !bioZFileLogToolStripMenuItem.Checked)); |
darienf | 3:36de8b9e4b1a | 1623 | } |
darienf | 3:36de8b9e4b1a | 1624 | |
darienf | 3:36de8b9e4b1a | 1625 | private void opticalAccelerometerFileLogToolStripMenuItem_Click(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 1626 | { |
darienf | 3:36de8b9e4b1a | 1627 | if (OpticalFileLogEnable != null) |
darienf | 3:36de8b9e4b1a | 1628 | OpticalFileLogEnable(this, new EnableEventArgs(StreamType.Optical,!opticalAccelerometerFileLogToolStripMenuItem.Checked)); |
darienf | 3:36de8b9e4b1a | 1629 | } |
darienf | 3:36de8b9e4b1a | 1630 | |
darienf | 3:36de8b9e4b1a | 1631 | private void registerExportToolStripMenuItem_Click(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 1632 | { |
darienf | 3:36de8b9e4b1a | 1633 | if (RegisterExport != null) |
darienf | 3:36de8b9e4b1a | 1634 | RegisterExport(this, e); |
darienf | 3:36de8b9e4b1a | 1635 | } |
darienf | 3:36de8b9e4b1a | 1636 | |
darienf | 3:36de8b9e4b1a | 1637 | private void loadAllRegisterSettingsToolStripMenuItem_Click(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 1638 | { |
darienf | 3:36de8b9e4b1a | 1639 | if (RegisterImport != null) |
darienf | 3:36de8b9e4b1a | 1640 | RegisterImport(this, e); |
darienf | 3:36de8b9e4b1a | 1641 | } |
darienf | 3:36de8b9e4b1a | 1642 | |
darienf | 3:36de8b9e4b1a | 1643 | |
darienf | 3:36de8b9e4b1a | 1644 | #region Home Tab |
darienf | 3:36de8b9e4b1a | 1645 | private void linkTempSensor_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) |
darienf | 3:36de8b9e4b1a | 1646 | { |
darienf | 3:36de8b9e4b1a | 1647 | maximTabControl1.SelectedTab = tpTemperature; |
darienf | 3:36de8b9e4b1a | 1648 | } |
darienf | 3:36de8b9e4b1a | 1649 | |
darienf | 3:36de8b9e4b1a | 1650 | private void linkOpticalSensor_Click(object sender, LinkLabelLinkClickedEventArgs e) |
darienf | 3:36de8b9e4b1a | 1651 | { |
darienf | 3:36de8b9e4b1a | 1652 | maximTabControl1.SelectedTab = tpOpticalSensor; |
darienf | 3:36de8b9e4b1a | 1653 | } |
darienf | 3:36de8b9e4b1a | 1654 | |
darienf | 3:36de8b9e4b1a | 1655 | private void linkEcgChannel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) |
darienf | 3:36de8b9e4b1a | 1656 | { |
darienf | 3:36de8b9e4b1a | 1657 | maximTabControl1.SelectedTab = tpMAX30001EcgChannel; |
darienf | 3:36de8b9e4b1a | 1658 | } |
darienf | 3:36de8b9e4b1a | 1659 | |
darienf | 3:36de8b9e4b1a | 1660 | private void linkEcgMux_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) |
darienf | 3:36de8b9e4b1a | 1661 | { |
darienf | 3:36de8b9e4b1a | 1662 | maximTabControl1.SelectedTab = tpMAX30001InputMux; |
darienf | 3:36de8b9e4b1a | 1663 | } |
darienf | 3:36de8b9e4b1a | 1664 | |
darienf | 3:36de8b9e4b1a | 1665 | private void linkPaceChannel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) |
darienf | 3:36de8b9e4b1a | 1666 | { |
darienf | 3:36de8b9e4b1a | 1667 | maximTabControl1.SelectedTab = tpMAX30001Pace; |
darienf | 3:36de8b9e4b1a | 1668 | } |
darienf | 3:36de8b9e4b1a | 1669 | |
darienf | 3:36de8b9e4b1a | 1670 | private void linkBioZChannel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) |
darienf | 3:36de8b9e4b1a | 1671 | { |
darienf | 3:36de8b9e4b1a | 1672 | maximTabControl1.SelectedTab = tpBioZChannel; |
darienf | 3:36de8b9e4b1a | 1673 | } |
darienf | 3:36de8b9e4b1a | 1674 | |
darienf | 3:36de8b9e4b1a | 1675 | private void linkBioZMux_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) |
darienf | 3:36de8b9e4b1a | 1676 | { |
darienf | 3:36de8b9e4b1a | 1677 | maximTabControl1.SelectedTab = tpMAX30001BioZInputMux; |
darienf | 3:36de8b9e4b1a | 1678 | } |
darienf | 3:36de8b9e4b1a | 1679 | |
darienf | 3:36de8b9e4b1a | 1680 | private void linkBioZLoad_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) |
darienf | 3:36de8b9e4b1a | 1681 | { |
darienf | 3:36de8b9e4b1a | 1682 | maximTabControl1.SelectedTab = tpMAX30001BioZLoad; |
darienf | 3:36de8b9e4b1a | 1683 | } |
darienf | 3:36de8b9e4b1a | 1684 | #endregion |
darienf | 3:36de8b9e4b1a | 1685 | |
darienf | 3:36de8b9e4b1a | 1686 | private void updateBlockDiagramLayout() |
darienf | 3:36de8b9e4b1a | 1687 | { |
darienf | 3:36de8b9e4b1a | 1688 | //Stopwatch stopWatch = new Stopwatch(); |
darienf | 3:36de8b9e4b1a | 1689 | double scale; |
darienf | 3:36de8b9e4b1a | 1690 | int scaledWidth, scaledHeight; |
darienf | 3:36de8b9e4b1a | 1691 | int widthOffset; |
darienf | 3:36de8b9e4b1a | 1692 | int blockWidth = pnlBlockDiagram.Width; |
darienf | 3:36de8b9e4b1a | 1693 | int blockHeight = pnlBlockDiagram.Height; |
darienf | 3:36de8b9e4b1a | 1694 | |
darienf | 3:36de8b9e4b1a | 1695 | int height = maximTabControl1.TabPages[0].Height; |
darienf | 3:36de8b9e4b1a | 1696 | int width = maximTabControl1.TabPages[0].Width; |
darienf | 3:36de8b9e4b1a | 1697 | |
darienf | 3:36de8b9e4b1a | 1698 | //stopWatch.Start(); |
darienf | 3:36de8b9e4b1a | 1699 | |
darienf | 3:36de8b9e4b1a | 1700 | if (height < width) |
darienf | 3:36de8b9e4b1a | 1701 | { |
darienf | 3:36de8b9e4b1a | 1702 | scale = (double)height / blockHeight; |
darienf | 3:36de8b9e4b1a | 1703 | } |
darienf | 3:36de8b9e4b1a | 1704 | else |
darienf | 3:36de8b9e4b1a | 1705 | { |
darienf | 3:36de8b9e4b1a | 1706 | scale = (double)width / blockWidth; |
darienf | 3:36de8b9e4b1a | 1707 | } |
darienf | 3:36de8b9e4b1a | 1708 | |
darienf | 3:36de8b9e4b1a | 1709 | scaledWidth = (int)(scale * blockWidth + 0.5); |
darienf | 3:36de8b9e4b1a | 1710 | scaledHeight = (int)(scale * blockHeight + 0.5); |
darienf | 3:36de8b9e4b1a | 1711 | widthOffset = (int)((width - scaledWidth + 0.5) / 2.0); |
darienf | 3:36de8b9e4b1a | 1712 | |
darienf | 3:36de8b9e4b1a | 1713 | pnlBlockDiagram.Width = scaledWidth; |
darienf | 3:36de8b9e4b1a | 1714 | pnlBlockDiagram.Height = scaledHeight; |
darienf | 3:36de8b9e4b1a | 1715 | pnlBlockDiagram.Location = new Point(widthOffset, 0); |
darienf | 3:36de8b9e4b1a | 1716 | |
darienf | 3:36de8b9e4b1a | 1717 | //System.Diagnostics.Debug.Print(" X: " + linkTempSensor.Location.X + " Y: " + linkTempSensor.Location.Y); |
darienf | 3:36de8b9e4b1a | 1718 | scaleControlCenter(linkTempSensor, scale); |
darienf | 3:36de8b9e4b1a | 1719 | scaleControlCenter(linkOpticalSensor, scale); |
darienf | 3:36de8b9e4b1a | 1720 | scaleControlCenter(linkEcgChannel, scale); |
darienf | 3:36de8b9e4b1a | 1721 | scaleControlCenter(linkEcgMux, scale); |
darienf | 3:36de8b9e4b1a | 1722 | scaleControlCenter(linkBioZChannel, scale); |
darienf | 3:36de8b9e4b1a | 1723 | scaleControlCenter(linkBioZMux, scale); |
darienf | 3:36de8b9e4b1a | 1724 | scaleControlCenter(linkBioZLoad, scale); |
darienf | 3:36de8b9e4b1a | 1725 | scaleControlCenter(linkPaceChannel, scale); |
darienf | 3:36de8b9e4b1a | 1726 | |
darienf | 3:36de8b9e4b1a | 1727 | // Quick Start Location |
darienf | 3:36de8b9e4b1a | 1728 | tlbQuickStart.Location = new Point(pnlBlockDiagram.Location.X + pnlBlockDiagram.Size.Width + 5, pnlBlockDiagram.Location.Y + 50); |
darienf | 3:36de8b9e4b1a | 1729 | //System.Diagnostics.Debug.Print("Scale: " + scale + " X: " + linkTempSensor.Location.X + " Y: " + linkTempSensor.Location.Y); |
darienf | 3:36de8b9e4b1a | 1730 | |
darienf | 3:36de8b9e4b1a | 1731 | if (maximTabControl1.SelectedTab.Name != "tpBlockDiagram") |
darienf | 3:36de8b9e4b1a | 1732 | { |
darienf | 3:36de8b9e4b1a | 1733 | maximTabControl1.Refresh(); |
darienf | 3:36de8b9e4b1a | 1734 | } |
darienf | 3:36de8b9e4b1a | 1735 | |
darienf | 3:36de8b9e4b1a | 1736 | //stopWatch.Stop(); |
darienf | 3:36de8b9e4b1a | 1737 | |
darienf | 3:36de8b9e4b1a | 1738 | //TimeSpan ts = stopWatch.Elapsed; |
darienf | 3:36de8b9e4b1a | 1739 | |
darienf | 3:36de8b9e4b1a | 1740 | //string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); |
darienf | 3:36de8b9e4b1a | 1741 | //System.Diagnostics.Debug.Print("Run time " + elapsedTime); |
darienf | 3:36de8b9e4b1a | 1742 | } |
darienf | 3:36de8b9e4b1a | 1743 | |
darienf | 3:36de8b9e4b1a | 1744 | private void updateOT90DiagramLayout(Panel panel) |
darienf | 3:36de8b9e4b1a | 1745 | { |
darienf | 3:36de8b9e4b1a | 1746 | updateOT90DiagramLayout(panel, 0); |
darienf | 3:36de8b9e4b1a | 1747 | } |
darienf | 3:36de8b9e4b1a | 1748 | |
darienf | 3:36de8b9e4b1a | 1749 | private void updateOT90DiagramLayout(Panel panel, int heightOffset) |
darienf | 3:36de8b9e4b1a | 1750 | { |
darienf | 3:36de8b9e4b1a | 1751 | Stopwatch stopWatch = new Stopwatch(); |
darienf | 3:36de8b9e4b1a | 1752 | double scale, scaleWidth, scaleHeight; |
darienf | 3:36de8b9e4b1a | 1753 | int scaledWidth, scaledHeight; |
darienf | 3:36de8b9e4b1a | 1754 | int widthOffset; |
darienf | 3:36de8b9e4b1a | 1755 | int blockWidth = panel.Width; |
darienf | 3:36de8b9e4b1a | 1756 | int blockHeight = panel.Height; |
darienf | 3:36de8b9e4b1a | 1757 | |
darienf | 3:36de8b9e4b1a | 1758 | int height = maximTabControl1.SelectedTab.Height - pnlMAX30001Global.Height - heightOffset; |
darienf | 3:36de8b9e4b1a | 1759 | int width = maximTabControl1.SelectedTab.Width; |
darienf | 3:36de8b9e4b1a | 1760 | |
darienf | 3:36de8b9e4b1a | 1761 | stopWatch.Start(); |
darienf | 3:36de8b9e4b1a | 1762 | |
darienf | 3:36de8b9e4b1a | 1763 | // Scale to the smaller dimension, the smaller side dominates the scaling factor |
darienf | 3:36de8b9e4b1a | 1764 | scaleWidth = (double)(width - 40) / blockWidth; |
darienf | 3:36de8b9e4b1a | 1765 | scaleHeight = (double)height / blockHeight; |
darienf | 3:36de8b9e4b1a | 1766 | if (scaleWidth < scaleHeight) |
darienf | 3:36de8b9e4b1a | 1767 | scale = scaleWidth; |
darienf | 3:36de8b9e4b1a | 1768 | else |
darienf | 3:36de8b9e4b1a | 1769 | scale = scaleHeight; |
darienf | 3:36de8b9e4b1a | 1770 | |
darienf | 3:36de8b9e4b1a | 1771 | scaledWidth = (int)(scale * blockWidth + 0.5); |
darienf | 3:36de8b9e4b1a | 1772 | scaledHeight = (int)(scale * blockHeight + 0.5); |
darienf | 3:36de8b9e4b1a | 1773 | widthOffset = (int)((width - scaledWidth + 0.5) / 2.0); |
darienf | 3:36de8b9e4b1a | 1774 | |
darienf | 3:36de8b9e4b1a | 1775 | panel.Width = scaledWidth; |
darienf | 3:36de8b9e4b1a | 1776 | panel.Height = scaledHeight; |
darienf | 3:36de8b9e4b1a | 1777 | panel.Location = new Point(widthOffset, 10); |
darienf | 3:36de8b9e4b1a | 1778 | |
darienf | 3:36de8b9e4b1a | 1779 | foreach (Control cntl in panel.Controls) |
darienf | 3:36de8b9e4b1a | 1780 | { |
darienf | 3:36de8b9e4b1a | 1781 | scaleControl(cntl, scale); |
darienf | 3:36de8b9e4b1a | 1782 | } |
darienf | 3:36de8b9e4b1a | 1783 | |
darienf | 3:36de8b9e4b1a | 1784 | //maximTabControl1.Refresh(); |
darienf | 3:36de8b9e4b1a | 1785 | |
darienf | 3:36de8b9e4b1a | 1786 | stopWatch.Stop(); |
darienf | 3:36de8b9e4b1a | 1787 | |
darienf | 3:36de8b9e4b1a | 1788 | TimeSpan ts = stopWatch.Elapsed; |
darienf | 3:36de8b9e4b1a | 1789 | |
darienf | 3:36de8b9e4b1a | 1790 | string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); |
darienf | 3:36de8b9e4b1a | 1791 | System.Diagnostics.Debug.Print("Run time " + elapsedTime); |
darienf | 3:36de8b9e4b1a | 1792 | } |
darienf | 3:36de8b9e4b1a | 1793 | |
darienf | 3:36de8b9e4b1a | 1794 | void scaleControl(Control c, double scale) |
darienf | 3:36de8b9e4b1a | 1795 | { |
darienf | 3:36de8b9e4b1a | 1796 | int x = c.Location.X; |
darienf | 3:36de8b9e4b1a | 1797 | int y = c.Location.Y; |
darienf | 3:36de8b9e4b1a | 1798 | |
darienf | 3:36de8b9e4b1a | 1799 | double newX, newY; |
darienf | 3:36de8b9e4b1a | 1800 | |
darienf | 3:36de8b9e4b1a | 1801 | newX = ((x) * scale + 0.5); |
darienf | 3:36de8b9e4b1a | 1802 | newY = ((y + c.Size.Height / 2) * scale + 0.5) - c.Size.Height / 2; |
darienf | 3:36de8b9e4b1a | 1803 | |
darienf | 3:36de8b9e4b1a | 1804 | c.Location = new Point((int)(newX), (int)(newY)); |
darienf | 3:36de8b9e4b1a | 1805 | } |
darienf | 3:36de8b9e4b1a | 1806 | |
darienf | 3:36de8b9e4b1a | 1807 | void scaleControlCenter(Control c, double scale) |
darienf | 3:36de8b9e4b1a | 1808 | { |
darienf | 3:36de8b9e4b1a | 1809 | int x = c.Location.X; |
darienf | 3:36de8b9e4b1a | 1810 | int y = c.Location.Y; |
darienf | 3:36de8b9e4b1a | 1811 | |
darienf | 3:36de8b9e4b1a | 1812 | double newX, newY; |
darienf | 3:36de8b9e4b1a | 1813 | |
darienf | 3:36de8b9e4b1a | 1814 | newX = ((x + c.Size.Width / 2) * scale + 0.5) - c.Size.Width / 2; |
darienf | 3:36de8b9e4b1a | 1815 | newY = ((y + c.Size.Height / 2) * scale + 0.5) - c.Size.Height / 2; |
darienf | 3:36de8b9e4b1a | 1816 | |
darienf | 3:36de8b9e4b1a | 1817 | c.Location = new Point((int)newX, (int)newY); |
darienf | 3:36de8b9e4b1a | 1818 | } |
darienf | 3:36de8b9e4b1a | 1819 | |
darienf | 3:36de8b9e4b1a | 1820 | void scaleControlRight(Control c, double scale) |
darienf | 3:36de8b9e4b1a | 1821 | { |
darienf | 3:36de8b9e4b1a | 1822 | double AlignX = 590.0/636; |
darienf | 3:36de8b9e4b1a | 1823 | int x = c.Location.X; |
darienf | 3:36de8b9e4b1a | 1824 | int y = c.Location.Y; |
darienf | 3:36de8b9e4b1a | 1825 | |
darienf | 3:36de8b9e4b1a | 1826 | double newX, newY; |
darienf | 3:36de8b9e4b1a | 1827 | |
darienf | 3:36de8b9e4b1a | 1828 | newX = ((x + c.Size.Width) * scale + 0.5) - c.Size.Width; |
darienf | 3:36de8b9e4b1a | 1829 | newY = ((y + c.Size.Height / 2) * scale + 0.5) - c.Size.Height / 2; |
darienf | 3:36de8b9e4b1a | 1830 | |
darienf | 3:36de8b9e4b1a | 1831 | c.Location = new Point((int)(AlignX * picBlockDiagram.Width - c.Size.Width), (int)(newY)); |
darienf | 3:36de8b9e4b1a | 1832 | |
darienf | 3:36de8b9e4b1a | 1833 | } |
darienf | 3:36de8b9e4b1a | 1834 | |
darienf | 3:36de8b9e4b1a | 1835 | private void updateAllBlockDiagrams() |
darienf | 3:36de8b9e4b1a | 1836 | { |
darienf | 3:36de8b9e4b1a | 1837 | //this.SuspendLayout(); |
darienf | 3:36de8b9e4b1a | 1838 | updateBlockDiagramLayout(); |
darienf | 3:36de8b9e4b1a | 1839 | updateOT90DiagramLayout(pnlEcgChannel, grpRToR.Height + 20); |
darienf | 3:36de8b9e4b1a | 1840 | updateOT90DiagramLayout(pnlEcgMux); |
darienf | 3:36de8b9e4b1a | 1841 | updateOT90DiagramLayout(pnlBioZChannel); |
darienf | 3:36de8b9e4b1a | 1842 | updateOT90DiagramLayout(pnlBioZMux); |
darienf | 3:36de8b9e4b1a | 1843 | updateOT90DiagramLayout(pnlBioZLoad); |
darienf | 3:36de8b9e4b1a | 1844 | updateOT90DiagramLayout(pnlPace); |
darienf | 3:36de8b9e4b1a | 1845 | //this.ResumeLayout(); |
darienf | 3:36de8b9e4b1a | 1846 | } |
darienf | 3:36de8b9e4b1a | 1847 | |
darienf | 3:36de8b9e4b1a | 1848 | private void HspForm_ResizeEnd(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 1849 | { |
darienf | 3:36de8b9e4b1a | 1850 | updateAllBlockDiagrams(); |
darienf | 3:36de8b9e4b1a | 1851 | } |
darienf | 3:36de8b9e4b1a | 1852 | |
darienf | 3:36de8b9e4b1a | 1853 | protected override void WndProc(ref Message m) |
darienf | 3:36de8b9e4b1a | 1854 | { |
darienf | 3:36de8b9e4b1a | 1855 | if (m.Msg == /*WM_SIZE*/ 0x0005) |
darienf | 3:36de8b9e4b1a | 1856 | { |
darienf | 3:36de8b9e4b1a | 1857 | if (this.WindowState == FormWindowState.Maximized || this.WindowState == FormWindowState.Normal) |
darienf | 3:36de8b9e4b1a | 1858 | { |
darienf | 3:36de8b9e4b1a | 1859 | updateAllBlockDiagrams(); |
darienf | 3:36de8b9e4b1a | 1860 | } |
darienf | 3:36de8b9e4b1a | 1861 | } |
darienf | 3:36de8b9e4b1a | 1862 | |
darienf | 3:36de8b9e4b1a | 1863 | base.WndProc(ref m); |
darienf | 3:36de8b9e4b1a | 1864 | } |
darienf | 3:36de8b9e4b1a | 1865 | |
darienf | 3:36de8b9e4b1a | 1866 | public class DebugTextWriter : StreamWriter |
darienf | 3:36de8b9e4b1a | 1867 | { |
darienf | 3:36de8b9e4b1a | 1868 | public DebugTextWriter() |
darienf | 3:36de8b9e4b1a | 1869 | : base(new DebugOutStream(), Encoding.Unicode, 1024) |
darienf | 3:36de8b9e4b1a | 1870 | { |
darienf | 3:36de8b9e4b1a | 1871 | this.AutoFlush = true; |
darienf | 3:36de8b9e4b1a | 1872 | } |
darienf | 3:36de8b9e4b1a | 1873 | |
darienf | 3:36de8b9e4b1a | 1874 | class DebugOutStream : Stream |
darienf | 3:36de8b9e4b1a | 1875 | { |
darienf | 3:36de8b9e4b1a | 1876 | public override void Write(byte[] buffer, int offset, int count) |
darienf | 3:36de8b9e4b1a | 1877 | { |
darienf | 3:36de8b9e4b1a | 1878 | Debug.Write(Encoding.Unicode.GetString(buffer, offset, count)); |
darienf | 3:36de8b9e4b1a | 1879 | } |
darienf | 3:36de8b9e4b1a | 1880 | |
darienf | 3:36de8b9e4b1a | 1881 | public override bool CanRead { get { return false; } } |
darienf | 3:36de8b9e4b1a | 1882 | public override bool CanSeek { get { return false; } } |
darienf | 3:36de8b9e4b1a | 1883 | public override bool CanWrite { get { return true; } } |
darienf | 3:36de8b9e4b1a | 1884 | public override void Flush() { Debug.Flush(); } |
darienf | 3:36de8b9e4b1a | 1885 | public override long Length { get { throw new InvalidOperationException(); } } |
darienf | 3:36de8b9e4b1a | 1886 | public override int Read(byte[] buffer, int offset, int count) { throw new InvalidOperationException(); } |
darienf | 3:36de8b9e4b1a | 1887 | public override long Seek(long offset, SeekOrigin origin) { throw new InvalidOperationException(); } |
darienf | 3:36de8b9e4b1a | 1888 | public override void SetLength(long value) { throw new InvalidOperationException(); } |
darienf | 3:36de8b9e4b1a | 1889 | public override long Position |
darienf | 3:36de8b9e4b1a | 1890 | { |
darienf | 3:36de8b9e4b1a | 1891 | get { throw new InvalidOperationException(); } |
darienf | 3:36de8b9e4b1a | 1892 | set { throw new InvalidOperationException(); } |
darienf | 3:36de8b9e4b1a | 1893 | } |
darienf | 3:36de8b9e4b1a | 1894 | }; |
darienf | 3:36de8b9e4b1a | 1895 | } |
darienf | 3:36de8b9e4b1a | 1896 | |
darienf | 3:36de8b9e4b1a | 1897 | private void onlineDocumentationToolStripMenuItem_Click(object sender, EventArgs e) |
darienf | 3:36de8b9e4b1a | 1898 | { |
darienf | 3:36de8b9e4b1a | 1899 | Process.Start("http://www.maximintegrated.com/MAXREFDES100"); |
darienf | 3:36de8b9e4b1a | 1900 | } |
darienf | 3:36de8b9e4b1a | 1901 | } |
darienf | 3:36de8b9e4b1a | 1902 | } |