repo time

Dependencies:   mbed MAX14720 MAX30205 USBDevice

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

Who changed what in which revision?

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