This is the latest working repository used in our demo video for the Maxim to display temperature readings on Bluetooth

Dependencies:   USBDevice

Committer:
darienf
Date:
Sun May 02 23:09:04 2021 +0000
Revision:
5:bc128a16232f
Parent:
3:36de8b9e4b1a
This is the program that was last used, that has the working temperature and some comments

Who changed what in which revision?

UserRevisionLine numberNew contents of line
darienf 3:36de8b9e4b1a 1 /*******************************************************************************
darienf 3:36de8b9e4b1a 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All rights Reserved.
darienf 3:36de8b9e4b1a 3 *
darienf 3:36de8b9e4b1a 4 * This software is protected by copyright laws of the United States and
darienf 3:36de8b9e4b1a 5 * of foreign countries. This material may also be protected by patent laws
darienf 3:36de8b9e4b1a 6 * and technology transfer regulations of the United States and of foreign
darienf 3:36de8b9e4b1a 7 * countries. This software is furnished under a license agreement and/or a
darienf 3:36de8b9e4b1a 8 * nondisclosure agreement and may only be used or reproduced in accordance
darienf 3:36de8b9e4b1a 9 * with the terms of those agreements. Dissemination of this information to
darienf 3:36de8b9e4b1a 10 * any party or parties not specified in the license agreement and/or
darienf 3:36de8b9e4b1a 11 * nondisclosure agreement is expressly prohibited.
darienf 3:36de8b9e4b1a 12 *
darienf 3:36de8b9e4b1a 13 * The above copyright notice and this permission notice shall be included
darienf 3:36de8b9e4b1a 14 * in all copies or substantial portions of the Software.
darienf 3:36de8b9e4b1a 15 *
darienf 3:36de8b9e4b1a 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
darienf 3:36de8b9e4b1a 17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
darienf 3:36de8b9e4b1a 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
darienf 3:36de8b9e4b1a 19 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
darienf 3:36de8b9e4b1a 20 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
darienf 3:36de8b9e4b1a 21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
darienf 3:36de8b9e4b1a 22 * OTHER DEALINGS IN THE SOFTWARE.
darienf 3:36de8b9e4b1a 23 *
darienf 3:36de8b9e4b1a 24 * Except as contained in this notice, the name of Maxim Integrated
darienf 3:36de8b9e4b1a 25 * Products, Inc. shall not be used except as stated in the Maxim Integrated
darienf 3:36de8b9e4b1a 26 * Products, Inc. Branding Policy.
darienf 3:36de8b9e4b1a 27 *
darienf 3:36de8b9e4b1a 28 * The mere transfer of this software does not imply any licenses
darienf 3:36de8b9e4b1a 29 * of trade secrets, proprietary technology, copyrights, patents,
darienf 3:36de8b9e4b1a 30 * trademarks, maskwork rights, or any other form of intellectual
darienf 3:36de8b9e4b1a 31 * property whatsoever. Maxim Integrated Products, Inc. retains all
darienf 3:36de8b9e4b1a 32 * ownership rights.
darienf 3:36de8b9e4b1a 33 *******************************************************************************
darienf 3:36de8b9e4b1a 34 */
darienf 3:36de8b9e4b1a 35
darienf 3:36de8b9e4b1a 36 using System;
darienf 3:36de8b9e4b1a 37 using System.Threading;
darienf 3:36de8b9e4b1a 38 using System.Windows.Forms;
darienf 3:36de8b9e4b1a 39 using System.Diagnostics;
darienf 3:36de8b9e4b1a 40 using NUnit.Framework;
darienf 3:36de8b9e4b1a 41 using Moq;
darienf 3:36de8b9e4b1a 42
darienf 3:36de8b9e4b1a 43 using RPCSupport;
darienf 3:36de8b9e4b1a 44 using RPCSupport.Devices;
darienf 3:36de8b9e4b1a 45
darienf 3:36de8b9e4b1a 46 namespace RPCSupportTest
darienf 3:36de8b9e4b1a 47 {
darienf 3:36de8b9e4b1a 48 //[TestFixture, RequiresThread]
darienf 3:36de8b9e4b1a 49 [TestFixture]
darienf 3:36de8b9e4b1a 50 [Property("Class", "MAX30101")]
darienf 3:36de8b9e4b1a 51 class MAX30101Test
darienf 3:36de8b9e4b1a 52 {
darienf 3:36de8b9e4b1a 53 RPCClient rpcClient;
darienf 3:36de8b9e4b1a 54 MAX30101 max30101;
darienf 3:36de8b9e4b1a 55
darienf 3:36de8b9e4b1a 56 int[] avg = new int[] { 1, 2, 4, 8, 16, 32 };
darienf 3:36de8b9e4b1a 57 int[] sr = new int[] { 50, 100, 200, 400 };
darienf 3:36de8b9e4b1a 58
darienf 3:36de8b9e4b1a 59 double minFactor = 0.75;
darienf 3:36de8b9e4b1a 60 double maxFactor = 1;
darienf 3:36de8b9e4b1a 61 int timeSleep = 10000;
darienf 3:36de8b9e4b1a 62
darienf 3:36de8b9e4b1a 63 [TestFixtureSetUp]
darienf 3:36de8b9e4b1a 64 public void Init()
darienf 3:36de8b9e4b1a 65 {
darienf 3:36de8b9e4b1a 66 rpcClient = new RPCClient(RPCClient.ePipeline.eSerialWrap);
darienf 3:36de8b9e4b1a 67 rpcClient.InitPipeline();
darienf 3:36de8b9e4b1a 68 rpcClient.Connect(ComPort.Port);
darienf 3:36de8b9e4b1a 69 //rpcClient.Pipeline.Discard();
darienf 3:36de8b9e4b1a 70 max30101 = rpcClient.Init_MAX30101(0xAE);
darienf 3:36de8b9e4b1a 71 //rpcClient.streaming.Init(rpcClient.Pipeline);
darienf 3:36de8b9e4b1a 72
darienf 3:36de8b9e4b1a 73 //rpcClient.Version();
darienf 3:36de8b9e4b1a 74 }
darienf 3:36de8b9e4b1a 75
darienf 3:36de8b9e4b1a 76 [TestFixtureTearDown]
darienf 3:36de8b9e4b1a 77 public void Dispose()
darienf 3:36de8b9e4b1a 78 {
darienf 3:36de8b9e4b1a 79 rpcClient.Disconnect();
darienf 3:36de8b9e4b1a 80 rpcClient.streaming.Stop();
darienf 3:36de8b9e4b1a 81 Thread.Sleep(100);
darienf 3:36de8b9e4b1a 82 }
darienf 3:36de8b9e4b1a 83
darienf 3:36de8b9e4b1a 84 [TestCase(0, 0)]
darienf 3:36de8b9e4b1a 85 [TestCase(0, 1)]
darienf 3:36de8b9e4b1a 86 [TestCase(0, 2)]
darienf 3:36de8b9e4b1a 87 [TestCase(0, 3)]
darienf 3:36de8b9e4b1a 88 [TestCase(1, 0)]
darienf 3:36de8b9e4b1a 89 [TestCase(1, 1)]
darienf 3:36de8b9e4b1a 90 [TestCase(1, 2)]
darienf 3:36de8b9e4b1a 91 [TestCase(1, 3)]
darienf 3:36de8b9e4b1a 92 [TestCase(2, 0)]
darienf 3:36de8b9e4b1a 93 [TestCase(2, 1)]
darienf 3:36de8b9e4b1a 94 [TestCase(2, 2)]
darienf 3:36de8b9e4b1a 95 [TestCase(2, 3)]
darienf 3:36de8b9e4b1a 96 //[TestCase(3, 0)]
darienf 3:36de8b9e4b1a 97 [TestCase(3, 1)]
darienf 3:36de8b9e4b1a 98 [TestCase(3, 2)]
darienf 3:36de8b9e4b1a 99 [TestCase(3, 3)]
darienf 3:36de8b9e4b1a 100 //[TestCase(4, 0)]
darienf 3:36de8b9e4b1a 101 //[TestCase(4, 1)]
darienf 3:36de8b9e4b1a 102 [TestCase(4, 2)]
darienf 3:36de8b9e4b1a 103 [TestCase(4, 3)]
darienf 3:36de8b9e4b1a 104 //[TestCase(5, 0)]
darienf 3:36de8b9e4b1a 105 //[TestCase(5, 1)]
darienf 3:36de8b9e4b1a 106 //[TestCase(5, 2)]
darienf 3:36de8b9e4b1a 107 [TestCase(5, 3)]
darienf 3:36de8b9e4b1a 108 public void HRModeTest(byte sampleAverage, byte sampleRate)
darienf 3:36de8b9e4b1a 109 {
darienf 3:36de8b9e4b1a 110 HRModeTest(sampleAverage, sampleRate, 3000);
darienf 3:36de8b9e4b1a 111 }
darienf 3:36de8b9e4b1a 112
darienf 3:36de8b9e4b1a 113 [TestCase(3, 0, 4000)]
darienf 3:36de8b9e4b1a 114 [TestCase(4, 0, 8000)]
darienf 3:36de8b9e4b1a 115 [TestCase(4, 1, 4000)]
darienf 3:36de8b9e4b1a 116 [TestCase(5, 0, 12000)]
darienf 3:36de8b9e4b1a 117 [TestCase(5, 1, 8000)]
darienf 3:36de8b9e4b1a 118 [TestCase(5, 2, 4000)]
darienf 3:36de8b9e4b1a 119 public void HRModeTest(byte sampleAverage, byte sampleRate, int sleepMilliSecond)
darienf 3:36de8b9e4b1a 120 {
darienf 3:36de8b9e4b1a 121 Mock<IPlotView> plotView;
darienf 3:36de8b9e4b1a 122 plotView = new Mock<IPlotView>();
darienf 3:36de8b9e4b1a 123 StreamHelper streamHelper = new StreamHelper(rpcClient, plotView.Object);
darienf 3:36de8b9e4b1a 124
darienf 3:36de8b9e4b1a 125 rpcClient.MAX30101.HRmode_init(0x0f, sampleAverage, sampleRate, 3, 0x33, (byte)(0 + 4));
darienf 3:36de8b9e4b1a 126 Thread.Sleep(sleepMilliSecond);
darienf 3:36de8b9e4b1a 127 rpcClient.MAX30101.HRmode_stop();
darienf 3:36de8b9e4b1a 128
darienf 3:36de8b9e4b1a 129 Application.DoEvents();
darienf 3:36de8b9e4b1a 130
darienf 3:36de8b9e4b1a 131 plotView.Verify(p => p.Display(It.IsAny<int[]>()), Times.AtLeast(1));
darienf 3:36de8b9e4b1a 132 }
darienf 3:36de8b9e4b1a 133
darienf 3:36de8b9e4b1a 134 [TestCase(0, 0)]
darienf 3:36de8b9e4b1a 135 [TestCase(0, 1)]
darienf 3:36de8b9e4b1a 136 [TestCase(0, 2)]
darienf 3:36de8b9e4b1a 137 [TestCase(0, 3)]
darienf 3:36de8b9e4b1a 138 [TestCase(1, 0)]
darienf 3:36de8b9e4b1a 139 [TestCase(1, 1)]
darienf 3:36de8b9e4b1a 140 [TestCase(1, 2)]
darienf 3:36de8b9e4b1a 141 [TestCase(1, 3)]
darienf 3:36de8b9e4b1a 142 [TestCase(2, 0)]
darienf 3:36de8b9e4b1a 143 [TestCase(2, 1)]
darienf 3:36de8b9e4b1a 144 [TestCase(2, 2)]
darienf 3:36de8b9e4b1a 145 [TestCase(2, 3)]
darienf 3:36de8b9e4b1a 146 //[TestCase(3, 0)]
darienf 3:36de8b9e4b1a 147 [TestCase(3, 1)]
darienf 3:36de8b9e4b1a 148 [TestCase(3, 2)]
darienf 3:36de8b9e4b1a 149 [TestCase(3, 3)]
darienf 3:36de8b9e4b1a 150 //[TestCase(4, 0)]
darienf 3:36de8b9e4b1a 151 //[TestCase(4, 1)]
darienf 3:36de8b9e4b1a 152 [TestCase(4, 2)]
darienf 3:36de8b9e4b1a 153 [TestCase(4, 3)]
darienf 3:36de8b9e4b1a 154 //[TestCase(5, 0)]
darienf 3:36de8b9e4b1a 155 //[TestCase(5, 1)]
darienf 3:36de8b9e4b1a 156 //[TestCase(5, 2)]
darienf 3:36de8b9e4b1a 157 [TestCase(5, 3)]
darienf 3:36de8b9e4b1a 158 public void SpO2ModeTest(byte sampleAverage, byte sampleRate)
darienf 3:36de8b9e4b1a 159 {
darienf 3:36de8b9e4b1a 160 SpO2ModeTest(sampleAverage, sampleRate, 3000);
darienf 3:36de8b9e4b1a 161 }
darienf 3:36de8b9e4b1a 162
darienf 3:36de8b9e4b1a 163 [TestCase(3, 0, 4000)]
darienf 3:36de8b9e4b1a 164 [TestCase(4, 0, 8000)]
darienf 3:36de8b9e4b1a 165 [TestCase(4, 1, 4000)]
darienf 3:36de8b9e4b1a 166 [TestCase(5, 0, 12000)]
darienf 3:36de8b9e4b1a 167 [TestCase(5, 1, 8000)]
darienf 3:36de8b9e4b1a 168 [TestCase(5, 2, 4000)]
darienf 3:36de8b9e4b1a 169 public void SpO2ModeTest(byte sampleAverage, byte sampleRate, int sleepMillisecond)
darienf 3:36de8b9e4b1a 170 {
darienf 3:36de8b9e4b1a 171 Mock<IPlotView> plotView = new Mock<IPlotView>();
darienf 3:36de8b9e4b1a 172 StreamHelper streamHelper = new StreamHelper(rpcClient, plotView.Object);
darienf 3:36de8b9e4b1a 173
darienf 3:36de8b9e4b1a 174 rpcClient.MAX30101.SpO2mode_init(0x0f, sampleAverage, sampleRate, 3, 0x33, 0x33, (byte)(sampleRate + 4));
darienf 3:36de8b9e4b1a 175 Thread.Sleep(sleepMillisecond);
darienf 3:36de8b9e4b1a 176 rpcClient.MAX30101.SpO2mode_stop();
darienf 3:36de8b9e4b1a 177
darienf 3:36de8b9e4b1a 178 Application.DoEvents();
darienf 3:36de8b9e4b1a 179
darienf 3:36de8b9e4b1a 180 plotView.Verify(p => p.Display(It.IsAny<int[]>()), Times.AtLeast(1));
darienf 3:36de8b9e4b1a 181 }
darienf 3:36de8b9e4b1a 182
darienf 3:36de8b9e4b1a 183
darienf 3:36de8b9e4b1a 184 [TestCase(0, 0)]
darienf 3:36de8b9e4b1a 185 [TestCase(0, 1)]
darienf 3:36de8b9e4b1a 186 [TestCase(0, 2)]
darienf 3:36de8b9e4b1a 187 [TestCase(0, 3)]
darienf 3:36de8b9e4b1a 188 [TestCase(1, 0)]
darienf 3:36de8b9e4b1a 189 [TestCase(1, 1)]
darienf 3:36de8b9e4b1a 190 [TestCase(1, 2)]
darienf 3:36de8b9e4b1a 191 [TestCase(1, 3)]
darienf 3:36de8b9e4b1a 192 [TestCase(2, 0)]
darienf 3:36de8b9e4b1a 193 [TestCase(2, 1)]
darienf 3:36de8b9e4b1a 194 [TestCase(2, 2)]
darienf 3:36de8b9e4b1a 195 [TestCase(2, 3)]
darienf 3:36de8b9e4b1a 196 //[TestCase(3,0)]
darienf 3:36de8b9e4b1a 197 [TestCase(3, 1)]
darienf 3:36de8b9e4b1a 198 [TestCase(3, 2)]
darienf 3:36de8b9e4b1a 199 [TestCase(3, 3)]
darienf 3:36de8b9e4b1a 200 //[TestCase(4, 0)]
darienf 3:36de8b9e4b1a 201 //[TestCase(4, 1)]
darienf 3:36de8b9e4b1a 202 [TestCase(4, 2)]
darienf 3:36de8b9e4b1a 203 [TestCase(4, 3)]
darienf 3:36de8b9e4b1a 204 //[TestCase(5, 0)]
darienf 3:36de8b9e4b1a 205 //[TestCase(5, 1)]
darienf 3:36de8b9e4b1a 206 //[TestCase(5, 2)]
darienf 3:36de8b9e4b1a 207 [TestCase(5, 3)]
darienf 3:36de8b9e4b1a 208 public void MultiModeTest(byte sampleAverage, byte sampleRate)
darienf 3:36de8b9e4b1a 209 {
darienf 3:36de8b9e4b1a 210 MultiModeTest(sampleAverage, sampleRate, 3000);
darienf 3:36de8b9e4b1a 211 }
darienf 3:36de8b9e4b1a 212
darienf 3:36de8b9e4b1a 213 [TestCase(3, 0, 4000)]
darienf 3:36de8b9e4b1a 214 [TestCase(4, 0, 8000)]
darienf 3:36de8b9e4b1a 215 [TestCase(4, 1, 4000)]
darienf 3:36de8b9e4b1a 216 [TestCase(5, 0, 12000)]
darienf 3:36de8b9e4b1a 217 [TestCase(5, 1, 8000)]
darienf 3:36de8b9e4b1a 218 [TestCase(5, 2, 4000)]
darienf 3:36de8b9e4b1a 219 public void MultiModeTest(byte sampleAverage, byte sampleRate, int sleepMilliSecond)
darienf 3:36de8b9e4b1a 220 {
darienf 3:36de8b9e4b1a 221 Mock<IPlotView> plotView = new Mock<IPlotView>();
darienf 3:36de8b9e4b1a 222 StreamHelper streamHelper = new StreamHelper(rpcClient, plotView.Object);
darienf 3:36de8b9e4b1a 223
darienf 3:36de8b9e4b1a 224 rpcClient.MAX30101.Multimode_init(0x0f, sampleAverage, sampleRate, 0, 0x33, 0x33, 0x33, 1, 2, 3, 0, (byte)(sampleRate + 4));
darienf 3:36de8b9e4b1a 225 Thread.Sleep(sleepMilliSecond);
darienf 3:36de8b9e4b1a 226 rpcClient.MAX30101.Multimode_stop();
darienf 3:36de8b9e4b1a 227
darienf 3:36de8b9e4b1a 228 Application.DoEvents();
darienf 3:36de8b9e4b1a 229
darienf 3:36de8b9e4b1a 230 plotView.Verify(p => p.Display(It.IsAny<int[]>()), Times.AtLeast(1));
darienf 3:36de8b9e4b1a 231 }
darienf 3:36de8b9e4b1a 232
darienf 3:36de8b9e4b1a 233 [TestCase(0, 0)]
darienf 3:36de8b9e4b1a 234 [TestCase(0, 1)]
darienf 3:36de8b9e4b1a 235 [TestCase(0, 2)]
darienf 3:36de8b9e4b1a 236 [TestCase(0, 3)]
darienf 3:36de8b9e4b1a 237 [TestCase(1, 0)]
darienf 3:36de8b9e4b1a 238 [TestCase(1, 1)]
darienf 3:36de8b9e4b1a 239 [TestCase(1, 2)]
darienf 3:36de8b9e4b1a 240 [TestCase(1, 3)]
darienf 3:36de8b9e4b1a 241 [TestCase(2, 0)]
darienf 3:36de8b9e4b1a 242 [TestCase(2, 1)]
darienf 3:36de8b9e4b1a 243 [TestCase(2, 2)]
darienf 3:36de8b9e4b1a 244 [TestCase(2, 3)]
darienf 3:36de8b9e4b1a 245 [TestCase(3, 0)]
darienf 3:36de8b9e4b1a 246 [TestCase(3, 1)]
darienf 3:36de8b9e4b1a 247 [TestCase(3, 2)]
darienf 3:36de8b9e4b1a 248 [TestCase(3, 3)]
darienf 3:36de8b9e4b1a 249 //[TestCase(4, 0)]
darienf 3:36de8b9e4b1a 250 [TestCase(4, 1)]
darienf 3:36de8b9e4b1a 251 [TestCase(4, 2)]
darienf 3:36de8b9e4b1a 252 [TestCase(4, 3)]
darienf 3:36de8b9e4b1a 253 //[TestCase(5, 0)]
darienf 3:36de8b9e4b1a 254 //[TestCase(5, 1)]
darienf 3:36de8b9e4b1a 255 [TestCase(5, 2)]
darienf 3:36de8b9e4b1a 256 [TestCase(5, 3)]
darienf 3:36de8b9e4b1a 257 public void HRModePointsTest(byte sampleAverage, byte sampleRate)
darienf 3:36de8b9e4b1a 258 {
darienf 3:36de8b9e4b1a 259 Stopwatch sw = new Stopwatch();
darienf 3:36de8b9e4b1a 260 PlotView plotView = new PlotView();
darienf 3:36de8b9e4b1a 261 StreamHelper streamHelper = new StreamHelper(rpcClient, plotView);
darienf 3:36de8b9e4b1a 262
darienf 3:36de8b9e4b1a 263 rpcClient.MAX30101.HRmode_init(0x0f, sampleAverage, sampleRate, 3, 0x33, (byte)(0 + 4));
darienf 3:36de8b9e4b1a 264 sw.Start();
darienf 3:36de8b9e4b1a 265 Thread.Sleep(timeSleep);
darienf 3:36de8b9e4b1a 266 rpcClient.MAX30101.HRmode_stop();
darienf 3:36de8b9e4b1a 267 sw.Stop();
darienf 3:36de8b9e4b1a 268
darienf 3:36de8b9e4b1a 269 Application.DoEvents();
darienf 3:36de8b9e4b1a 270
darienf 3:36de8b9e4b1a 271 Console.WriteLine("Points: " + plotView.Points + "Time: " + sw.ElapsedMilliseconds / 1000.0);
darienf 3:36de8b9e4b1a 272 Assert.That(plotView.Points, Is.GreaterThan(minFactor * sw.ElapsedMilliseconds / 1000 * sr[sampleRate] / avg[sampleAverage]));
darienf 3:36de8b9e4b1a 273 Assert.That(plotView.Points, Is.LessThan(maxFactor * sw.ElapsedMilliseconds / 1000 * sr[sampleRate] / avg[sampleAverage]));
darienf 3:36de8b9e4b1a 274 }
darienf 3:36de8b9e4b1a 275
darienf 3:36de8b9e4b1a 276 [TestCase(0, 0)]
darienf 3:36de8b9e4b1a 277 [TestCase(0, 1)]
darienf 3:36de8b9e4b1a 278 [TestCase(0, 2)]
darienf 3:36de8b9e4b1a 279 [TestCase(0, 3)]
darienf 3:36de8b9e4b1a 280 [TestCase(1, 0)]
darienf 3:36de8b9e4b1a 281 [TestCase(1, 1)]
darienf 3:36de8b9e4b1a 282 [TestCase(1, 2)]
darienf 3:36de8b9e4b1a 283 [TestCase(1, 3)]
darienf 3:36de8b9e4b1a 284 [TestCase(2, 0)]
darienf 3:36de8b9e4b1a 285 [TestCase(2, 1)]
darienf 3:36de8b9e4b1a 286 [TestCase(2, 2)]
darienf 3:36de8b9e4b1a 287 [TestCase(2, 3)]
darienf 3:36de8b9e4b1a 288 [TestCase(3, 0)]
darienf 3:36de8b9e4b1a 289 [TestCase(3, 1)]
darienf 3:36de8b9e4b1a 290 [TestCase(3, 2)]
darienf 3:36de8b9e4b1a 291 [TestCase(3, 3)]
darienf 3:36de8b9e4b1a 292 //[TestCase(4, 0)]
darienf 3:36de8b9e4b1a 293 [TestCase(4, 1)]
darienf 3:36de8b9e4b1a 294 [TestCase(4, 2)]
darienf 3:36de8b9e4b1a 295 [TestCase(4, 3)]
darienf 3:36de8b9e4b1a 296 //[TestCase(5, 0)]
darienf 3:36de8b9e4b1a 297 //[TestCase(5, 1)]
darienf 3:36de8b9e4b1a 298 [TestCase(5, 2)]
darienf 3:36de8b9e4b1a 299 [TestCase(5, 3)]
darienf 3:36de8b9e4b1a 300 public void SpO2ModePointsTest(byte sampleAverage, byte sampleRate)
darienf 3:36de8b9e4b1a 301 {
darienf 3:36de8b9e4b1a 302 //ManualResetEvent eventRasied = new ManualResetEvent(false);
darienf 3:36de8b9e4b1a 303 Stopwatch sw = new Stopwatch();
darienf 3:36de8b9e4b1a 304 PlotView plotView = new PlotView();
darienf 3:36de8b9e4b1a 305 StreamHelper streamHelper = new StreamHelper(rpcClient, plotView);
darienf 3:36de8b9e4b1a 306
darienf 3:36de8b9e4b1a 307 //rpcClient.streaming.PartialArrayIntAvailable += (sender, e) => { eventRasied.Set(); };
darienf 3:36de8b9e4b1a 308
darienf 3:36de8b9e4b1a 309 rpcClient.MAX30101.SpO2mode_init(0x0f, sampleAverage, sampleRate, 3, 0x33, 0x33, (byte)(sampleRate + 4));
darienf 3:36de8b9e4b1a 310 sw.Start();
darienf 3:36de8b9e4b1a 311 Thread.Sleep(timeSleep);
darienf 3:36de8b9e4b1a 312 rpcClient.MAX30101.SpO2mode_stop();
darienf 3:36de8b9e4b1a 313 sw.Stop();
darienf 3:36de8b9e4b1a 314
darienf 3:36de8b9e4b1a 315 Application.DoEvents();
darienf 3:36de8b9e4b1a 316
darienf 3:36de8b9e4b1a 317 Console.WriteLine("Points: " + plotView.Points + "Time: " + sw.ElapsedMilliseconds / 1000.0);
darienf 3:36de8b9e4b1a 318 Assert.That(plotView.Points, Is.GreaterThan(minFactor * sw.ElapsedMilliseconds / 1000 * sr[sampleRate] / avg[sampleAverage]));
darienf 3:36de8b9e4b1a 319 Assert.That(plotView.Points, Is.LessThan(maxFactor * sw.ElapsedMilliseconds / 1000 * sr[sampleRate] / avg[sampleAverage]));
darienf 3:36de8b9e4b1a 320 //Assert.IsTrue(eventRasied.WaitOne(10000));
darienf 3:36de8b9e4b1a 321 }
darienf 3:36de8b9e4b1a 322
darienf 3:36de8b9e4b1a 323 [TestCase(0, 0)]
darienf 3:36de8b9e4b1a 324 [TestCase(0, 1)]
darienf 3:36de8b9e4b1a 325 [TestCase(0, 2)]
darienf 3:36de8b9e4b1a 326 [TestCase(0, 3)]
darienf 3:36de8b9e4b1a 327 [TestCase(1, 0)]
darienf 3:36de8b9e4b1a 328 [TestCase(1, 1)]
darienf 3:36de8b9e4b1a 329 [TestCase(1, 2)]
darienf 3:36de8b9e4b1a 330 [TestCase(1, 3)]
darienf 3:36de8b9e4b1a 331 [TestCase(2, 0)]
darienf 3:36de8b9e4b1a 332 [TestCase(2, 1)]
darienf 3:36de8b9e4b1a 333 [TestCase(2, 2)]
darienf 3:36de8b9e4b1a 334 [TestCase(2, 3)]
darienf 3:36de8b9e4b1a 335 [TestCase(3, 0)]
darienf 3:36de8b9e4b1a 336 [TestCase(3, 1)]
darienf 3:36de8b9e4b1a 337 [TestCase(3, 2)]
darienf 3:36de8b9e4b1a 338 [TestCase(3, 3)]
darienf 3:36de8b9e4b1a 339 //[TestCase(4, 0)]
darienf 3:36de8b9e4b1a 340 [TestCase(4, 1)]
darienf 3:36de8b9e4b1a 341 [TestCase(4, 2)]
darienf 3:36de8b9e4b1a 342 [TestCase(4, 3)]
darienf 3:36de8b9e4b1a 343 //[TestCase(5, 0)]
darienf 3:36de8b9e4b1a 344 //[TestCase(5, 1)]
darienf 3:36de8b9e4b1a 345 [TestCase(5, 2)]
darienf 3:36de8b9e4b1a 346 [TestCase(5, 3)]
darienf 3:36de8b9e4b1a 347 public void MultiModePointsTest(byte sampleAverage, byte sampleRate)
darienf 3:36de8b9e4b1a 348 {
darienf 3:36de8b9e4b1a 349 Stopwatch sw = new Stopwatch();
darienf 3:36de8b9e4b1a 350 PlotView plotView = new PlotView();
darienf 3:36de8b9e4b1a 351 StreamHelper streamHelper = new StreamHelper(rpcClient, plotView);
darienf 3:36de8b9e4b1a 352
darienf 3:36de8b9e4b1a 353 rpcClient.MAX30101.Multimode_init(0x0f, sampleAverage, sampleRate, 0, 0x33, 0x33, 0x33, 1, 2, 3, 0, (byte)(sampleRate + 4));
darienf 3:36de8b9e4b1a 354 sw.Start();
darienf 3:36de8b9e4b1a 355 Thread.Sleep(timeSleep);
darienf 3:36de8b9e4b1a 356 rpcClient.MAX30101.Multimode_stop();
darienf 3:36de8b9e4b1a 357 sw.Stop();
darienf 3:36de8b9e4b1a 358
darienf 3:36de8b9e4b1a 359 Application.DoEvents();
darienf 3:36de8b9e4b1a 360
darienf 3:36de8b9e4b1a 361 Console.WriteLine("Points: " + plotView.Points + "Time: " + sw.ElapsedMilliseconds / 1000.0);
darienf 3:36de8b9e4b1a 362 Assert.That(plotView.Points, Is.GreaterThan(minFactor * sw.ElapsedMilliseconds / 1000 * sr[sampleRate] / avg[sampleAverage]));
darienf 3:36de8b9e4b1a 363 Assert.That(plotView.Points, Is.LessThan(maxFactor * sw.ElapsedMilliseconds / 1000 * sr[sampleRate] / avg[sampleAverage]));
darienf 3:36de8b9e4b1a 364 }
darienf 3:36de8b9e4b1a 365 }
darienf 3:36de8b9e4b1a 366 }