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.Threading;
darienf 20:6d2af70c92ab 38 using System.Windows.Forms;
darienf 20:6d2af70c92ab 39 using System.Diagnostics;
darienf 20:6d2af70c92ab 40 using NUnit.Framework;
darienf 20:6d2af70c92ab 41 using Moq;
darienf 20:6d2af70c92ab 42
darienf 20:6d2af70c92ab 43 using RPCSupport;
darienf 20:6d2af70c92ab 44 using RPCSupport.Devices;
darienf 20:6d2af70c92ab 45
darienf 20:6d2af70c92ab 46 namespace RPCSupportTest
darienf 20:6d2af70c92ab 47 {
darienf 20:6d2af70c92ab 48 //[TestFixture, RequiresThread]
darienf 20:6d2af70c92ab 49 [TestFixture]
darienf 20:6d2af70c92ab 50 [Property("Class", "MAX30101")]
darienf 20:6d2af70c92ab 51 class MAX30101Test
darienf 20:6d2af70c92ab 52 {
darienf 20:6d2af70c92ab 53 RPCClient rpcClient;
darienf 20:6d2af70c92ab 54 MAX30101 max30101;
darienf 20:6d2af70c92ab 55
darienf 20:6d2af70c92ab 56 int[] avg = new int[] { 1, 2, 4, 8, 16, 32 };
darienf 20:6d2af70c92ab 57 int[] sr = new int[] { 50, 100, 200, 400 };
darienf 20:6d2af70c92ab 58
darienf 20:6d2af70c92ab 59 double minFactor = 0.75;
darienf 20:6d2af70c92ab 60 double maxFactor = 1;
darienf 20:6d2af70c92ab 61 int timeSleep = 10000;
darienf 20:6d2af70c92ab 62
darienf 20:6d2af70c92ab 63 [TestFixtureSetUp]
darienf 20:6d2af70c92ab 64 public void Init()
darienf 20:6d2af70c92ab 65 {
darienf 20:6d2af70c92ab 66 rpcClient = new RPCClient(RPCClient.ePipeline.eSerialWrap);
darienf 20:6d2af70c92ab 67 rpcClient.InitPipeline();
darienf 20:6d2af70c92ab 68 rpcClient.Connect(ComPort.Port);
darienf 20:6d2af70c92ab 69 //rpcClient.Pipeline.Discard();
darienf 20:6d2af70c92ab 70 max30101 = rpcClient.Init_MAX30101(0xAE);
darienf 20:6d2af70c92ab 71 //rpcClient.streaming.Init(rpcClient.Pipeline);
darienf 20:6d2af70c92ab 72
darienf 20:6d2af70c92ab 73 //rpcClient.Version();
darienf 20:6d2af70c92ab 74 }
darienf 20:6d2af70c92ab 75
darienf 20:6d2af70c92ab 76 [TestFixtureTearDown]
darienf 20:6d2af70c92ab 77 public void Dispose()
darienf 20:6d2af70c92ab 78 {
darienf 20:6d2af70c92ab 79 rpcClient.Disconnect();
darienf 20:6d2af70c92ab 80 rpcClient.streaming.Stop();
darienf 20:6d2af70c92ab 81 Thread.Sleep(100);
darienf 20:6d2af70c92ab 82 }
darienf 20:6d2af70c92ab 83
darienf 20:6d2af70c92ab 84 [TestCase(0, 0)]
darienf 20:6d2af70c92ab 85 [TestCase(0, 1)]
darienf 20:6d2af70c92ab 86 [TestCase(0, 2)]
darienf 20:6d2af70c92ab 87 [TestCase(0, 3)]
darienf 20:6d2af70c92ab 88 [TestCase(1, 0)]
darienf 20:6d2af70c92ab 89 [TestCase(1, 1)]
darienf 20:6d2af70c92ab 90 [TestCase(1, 2)]
darienf 20:6d2af70c92ab 91 [TestCase(1, 3)]
darienf 20:6d2af70c92ab 92 [TestCase(2, 0)]
darienf 20:6d2af70c92ab 93 [TestCase(2, 1)]
darienf 20:6d2af70c92ab 94 [TestCase(2, 2)]
darienf 20:6d2af70c92ab 95 [TestCase(2, 3)]
darienf 20:6d2af70c92ab 96 //[TestCase(3, 0)]
darienf 20:6d2af70c92ab 97 [TestCase(3, 1)]
darienf 20:6d2af70c92ab 98 [TestCase(3, 2)]
darienf 20:6d2af70c92ab 99 [TestCase(3, 3)]
darienf 20:6d2af70c92ab 100 //[TestCase(4, 0)]
darienf 20:6d2af70c92ab 101 //[TestCase(4, 1)]
darienf 20:6d2af70c92ab 102 [TestCase(4, 2)]
darienf 20:6d2af70c92ab 103 [TestCase(4, 3)]
darienf 20:6d2af70c92ab 104 //[TestCase(5, 0)]
darienf 20:6d2af70c92ab 105 //[TestCase(5, 1)]
darienf 20:6d2af70c92ab 106 //[TestCase(5, 2)]
darienf 20:6d2af70c92ab 107 [TestCase(5, 3)]
darienf 20:6d2af70c92ab 108 public void HRModeTest(byte sampleAverage, byte sampleRate)
darienf 20:6d2af70c92ab 109 {
darienf 20:6d2af70c92ab 110 HRModeTest(sampleAverage, sampleRate, 3000);
darienf 20:6d2af70c92ab 111 }
darienf 20:6d2af70c92ab 112
darienf 20:6d2af70c92ab 113 [TestCase(3, 0, 4000)]
darienf 20:6d2af70c92ab 114 [TestCase(4, 0, 8000)]
darienf 20:6d2af70c92ab 115 [TestCase(4, 1, 4000)]
darienf 20:6d2af70c92ab 116 [TestCase(5, 0, 12000)]
darienf 20:6d2af70c92ab 117 [TestCase(5, 1, 8000)]
darienf 20:6d2af70c92ab 118 [TestCase(5, 2, 4000)]
darienf 20:6d2af70c92ab 119 public void HRModeTest(byte sampleAverage, byte sampleRate, int sleepMilliSecond)
darienf 20:6d2af70c92ab 120 {
darienf 20:6d2af70c92ab 121 Mock<IPlotView> plotView;
darienf 20:6d2af70c92ab 122 plotView = new Mock<IPlotView>();
darienf 20:6d2af70c92ab 123 StreamHelper streamHelper = new StreamHelper(rpcClient, plotView.Object);
darienf 20:6d2af70c92ab 124
darienf 20:6d2af70c92ab 125 rpcClient.MAX30101.HRmode_init(0x0f, sampleAverage, sampleRate, 3, 0x33, (byte)(0 + 4));
darienf 20:6d2af70c92ab 126 Thread.Sleep(sleepMilliSecond);
darienf 20:6d2af70c92ab 127 rpcClient.MAX30101.HRmode_stop();
darienf 20:6d2af70c92ab 128
darienf 20:6d2af70c92ab 129 Application.DoEvents();
darienf 20:6d2af70c92ab 130
darienf 20:6d2af70c92ab 131 plotView.Verify(p => p.Display(It.IsAny<int[]>()), Times.AtLeast(1));
darienf 20:6d2af70c92ab 132 }
darienf 20:6d2af70c92ab 133
darienf 20:6d2af70c92ab 134 [TestCase(0, 0)]
darienf 20:6d2af70c92ab 135 [TestCase(0, 1)]
darienf 20:6d2af70c92ab 136 [TestCase(0, 2)]
darienf 20:6d2af70c92ab 137 [TestCase(0, 3)]
darienf 20:6d2af70c92ab 138 [TestCase(1, 0)]
darienf 20:6d2af70c92ab 139 [TestCase(1, 1)]
darienf 20:6d2af70c92ab 140 [TestCase(1, 2)]
darienf 20:6d2af70c92ab 141 [TestCase(1, 3)]
darienf 20:6d2af70c92ab 142 [TestCase(2, 0)]
darienf 20:6d2af70c92ab 143 [TestCase(2, 1)]
darienf 20:6d2af70c92ab 144 [TestCase(2, 2)]
darienf 20:6d2af70c92ab 145 [TestCase(2, 3)]
darienf 20:6d2af70c92ab 146 //[TestCase(3, 0)]
darienf 20:6d2af70c92ab 147 [TestCase(3, 1)]
darienf 20:6d2af70c92ab 148 [TestCase(3, 2)]
darienf 20:6d2af70c92ab 149 [TestCase(3, 3)]
darienf 20:6d2af70c92ab 150 //[TestCase(4, 0)]
darienf 20:6d2af70c92ab 151 //[TestCase(4, 1)]
darienf 20:6d2af70c92ab 152 [TestCase(4, 2)]
darienf 20:6d2af70c92ab 153 [TestCase(4, 3)]
darienf 20:6d2af70c92ab 154 //[TestCase(5, 0)]
darienf 20:6d2af70c92ab 155 //[TestCase(5, 1)]
darienf 20:6d2af70c92ab 156 //[TestCase(5, 2)]
darienf 20:6d2af70c92ab 157 [TestCase(5, 3)]
darienf 20:6d2af70c92ab 158 public void SpO2ModeTest(byte sampleAverage, byte sampleRate)
darienf 20:6d2af70c92ab 159 {
darienf 20:6d2af70c92ab 160 SpO2ModeTest(sampleAverage, sampleRate, 3000);
darienf 20:6d2af70c92ab 161 }
darienf 20:6d2af70c92ab 162
darienf 20:6d2af70c92ab 163 [TestCase(3, 0, 4000)]
darienf 20:6d2af70c92ab 164 [TestCase(4, 0, 8000)]
darienf 20:6d2af70c92ab 165 [TestCase(4, 1, 4000)]
darienf 20:6d2af70c92ab 166 [TestCase(5, 0, 12000)]
darienf 20:6d2af70c92ab 167 [TestCase(5, 1, 8000)]
darienf 20:6d2af70c92ab 168 [TestCase(5, 2, 4000)]
darienf 20:6d2af70c92ab 169 public void SpO2ModeTest(byte sampleAverage, byte sampleRate, int sleepMillisecond)
darienf 20:6d2af70c92ab 170 {
darienf 20:6d2af70c92ab 171 Mock<IPlotView> plotView = new Mock<IPlotView>();
darienf 20:6d2af70c92ab 172 StreamHelper streamHelper = new StreamHelper(rpcClient, plotView.Object);
darienf 20:6d2af70c92ab 173
darienf 20:6d2af70c92ab 174 rpcClient.MAX30101.SpO2mode_init(0x0f, sampleAverage, sampleRate, 3, 0x33, 0x33, (byte)(sampleRate + 4));
darienf 20:6d2af70c92ab 175 Thread.Sleep(sleepMillisecond);
darienf 20:6d2af70c92ab 176 rpcClient.MAX30101.SpO2mode_stop();
darienf 20:6d2af70c92ab 177
darienf 20:6d2af70c92ab 178 Application.DoEvents();
darienf 20:6d2af70c92ab 179
darienf 20:6d2af70c92ab 180 plotView.Verify(p => p.Display(It.IsAny<int[]>()), Times.AtLeast(1));
darienf 20:6d2af70c92ab 181 }
darienf 20:6d2af70c92ab 182
darienf 20:6d2af70c92ab 183
darienf 20:6d2af70c92ab 184 [TestCase(0, 0)]
darienf 20:6d2af70c92ab 185 [TestCase(0, 1)]
darienf 20:6d2af70c92ab 186 [TestCase(0, 2)]
darienf 20:6d2af70c92ab 187 [TestCase(0, 3)]
darienf 20:6d2af70c92ab 188 [TestCase(1, 0)]
darienf 20:6d2af70c92ab 189 [TestCase(1, 1)]
darienf 20:6d2af70c92ab 190 [TestCase(1, 2)]
darienf 20:6d2af70c92ab 191 [TestCase(1, 3)]
darienf 20:6d2af70c92ab 192 [TestCase(2, 0)]
darienf 20:6d2af70c92ab 193 [TestCase(2, 1)]
darienf 20:6d2af70c92ab 194 [TestCase(2, 2)]
darienf 20:6d2af70c92ab 195 [TestCase(2, 3)]
darienf 20:6d2af70c92ab 196 //[TestCase(3,0)]
darienf 20:6d2af70c92ab 197 [TestCase(3, 1)]
darienf 20:6d2af70c92ab 198 [TestCase(3, 2)]
darienf 20:6d2af70c92ab 199 [TestCase(3, 3)]
darienf 20:6d2af70c92ab 200 //[TestCase(4, 0)]
darienf 20:6d2af70c92ab 201 //[TestCase(4, 1)]
darienf 20:6d2af70c92ab 202 [TestCase(4, 2)]
darienf 20:6d2af70c92ab 203 [TestCase(4, 3)]
darienf 20:6d2af70c92ab 204 //[TestCase(5, 0)]
darienf 20:6d2af70c92ab 205 //[TestCase(5, 1)]
darienf 20:6d2af70c92ab 206 //[TestCase(5, 2)]
darienf 20:6d2af70c92ab 207 [TestCase(5, 3)]
darienf 20:6d2af70c92ab 208 public void MultiModeTest(byte sampleAverage, byte sampleRate)
darienf 20:6d2af70c92ab 209 {
darienf 20:6d2af70c92ab 210 MultiModeTest(sampleAverage, sampleRate, 3000);
darienf 20:6d2af70c92ab 211 }
darienf 20:6d2af70c92ab 212
darienf 20:6d2af70c92ab 213 [TestCase(3, 0, 4000)]
darienf 20:6d2af70c92ab 214 [TestCase(4, 0, 8000)]
darienf 20:6d2af70c92ab 215 [TestCase(4, 1, 4000)]
darienf 20:6d2af70c92ab 216 [TestCase(5, 0, 12000)]
darienf 20:6d2af70c92ab 217 [TestCase(5, 1, 8000)]
darienf 20:6d2af70c92ab 218 [TestCase(5, 2, 4000)]
darienf 20:6d2af70c92ab 219 public void MultiModeTest(byte sampleAverage, byte sampleRate, int sleepMilliSecond)
darienf 20:6d2af70c92ab 220 {
darienf 20:6d2af70c92ab 221 Mock<IPlotView> plotView = new Mock<IPlotView>();
darienf 20:6d2af70c92ab 222 StreamHelper streamHelper = new StreamHelper(rpcClient, plotView.Object);
darienf 20:6d2af70c92ab 223
darienf 20:6d2af70c92ab 224 rpcClient.MAX30101.Multimode_init(0x0f, sampleAverage, sampleRate, 0, 0x33, 0x33, 0x33, 1, 2, 3, 0, (byte)(sampleRate + 4));
darienf 20:6d2af70c92ab 225 Thread.Sleep(sleepMilliSecond);
darienf 20:6d2af70c92ab 226 rpcClient.MAX30101.Multimode_stop();
darienf 20:6d2af70c92ab 227
darienf 20:6d2af70c92ab 228 Application.DoEvents();
darienf 20:6d2af70c92ab 229
darienf 20:6d2af70c92ab 230 plotView.Verify(p => p.Display(It.IsAny<int[]>()), Times.AtLeast(1));
darienf 20:6d2af70c92ab 231 }
darienf 20:6d2af70c92ab 232
darienf 20:6d2af70c92ab 233 [TestCase(0, 0)]
darienf 20:6d2af70c92ab 234 [TestCase(0, 1)]
darienf 20:6d2af70c92ab 235 [TestCase(0, 2)]
darienf 20:6d2af70c92ab 236 [TestCase(0, 3)]
darienf 20:6d2af70c92ab 237 [TestCase(1, 0)]
darienf 20:6d2af70c92ab 238 [TestCase(1, 1)]
darienf 20:6d2af70c92ab 239 [TestCase(1, 2)]
darienf 20:6d2af70c92ab 240 [TestCase(1, 3)]
darienf 20:6d2af70c92ab 241 [TestCase(2, 0)]
darienf 20:6d2af70c92ab 242 [TestCase(2, 1)]
darienf 20:6d2af70c92ab 243 [TestCase(2, 2)]
darienf 20:6d2af70c92ab 244 [TestCase(2, 3)]
darienf 20:6d2af70c92ab 245 [TestCase(3, 0)]
darienf 20:6d2af70c92ab 246 [TestCase(3, 1)]
darienf 20:6d2af70c92ab 247 [TestCase(3, 2)]
darienf 20:6d2af70c92ab 248 [TestCase(3, 3)]
darienf 20:6d2af70c92ab 249 //[TestCase(4, 0)]
darienf 20:6d2af70c92ab 250 [TestCase(4, 1)]
darienf 20:6d2af70c92ab 251 [TestCase(4, 2)]
darienf 20:6d2af70c92ab 252 [TestCase(4, 3)]
darienf 20:6d2af70c92ab 253 //[TestCase(5, 0)]
darienf 20:6d2af70c92ab 254 //[TestCase(5, 1)]
darienf 20:6d2af70c92ab 255 [TestCase(5, 2)]
darienf 20:6d2af70c92ab 256 [TestCase(5, 3)]
darienf 20:6d2af70c92ab 257 public void HRModePointsTest(byte sampleAverage, byte sampleRate)
darienf 20:6d2af70c92ab 258 {
darienf 20:6d2af70c92ab 259 Stopwatch sw = new Stopwatch();
darienf 20:6d2af70c92ab 260 PlotView plotView = new PlotView();
darienf 20:6d2af70c92ab 261 StreamHelper streamHelper = new StreamHelper(rpcClient, plotView);
darienf 20:6d2af70c92ab 262
darienf 20:6d2af70c92ab 263 rpcClient.MAX30101.HRmode_init(0x0f, sampleAverage, sampleRate, 3, 0x33, (byte)(0 + 4));
darienf 20:6d2af70c92ab 264 sw.Start();
darienf 20:6d2af70c92ab 265 Thread.Sleep(timeSleep);
darienf 20:6d2af70c92ab 266 rpcClient.MAX30101.HRmode_stop();
darienf 20:6d2af70c92ab 267 sw.Stop();
darienf 20:6d2af70c92ab 268
darienf 20:6d2af70c92ab 269 Application.DoEvents();
darienf 20:6d2af70c92ab 270
darienf 20:6d2af70c92ab 271 Console.WriteLine("Points: " + plotView.Points + "Time: " + sw.ElapsedMilliseconds / 1000.0);
darienf 20:6d2af70c92ab 272 Assert.That(plotView.Points, Is.GreaterThan(minFactor * sw.ElapsedMilliseconds / 1000 * sr[sampleRate] / avg[sampleAverage]));
darienf 20:6d2af70c92ab 273 Assert.That(plotView.Points, Is.LessThan(maxFactor * sw.ElapsedMilliseconds / 1000 * sr[sampleRate] / avg[sampleAverage]));
darienf 20:6d2af70c92ab 274 }
darienf 20:6d2af70c92ab 275
darienf 20:6d2af70c92ab 276 [TestCase(0, 0)]
darienf 20:6d2af70c92ab 277 [TestCase(0, 1)]
darienf 20:6d2af70c92ab 278 [TestCase(0, 2)]
darienf 20:6d2af70c92ab 279 [TestCase(0, 3)]
darienf 20:6d2af70c92ab 280 [TestCase(1, 0)]
darienf 20:6d2af70c92ab 281 [TestCase(1, 1)]
darienf 20:6d2af70c92ab 282 [TestCase(1, 2)]
darienf 20:6d2af70c92ab 283 [TestCase(1, 3)]
darienf 20:6d2af70c92ab 284 [TestCase(2, 0)]
darienf 20:6d2af70c92ab 285 [TestCase(2, 1)]
darienf 20:6d2af70c92ab 286 [TestCase(2, 2)]
darienf 20:6d2af70c92ab 287 [TestCase(2, 3)]
darienf 20:6d2af70c92ab 288 [TestCase(3, 0)]
darienf 20:6d2af70c92ab 289 [TestCase(3, 1)]
darienf 20:6d2af70c92ab 290 [TestCase(3, 2)]
darienf 20:6d2af70c92ab 291 [TestCase(3, 3)]
darienf 20:6d2af70c92ab 292 //[TestCase(4, 0)]
darienf 20:6d2af70c92ab 293 [TestCase(4, 1)]
darienf 20:6d2af70c92ab 294 [TestCase(4, 2)]
darienf 20:6d2af70c92ab 295 [TestCase(4, 3)]
darienf 20:6d2af70c92ab 296 //[TestCase(5, 0)]
darienf 20:6d2af70c92ab 297 //[TestCase(5, 1)]
darienf 20:6d2af70c92ab 298 [TestCase(5, 2)]
darienf 20:6d2af70c92ab 299 [TestCase(5, 3)]
darienf 20:6d2af70c92ab 300 public void SpO2ModePointsTest(byte sampleAverage, byte sampleRate)
darienf 20:6d2af70c92ab 301 {
darienf 20:6d2af70c92ab 302 //ManualResetEvent eventRasied = new ManualResetEvent(false);
darienf 20:6d2af70c92ab 303 Stopwatch sw = new Stopwatch();
darienf 20:6d2af70c92ab 304 PlotView plotView = new PlotView();
darienf 20:6d2af70c92ab 305 StreamHelper streamHelper = new StreamHelper(rpcClient, plotView);
darienf 20:6d2af70c92ab 306
darienf 20:6d2af70c92ab 307 //rpcClient.streaming.PartialArrayIntAvailable += (sender, e) => { eventRasied.Set(); };
darienf 20:6d2af70c92ab 308
darienf 20:6d2af70c92ab 309 rpcClient.MAX30101.SpO2mode_init(0x0f, sampleAverage, sampleRate, 3, 0x33, 0x33, (byte)(sampleRate + 4));
darienf 20:6d2af70c92ab 310 sw.Start();
darienf 20:6d2af70c92ab 311 Thread.Sleep(timeSleep);
darienf 20:6d2af70c92ab 312 rpcClient.MAX30101.SpO2mode_stop();
darienf 20:6d2af70c92ab 313 sw.Stop();
darienf 20:6d2af70c92ab 314
darienf 20:6d2af70c92ab 315 Application.DoEvents();
darienf 20:6d2af70c92ab 316
darienf 20:6d2af70c92ab 317 Console.WriteLine("Points: " + plotView.Points + "Time: " + sw.ElapsedMilliseconds / 1000.0);
darienf 20:6d2af70c92ab 318 Assert.That(plotView.Points, Is.GreaterThan(minFactor * sw.ElapsedMilliseconds / 1000 * sr[sampleRate] / avg[sampleAverage]));
darienf 20:6d2af70c92ab 319 Assert.That(plotView.Points, Is.LessThan(maxFactor * sw.ElapsedMilliseconds / 1000 * sr[sampleRate] / avg[sampleAverage]));
darienf 20:6d2af70c92ab 320 //Assert.IsTrue(eventRasied.WaitOne(10000));
darienf 20:6d2af70c92ab 321 }
darienf 20:6d2af70c92ab 322
darienf 20:6d2af70c92ab 323 [TestCase(0, 0)]
darienf 20:6d2af70c92ab 324 [TestCase(0, 1)]
darienf 20:6d2af70c92ab 325 [TestCase(0, 2)]
darienf 20:6d2af70c92ab 326 [TestCase(0, 3)]
darienf 20:6d2af70c92ab 327 [TestCase(1, 0)]
darienf 20:6d2af70c92ab 328 [TestCase(1, 1)]
darienf 20:6d2af70c92ab 329 [TestCase(1, 2)]
darienf 20:6d2af70c92ab 330 [TestCase(1, 3)]
darienf 20:6d2af70c92ab 331 [TestCase(2, 0)]
darienf 20:6d2af70c92ab 332 [TestCase(2, 1)]
darienf 20:6d2af70c92ab 333 [TestCase(2, 2)]
darienf 20:6d2af70c92ab 334 [TestCase(2, 3)]
darienf 20:6d2af70c92ab 335 [TestCase(3, 0)]
darienf 20:6d2af70c92ab 336 [TestCase(3, 1)]
darienf 20:6d2af70c92ab 337 [TestCase(3, 2)]
darienf 20:6d2af70c92ab 338 [TestCase(3, 3)]
darienf 20:6d2af70c92ab 339 //[TestCase(4, 0)]
darienf 20:6d2af70c92ab 340 [TestCase(4, 1)]
darienf 20:6d2af70c92ab 341 [TestCase(4, 2)]
darienf 20:6d2af70c92ab 342 [TestCase(4, 3)]
darienf 20:6d2af70c92ab 343 //[TestCase(5, 0)]
darienf 20:6d2af70c92ab 344 //[TestCase(5, 1)]
darienf 20:6d2af70c92ab 345 [TestCase(5, 2)]
darienf 20:6d2af70c92ab 346 [TestCase(5, 3)]
darienf 20:6d2af70c92ab 347 public void MultiModePointsTest(byte sampleAverage, byte sampleRate)
darienf 20:6d2af70c92ab 348 {
darienf 20:6d2af70c92ab 349 Stopwatch sw = new Stopwatch();
darienf 20:6d2af70c92ab 350 PlotView plotView = new PlotView();
darienf 20:6d2af70c92ab 351 StreamHelper streamHelper = new StreamHelper(rpcClient, plotView);
darienf 20:6d2af70c92ab 352
darienf 20:6d2af70c92ab 353 rpcClient.MAX30101.Multimode_init(0x0f, sampleAverage, sampleRate, 0, 0x33, 0x33, 0x33, 1, 2, 3, 0, (byte)(sampleRate + 4));
darienf 20:6d2af70c92ab 354 sw.Start();
darienf 20:6d2af70c92ab 355 Thread.Sleep(timeSleep);
darienf 20:6d2af70c92ab 356 rpcClient.MAX30101.Multimode_stop();
darienf 20:6d2af70c92ab 357 sw.Stop();
darienf 20:6d2af70c92ab 358
darienf 20:6d2af70c92ab 359 Application.DoEvents();
darienf 20:6d2af70c92ab 360
darienf 20:6d2af70c92ab 361 Console.WriteLine("Points: " + plotView.Points + "Time: " + sw.ElapsedMilliseconds / 1000.0);
darienf 20:6d2af70c92ab 362 Assert.That(plotView.Points, Is.GreaterThan(minFactor * sw.ElapsedMilliseconds / 1000 * sr[sampleRate] / avg[sampleAverage]));
darienf 20:6d2af70c92ab 363 Assert.That(plotView.Points, Is.LessThan(maxFactor * sw.ElapsedMilliseconds / 1000 * sr[sampleRate] / avg[sampleAverage]));
darienf 20:6d2af70c92ab 364 }
darienf 20:6d2af70c92ab 365 }
darienf 20:6d2af70c92ab 366 }