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.
Dependencies: mbed MAX14720 MAX30205 USBDevice
MaximAlgorithmClass.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.Linq; 00039 using System.Text; 00040 00041 //------------------------------------------------------------------------------------------ 00042 // OS24EVK-59 split into HeartRateApp EXE and MAX30101 DLL. 00043 // Moved all MAX30101 DLL classes into namespace Maxim.MAX30101GUI 00044 // Moved all HeartRateApp GUI classes into namespace Maxim.MAX30101 00045 // OS24EVK-59 Create separate project that builds Maxim.MAX30101GUI DLL library 00046 00047 namespace Maxim.MAX30101GUI 00048 { 00049 /// <summary> 00050 /// Base class common to any HeartRate / SpO2 algorithm. 00051 /// Input is Red / IR / Green LED data, output is Heart Rate and SpO2. 00052 /// </summary> 00053 public class MaximAlgorithmClass : InterfaceRedIRGreenLEDdataConsumer 00054 { 00055 public MaximAlgorithmClass() 00056 { 00057 Name = "Maxim Generic Algorithm Base Class"; 00058 } 00059 00060 public string Name; 00061 public int _sampleNumber; 00062 public int _sampleNumberLastValidHR; 00063 public int _sampleNumberLastValidSpO2; 00064 00065 public double _heartRateBPM; 00066 public bool _heartRateBPMValid; 00067 public double _heartRateBPMSignalStrength; 00068 public double _spO2Percent; 00069 public bool _spO2PercentValid; 00070 public double _spO2PercentSignalStrength; 00071 00072 /// <summary> 00073 /// Clear any internal class members, 00074 /// in response to startMonitorToolStripMenuItem 00075 /// </summary> 00076 public virtual void Clear() 00077 { 00078 } 00079 00080 /// <summary> 00081 /// <para>InterfaceRedIRGreenLEDdataConsumer</para> 00082 /// <para>Producer-Consumer data sink for 00083 /// raw Red/IR/Green LED data. 00084 /// Produced by MAX30101, consumed by algorithm. 00085 /// </para> 00086 /// </summary> 00087 /// <param name="sampleNumber"></param> 00088 /// <param name="rawIR"></param> 00089 /// <param name="rawRed"></param> 00090 /// <param name="rawGreen"></param> 00091 /// <param name="rawIRvalid"></param> 00092 /// <param name="rawRedvalid"></param> 00093 /// <param name="rawGreenvalid"></param> 00094 public virtual void ConsumeRedIRGreenLEDdata( 00095 int sampleNumber, 00096 int rawIR, 00097 int rawRed, 00098 int rawGreen, 00099 bool rawIRvalid, 00100 bool rawRedvalid, 00101 bool rawGreenvalid 00102 ) 00103 { 00104 _sampleNumber = sampleNumber; 00105 } 00106 00107 // prepare for OS24EVK-37 by adding SensorTemperatureDegreesC(double) to InterfaceRedIRGreenLEDdataConsumer 00108 public double _temperatureDegreesC; 00109 00110 /// <summary> 00111 /// <para>Temperature measured at MAX30101, optionally used by algorithm to estimate actual Red LED wavelength.</para> 00112 /// </summary> 00113 /// <param name="temperatureDegreesC"></param> 00114 public void SensorTemperatureDegreesC(double temperatureDegreesC) 00115 { 00116 _temperatureDegreesC = temperatureDegreesC; 00117 } 00118 00119 /// <summary> 00120 /// <para>Delegate type for event <see cref="OnHeartRateSpO2dataAvailable"/></para> 00121 /// </summary> 00122 /// <param name="heartRateBPM"></param> 00123 /// <param name="heartRateBPMValid"></param> 00124 /// <param name="heartRateBPMSignalStrength"></param> 00125 /// <param name="spO2Percent"></param> 00126 /// <param name="spO2PercentValid"></param> 00127 /// <param name="spO2PercentSignalStrength"></param> 00128 public delegate void OnHeartRateSpO2dataAvailableHandler( 00129 double heartRateBPM, 00130 bool heartRateBPMValid, 00131 double heartRateBPMSignalStrength, 00132 double spO2Percent, 00133 bool spO2PercentValid, 00134 double spO2PercentSignalStrength 00135 ); 00136 00137 /// <summary> 00138 /// <para>Occurs when HeartRate Data Available Event happens. 00139 /// </para> 00140 /// <para>An algorithm reports its results by invoking 00141 /// <code>OnHeartRateSpO2dataAvailable(heartRateBPM, heartRateBPMValid, heartRateBPMSignalStrength, spO2Percent, spO2PercentValid, spO2PercentSignalStrength);</code> 00142 /// </para> 00143 /// </summary> 00144 public event OnHeartRateSpO2dataAvailableHandler OnHeartRateSpO2dataAvailable; 00145 00146 /// <summary> 00147 /// Report the results of running the algorithm, 00148 /// by firing the OnHeartRateSpO2dataAvailable event. 00149 /// </summary> 00150 /// <param name="heartRateBPM"></param> 00151 /// <param name="heartRateBPMValid"></param> 00152 /// <param name="heartRateBPMSignalStrength"></param> 00153 /// <param name="spO2Percent"></param> 00154 /// <param name="spO2PercentValid"></param> 00155 /// <param name="spO2PercentSignalStrength"></param> 00156 public void ReportResultsHeartRateSpO2dataAvailable( 00157 double heartRateBPM, 00158 bool heartRateBPMValid, 00159 double heartRateBPMSignalStrength, 00160 double spO2Percent, 00161 bool spO2PercentValid, 00162 double spO2PercentSignalStrength 00163 ) 00164 { 00165 _heartRateBPM = heartRateBPM; 00166 _heartRateBPMValid = heartRateBPMValid; 00167 _heartRateBPMSignalStrength = heartRateBPMSignalStrength; 00168 _spO2Percent = spO2Percent; 00169 _spO2PercentValid = spO2PercentValid; 00170 _spO2PercentSignalStrength = spO2PercentSignalStrength; 00171 if (heartRateBPMValid) 00172 { 00173 _sampleNumberLastValidHR = _sampleNumber; 00174 } 00175 if (spO2PercentValid) 00176 { 00177 _sampleNumberLastValidSpO2 = _sampleNumber; 00178 } 00179 if (OnHeartRateSpO2dataAvailable != null) 00180 { 00181 OnHeartRateSpO2dataAvailable(heartRateBPM, heartRateBPMValid, heartRateBPMSignalStrength, spO2Percent, spO2PercentValid, spO2PercentSignalStrength); 00182 } 00183 } 00184 00185 } 00186 }
Generated on Thu Jul 28 2022 18:07:15 by
1.7.2