Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Form1.cs
00001 /******************************************************************************* 00002 * Copyright (C) 2016 Maxim Integrated Products, Inc., All rights Reserved. 00003 * 00004 * This software is protected by copyright laws of the United States and 00005 * of foreign countries. This material may also be protected by patent laws 00006 * and technology transfer regulations of the United States and of foreign 00007 * countries. This software is furnished under a license agreement and/or a 00008 * nondisclosure agreement and may only be used or reproduced in accordance 00009 * with the terms of those agreements. Dissemination of this information to 00010 * any party or parties not specified in the license agreement and/or 00011 * nondisclosure agreement is expressly prohibited. 00012 * 00013 * The above copyright notice and this permission notice shall be included 00014 * in all copies or substantial portions of the Software. 00015 * 00016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00017 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00018 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00019 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES 00020 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00021 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00022 * OTHER DEALINGS IN THE SOFTWARE. 00023 * 00024 * Except as contained in this notice, the name of Maxim Integrated 00025 * Products, Inc. shall not be used except as stated in the Maxim Integrated 00026 * Products, Inc. Branding Policy. 00027 * 00028 * The mere transfer of this software does not imply any licenses 00029 * of trade secrets, proprietary technology, copyrights, patents, 00030 * trademarks, maskwork rights, or any other form of intellectual 00031 * property whatsoever. Maxim Integrated Products, Inc. retains all 00032 * ownership rights. 00033 ******************************************************************************* 00034 */ 00035 00036 using System; 00037 using System.Collections.Generic; 00038 using System.ComponentModel; 00039 using System.Data; 00040 using System.Drawing; 00041 using System.Linq; 00042 using System.Text; 00043 00044 using System.Windows.Forms; 00045 using Microsoft.Win32; 00046 using Microsoft.Win32.SafeHandles; 00047 using System.Globalization; 00048 using System.Threading; 00049 using System.Management; 00050 using System.Diagnostics; 00051 using System.IO; 00052 using System.Collections.Specialized; 00053 00054 using HealthSensorPlatform.DeviceDescriptions; 00055 using HealthSensorPlatform.CustomControls; 00056 using HealthSensorPlatform.View; 00057 using HealthSensorPlatform.Presenter; 00058 using HealthSensorPlatform.Model; 00059 00060 using MAX30205EVKit.Presenter; 00061 00062 using Maxim.MAX30101GUI; 00063 using Maxim.Utility; 00064 00065 using MaximStyle; 00066 00067 namespace HealthSensorPlatform 00068 { 00069 00070 public partial class HspForm : Form, IFormView, IHspSetting 00071 { 00072 /* Constants */ 00073 //Software Version 00074 internal const int MAJORVERSION = 3; 00075 internal const int MINORVERSION = 0; 00076 internal const int PATCHVERSION = 1; 00077 const string VersionSuffix = ""; 00078 00079 const string PartNumber = "MAXREFDES100"; 00080 00081 const string readVersionCommand = "/System/ReadVer\r\n"; 00082 const string readFlashIDCommand = "/S25FS512/ReadId\r\n"; 00083 const string firmwareKey = "HSP FW Version"; 00084 00085 /* Fields */ 00086 SplashScreen splashScreen = new SplashScreen(); 00087 FormConnection connectionDialog = new FormConnection(); 00088 string port; 00089 bool connected = false; 00090 bool internalUpdate = false; // Used to prevent events from triggering 00091 bool streaming = false; // Disable GUI features while streaming is enabled 00092 00093 static ManagementEventWatcher watcher; 00094 00095 /* // TODO: Do not remember what this is for, can remove 00096 MaximStyle.MaximNumericUpDown[] ud_cmd = new MaximStyle.MaximNumericUpDown[3]; 00097 MaximStyle.MaximNumericUpDown[] ud_data = new MaximStyle.MaximNumericUpDown[8]; 00098 Panel[] p_cmd = new Panel[3]; 00099 Panel[] p_data = new Panel[8]; 00100 */ 00101 00102 IDeviceView[] deviceViews; 00103 Maxim.CustomControls.RegisterView[] registerViews; 00104 TabPage[] max30001TabPages; 00105 00106 RPCSupport.RPCClient rpcClient; 00107 RPCSupport.Devices.I2cDevice i2cDevice; 00108 RPCSupport.Devices.SpiDevice spiDevice; 00109 RPCSupport.Devices.MAX30101 max30101; 00110 RPCSupport.Devices.MAX30205 max30205; 00111 RPCSupport.Devices.LIS2HD lis2hd; 00112 RPCSupport.Devices.MAX30001 max30001; 00113 RPCSupport.DataLogging.DataLogging logging; 00114 00115 ListDictionary registerViewDict; 00116 00117 //FileLogPresenter fileLogPresenter; 00118 RawFileLogPresenter rawFileLogPresenter; 00119 OpticalFileLogPresenter opticalFileLogPresenter; 00120 TemperaturePresenter temperaturePresenter; 00121 00122 Model.MAX30001Model max30001Model; 00123 00124 public event EventHandler<EnableEventArgs> FileLogEnable; 00125 public event EventHandler<EnableEventArgs> OpticalFileLogEnable; 00126 public event EventHandler<EventArgs> RegisterExport; 00127 public event EventHandler<EventArgs> RegisterImport; 00128 00129 public event EventHandler<EventArgs> Connected; 00130 00131 /* Constructor */ 00132 /// <summary> 00133 /// 00134 /// </summary> 00135 public HspForm() 00136 { 00137 InitializeComponent(); 00138 00139 InitSplashScreen(); 00140 00141 //initialize text in status bar 00142 ss_Status.Items[0].Text = ""; 00143 ss_Status.Items[1].Text = ""; 00144 00145 deviceViews = new IDeviceView[] { 00146 opticalView1, 00147 temperatureView1, 00148 ecgView1, 00149 dataLoggingView1, 00150 rvLIS2HD, 00151 rvMAX14720, 00152 rvMAX30001, 00153 rvMAX30101, 00154 rvMAX30205, 00155 rvMAX30205_U18 00156 }; 00157 00158 registerViews = new Maxim.CustomControls.RegisterView[] { 00159 rvMAX30101, 00160 rvMAX30205, 00161 rvMAX30205_U18, 00162 rvLIS2HD, 00163 rvMAX30001, 00164 rvMAX14720 00165 }; 00166 00167 max30001TabPages = new TabPage[] { tpMAX30001BioZInputMux, tpBioZChannel, tpMAX30001BioZLoad, tpMAX30001Pace }; 00168 00169 registerViewDict = new ListDictionary(); 00170 00171 InitRpcClient(); 00172 00173 InitRpcDevices(); 00174 PrimitivesViewInit(); 00175 RegistersTabInit(); 00176 LoggingViewInit(); 00177 TemperatureViewInit(); 00178 OpticalViewInit(); 00179 00180 BlockDiagramsInit(); 00181 ECGPlotsViewInit(); 00182 00183 InitalizeUSBDetection(); 00184 00185 FileLoggingInit(); 00186 00187 RegisterExportInit(); 00188 00189 SetupSwitchPictureBoxes(); 00190 } 00191 00192 private void SetupSwitchPictureBoxes() 00193 { 00194 //ECGMux Tab 00195 picECGLeadConfig.Controls.Add(picSw1); 00196 picSw1.Controls.Add(picSw2); 00197 picSw2.Controls.Add(picSw3); 00198 picSw3.Controls.Add(picSw4); 00199 picSw4.Controls.Add(picSw5); 00200 picSw5.Controls.Add(picSw6); 00201 picSw6.Controls.Add(picSw7); 00202 picSw7.Controls.Add(picSw8); 00203 picSw8.Controls.Add(picSw9); 00204 picSw9.Controls.Add(picSw10); 00205 picSw10.Controls.Add(picSw11); 00206 picSw11.Controls.Add(picSw12); 00207 picSw12.Controls.Add(picSw13); 00208 picSw13.Controls.Add(picSw14); 00209 00210 //BioZMux Tab 00211 pictureBox2.Controls.Add(picLoff1); 00212 picLoff1.Controls.Add(picLoff2); 00213 picLoff2.Controls.Add(picLeadOn); 00214 picLeadOn.Controls.Add(picBioZsw1); 00215 picBioZsw1.Controls.Add(picBioZsw2); 00216 picBioZsw2.Controls.Add(picLeadBias1); 00217 picLeadBias1.Controls.Add(picLeadBias2); 00218 picLeadBias2.Controls.Add(picBioZCal1); 00219 picBioZCal1.Controls.Add(picBioZCal2); 00220 00221 //BioZLoad Tab 00222 picBioZLoad.Controls.Add(picBioZLresload); 00223 picBioZLresload.Controls.Add(picBioZLloff1); 00224 picBioZLloff1.Controls.Add(picBioZLloff2); 00225 picBioZLloff2.Controls.Add(picBioZLlon); 00226 picBioZLlon.Controls.Add(picBioZLsw1); 00227 picBioZLsw1.Controls.Add(picBioZLsw2); 00228 picBioZLsw2.Controls.Add(picBioZLlb1); 00229 picBioZLlb1.Controls.Add(picBioZLlb2); 00230 picBioZLlb2.Controls.Add(picBioZLcal1); 00231 picBioZLcal1.Controls.Add(picBioZLcal2); 00232 00233 00234 } 00235 00236 /* Delegates */ 00237 delegate void guiDisconnectedCallBack(); 00238 00239 public void MessageInfo(string message) 00240 { 00241 ss_Status.MessagesLabel.Text = message; 00242 } 00243 00244 public void MessageBoxShow(string message) 00245 { 00246 MessageBox.Show(message); 00247 } 00248 00249 public void MessageBoxShow(string message, string title) 00250 { 00251 MessageBox.Show(message, title); 00252 } 00253 00254 00255 /// <summary> 00256 /// http://stackoverflow.com/questions/286184/how-to-capture-a-serial-port-that-disappears-because-the-usb-cable-gets-unplugge 00257 /// </summary> 00258 private void InitalizeUSBDetection() 00259 { 00260 WqlEventQuery query; 00261 ManagementScope scope; 00262 00263 scope = new ManagementScope("root\\CIMV2"); 00264 scope.Options.EnablePrivileges = true; 00265 00266 query = new WqlEventQuery(); 00267 query.EventClassName = "__InstanceDeletionEvent"; // "__InstanceCreationEvent" can be used for insertion 00268 query.WithinInterval = new TimeSpan(0, 0, 3); 00269 query.Condition = @"TargetInstance ISA 'Win32_USBControllerdevice'"; 00270 watcher = new ManagementEventWatcher(scope, query); 00271 watcher.EventArrived += new EventArrivedEventHandler(USBRemovedHandler); 00272 watcher.Start(); 00273 } 00274 00275 /// <summary> 00276 /// http://stackoverflow.com/questions/286184/how-to-capture-a-serial-port-that-disappears-because-the-usb-cable-gets-unplugge 00277 /// </summary> 00278 /// <param name="sender"></param> 00279 /// <param name="e"></param> 00280 private void USBRemovedHandler(object sender, EventArrivedEventArgs e) 00281 { 00282 PropertyData targetInstanceData = e.NewEvent.Properties["TargetInstance"]; 00283 00284 if (targetInstanceData != null) 00285 { 00286 ManagementBaseObject targetInstanceObject = (ManagementBaseObject)targetInstanceData.Value; 00287 if (targetInstanceData != null) 00288 { 00289 string dependent = targetInstanceObject.Properties["Dependent"].Value.ToString(); 00290 string deviceId = dependent.Substring(dependent.IndexOf("DeviceID=") + 10); 00291 00292 if (deviceId.StartsWith("USB\\\\VID_0B6A&PID_003C") // FW 1.5 00293 || deviceId.StartsWith("USB\\\\VID_1F00&PID_2012\\\\0123456789") 00294 || deviceId.StartsWith("USB\\\\VID_0B6A&PID_0100")) // FW 2.0 mbed 00295 { 00296 // device is disconnected 00297 guiDisconnected(); 00298 try 00299 { 00300 rpcClient.Disconnect(); 00301 } 00302 catch (System.IO.IOException) 00303 { 00304 00305 } 00306 catch (NullReferenceException) 00307 { 00308 // Disconnecting when it doesn't exist 00309 // Occurs when you pull the USB while on the com port selection window 00310 } 00311 } 00312 } 00313 00314 } 00315 00316 } 00317 00318 private void InitSplashScreen() 00319 { 00320 splashScreen.maximSplashScreen1.CopyrightString = "©2016 Maxim Integrated Products, Inc."; 00321 splashScreen.maximSplashScreen1.VersionString = "Version " + MAJORVERSION.ToString() + "." + MINORVERSION.ToString() + "." + PATCHVERSION.ToString() + VersionSuffix; 00322 splashScreen.maximSplashScreen1.ApplicationName = this.Text; 00323 //splashScreen.maximSplashScreen1.Checked = Properties.Settings.Default.DisableSplash; 00324 } 00325 00326 void comPortConnect() 00327 { 00328 bool tryPreviousComPort = true; 00329 00330 connectionDialog.Reset(); 00331 connectionDialog.ScanPorts(); 00332 00333 while (true) 00334 { 00335 // Try to connect to the previous port, if we have not tried before 00336 // and it the port string is not an empty string ("") 00337 if (tryPreviousComPort == true 00338 && String.Compare(Properties.Settings.Default.ComPort, "") != 0) 00339 { 00340 tryPreviousComPort = false; 00341 } 00342 else 00343 { 00344 connectionDialog.ShowDialog(); 00345 } 00346 00347 // Break out of loop if user canceled 00348 if (connectionDialog.Canceled == true) 00349 { 00350 guiDisconnected(); 00351 break; 00352 } 00353 00354 // Get the port from the dialog form, returns default property 00355 // for first use 00356 port = connectionDialog.Port; 00357 if (String.Compare(port, "") == 0) 00358 continue; 00359 00360 00361 // Connect to port 00362 try 00363 { 00364 rpcClient.Connect(port); 00365 if (rpcClient.IsConnected() == true) 00366 { 00367 guiConnected(); 00368 break; 00369 } 00370 else // Connected to COM port, but cannot query STM32_HV 00371 { 00372 MessageBox.Show("Device not found on selected port", "Connection Issue"); 00373 guiDisconnected(); 00374 } 00375 } 00376 catch (TimeoutException) 00377 { 00378 guiDisconnected(); 00379 rpcClient.Disconnect(); 00380 MessageBox.Show("Unable to communicate with device, communication timed out.\nVerified selected port is correct.", 00381 "Connection Issue"); 00382 } 00383 catch (System.IO.IOException) 00384 { 00385 guiDisconnected(); 00386 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.", 00387 "Connection Issue"); 00388 } 00389 catch (UnauthorizedAccessException) 00390 { 00391 // Port does not exist 00392 } 00393 } 00394 } 00395 00396 bool checkFirmware() 00397 { 00398 string reply; 00399 00400 reply = rpcClient.RawRpcCall(readVersionCommand, true); 00401 00402 return reply.StartsWith(firmwareKey); 00403 } 00404 00405 void guiConnected() 00406 { 00407 ss_Status.Items[1].Text = rpcClient.Version();//rpcClient.RawRpcCall(readVersionCommand, true); // TODO this should be moved into the RPCSupport as a virtual system device 00408 ss_Status.Items[2].Text = "Hardware Connected (" + port + ")"; 00409 00410 connected = true; 00411 00412 //connectionToolStripMenuItem.Enabled = false; 00413 //disconnectToolStripMenuItem.Enabled = true; 00414 00415 connectionToolStripMenuItem.Checked = true; 00416 disconnectToolStripMenuItem.Checked = false; 00417 00418 // Enable Communication for each Device View 00419 foreach (IDeviceView device in deviceViews) 00420 { 00421 device.Connected = true; 00422 } 00423 00424 // TODO Ask F/W team if this is needed 00425 rpcClient.MAX30001.WriteReg(0x02, 0x3); 00426 rpcClient.MAX30001.WriteReg(0x03, 0x3); 00427 00428 max30001Model = new Model.MAX30001Model(max30001); 00429 partIDInit(); 00430 00431 dataLoggingView1.Enabled = checkFlashID(); 00432 00433 // Read device registers 00434 UpdateRegisters(); 00435 00436 if (Connected != null) 00437 Connected(this, new EventArgs()); 00438 } 00439 00440 00441 void guiDisconnected() 00442 { 00443 if (this.ss_Status.InvokeRequired) 00444 { 00445 guiDisconnectedCallBack d = new guiDisconnectedCallBack(guiDisconnected); 00446 this.Invoke(d); 00447 } 00448 else 00449 { 00450 ss_Status.Items[1].Text = ""; 00451 ss_Status.Items[2].Text = "Hardware Not Connected"; 00452 //UpdateConnection(null, false);; 00453 connected = false; 00454 00455 //connectionToolStripMenuItem.Enabled = true; 00456 //disconnectToolStripMenuItem.Enabled = false; 00457 00458 connectionToolStripMenuItem.Checked = false; 00459 disconnectToolStripMenuItem.Checked = true; 00460 00461 foreach (IDeviceView device in deviceViews) 00462 { 00463 device.Connected = false; 00464 } 00465 } 00466 } 00467 00468 void InitRpcClient() 00469 { 00470 rpcClient = new RPCSupport.RPCClient(RPCSupport.RPCClient.ePipeline.eSerialWrap); 00471 rpcClient.InitPipeline(); 00472 } 00473 00474 void InitRpcDevices() 00475 { 00476 i2cDevice = rpcClient.Init_I2cDevice(); 00477 spiDevice = rpcClient.Init_SpiDevice(); 00478 max30101 = rpcClient.Init_MAX30101(0xAE); 00479 max30205 = rpcClient.Init_MAX30205(0x32); 00480 lis2hd = rpcClient.Init_LIS2HD(0x50); 00481 max30001 = rpcClient.Init_MAX30001(); 00482 logging = rpcClient.Init_Logging(); 00483 } 00484 00485 private void Form_Load(object sender, EventArgs e) 00486 { 00487 if (splashScreen.SplashDisabled() == false) 00488 splashScreen.ShowDialog(); 00489 00490 while (splashScreen.Visible == true) 00491 Thread.Sleep(100); 00492 00493 comPortConnect(); 00494 } 00495 00496 void PrimitivesViewInit() 00497 { 00498 primitivesView1.rpcClient = rpcClient; 00499 primitivesView1.i2cDevice = i2cDevice; 00500 primitivesView1.spiDevice = spiDevice; 00501 primitivesView1.max30101 = max30101; 00502 primitivesView1.max30205 = max30205; 00503 primitivesView1.max30001 = max30001; 00504 primitivesView1.lis2hd = lis2hd; 00505 00506 maximTabControl1.HideTab("tpPrimitives"); 00507 } 00508 00509 void OpticalViewInit() 00510 { 00511 opticalView1.RPCClient = rpcClient; 00512 //opticalView1.StreamingStartStop += new OpticalView.StreamingStartStopEventHandler(opticalView_StreamingStartStop); 00513 opticalView1.StreamingStartStop += new EventHandler<StreamingStartStopEventArgs>(opticalView_StreamingStartStop); 00514 dataLoggingView1.LoggingParametersChanged += new DataLoggingView.LoggingParametersHandler(dataLoggingFlashReadEventHandler); 00515 00516 MaximSKAlgorithmClass algorithm = new MaximSKAlgorithmClass(); 00517 OpticalAlgorithmPresenter presenter = new OpticalAlgorithmPresenter(rpcClient, algorithm, opticalView1); 00518 } 00519 00520 void ECGPlotsViewInit() 00521 { 00522 ecgView1.RPCClient = rpcClient; 00523 00524 //cboEnRToR.SelectedIndexChanged += new EventHandler(cboStreaming_SelectedIndexChanged); 00525 //cboECGChannelEnable.SelectedIndexChanged += new EventHandler(cboStreaming_SelectedIndexChanged); 00526 00527 ecgView1.GetEcgInitArgsPointer = new CustomControls.EcgView.GetEcgInitArgs(getEcgArgs); 00528 ecgView1.GetRToRInitArgsPointer = new CustomControls.EcgView.GetRToRInitArgs(getRToRArgs); 00529 ecgView1.GetBioZInitArgsPointer = new CustomControls.EcgView.GetBioZInitArgs(getBioZArgs); 00530 ecgView1.GetPaceInitArgsPointer = new CustomControls.EcgView.GetPaceInitArgs(getPaceArgs); 00531 00532 ecgView1.StreamingStartStop += new EventHandler<StreamingStartStopEventArgs>(ecgView_StreamingStartStop); 00533 00534 ecgView1.HspSetting = this; 00535 00536 StreamPresenter streamPresenter = new StreamPresenter(rpcClient, ecgView1, this); 00537 } 00538 00539 void LoggingViewInit() 00540 { 00541 dataLoggingView1.RPCClient = rpcClient; 00542 00543 dataLoggingView1.GetEcgInitArgsPointer = new CustomControls.DataLoggingView.GetEcgInitArgs(getEcgArgs); 00544 dataLoggingView1.GetRToRInitArgsPointer = new CustomControls.DataLoggingView.GetRToRInitArgs(getRToRArgs); 00545 dataLoggingView1.GetBioZInitArgsPointer = new CustomControls.DataLoggingView.GetBioZInitArgs(getBioZArgs); 00546 dataLoggingView1.GetPaceInitArgsPointer = new CustomControls.DataLoggingView.GetPaceInitArgs(getPaceArgs); 00547 dataLoggingView1.GetFMSTRInitArgsPointer = new CustomControls.DataLoggingView.GetFMSTRInitArgs(getFMSTRArgs); 00548 dataLoggingView1.GetHRModeInitArgsPointer = new CustomControls.DataLoggingView.GetHRModeInitArgs(opticalView1.GetHRModeArgs); 00549 dataLoggingView1.GetSpO2HRModeInitArgsPointer = new CustomControls.DataLoggingView.GetSpO2HRModeInitArgs(opticalView1.GetSpO2HRModeArgs); 00550 dataLoggingView1.GetMultiModeInitArgsPointer = new CustomControls.DataLoggingView.GetMultiModeInitArgs(opticalView1.GetMultiModeArgs); 00551 00552 Model.DataLogModel dataLogModel = new Model.DataLogModel(rpcClient); 00553 DataLogPresenter dataLogPresenter = new DataLogPresenter(this, ecgView1, opticalView1, dataLogModel, dataLoggingView1, new RawFileLogView(), new RawFileLogView(), new RawFileLogView(), 00554 new RawFileLogView(), new RawFileLogView(), new RawFileLogView(), new RawFileLogView(), new RawFileLogView(), new RawFileLogView()); 00555 } 00556 00557 void FileLoggingInit() 00558 { 00559 IRawFileLogView ecgFileLog = new RawFileLogView(); 00560 IRawFileLogView bioZFileLog = new RawFileLogView(); 00561 00562 //fileLogPresenter = new FileLogPresenter(ecgFileLog, bioZFileLog, this, rpcClient, ecgView1); 00563 //ecgView1.EcgLog = ecgFileLog; 00564 //ecgView1.BioZLog = bioZFileLog; 00565 00566 IRawFileLogView ecgRawFileLog = new RawFileLogView(); 00567 IRawFileLogView paceRawFileLog = new RawFileLogView(); 00568 IRawFileLogView rToRFileLog = new RawFileLogView(); 00569 IRawFileLogView bioZRawFileLog = new RawFileLogView(); 00570 rawFileLogPresenter = new RawFileLogPresenter(ecgRawFileLog, bioZRawFileLog, rToRFileLog, paceRawFileLog, this, rpcClient, ecgView1, dataLoggingView1); 00571 00572 IRawFileLogView opticalFileLog = new RawFileLogView(); 00573 IRawFileLogView accelFileLog = new RawFileLogView(); 00574 00575 opticalFileLogPresenter = new OpticalFileLogPresenter(rpcClient, this, opticalView1, opticalFileLog, accelFileLog); 00576 00577 } 00578 00579 void RegisterExportInit() 00580 { 00581 RegisterExportPresenter registerExportPresenter; 00582 RegisterExportForm exportForm = new RegisterExportForm(); 00583 List<Maxim.CustomControls.RegisterView> registerViewList = new List<Maxim.CustomControls.RegisterView>(); 00584 00585 registerViewList.AddRange(registerViews); 00586 00587 registerExportPresenter = new RegisterExportPresenter(this, exportForm, registerViewList); 00588 } 00589 00590 private void txt_Status_TextChanged(object sender, EventArgs e) 00591 { 00592 //Scroll to the bottom of the textbox when text is added 00593 txt_Status.SelectionStart = txt_Status.Text.Length; 00594 txt_Status.ScrollToCaret(); 00595 txt_Status.Refresh(); 00596 } 00597 00598 private void btn_Clear_Click(object sender, EventArgs e) 00599 { 00600 //clear the status box 00601 txt_Status.Text = ""; 00602 } 00603 00604 private void rvLIS2HDInit() 00605 { 00606 Maxim.CustomControls.LIS2DHInfo lis2DHInfo = new Maxim.CustomControls.LIS2DHInfo(); 00607 Maxim.CustomControls.DeviceController controller = new Maxim.CustomControls.DeviceController(); 00608 controller.SetRegisterInfo(lis2DHInfo); 00609 controller.SetInterface(rpcClient); 00610 rvLIS2HD.SetController(controller); 00611 //rvLIS2HD.ReadAll(); 00612 rvLIS2HD.DisplayRegisters(); 00613 rvLIS2HD.DeviceName = "LIS2DH"; 00614 00615 00616 //registerInfoData[0] = lis2DHInfo.Info; 00617 } 00618 00619 private void rvMAX30101Init() 00620 { 00621 Maxim.CustomControls.MAX30101Info max30101Info = new Maxim.CustomControls.MAX30101Info(); 00622 Maxim.CustomControls.DeviceController controller = new Maxim.CustomControls.DeviceController(); 00623 controller.SetRegisterInfo(max30101Info); 00624 controller.SetInterface(rpcClient); 00625 rvMAX30101.SetController(controller); 00626 //rvMAX30101.ReadAll(); 00627 rvMAX30101.DisplayRegisters(); 00628 rvMAX30101.DeviceName = "MAX30101"; 00629 00630 00631 //registerInfoData[1] = max30101Info.Info; 00632 } 00633 00634 private void rvMAX30205Init() 00635 { 00636 Maxim.CustomControls.MAX30205Info max30205Info = new Maxim.CustomControls.MAX30205Info(0x92); 00637 Maxim.CustomControls.DeviceController controller = new Maxim.CustomControls.DeviceController(); 00638 controller.SetRegisterInfo(max30205Info); 00639 controller.SetInterface(rpcClient); 00640 rvMAX30205.SetController(controller); 00641 //rvMAX30205.ReadAll(); 00642 rvMAX30205.DisplayRegisters(); 00643 rvMAX30205.DeviceName = "MAX30205 (Top)"; 00644 00645 00646 //registerInfoData[2] = max30205Info.Info; 00647 } 00648 00649 private void rvMAX30205_U18Init() 00650 { 00651 Maxim.CustomControls.MAX30205Info max30205Info = new Maxim.CustomControls.MAX30205Info(); 00652 Maxim.CustomControls.DeviceController controller = new Maxim.CustomControls.DeviceController(); 00653 controller.SetRegisterInfo(max30205Info); 00654 controller.SetInterface(rpcClient); 00655 rvMAX30205_U18.SetController(controller); 00656 //rvMAX30205_U18.ReadAll(); 00657 rvMAX30205_U18.DisplayRegisters(); 00658 rvMAX30205_U18.DeviceName = "MAX30205 (Bottom)"; 00659 00660 00661 //registerInfoData[3] = max30205Info.Info; 00662 } 00663 00664 private void rvMAX30001Init() 00665 { 00666 Maxim.CustomControls.MAX30001Info max30001Info = new Maxim.CustomControls.MAX30001Info(); 00667 Maxim.CustomControls.DeviceController controller = new Maxim.CustomControls.DeviceController(); 00668 controller.SetRegisterInfo(max30001Info); 00669 controller.SetInterface(rpcClient); 00670 rvMAX30001.SetController(controller); 00671 //rvMAX30001.ReadAll(); 00672 rvMAX30001.DisplayRegisters(); 00673 rvMAX30001.DeviceName = "MAX30001"; 00674 00675 00676 //registerInfoData[4] = max30001Info.Info; 00677 } 00678 00679 private void rvMAX30003Init() 00680 { 00681 Maxim.CustomControls.MAX30003Info max30003Info = new Maxim.CustomControls.MAX30003Info(); 00682 Maxim.CustomControls.DeviceController controller = new Maxim.CustomControls.DeviceController(); 00683 controller.SetRegisterInfo(max30003Info); 00684 controller.SetInterface(rpcClient); 00685 rvMAX30001.SetController(controller); 00686 //rvMAX30001.ReadAll(); 00687 rvMAX30001.DisplayRegisters(); 00688 rvMAX30001.DeviceName = "MAX30003"; 00689 } 00690 00691 private void rvMAX14720Init() 00692 { 00693 Maxim.CustomControls.MAX14720Info max14720Info = new Maxim.CustomControls.MAX14720Info(); 00694 Maxim.CustomControls.DeviceController controller = new Maxim.CustomControls.DeviceController(); 00695 controller.SetRegisterInfo(max14720Info); 00696 controller.SetInterface(rpcClient); 00697 rvMAX14720.SetController(controller); 00698 //rvMAX14720.ReadAll(); 00699 rvMAX14720.DisplayRegisters(); 00700 rvMAX14720.DeviceName = "MAX14720"; 00701 00702 //registerInfoData[5] = max14720Info.Info; 00703 } 00704 00705 private void partIDInit() 00706 { 00707 //rvMAX30001.Clear(); 00708 tabPageEnable(null, false); 00709 switch (max30001Model.PartID) 00710 { 00711 case Model.MAX30001Model.Part.MAX30003: 00712 // General GUI 00713 bioZMilliohmScaleToolStripMenuItem.Enabled = false; 00714 registerNamesToolStripMenuItem.Text = "Show MAX30003 Register Names"; 00715 paceFileLogToolStripMenuItem.Enabled = false; 00716 bioZFileLogToolStripMenuItem.Enabled = false; 00717 00718 // Block Diagram 00719 picBlockDiagram.Image = global::HealthSensorPlatform.Properties.Resources.system_block_diagram_max30003; 00720 linkBioZChannel.Visible = false; 00721 linkBioZMux.Visible = false; 00722 linkBioZLoad.Visible = false; 00723 linkPaceChannel.Visible = false; 00724 linkLabelQuickBioimpedance.Visible = false; 00725 linkLabelQuickRespiration.Visible = false; 00726 00727 // Global Panel 00728 chkEnBioZ.Enabled = false; 00729 chkEnPace.Enabled = false; 00730 grpGlobalControls.Text = "MAX30003 Global Controls"; 00731 00732 // Tabs - not working 00733 tabPageEnable(null, true); 00734 00735 // Plots 00736 ecgView1.BioZFunction(false); 00737 00738 // Data Logging Tab 00739 dataLoggingView1.PaceFunction(false); 00740 dataLoggingView1.BioZFunction(false); 00741 00742 //Register Tabs 00743 for(int i = 0; i < cboRegisterTabDevice.Items.Count; i++) 00744 { 00745 if ((string)cboRegisterTabDevice.Items[i] == "MAX30001") 00746 { 00747 cboRegisterTabDevice.Items[i] = "MAX30003"; 00748 } 00749 00750 } 00751 rvMAX30003Init(); 00752 00753 break; 00754 case Model.MAX30001Model.Part.MAX30001: 00755 // Defaults 00756 // General GUI 00757 bioZMilliohmScaleToolStripMenuItem.Enabled = true; 00758 registerNamesToolStripMenuItem.Text = "Show MAX30001 Register Names"; 00759 paceFileLogToolStripMenuItem.Enabled = true; 00760 bioZFileLogToolStripMenuItem.Enabled = true; 00761 00762 // Block Diagram 00763 picBlockDiagram.Image = global::HealthSensorPlatform.Properties.Resources.system_block_diagram; 00764 linkBioZChannel.Visible = true; 00765 linkBioZMux.Visible = true; 00766 linkBioZLoad.Visible = true; 00767 linkPaceChannel.Visible = true; 00768 linkLabelQuickBioimpedance.Visible = true; 00769 linkLabelQuickRespiration.Visible = true; 00770 00771 // Global Panel 00772 grpGlobalControls.Text = "MAX30001 Global Controls"; 00773 chkEnBioZ.Enabled = true; 00774 chkEnECG.Enabled = true; 00775 chkEnPace.Enabled = true; 00776 chkEnRtor.Enabled = true; 00777 00778 // Tabs - not working 00779 tabPageEnable(null, true); 00780 00781 // Plots 00782 ecgView1.BioZFunction(true); 00783 00784 // Data Logging Tab 00785 dataLoggingView1.PaceFunction(true); 00786 dataLoggingView1.BioZFunction(true); 00787 00788 //Register Tabs 00789 for (int i = 0; i < cboRegisterTabDevice.Items.Count; i++) 00790 { 00791 if ((string)cboRegisterTabDevice.Items[i] == "MAX30003") 00792 { 00793 cboRegisterTabDevice.Items[i] = "MAX30001"; 00794 } 00795 00796 } 00797 rvMAX30001Init(); 00798 break; 00799 } 00800 } 00801 00802 private bool checkFlashID() 00803 { 00804 string reply; 00805 00806 reply = rpcClient.RawRpcCall(readFlashIDCommand, true); 00807 00808 return (reply.StartsWith("00010219")); 00809 } 00810 00811 private void tabPageEnable(TabPage exception, bool enable) 00812 { 00813 if (enable) 00814 { 00815 if (max30001Model.PartID == MAX30001Model.Part.MAX30003) 00816 { 00817 foreach (TabPage tp in maximTabControl1.TabPages) 00818 { 00819 if (!max30001TabPages.Contains(tp)) 00820 tp.Enabled = true; 00821 } 00822 } 00823 else 00824 { 00825 foreach (TabPage tp in maximTabControl1.TabPages) 00826 { 00827 tp.Enabled = true; 00828 } 00829 } 00830 } 00831 else 00832 { 00833 foreach (TabPage tp in maximTabControl1.TabPages) 00834 { 00835 if (tp != exception) 00836 tp.Enabled = false; 00837 } 00838 } 00839 00840 maximTabControl1.Invalidate(); 00841 } 00842 00843 private void aboutToolStripMenuItem_Click(object sender, EventArgs e) 00844 { 00845 splashScreen = new SplashScreen(120); 00846 InitSplashScreen(); 00847 splashScreen.Show(); 00848 splashScreen.ShowOKButton(); 00849 } 00850 00851 private void exitToolStripMenuItem_Click(object sender, EventArgs e) 00852 { 00853 Application.Exit(); 00854 } 00855 00856 private void maximTabControl1_SelectedIndexChanged(object sender, EventArgs e) 00857 { 00858 00859 temperatureView1.TimerState(false); 00860 //ecgView1.Stream = false; // Disconnect plotting event for flash log data loading 00861 00862 if (maximTabControl1.SelectedTab == tpBlockDiagram) 00863 { 00864 updateBlockDiagramLayout(); 00865 } 00866 else if (maximTabControl1.SelectedTab == tpTemperature) 00867 { 00868 if (connected) 00869 { 00870 // TODO 00871 /* 00872 temperatureView1.TimerState(true); 00873 temperatureView1.UpdateRegisters(); 00874 temperatureView1.ReadTemperature(); 00875 */ 00876 temperatureView1.TimerState(true); 00877 temperaturePresenter.OnReadAll(this, new EventArgs()); 00878 } 00879 } 00880 else if (maximTabControl1.SelectedTab == tpMAX30001EcgChannel) 00881 { 00882 if (connected) 00883 { 00884 ECGChannelUpdateRegisters(); // and R to R 00885 ECGGlobalUpdateRegisters(); 00886 } 00887 00888 pnlMAX30001Global.Parent = tpMAX30001EcgChannel; 00889 } 00890 else if (maximTabControl1.SelectedTab == tpMAX30001InputMux) 00891 { 00892 if (connected) 00893 { 00894 ECGInputMuxUpdateRegisters(); 00895 ECGGlobalUpdateRegisters(); 00896 } 00897 00898 pnlMAX30001Global.Parent = tpMAX30001InputMux; 00899 } 00900 else if (maximTabControl1.SelectedTab == tpMAX30001Plots) 00901 { 00902 pnlMAX30001Global.Parent = tpMAX30001Plots; 00903 //ecgView1.Stream = true; 00904 //pnlMAX30001Global.BringToFront(); 00905 if (connected) 00906 { 00907 ECGGlobalUpdateRegisters(); 00908 } 00909 } 00910 else if (maximTabControl1.SelectedTab == tpBioZChannel) 00911 { 00912 if (connected) 00913 { 00914 BioZChannelUpdateRegisters(); 00915 ECGGlobalUpdateRegisters(); 00916 } 00917 pnlMAX30001Global.Parent = tpBioZChannel; 00918 } 00919 else if (maximTabControl1.SelectedTab == tpMAX30001BioZInputMux) 00920 { 00921 if (connected) 00922 { 00923 BioZInputMuxUpdateRegisters(); 00924 ECGGlobalUpdateRegisters(); 00925 } 00926 pnlMAX30001Global.Parent = tpMAX30001BioZInputMux; 00927 } 00928 else if (maximTabControl1.SelectedTab == tpMAX30001BioZLoad) 00929 { 00930 if (connected) 00931 { 00932 BioZLoadUpdateRegisters(); 00933 ECGGlobalUpdateRegisters(); 00934 } 00935 UpdateBioZLoadSwitches(); 00936 pnlMAX30001Global.Parent = tpMAX30001BioZLoad; 00937 } 00938 else if (maximTabControl1.SelectedTab == tpMAX30001Pace) 00939 { 00940 if (connected) 00941 { 00942 PaceChannelUpdateRegisters(); 00943 ECGGlobalUpdateRegisters(); 00944 } 00945 pnlMAX30001Global.Parent = tpMAX30001Pace; 00946 } 00947 else if (maximTabControl1.SelectedTab == tpFlashLog) 00948 { 00949 if (connected) 00950 { 00951 dataLoggingView1.UpdateArgs(); 00952 } 00953 } 00954 else if (maximTabControl1.SelectedTab == tpRegisters) 00955 { 00956 if (connected) 00957 { 00958 ((Maxim.CustomControls.RegisterView)registerViewDict[(string)(cboRegisterTabDevice.SelectedItem)]).ReadAll(); 00959 } 00960 } 00961 00962 if (maximTabControl1.SelectedTab != null) // Support dynamic adding/removing of tabs 00963 pnlMAX30001Global.Location = new Point(0, maximTabControl1.SelectedTab.Size.Height - pnlMAX30001Global.Size.Height); 00964 00965 ss_Status.MessagesLabel.Text = ""; // Clear any message from previous tabs 00966 } 00967 00968 /// <summary> 00969 /// Read all registers, used for first connect 00970 /// </summary> 00971 public void UpdateRegisters() 00972 { 00973 ECGChannelUpdateRegisters(); 00974 ECGInputMuxUpdateRegisters(); 00975 ECGGlobalUpdateRegisters(); 00976 BioZChannelUpdateRegisters(); 00977 BioZInputMuxUpdateRegisters(); 00978 BioZLoadUpdateRegisters(); 00979 PaceChannelUpdateRegisters(); 00980 00981 //rvLIS2HD.ReadAll(); 00982 //rvMAX14720.ReadAll(); 00983 //rvMAX30001.ReadAll(); 00984 //rvMAX30101.ReadAll(); 00985 //rvMAX30205.ReadAll(); 00986 //rvMAX30205_U18.ReadAll(); 00987 } 00988 00989 #region Temperature Tab 00990 private void TemperatureViewInit() 00991 { 00992 MAX30205Model max30205_1 = new MAX30205Model(rpcClient.I2cDevice, 0x92); 00993 MAX30205Model max30205_2 = new MAX30205Model(rpcClient.I2cDevice, 0x90); 00994 00995 temperaturePresenter = new MAX30205EVKit.Presenter.TemperaturePresenter(new MAX30205Model[] { max30205_1, max30205_2 }, temperatureView1, temperatureView1); 00996 //temperatureView1.max30205_1 = max30205; 00997 //temperatureView1.i2cDevice = i2cDevice; 00998 } 00999 #endregion 01000 01001 #region Register Tab 01002 private void RegistersTabInit() 01003 { 01004 pnlRegMAX30101.Visible = true; 01005 pnlRegMAX30101.Visible = false; 01006 pnlRegMAX30205.Visible = false; 01007 pnlRegMAX14720.Visible = false; 01008 01009 rvLIS2HDInit(); 01010 rvMAX30001Init(); 01011 rvMAX30101Init(); 01012 rvMAX30205Init(); 01013 rvMAX30205_U18Init(); 01014 rvMAX14720Init(); 01015 registerViewDict.Add(rvLIS2HD.DeviceName, rvLIS2HD); 01016 registerViewDict.Add(rvMAX30001.DeviceName, rvMAX30001); 01017 registerViewDict.Add("MAX30003", rvMAX30001); 01018 registerViewDict.Add(rvMAX30101.DeviceName, rvMAX30101); 01019 registerViewDict.Add(rvMAX30205.DeviceName, rvMAX30205); 01020 registerViewDict.Add(rvMAX30205_U18.DeviceName, rvMAX30205_U18); 01021 registerViewDict.Add(rvMAX14720.DeviceName, rvMAX14720); 01022 01023 cboRegisterTabDevice.Items.Clear(); 01024 foreach (Maxim.CustomControls.RegisterView rv in registerViews) 01025 cboRegisterTabDevice.Items.Add(rv.DeviceName); 01026 01027 cboRegisterTabDevice.SelectedIndex = 0; 01028 01029 // Update status message when write is complete. Clear status message when entering the register data cell 01030 foreach (Maxim.CustomControls.RegisterView rv in registerViews) 01031 { 01032 rv.CellBeginEdit += new Maxim.CustomControls.RegisterView.CellBeginEditHandler(registerView_CellBeginEdit); 01033 rv.RegisterWriteComplete += new Maxim.CustomControls.RegisterView.RegisterWriteCompleteHandler(registerView_WriteComplete); 01034 } 01035 01036 } 01037 01038 private void cboRegisterTabDevice_SelectedIndexChanged(object sender, EventArgs e) 01039 { 01040 MaximStyle.MaximComboBox cbo = (MaximStyle.MaximComboBox)sender; 01041 01042 if (cbo.Text.CompareTo(rvMAX30001.DeviceName) == 0) 01043 { 01044 pnlRegMAX30001.Visible = true; 01045 pnlRegMAX30101.Visible = false; 01046 pnlRegMAX30205.Visible = false; 01047 pnlRegMAX30205_U18.Visible = false; 01048 pnlRegLIS2HD.Visible = false; 01049 pnlRegMAX14720.Visible = false; 01050 rvMAX30001.ReadAll(); 01051 } 01052 else if (cbo.Text.CompareTo(rvMAX30101.DeviceName) == 0) 01053 { 01054 pnlRegMAX30001.Visible = false; 01055 pnlRegMAX30101.Visible = true; 01056 pnlRegMAX30205.Visible = false; 01057 pnlRegMAX30205_U18.Visible = false; 01058 pnlRegLIS2HD.Visible = false; 01059 pnlRegMAX14720.Visible = false; 01060 rvMAX30101.ReadAll(); 01061 } 01062 else if (cbo.Text.CompareTo(rvMAX30205.DeviceName) == 0) 01063 { 01064 pnlRegMAX30001.Visible = false; 01065 pnlRegMAX30101.Visible = false; 01066 pnlRegMAX30205.Visible = true; 01067 pnlRegMAX30205_U18.Visible = false; 01068 pnlRegLIS2HD.Visible = false; 01069 pnlRegMAX14720.Visible = false; 01070 rvMAX30205.ReadAll(); 01071 } 01072 else if (cbo.Text.CompareTo(rvMAX30205_U18.DeviceName) == 0) 01073 { 01074 pnlRegMAX30001.Visible = false; 01075 pnlRegMAX30101.Visible = false; 01076 pnlRegMAX30205.Visible = true; 01077 pnlRegMAX30205_U18.Visible = true; 01078 pnlRegLIS2HD.Visible = false; 01079 pnlRegMAX14720.Visible = false; 01080 rvMAX30205_U18.ReadAll(); 01081 } 01082 else if (cbo.Text.CompareTo(rvLIS2HD.DeviceName) == 0) 01083 { 01084 pnlRegMAX30001.Visible = false; 01085 pnlRegMAX30101.Visible = false; 01086 pnlRegMAX30205.Visible = false; 01087 pnlRegMAX30205_U18.Visible = false; 01088 pnlRegLIS2HD.Visible = true; 01089 pnlRegMAX14720.Visible = false; 01090 rvLIS2HD.ReadAll(); 01091 } 01092 else if (cbo.Text.CompareTo(rvMAX14720.DeviceName) == 0) 01093 { 01094 pnlRegMAX30001.Visible = false; 01095 pnlRegMAX30101.Visible = false; 01096 pnlRegMAX30205.Visible = false; 01097 pnlRegMAX30205_U18.Visible = false; 01098 pnlRegLIS2HD.Visible = false; 01099 pnlRegMAX14720.Visible = true; 01100 rvMAX14720.ReadAll(); 01101 } 01102 } 01103 #endregion 01104 01105 #region Optical Tab 01106 private void opticalView_StreamingStartStop(object sender, StreamingStartStopEventArgs e) 01107 { 01108 /* Disable user selection to Tabs when Streaming is enabled */ 01109 streaming = e.state; 01110 if (e.state == true) 01111 { 01112 tabPageEnable(tpOpticalSensor, false); 01113 } 01114 else 01115 { 01116 tabPageEnable(tpOpticalSensor, true); 01117 } 01118 maximTabControl1.Invalidate(); // Redraw the tabs 01119 } 01120 #endregion 01121 01122 #region Block Diagrams 01123 private void BlockDiagramsInit() 01124 { 01125 initalizeECGConfigFields(); 01126 initalizeECGInputMuxFields(); 01127 initalizeRToRFields(); 01128 initalizeECGGlobalControls(); 01129 initalizeBioZConfigFields(); 01130 initalizeBioZInputMuxFields(); 01131 initalizeBioZLoadFields(); 01132 initalizePaceChannelFields(); 01133 01134 // Set ECG Gain setting for chart Y-scale purposes 01135 cboChannelGain.SelectedIndexChanged += new EventHandler(cboChannelGain_SelectedIndexChanged); 01136 01137 //cboECGChannelEnable.SelectedIndex = 0; // Default is disabled 01138 01139 initalizeToolTipEvents(ecgChannelField); 01140 initalizeToolTipEvents(rToRField); 01141 initalizeToolTipEvents(ecgInputMuxField); 01142 initalizeToolTipEvents(ecgGlobalField); 01143 initalizeToolTipEvents(bioZChannelField); 01144 initalizeToolTipEvents(bioZInputMuxField); 01145 initalizeToolTipEvents(bioZLoadField); 01146 initalizeToolTipEvents(paceChannelField); 01147 01148 // Force panel load for location placement in case of window resize 01149 // on a tab where the panel is not shown otherwise it will show in a strange location 01150 pnlMAX30001Global.Parent = tpMAX30001EcgChannel; 01151 } 01152 01153 #endregion 01154 01155 #region Streaming 01156 private void ecgView_StreamingStartStop(object sender, StreamingStartStopEventArgs e) 01157 { 01158 streaming = e.state; 01159 /* Disable user selection to Tabs when Streaming is enabled */ 01160 if (e.state == true) 01161 { 01162 tabPageEnable(tpMAX30001Plots, false); 01163 01164 grpChannelPlotEnable.Enabled = false; 01165 grpGlobalControls.Enabled = false; 01166 menuStrip1.Enabled = false; 01167 } 01168 else 01169 { 01170 if (connected) 01171 { 01172 // Rewrite enable bits for global controls to allow GUI to maintain consistent state 01173 foreach (RegisterField field in channelEnableField) 01174 { 01175 MaximCheckBox chk = (MaximStyle.MaximCheckBox)field.Control; 01176 01177 if (chk.Checked) 01178 writeCheckBox(chk); 01179 } 01180 01181 if (cboEnRbias.SelectedIndex != 0) 01182 writeComboBox(cboEnRbias); 01183 else if (cboBioZEnRbias.SelectedIndex != 0) 01184 writeComboBox(cboBioZEnRbias); 01185 01186 if (cboEnDcloff.SelectedIndex != 0) 01187 writeComboBox(cboEnDcloff); 01188 else if (cboBioZEnDcloff.SelectedIndex != 0) 01189 writeComboBox(cboBioZEnDcloff); 01190 01191 if (cboBioZDigitalLeadOffDetectionEnable.SelectedIndex != 0) 01192 writeComboBox(cboBioZDigitalLeadOffDetectionEnable); 01193 01194 if (cboEmuxEnUlpLon.SelectedIndex != 0) 01195 writeComboBox(cboEmuxEnUlpLon); 01196 else if (cboBmuxEnUlpLon.SelectedIndex != 0) 01197 writeComboBox(cboBmuxEnUlpLon); 01198 01199 } 01200 01201 tabPageEnable(tpMAX30001Plots, true); 01202 01203 grpChannelPlotEnable.Enabled = true; 01204 grpGlobalControls.Enabled = true; 01205 menuStrip1.Enabled = true; 01206 } 01207 01208 maximTabControl1.Invalidate(); // Redraw the tabs 01209 } 01210 #endregion 01211 01212 #region Data Logging 01213 // When Data Logging reads the flash, update the values on the other tabs to match what is in the flash 01214 // The data logging tab will generate an event and run this method 01215 private void dataLoggingFlashReadEventHandler(object sender, EventArgs e) 01216 { 01217 DataLoggingView dlView = (DataLoggingView)sender; 01218 01219 if (dlView.EnableOpticalHR) 01220 { 01221 opticalView1.SetHRModeArgs(dlView.HRModeArgs); 01222 } 01223 else if (dlView.EnableOpticalSpO2) 01224 { 01225 opticalView1.SetSpO2HRModeArgs(dlView.SpO2HRModeArgs); 01226 } 01227 else if (dlView.EnableOpticalMulti) 01228 { 01229 opticalView1.SetMultiModeArgs(dlView.MultiModeArgs); 01230 } 01231 01232 if (dlView.EnableEcg) 01233 { 01234 setEcgArgs(dlView.EcgArgs); 01235 } 01236 01237 if (dlView.EnableBioz) 01238 { 01239 setBioZArgs(dlView.BioZArgs); 01240 } 01241 01242 if (dlView.EnableRToR) 01243 { 01244 setRToRArgs(dlView.RToRArgs); 01245 } 01246 01247 if (dlView.EnablePace) 01248 { 01249 setPaceArgs(dlView.PaceArgs); 01250 } 01251 } 01252 #endregion 01253 01254 private void connectionToolStripMenuItem_Click(object sender, EventArgs e) 01255 { 01256 if (connectionToolStripMenuItem.Checked) 01257 { 01258 connectionToolStripMenuItem.Checked = true; 01259 return; 01260 } 01261 01262 if (!connected) 01263 { 01264 comPortConnect(); 01265 } 01266 } 01267 01268 private void disconnectToolStripMenuItem_Click(object sender, EventArgs e) 01269 { 01270 if (disconnectToolStripMenuItem.Checked) 01271 { 01272 disconnectToolStripMenuItem.Checked = true; 01273 return; 01274 } 01275 01276 if (connected) 01277 { 01278 guiDisconnected(); 01279 rpcClient.Disconnect(); 01280 } 01281 } 01282 01283 /// <summary> 01284 /// Stop streaming before exiting HSP 01285 /// </summary> 01286 /// <param name="sender"></param> 01287 /// <param name="e"></param> 01288 private void HspForm_FormClosing(object sender, FormClosingEventArgs e) 01289 { 01290 try 01291 { 01292 if (connected) 01293 { 01294 opticalView1.Close(); // Stop streaming 01295 ecgView1.Close(); 01296 } 01297 } 01298 catch (Exception) 01299 { 01300 // We are exiting the GUI, we can ignore all exceptions 01301 // Adding this for the case where the user unplugs HSP and quickly tries to close 01302 // before the operating system reports USB removed 01303 // Occurs while streaming ECG because we re-write the interrupt registers on stream stop 01304 return; 01305 } 01306 } 01307 01308 private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 01309 { 01310 maximTabControl1.SelectedTab = tpMAX30001InputMux; 01311 } 01312 01313 private void linkLabel2_Click(object sender, EventArgs e) 01314 { 01315 maximTabControl1.SelectedTab = tpMAX30001BioZInputMux; 01316 } 01317 01318 private void linkLabelBioZLoad_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 01319 { 01320 maximTabControl1.SelectedTab = tpMAX30001BioZLoad; 01321 } 01322 01323 private void linkLabelQuickOpticalSpO2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 01324 { 01325 if (connected) 01326 { 01327 opticalView1.OpticalSensorDefaults(); 01328 maximTabControl1.SelectedTab = tpOpticalSensor; 01329 } 01330 } 01331 01332 private void linkLabelQuickTemperature_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 01333 { 01334 if (connected) 01335 { 01336 temperaturePresenter.WriteRegister(0, 1, 0); 01337 temperaturePresenter.WriteRegister(1, 1, 0); 01338 maximTabControl1.SelectedTab = tpTemperature; 01339 } 01340 } 01341 01342 private void linkLabelQuickEcg_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 01343 { 01344 if (connected) 01345 { 01346 // SW_RST 01347 max30001Model.Write(0x08, 1); 01348 max30001Model.Write(0x08, 0); 01349 // CNFG_GEN 01350 max30001Model.Write(0x10, 0x080017); 01351 // CNFG_EMUX 01352 max30001Model.Write(0x14, 0x000000); 01353 // CNFG_RTOR1 01354 max30001Model.Write(0x1d, 0x3FA300); 01355 01356 ECGChannelUpdateRegisters(); 01357 ECGInputMuxUpdateRegisters(); 01358 01359 maximTabControl1.SelectedTab = tpMAX30001Plots; 01360 } 01361 } 01362 01363 private void linkLabelQuickBioimpedance_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 01364 { 01365 if (connected) 01366 { 01367 // SW_RST 01368 max30001Model.Write(0x08, 1); 01369 max30001Model.Write(0x08, 0); 01370 // CNFG_GEN 01371 max30001Model.Write(0x10, 0x040027); 01372 // CNFG_BMUX 01373 max30001Model.Write(0x17, 0x000040); 01374 // CNFG_BIOZ 01375 max30001Model.Write(0x18, 0x601430); 01376 01377 ECGChannelUpdateRegisters(); 01378 ECGInputMuxUpdateRegisters(); 01379 BioZChannelUpdateRegisters(); 01380 BioZInputMuxUpdateRegisters(); 01381 01382 bioZMilliohmScaleToolStripMenuItem.Checked = false; 01383 ecgView1.BioZMilliOhmRange = false; 01384 01385 maximTabControl1.SelectedTab = tpMAX30001Plots; 01386 } 01387 } 01388 01389 private void linkLabelQuickRespiration_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 01390 { 01391 if (connected) 01392 { 01393 // SW_RST 01394 max30001Model.Write(0x08, 1); 01395 max30001Model.Write(0x08, 0); 01396 // CNFG_GEN 01397 max30001Model.Write(0x10, 0x040027); 01398 // CNFG_BMUX 01399 max30001Model.Write(0x17, 0x000040); 01400 // CNFG_BIOZ 01401 max30001Model.Write(0x18, 0x201050); 01402 01403 ECGChannelUpdateRegisters(); 01404 ECGInputMuxUpdateRegisters(); 01405 BioZChannelUpdateRegisters(); 01406 BioZInputMuxUpdateRegisters(); 01407 01408 bioZMilliohmScaleToolStripMenuItem.Checked = true; 01409 ecgView1.BioZMilliOhmRange = true; 01410 01411 maximTabControl1.SelectedTab = tpMAX30001Plots; 01412 } 01413 } 01414 01415 private void btnSwRst_Click(object sender, EventArgs e) 01416 { 01417 if (!connected) 01418 return; 01419 01420 max30001.WriteReg(0x08, 0x01); 01421 max30001.WriteReg(0x08, 0x00); 01422 01423 UpdateRegisters(); 01424 } 01425 01426 private void btnSynch_Click(object sender, EventArgs e) 01427 { 01428 if (!connected) 01429 return; 01430 01431 max30001.WriteReg(0x09, 0x01); 01432 max30001.WriteReg(0x09, 0x00); 01433 } 01434 01435 private void btnFifoRst_Click(object sender, EventArgs e) 01436 { 01437 if (!connected) 01438 return; 01439 01440 max30001.WriteReg(0x0A, 0x01); 01441 max30001.WriteReg(0x0A, 0x00); 01442 } 01443 01444 private void registerNamesToolStripMenuItem_Click(object sender, EventArgs e) 01445 { 01446 List<RegisterField>[] fields = new List<RegisterField>[]{ ecgChannelField, ecgInputMuxField, ecgGlobalField, rToRField, bioZChannelField, bioZInputMuxField, bioZLoadField, paceChannelField }; 01447 ToolStripMenuItem tsi = (ToolStripMenuItem)sender; 01448 01449 if (tsi.Checked == true) 01450 { 01451 // Combo Boxes 01452 foreach (List<RegisterField> listRegisterField in fields) 01453 { 01454 foreach(RegisterField rf in listRegisterField) 01455 { 01456 if (rf.Label != null) 01457 rf.Label.Text = rf.Name; 01458 } 01459 } 01460 01461 // Check Boxes 01462 foreach (RegisterField rf in channelEnableField) 01463 { 01464 rf.LabelDescription = rf.Control.Text; 01465 rf.Control.Text = rf.Name; 01466 } 01467 01468 string calHighRegName = "CAL_THIGH"; 01469 cboCalFifty.Items[0] = calHighRegName; 01470 cboBioZCalFifty.Items[0] = calHighRegName; 01471 if (cboCalFifty.SelectedIndex == 0) 01472 { 01473 cboCalFifty.SelectedIndex = ecgCalFiftyField.ReadField(); 01474 cboBioZCalFifty.SelectedIndex = biozCalFiftyField.ReadField(); 01475 } 01476 01477 } 01478 else 01479 { 01480 // Combo Boxes 01481 foreach (List<RegisterField> listRegisterField in fields) 01482 { 01483 foreach (RegisterField rf in listRegisterField) 01484 { 01485 if (rf.Label != null) 01486 rf.Label.Text = rf.LabelDescription; 01487 } 01488 } 01489 01490 // Check Boxes 01491 foreach (RegisterField rf in channelEnableField) 01492 { 01493 rf.Control.Text = rf.LabelDescription; 01494 } 01495 01496 string calHighRegName = "Time High"; 01497 cboCalFifty.Items[0] = calHighRegName; 01498 cboBioZCalFifty.Items[0] = calHighRegName; 01499 if (cboCalFifty.SelectedIndex == 0) 01500 { 01501 cboCalFifty.SelectedIndex = ecgCalFiftyField.ReadField(); 01502 cboBioZCalFifty.SelectedIndex = biozCalFiftyField.ReadField(); 01503 } 01504 } 01505 } 01506 01507 /// <summary> 01508 /// Prevent tab changes while streaming 01509 /// </summary> 01510 /// <param name="sender"></param> 01511 /// <param name="e"></param> 01512 private void maximTabControl1_Selecting(object sender, TabControlCancelEventArgs e) 01513 { 01514 if (streaming && connected) 01515 e.Cancel = true; 01516 } 01517 01518 private void showAdvancedTabToolStripMenuItem_Click(object sender, EventArgs e) 01519 { 01520 if (showAdvancedTabToolStripMenuItem.Checked) 01521 { 01522 maximTabControl1.UnhideTab("tpPrimitives"); 01523 } 01524 else 01525 { 01526 maximTabControl1.HideTab("tpPrimitives"); 01527 } 01528 } 01529 01530 private void registerView_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) 01531 { 01532 ss_Status.MessagesLabel.Text = ""; 01533 } 01534 01535 private void registerView_WriteComplete(object sender, Maxim.CustomControls.RegisterView.RegisterArgs e) 01536 { 01537 ss_Status.MessagesLabel.Text = "Write Reg " + e.Register.ToString("X2") + "h Complete"; 01538 } 01539 01540 private void bioZMilliohmScaleToolStripMenuItem_Click(object sender, EventArgs e) 01541 { 01542 // Set the BioZ chart to be in units of milliohms or ohms 01543 ecgView1.BioZMilliOhmRange = bioZMilliohmScaleToolStripMenuItem.Checked; 01544 } 01545 01546 public void LogFileItem(StreamType stream, bool state) 01547 { 01548 switch(stream) 01549 { 01550 case StreamType.Ecg: 01551 eCGFileLogToolStripMenuItem.Checked = state; 01552 break; 01553 case StreamType.RToR: 01554 rToRFileLogToolStripMenuItem.Checked = state; 01555 break; 01556 case StreamType.Pace: 01557 paceFileLogToolStripMenuItem.Checked = state; 01558 break; 01559 case StreamType.BioZ: 01560 bioZFileLogToolStripMenuItem.Checked = state; 01561 break; 01562 case StreamType.Optical: 01563 opticalAccelerometerFileLogToolStripMenuItem.Checked = state; 01564 break; 01565 01566 // TODO other stream types 01567 } 01568 } 01569 01570 public void OpticalLogFileItem(bool state) 01571 { 01572 opticalAccelerometerFileLogToolStripMenuItem.Checked = state; 01573 } 01574 01575 public void EcgLogFileItem(bool state) 01576 { 01577 eCGFileLogToolStripMenuItem.Checked = state; 01578 } 01579 01580 public void BioZLogFileItem(bool state) 01581 { 01582 bioZFileLogToolStripMenuItem.Checked = state; 01583 } 01584 01585 public void RtoRLogFileItem(bool state) 01586 { 01587 rToRFileLogToolStripMenuItem.Checked = state; 01588 } 01589 01590 public void PaceLogFileItem(bool state) 01591 { 01592 paceFileLogToolStripMenuItem.Checked = state; 01593 } 01594 01595 private void eCGBioZFileLogToolStripMenuItem_Click(object sender, EventArgs e) 01596 { 01597 if (FileLogEnable != null) 01598 FileLogEnable(this, new EnableEventArgs(StreamType.Ecg, !eCGBioZFileLogToolStripMenuItem.Checked)); 01599 } 01600 01601 private void eCGFileLogToolStripMenuItem_Click(object sender, EventArgs e) 01602 { 01603 if (FileLogEnable != null) 01604 FileLogEnable(this, new EnableEventArgs(StreamType.Ecg, !eCGFileLogToolStripMenuItem.Checked)); 01605 } 01606 01607 private void rToRFileLogToolStripMenuItem_Click(object sender, EventArgs e) 01608 { 01609 if (FileLogEnable != null) 01610 FileLogEnable(this, new EnableEventArgs(StreamType.RToR, !rToRFileLogToolStripMenuItem.Checked)); 01611 } 01612 01613 private void paceFileLogToolStripMenuItem_Click(object sender, EventArgs e) 01614 { 01615 if (FileLogEnable != null) 01616 FileLogEnable(this, new EnableEventArgs(StreamType.Pace, !paceFileLogToolStripMenuItem.Checked)); 01617 } 01618 01619 private void bioZFileLogToolStripMenuItem_Click(object sender, EventArgs e) 01620 { 01621 if (FileLogEnable != null) 01622 FileLogEnable(this, new EnableEventArgs(StreamType.BioZ, !bioZFileLogToolStripMenuItem.Checked)); 01623 } 01624 01625 private void opticalAccelerometerFileLogToolStripMenuItem_Click(object sender, EventArgs e) 01626 { 01627 if (OpticalFileLogEnable != null) 01628 OpticalFileLogEnable(this, new EnableEventArgs(StreamType.Optical,!opticalAccelerometerFileLogToolStripMenuItem.Checked)); 01629 } 01630 01631 private void registerExportToolStripMenuItem_Click(object sender, EventArgs e) 01632 { 01633 if (RegisterExport != null) 01634 RegisterExport(this, e); 01635 } 01636 01637 private void loadAllRegisterSettingsToolStripMenuItem_Click(object sender, EventArgs e) 01638 { 01639 if (RegisterImport != null) 01640 RegisterImport(this, e); 01641 } 01642 01643 01644 #region Home Tab 01645 private void linkTempSensor_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 01646 { 01647 maximTabControl1.SelectedTab = tpTemperature; 01648 } 01649 01650 private void linkOpticalSensor_Click(object sender, LinkLabelLinkClickedEventArgs e) 01651 { 01652 maximTabControl1.SelectedTab = tpOpticalSensor; 01653 } 01654 01655 private void linkEcgChannel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 01656 { 01657 maximTabControl1.SelectedTab = tpMAX30001EcgChannel; 01658 } 01659 01660 private void linkEcgMux_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 01661 { 01662 maximTabControl1.SelectedTab = tpMAX30001InputMux; 01663 } 01664 01665 private void linkPaceChannel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 01666 { 01667 maximTabControl1.SelectedTab = tpMAX30001Pace; 01668 } 01669 01670 private void linkBioZChannel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 01671 { 01672 maximTabControl1.SelectedTab = tpBioZChannel; 01673 } 01674 01675 private void linkBioZMux_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 01676 { 01677 maximTabControl1.SelectedTab = tpMAX30001BioZInputMux; 01678 } 01679 01680 private void linkBioZLoad_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 01681 { 01682 maximTabControl1.SelectedTab = tpMAX30001BioZLoad; 01683 } 01684 #endregion 01685 01686 private void updateBlockDiagramLayout() 01687 { 01688 //Stopwatch stopWatch = new Stopwatch(); 01689 double scale; 01690 int scaledWidth, scaledHeight; 01691 int widthOffset; 01692 int blockWidth = pnlBlockDiagram.Width; 01693 int blockHeight = pnlBlockDiagram.Height; 01694 01695 int height = maximTabControl1.TabPages[0].Height; 01696 int width = maximTabControl1.TabPages[0].Width; 01697 01698 //stopWatch.Start(); 01699 01700 if (height < width) 01701 { 01702 scale = (double)height / blockHeight; 01703 } 01704 else 01705 { 01706 scale = (double)width / blockWidth; 01707 } 01708 01709 scaledWidth = (int)(scale * blockWidth + 0.5); 01710 scaledHeight = (int)(scale * blockHeight + 0.5); 01711 widthOffset = (int)((width - scaledWidth + 0.5) / 2.0); 01712 01713 pnlBlockDiagram.Width = scaledWidth; 01714 pnlBlockDiagram.Height = scaledHeight; 01715 pnlBlockDiagram.Location = new Point(widthOffset, 0); 01716 01717 //System.Diagnostics.Debug.Print(" X: " + linkTempSensor.Location.X + " Y: " + linkTempSensor.Location.Y); 01718 scaleControlCenter(linkTempSensor, scale); 01719 scaleControlCenter(linkOpticalSensor, scale); 01720 scaleControlCenter(linkEcgChannel, scale); 01721 scaleControlCenter(linkEcgMux, scale); 01722 scaleControlCenter(linkBioZChannel, scale); 01723 scaleControlCenter(linkBioZMux, scale); 01724 scaleControlCenter(linkBioZLoad, scale); 01725 scaleControlCenter(linkPaceChannel, scale); 01726 01727 // Quick Start Location 01728 tlbQuickStart.Location = new Point(pnlBlockDiagram.Location.X + pnlBlockDiagram.Size.Width + 5, pnlBlockDiagram.Location.Y + 50); 01729 //System.Diagnostics.Debug.Print("Scale: " + scale + " X: " + linkTempSensor.Location.X + " Y: " + linkTempSensor.Location.Y); 01730 01731 if (maximTabControl1.SelectedTab.Name != "tpBlockDiagram") 01732 { 01733 maximTabControl1.Refresh(); 01734 } 01735 01736 //stopWatch.Stop(); 01737 01738 //TimeSpan ts = stopWatch.Elapsed; 01739 01740 //string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); 01741 //System.Diagnostics.Debug.Print("Run time " + elapsedTime); 01742 } 01743 01744 private void updateOT90DiagramLayout(Panel panel) 01745 { 01746 updateOT90DiagramLayout(panel, 0); 01747 } 01748 01749 private void updateOT90DiagramLayout(Panel panel, int heightOffset) 01750 { 01751 Stopwatch stopWatch = new Stopwatch(); 01752 double scale, scaleWidth, scaleHeight; 01753 int scaledWidth, scaledHeight; 01754 int widthOffset; 01755 int blockWidth = panel.Width; 01756 int blockHeight = panel.Height; 01757 01758 int height = maximTabControl1.SelectedTab.Height - pnlMAX30001Global.Height - heightOffset; 01759 int width = maximTabControl1.SelectedTab.Width; 01760 01761 stopWatch.Start(); 01762 01763 // Scale to the smaller dimension, the smaller side dominates the scaling factor 01764 scaleWidth = (double)(width - 40) / blockWidth; 01765 scaleHeight = (double)height / blockHeight; 01766 if (scaleWidth < scaleHeight) 01767 scale = scaleWidth; 01768 else 01769 scale = scaleHeight; 01770 01771 scaledWidth = (int)(scale * blockWidth + 0.5); 01772 scaledHeight = (int)(scale * blockHeight + 0.5); 01773 widthOffset = (int)((width - scaledWidth + 0.5) / 2.0); 01774 01775 panel.Width = scaledWidth; 01776 panel.Height = scaledHeight; 01777 panel.Location = new Point(widthOffset, 10); 01778 01779 foreach (Control cntl in panel.Controls) 01780 { 01781 scaleControl(cntl, scale); 01782 } 01783 01784 //maximTabControl1.Refresh(); 01785 01786 stopWatch.Stop(); 01787 01788 TimeSpan ts = stopWatch.Elapsed; 01789 01790 string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); 01791 System.Diagnostics.Debug.Print("Run time " + elapsedTime); 01792 } 01793 01794 void scaleControl(Control c, double scale) 01795 { 01796 int x = c.Location.X; 01797 int y = c.Location.Y; 01798 01799 double newX, newY; 01800 01801 newX = ((x) * scale + 0.5); 01802 newY = ((y + c.Size.Height / 2) * scale + 0.5) - c.Size.Height / 2; 01803 01804 c.Location = new Point((int)(newX), (int)(newY)); 01805 } 01806 01807 void scaleControlCenter(Control c, double scale) 01808 { 01809 int x = c.Location.X; 01810 int y = c.Location.Y; 01811 01812 double newX, newY; 01813 01814 newX = ((x + c.Size.Width / 2) * scale + 0.5) - c.Size.Width / 2; 01815 newY = ((y + c.Size.Height / 2) * scale + 0.5) - c.Size.Height / 2; 01816 01817 c.Location = new Point((int)newX, (int)newY); 01818 } 01819 01820 void scaleControlRight(Control c, double scale) 01821 { 01822 double AlignX = 590.0/636; 01823 int x = c.Location.X; 01824 int y = c.Location.Y; 01825 01826 double newX, newY; 01827 01828 newX = ((x + c.Size.Width) * scale + 0.5) - c.Size.Width; 01829 newY = ((y + c.Size.Height / 2) * scale + 0.5) - c.Size.Height / 2; 01830 01831 c.Location = new Point((int)(AlignX * picBlockDiagram.Width - c.Size.Width), (int)(newY)); 01832 01833 } 01834 01835 private void updateAllBlockDiagrams() 01836 { 01837 //this.SuspendLayout(); 01838 updateBlockDiagramLayout(); 01839 updateOT90DiagramLayout(pnlEcgChannel, grpRToR.Height + 20); 01840 updateOT90DiagramLayout(pnlEcgMux); 01841 updateOT90DiagramLayout(pnlBioZChannel); 01842 updateOT90DiagramLayout(pnlBioZMux); 01843 updateOT90DiagramLayout(pnlBioZLoad); 01844 updateOT90DiagramLayout(pnlPace); 01845 //this.ResumeLayout(); 01846 } 01847 01848 private void HspForm_ResizeEnd(object sender, EventArgs e) 01849 { 01850 updateAllBlockDiagrams(); 01851 } 01852 01853 protected override void WndProc(ref Message m) 01854 { 01855 if (m.Msg == /*WM_SIZE*/ 0x0005) 01856 { 01857 if (this.WindowState == FormWindowState.Maximized || this.WindowState == FormWindowState.Normal) 01858 { 01859 updateAllBlockDiagrams(); 01860 } 01861 } 01862 01863 base.WndProc(ref m); 01864 } 01865 01866 public class DebugTextWriter : StreamWriter 01867 { 01868 public DebugTextWriter() 01869 : base(new DebugOutStream(), Encoding.Unicode, 1024) 01870 { 01871 this.AutoFlush = true; 01872 } 01873 01874 class DebugOutStream : Stream 01875 { 01876 public override void Write(byte[] buffer, int offset, int count) 01877 { 01878 Debug.Write(Encoding.Unicode.GetString(buffer, offset, count)); 01879 } 01880 01881 public override bool CanRead { get { return false; } } 01882 public override bool CanSeek { get { return false; } } 01883 public override bool CanWrite { get { return true; } } 01884 public override void Flush() { Debug.Flush(); } 01885 public override long Length { get { throw new InvalidOperationException(); } } 01886 public override int Read(byte[] buffer, int offset, int count) { throw new InvalidOperationException(); } 01887 public override long Seek(long offset, SeekOrigin origin) { throw new InvalidOperationException(); } 01888 public override void SetLength(long value) { throw new InvalidOperationException(); } 01889 public override long Position 01890 { 01891 get { throw new InvalidOperationException(); } 01892 set { throw new InvalidOperationException(); } 01893 } 01894 }; 01895 } 01896 01897 private void onlineDocumentationToolStripMenuItem_Click(object sender, EventArgs e) 01898 { 01899 Process.Start("http://www.maximintegrated.com/MAXREFDES100"); 01900 } 01901 } 01902 }
Generated on Tue Jul 12 2022 21:52:37 by
1.7.2