Darien Figueroa / Mbed 2 deprecated repo3

Dependencies:   mbed MAX14720 MAX30205 USBDevice

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers RToRTest.cs Source File

RToRTest.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 using System.Threading.Tasks;
00041 
00042 using NUnit.Framework;
00043 using HealthSensorPlatform.CustomControls;
00044 using HealthSensorPlatform.Presenter;
00045 
00046 namespace EcgViewTest
00047 {
00048     class RToRTest
00049     {
00050         [TestCase(8746, 0)]
00051         [TestCase(9002, 1)]
00052         [TestCase(12586, 15)]
00053         public void RToRDetectionDelay(int expect, int rToRWndw)
00054         {
00055             EcgView view = new EcgView();
00056 
00057             view.RToRWindowField = rToRWndw;
00058 
00059             Assert.AreEqual(expect, view.RToRDelay);
00060         }
00061 
00062         [TestCase(650, 0, 0, 0)]
00063         [TestCase(1034, 0, 0, 1)]
00064         [TestCase(1034, 0, 0, 2)]
00065         [TestCase(1034, 0, 0, 3)]
00066         [TestCase(2922, 0, 1, 0)]
00067         [TestCase(3370, 0, 2, 0)]
00068         [TestCase(3370, 0, 3, 0)]
00069         [TestCase(1242, 2, 2, 0)]
00070         [TestCase(1242, 3, 2, 0)]
00071         [TestCase(1242, 3, 3, 0)]
00072         [TestCase(2202, 3, 3, 1)]
00073         public void EcgDecimationDelay(int expect, int masterClock, int rate, int lpf)
00074         {
00075             EcgView view = new EcgView();
00076             InitArgs.EcgInitStart ecgInit = new InitArgs.EcgInitStart();
00077 
00078             ecgInit.Rate = rate;
00079             ecgInit.Dlpf = lpf;
00080 
00081             view.ecgArgs = ecgInit;
00082             view.FrequencyMasterField = masterClock;
00083 
00084             Assert.AreEqual(expect, view.EcgDecimationDelay);
00085         }
00086 
00087         /*
00088         [TestCase(100, 118)]
00089         public void RToRToEcgPoints(int expect, int rToR)
00090         {
00091             EcgView view = new EcgView();
00092             InitArgs.EcgInitStart ecgInit = new InitArgs.EcgInitStart();
00093 
00094             ecgInit.Rate = 3;
00095             ecgInit.Dlpf = 1;
00096 
00097             view.ecgArgs = ecgInit;
00098             view.FrequencyMasterField = 0;
00099             view.RToRWindowField = 3;
00100 
00101             Assert.AreEqual(expect, view.RToREcgPoints(rToR, true));
00102         }
00103 
00104         [TestCase(205, 128, 1)]
00105         [TestCase(205, 128, 2)]
00106         [TestCase(204, 128, 3)]
00107         [TestCase(205, 128, 4)]
00108         [TestCase(205, 128, 5)]
00109         [TestCase(205, 128, 6)]
00110         [TestCase(205, 128, 7)]
00111         [TestCase(204, 128, 8)]
00112         [TestCase(205, 128, 9)]
00113         [TestCase(205, 128, 10)]
00114         [TestCase(205, 128, 11)]
00115         [TestCase(205, 128, 12)]
00116         [TestCase(204, 128, 13)]
00117         public void RToREcgPointRoundingLoop(int expect, int rToR, int loop)
00118         {
00119             int result = 0;
00120 
00121             EcgView view = new EcgView();
00122             InitArgs.EcgInitStart ecgInit = new InitArgs.EcgInitStart();
00123 
00124             ecgInit.Rate = 3;
00125             ecgInit.Dlpf = 1;
00126 
00127             view.SampleRateECG = 199.8;
00128 
00129             view.ecgArgs = ecgInit;
00130             view.FrequencyMasterField = 3;
00131 
00132             for (int i = 0; i < loop; i++)
00133             {
00134                 result = view.RToREcgPoints(rToR, false);
00135             }
00136 
00137             Assert.AreEqual(expect, result);
00138         }
00139          * */
00140 
00141         [TestCase(205, 128, 1)]
00142         [TestCase(205, 128, 2)]
00143         [TestCase(204, 128, 3)]
00144         [TestCase(205, 128, 4)]
00145         [TestCase(205, 128, 5)]
00146         [TestCase(205, 128, 6)]
00147         [TestCase(205, 128, 7)]
00148         [TestCase(204, 128, 8)]
00149         [TestCase(205, 128, 9)]
00150         [TestCase(205, 128, 10)]
00151         [TestCase(205, 128, 11)]
00152         [TestCase(205, 128, 12)]
00153         [TestCase(204, 128, 13)]
00154         public void RToRCalculatorRoundingLoop(int expect, int rToR, int loop)
00155         {
00156             int result = 0;
00157 
00158             RToRCalculator rToRCalculator = new RToRCalculator(3, 3, 1, 0);
00159 
00160             for (int i = 0; i < loop; i++)
00161             {
00162                 result = rToRCalculator.EcgPoints(rToR, false);
00163             }
00164 
00165             Assert.AreEqual(expect, result);
00166         }
00167     }
00168 }