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.Collections.Generic;
darienf 20:6d2af70c92ab 38 using System.Linq;
darienf 20:6d2af70c92ab 39 using System.Text;
darienf 20:6d2af70c92ab 40 using RPCSupport.Devices;
darienf 20:6d2af70c92ab 41 using System.Globalization;
darienf 20:6d2af70c92ab 42 using System.Runtime.Serialization.Formatters.Binary;
darienf 20:6d2af70c92ab 43 using System.IO;
darienf 20:6d2af70c92ab 44 using System.Threading;
darienf 20:6d2af70c92ab 45
darienf 20:6d2af70c92ab 46 namespace RPCSupport.DataLogging
darienf 20:6d2af70c92ab 47 {
darienf 20:6d2af70c92ab 48 public class DataLogging : ClientDevice
darienf 20:6d2af70c92ab 49 {
darienf 20:6d2af70c92ab 50
darienf 20:6d2af70c92ab 51 public class cParametersEcg : cDeviceMethodParameters
darienf 20:6d2af70c92ab 52 {
darienf 20:6d2af70c92ab 53 public cParametersEcg(String className, String methodName) : base(className, methodName) { }
darienf 20:6d2af70c92ab 54 public int En_ecg;
darienf 20:6d2af70c92ab 55 public int Openp;
darienf 20:6d2af70c92ab 56 public int Openn;
darienf 20:6d2af70c92ab 57 public int Pol;
darienf 20:6d2af70c92ab 58 public int Calp_sel;
darienf 20:6d2af70c92ab 59 public int Caln_sel;
darienf 20:6d2af70c92ab 60 public int E_fit;
darienf 20:6d2af70c92ab 61 public int Rate;
darienf 20:6d2af70c92ab 62 public int Gain;
darienf 20:6d2af70c92ab 63 public int Dhpf;
darienf 20:6d2af70c92ab 64 public int Dlpf;
darienf 20:6d2af70c92ab 65
darienf 20:6d2af70c92ab 66 public override void AssignByIntArray(int[] intArray)
darienf 20:6d2af70c92ab 67 {
darienf 20:6d2af70c92ab 68 int i = 0;
darienf 20:6d2af70c92ab 69 En_ecg = intArray[i++];
darienf 20:6d2af70c92ab 70 Openp = intArray[i++];
darienf 20:6d2af70c92ab 71 Openn = intArray[i++];
darienf 20:6d2af70c92ab 72 Pol = intArray[i++];
darienf 20:6d2af70c92ab 73 Calp_sel = intArray[i++];
darienf 20:6d2af70c92ab 74 Caln_sel = intArray[i++];
darienf 20:6d2af70c92ab 75 E_fit = intArray[i++];
darienf 20:6d2af70c92ab 76 Rate = intArray[i++];
darienf 20:6d2af70c92ab 77 Gain = intArray[i++];
darienf 20:6d2af70c92ab 78 Dhpf = intArray[i++];
darienf 20:6d2af70c92ab 79 Dlpf = intArray[i++];
darienf 20:6d2af70c92ab 80 }
darienf 20:6d2af70c92ab 81 public override int[] ToIntArray()
darienf 20:6d2af70c92ab 82 {
darienf 20:6d2af70c92ab 83 int i = 0;
darienf 20:6d2af70c92ab 84 List<int> intArray = new List<int>();
darienf 20:6d2af70c92ab 85 intArray.Add(En_ecg);
darienf 20:6d2af70c92ab 86 intArray.Add(Openp);
darienf 20:6d2af70c92ab 87 intArray.Add(Openn);
darienf 20:6d2af70c92ab 88 intArray.Add(Pol);
darienf 20:6d2af70c92ab 89 intArray.Add(Calp_sel);
darienf 20:6d2af70c92ab 90 intArray.Add(Caln_sel);
darienf 20:6d2af70c92ab 91 intArray.Add(E_fit);
darienf 20:6d2af70c92ab 92 intArray.Add(Rate);
darienf 20:6d2af70c92ab 93 intArray.Add(Gain);
darienf 20:6d2af70c92ab 94 intArray.Add(Dhpf);
darienf 20:6d2af70c92ab 95 intArray.Add(Dlpf);
darienf 20:6d2af70c92ab 96 return intArray.ToArray();
darienf 20:6d2af70c92ab 97 }
darienf 20:6d2af70c92ab 98
darienf 20:6d2af70c92ab 99 public void AssignByValue(
darienf 20:6d2af70c92ab 100 int En_ecg,
darienf 20:6d2af70c92ab 101 int Openp,
darienf 20:6d2af70c92ab 102 int Openn,
darienf 20:6d2af70c92ab 103 int Pol,
darienf 20:6d2af70c92ab 104 int Calp_sel,
darienf 20:6d2af70c92ab 105 int Caln_sel,
darienf 20:6d2af70c92ab 106 int E_fit,
darienf 20:6d2af70c92ab 107 int Rate,
darienf 20:6d2af70c92ab 108 int Gain,
darienf 20:6d2af70c92ab 109 int Dhpf,
darienf 20:6d2af70c92ab 110 int Dlpf)
darienf 20:6d2af70c92ab 111 {
darienf 20:6d2af70c92ab 112 this.En_ecg = En_ecg;
darienf 20:6d2af70c92ab 113 this.Openp = Openp;
darienf 20:6d2af70c92ab 114 this.Openn = Openn;
darienf 20:6d2af70c92ab 115 this.Pol = Pol;
darienf 20:6d2af70c92ab 116 this.Calp_sel = Calp_sel;
darienf 20:6d2af70c92ab 117 this.Caln_sel = Caln_sel;
darienf 20:6d2af70c92ab 118 this.E_fit = E_fit;
darienf 20:6d2af70c92ab 119 this.Rate = Rate;
darienf 20:6d2af70c92ab 120 this.Gain = Gain;
darienf 20:6d2af70c92ab 121 this.Dhpf = Dhpf;
darienf 20:6d2af70c92ab 122 this.Dlpf = Dlpf;
darienf 20:6d2af70c92ab 123 }
darienf 20:6d2af70c92ab 124 }
darienf 20:6d2af70c92ab 125 // public cParametersEcg ParametersMAX30001Ecg = new cParametersEcg();
darienf 20:6d2af70c92ab 126
darienf 20:6d2af70c92ab 127 public class cParametersBioz : cDeviceMethodParameters
darienf 20:6d2af70c92ab 128 {
darienf 20:6d2af70c92ab 129 public cParametersBioz(String className, String methodName) : base(className, methodName) { }
darienf 20:6d2af70c92ab 130 public int En_bioz;
darienf 20:6d2af70c92ab 131 public int Openp;
darienf 20:6d2af70c92ab 132 public int Openn;
darienf 20:6d2af70c92ab 133 public int Calp_sel;
darienf 20:6d2af70c92ab 134 public int Caln_sel;
darienf 20:6d2af70c92ab 135 public int CG_mode;
darienf 20:6d2af70c92ab 136 public int B_fit;
darienf 20:6d2af70c92ab 137 public int Rate;
darienf 20:6d2af70c92ab 138 public int Ahpf;
darienf 20:6d2af70c92ab 139 public int Ext_rbias;
darienf 20:6d2af70c92ab 140 public int Gain;
darienf 20:6d2af70c92ab 141 public int Dhpf;
darienf 20:6d2af70c92ab 142 public int Dlpf;
darienf 20:6d2af70c92ab 143 public int Fcgen;
darienf 20:6d2af70c92ab 144 public int Cgmon;
darienf 20:6d2af70c92ab 145 public int Cgmag;
darienf 20:6d2af70c92ab 146 public int Phoff;
darienf 20:6d2af70c92ab 147 public override void AssignByIntArray(int[] intArray)
darienf 20:6d2af70c92ab 148 {
darienf 20:6d2af70c92ab 149 int i = 0;
darienf 20:6d2af70c92ab 150 En_bioz = intArray[i++];
darienf 20:6d2af70c92ab 151 Openp = intArray[i++];
darienf 20:6d2af70c92ab 152 Openn = intArray[i++];
darienf 20:6d2af70c92ab 153 Calp_sel = intArray[i++];
darienf 20:6d2af70c92ab 154 Caln_sel = intArray[i++];
darienf 20:6d2af70c92ab 155 CG_mode = intArray[i++];
darienf 20:6d2af70c92ab 156 B_fit = intArray[i++];
darienf 20:6d2af70c92ab 157 Rate = intArray[i++];
darienf 20:6d2af70c92ab 158 Ahpf = intArray[i++];
darienf 20:6d2af70c92ab 159 Ext_rbias = intArray[i++];
darienf 20:6d2af70c92ab 160 Gain = intArray[i++];
darienf 20:6d2af70c92ab 161 Dhpf = intArray[i++];
darienf 20:6d2af70c92ab 162 Dlpf = intArray[i++];
darienf 20:6d2af70c92ab 163 Fcgen = intArray[i++];
darienf 20:6d2af70c92ab 164 Cgmon = intArray[i++];
darienf 20:6d2af70c92ab 165 Cgmag = intArray[i++];
darienf 20:6d2af70c92ab 166 Phoff = intArray[i++];
darienf 20:6d2af70c92ab 167 }
darienf 20:6d2af70c92ab 168
darienf 20:6d2af70c92ab 169 public override int[] ToIntArray()
darienf 20:6d2af70c92ab 170 {
darienf 20:6d2af70c92ab 171 int i = 0;
darienf 20:6d2af70c92ab 172 List<int> intArray = new List<int>();
darienf 20:6d2af70c92ab 173 intArray.Add(En_bioz);
darienf 20:6d2af70c92ab 174 intArray.Add(Openp);
darienf 20:6d2af70c92ab 175 intArray.Add(Openn);
darienf 20:6d2af70c92ab 176 intArray.Add(Calp_sel);
darienf 20:6d2af70c92ab 177 intArray.Add(Caln_sel);
darienf 20:6d2af70c92ab 178 intArray.Add(CG_mode);
darienf 20:6d2af70c92ab 179 intArray.Add(B_fit);
darienf 20:6d2af70c92ab 180 intArray.Add(Rate);
darienf 20:6d2af70c92ab 181 intArray.Add(Ahpf);
darienf 20:6d2af70c92ab 182 intArray.Add(Ext_rbias);
darienf 20:6d2af70c92ab 183 intArray.Add(Gain);
darienf 20:6d2af70c92ab 184 intArray.Add(Dhpf);
darienf 20:6d2af70c92ab 185 intArray.Add(Dlpf);
darienf 20:6d2af70c92ab 186 intArray.Add(Fcgen);
darienf 20:6d2af70c92ab 187 intArray.Add(Cgmon);
darienf 20:6d2af70c92ab 188 intArray.Add(Cgmag);
darienf 20:6d2af70c92ab 189 intArray.Add(Phoff);
darienf 20:6d2af70c92ab 190 return intArray.ToArray();
darienf 20:6d2af70c92ab 191 }
darienf 20:6d2af70c92ab 192
darienf 20:6d2af70c92ab 193 public void AssignByValue(
darienf 20:6d2af70c92ab 194 int En_bioz,
darienf 20:6d2af70c92ab 195 int Openp,
darienf 20:6d2af70c92ab 196 int Openn,
darienf 20:6d2af70c92ab 197 int Calp_sel,
darienf 20:6d2af70c92ab 198 int Caln_sel,
darienf 20:6d2af70c92ab 199 int CG_mode,
darienf 20:6d2af70c92ab 200 int B_fit,
darienf 20:6d2af70c92ab 201 int Rate,
darienf 20:6d2af70c92ab 202 int Ahpf,
darienf 20:6d2af70c92ab 203 int Ext_rbias,
darienf 20:6d2af70c92ab 204 int Gain,
darienf 20:6d2af70c92ab 205 int Dhpf,
darienf 20:6d2af70c92ab 206 int Dlpf,
darienf 20:6d2af70c92ab 207 int Fcgen,
darienf 20:6d2af70c92ab 208 int Cgmon,
darienf 20:6d2af70c92ab 209 int Cgmag,
darienf 20:6d2af70c92ab 210 int Phoff)
darienf 20:6d2af70c92ab 211 {
darienf 20:6d2af70c92ab 212 this.En_bioz = En_bioz;
darienf 20:6d2af70c92ab 213 this.Openp = Openp;
darienf 20:6d2af70c92ab 214 this.Openn = Openn;
darienf 20:6d2af70c92ab 215 this.Calp_sel = Calp_sel;
darienf 20:6d2af70c92ab 216 this.Caln_sel = Caln_sel;
darienf 20:6d2af70c92ab 217 this.CG_mode = CG_mode;
darienf 20:6d2af70c92ab 218 this.B_fit = B_fit;
darienf 20:6d2af70c92ab 219 this.Rate = Rate;
darienf 20:6d2af70c92ab 220 this.Ahpf = Ahpf;
darienf 20:6d2af70c92ab 221 this.Ext_rbias = Ext_rbias;
darienf 20:6d2af70c92ab 222 this.Gain = Gain;
darienf 20:6d2af70c92ab 223 this.Dhpf = Dhpf;
darienf 20:6d2af70c92ab 224 this.Dlpf = Dlpf;
darienf 20:6d2af70c92ab 225 this.Fcgen = Fcgen;
darienf 20:6d2af70c92ab 226 this.Cgmon = Cgmon;
darienf 20:6d2af70c92ab 227 this.Cgmag = Cgmag;
darienf 20:6d2af70c92ab 228 this.Phoff = Phoff;
darienf 20:6d2af70c92ab 229 }
darienf 20:6d2af70c92ab 230 }
darienf 20:6d2af70c92ab 231 //public cParametersBioz ParametersMAX30001Bioz = new cParametersBioz();
darienf 20:6d2af70c92ab 232
darienf 20:6d2af70c92ab 233 public class cParametersRtoR : cDeviceMethodParameters
darienf 20:6d2af70c92ab 234 {
darienf 20:6d2af70c92ab 235 public cParametersRtoR(String className, String methodName) : base(className, methodName) { }
darienf 20:6d2af70c92ab 236 public int En_rtor;
darienf 20:6d2af70c92ab 237 public int Wndw;
darienf 20:6d2af70c92ab 238 public int Gain;
darienf 20:6d2af70c92ab 239 public int Pavg;
darienf 20:6d2af70c92ab 240 public int Ptsf;
darienf 20:6d2af70c92ab 241 public int Hoff;
darienf 20:6d2af70c92ab 242 public int Ravg;
darienf 20:6d2af70c92ab 243 public int Rhsf;
darienf 20:6d2af70c92ab 244 public int Clr_rrint;
darienf 20:6d2af70c92ab 245 public override void AssignByIntArray(int[] intArray)
darienf 20:6d2af70c92ab 246 {
darienf 20:6d2af70c92ab 247 int i = 0;
darienf 20:6d2af70c92ab 248 En_rtor = intArray[i++];
darienf 20:6d2af70c92ab 249 Wndw = intArray[i++];
darienf 20:6d2af70c92ab 250 Gain = intArray[i++];
darienf 20:6d2af70c92ab 251 Pavg = intArray[i++];
darienf 20:6d2af70c92ab 252 Ptsf = intArray[i++];
darienf 20:6d2af70c92ab 253 Hoff = intArray[i++];
darienf 20:6d2af70c92ab 254 Ravg = intArray[i++];
darienf 20:6d2af70c92ab 255 Rhsf = intArray[i++];
darienf 20:6d2af70c92ab 256 Clr_rrint = intArray[i++];
darienf 20:6d2af70c92ab 257 }
darienf 20:6d2af70c92ab 258
darienf 20:6d2af70c92ab 259 public override int[] ToIntArray()
darienf 20:6d2af70c92ab 260 {
darienf 20:6d2af70c92ab 261 int i = 0;
darienf 20:6d2af70c92ab 262 List<int> intArray = new List<int>();
darienf 20:6d2af70c92ab 263 intArray.Add(En_rtor);
darienf 20:6d2af70c92ab 264 intArray.Add(Wndw);
darienf 20:6d2af70c92ab 265 intArray.Add(Gain);
darienf 20:6d2af70c92ab 266 intArray.Add(Pavg);
darienf 20:6d2af70c92ab 267 intArray.Add(Ptsf);
darienf 20:6d2af70c92ab 268 intArray.Add(Hoff);
darienf 20:6d2af70c92ab 269 intArray.Add(Ravg);
darienf 20:6d2af70c92ab 270 intArray.Add(Rhsf);
darienf 20:6d2af70c92ab 271 intArray.Add(Clr_rrint);
darienf 20:6d2af70c92ab 272 return intArray.ToArray();
darienf 20:6d2af70c92ab 273 }
darienf 20:6d2af70c92ab 274
darienf 20:6d2af70c92ab 275 public void AssignByValue(
darienf 20:6d2af70c92ab 276 int En_rtor,
darienf 20:6d2af70c92ab 277 int Wndw,
darienf 20:6d2af70c92ab 278 int Gain,
darienf 20:6d2af70c92ab 279 int Pavg,
darienf 20:6d2af70c92ab 280 int Ptsf,
darienf 20:6d2af70c92ab 281 int Hoff,
darienf 20:6d2af70c92ab 282 int Ravg,
darienf 20:6d2af70c92ab 283 int Rhsf,
darienf 20:6d2af70c92ab 284 int Clr_rrint)
darienf 20:6d2af70c92ab 285 {
darienf 20:6d2af70c92ab 286 this.En_rtor = En_rtor;
darienf 20:6d2af70c92ab 287 this.Wndw = Wndw;
darienf 20:6d2af70c92ab 288 this.Gain = Gain;
darienf 20:6d2af70c92ab 289 this.Pavg = Pavg;
darienf 20:6d2af70c92ab 290 this.Ptsf = Ptsf;
darienf 20:6d2af70c92ab 291 this.Hoff = Hoff;
darienf 20:6d2af70c92ab 292 this.Ravg = Ravg;
darienf 20:6d2af70c92ab 293 this.Rhsf = Rhsf;
darienf 20:6d2af70c92ab 294 this.Clr_rrint = Clr_rrint;
darienf 20:6d2af70c92ab 295 }
darienf 20:6d2af70c92ab 296 }
darienf 20:6d2af70c92ab 297 //public cParametersRtoR ParametersMAX30001RtoR = new cParametersRtoR();
darienf 20:6d2af70c92ab 298
darienf 20:6d2af70c92ab 299 public class cParametersPace : cDeviceMethodParameters
darienf 20:6d2af70c92ab 300 {
darienf 20:6d2af70c92ab 301 public cParametersPace(String className, String methodName) : base(className, methodName) { }
darienf 20:6d2af70c92ab 302 public int En_pace;
darienf 20:6d2af70c92ab 303 public int Clr_pedge;
darienf 20:6d2af70c92ab 304 public int Pol;
darienf 20:6d2af70c92ab 305 public int Gn_diff_off;
darienf 20:6d2af70c92ab 306 public int Gain;
darienf 20:6d2af70c92ab 307 public int Aout_lbw;
darienf 20:6d2af70c92ab 308 public int Aout;
darienf 20:6d2af70c92ab 309 public int Dacp;
darienf 20:6d2af70c92ab 310 public int Dacn;
darienf 20:6d2af70c92ab 311 public override void AssignByIntArray(int[] intArray)
darienf 20:6d2af70c92ab 312 {
darienf 20:6d2af70c92ab 313 int i = 0;
darienf 20:6d2af70c92ab 314 En_pace = intArray[i++];
darienf 20:6d2af70c92ab 315 Clr_pedge = intArray[i++];
darienf 20:6d2af70c92ab 316 Pol = intArray[i++];
darienf 20:6d2af70c92ab 317 Gn_diff_off = intArray[i++];
darienf 20:6d2af70c92ab 318 Gain = intArray[i++];
darienf 20:6d2af70c92ab 319 Aout_lbw = intArray[i++];
darienf 20:6d2af70c92ab 320 Aout = intArray[i++];
darienf 20:6d2af70c92ab 321 Dacp = intArray[i++];
darienf 20:6d2af70c92ab 322 Dacn = intArray[i++];
darienf 20:6d2af70c92ab 323 }
darienf 20:6d2af70c92ab 324
darienf 20:6d2af70c92ab 325 public override int[] ToIntArray()
darienf 20:6d2af70c92ab 326 {
darienf 20:6d2af70c92ab 327 int i = 0;
darienf 20:6d2af70c92ab 328 List<int> intArray = new List<int>();
darienf 20:6d2af70c92ab 329 intArray.Add(En_pace);
darienf 20:6d2af70c92ab 330 intArray.Add(Clr_pedge);
darienf 20:6d2af70c92ab 331 intArray.Add(Pol);
darienf 20:6d2af70c92ab 332 intArray.Add(Gn_diff_off);
darienf 20:6d2af70c92ab 333 intArray.Add(Gain);
darienf 20:6d2af70c92ab 334 intArray.Add(Aout_lbw);
darienf 20:6d2af70c92ab 335 intArray.Add(Aout);
darienf 20:6d2af70c92ab 336 intArray.Add(Dacp);
darienf 20:6d2af70c92ab 337 intArray.Add(Dacn);
darienf 20:6d2af70c92ab 338 return intArray.ToArray();
darienf 20:6d2af70c92ab 339 }
darienf 20:6d2af70c92ab 340
darienf 20:6d2af70c92ab 341 public void AssignByValue(
darienf 20:6d2af70c92ab 342 int En_pace,
darienf 20:6d2af70c92ab 343 int Clr_pedge,
darienf 20:6d2af70c92ab 344 int Pol,
darienf 20:6d2af70c92ab 345 int Gn_diff_off,
darienf 20:6d2af70c92ab 346 int Gain,
darienf 20:6d2af70c92ab 347 int Aout_lbw,
darienf 20:6d2af70c92ab 348 int Aout,
darienf 20:6d2af70c92ab 349 int Dacp,
darienf 20:6d2af70c92ab 350 int Dacn)
darienf 20:6d2af70c92ab 351 {
darienf 20:6d2af70c92ab 352 this.En_pace = En_pace;
darienf 20:6d2af70c92ab 353 this.Clr_pedge = Clr_pedge;
darienf 20:6d2af70c92ab 354 this.Pol = Pol;
darienf 20:6d2af70c92ab 355 this.Gn_diff_off = Gn_diff_off;
darienf 20:6d2af70c92ab 356 this.Gain = Gain;
darienf 20:6d2af70c92ab 357 this.Aout = Aout;
darienf 20:6d2af70c92ab 358 this.Dacp = Dacp;
darienf 20:6d2af70c92ab 359 this.Dacn = Dacn;
darienf 20:6d2af70c92ab 360 }
darienf 20:6d2af70c92ab 361 }
darienf 20:6d2af70c92ab 362
darienf 20:6d2af70c92ab 363 public class cParametersCal : cDeviceMethodParameters
darienf 20:6d2af70c92ab 364 {
darienf 20:6d2af70c92ab 365 public cParametersCal(String className, String methodName) : base(className, methodName) { }
darienf 20:6d2af70c92ab 366 public int parameter1;
darienf 20:6d2af70c92ab 367 public int parameter2;
darienf 20:6d2af70c92ab 368 public int parameter3;
darienf 20:6d2af70c92ab 369 public int parameter4;
darienf 20:6d2af70c92ab 370 public int parameter5;
darienf 20:6d2af70c92ab 371 public int parameter6;
darienf 20:6d2af70c92ab 372 public override void AssignByIntArray(int[] intArray)
darienf 20:6d2af70c92ab 373 {
darienf 20:6d2af70c92ab 374 int i = 0;
darienf 20:6d2af70c92ab 375 parameter1 = intArray[i++];
darienf 20:6d2af70c92ab 376 parameter2 = intArray[i++];
darienf 20:6d2af70c92ab 377 parameter3 = intArray[i++];
darienf 20:6d2af70c92ab 378 parameter4 = intArray[i++];
darienf 20:6d2af70c92ab 379 parameter5 = intArray[i++];
darienf 20:6d2af70c92ab 380 parameter6 = intArray[i++];
darienf 20:6d2af70c92ab 381 }
darienf 20:6d2af70c92ab 382
darienf 20:6d2af70c92ab 383 public override int[] ToIntArray()
darienf 20:6d2af70c92ab 384 {
darienf 20:6d2af70c92ab 385 int i = 0;
darienf 20:6d2af70c92ab 386 List<int> intArray = new List<int>();
darienf 20:6d2af70c92ab 387 intArray.Add(parameter1);
darienf 20:6d2af70c92ab 388 intArray.Add(parameter2);
darienf 20:6d2af70c92ab 389 intArray.Add(parameter3);
darienf 20:6d2af70c92ab 390 intArray.Add(parameter4);
darienf 20:6d2af70c92ab 391 intArray.Add(parameter5);
darienf 20:6d2af70c92ab 392 intArray.Add(parameter6);
darienf 20:6d2af70c92ab 393 return intArray.ToArray();
darienf 20:6d2af70c92ab 394 }
darienf 20:6d2af70c92ab 395
darienf 20:6d2af70c92ab 396 public void AssignByValue(
darienf 20:6d2af70c92ab 397 int parameter1,
darienf 20:6d2af70c92ab 398 int parameter2,
darienf 20:6d2af70c92ab 399 int parameter3,
darienf 20:6d2af70c92ab 400 int parameter4,
darienf 20:6d2af70c92ab 401 int parameter5,
darienf 20:6d2af70c92ab 402 int parameter6
darienf 20:6d2af70c92ab 403 )
darienf 20:6d2af70c92ab 404
darienf 20:6d2af70c92ab 405 {
darienf 20:6d2af70c92ab 406 this.parameter1 = parameter1;
darienf 20:6d2af70c92ab 407 this.parameter2 = parameter2;
darienf 20:6d2af70c92ab 408 this.parameter3 = parameter3;
darienf 20:6d2af70c92ab 409 this.parameter4 = parameter4;
darienf 20:6d2af70c92ab 410 this.parameter5 = parameter5;
darienf 20:6d2af70c92ab 411 this.parameter6 = parameter6;
darienf 20:6d2af70c92ab 412 }
darienf 20:6d2af70c92ab 413 }
darienf 20:6d2af70c92ab 414
darienf 20:6d2af70c92ab 415 // public cParametersPace ParametersMAX30001Pace = new cParametersPace();
darienf 20:6d2af70c92ab 416 public class cParametersTemp : cDeviceMethodParameters
darienf 20:6d2af70c92ab 417 {
darienf 20:6d2af70c92ab 418 public cParametersTemp(String className, String methodName, int deviceNumber) : base(className, methodName) { this.deviceNumber = deviceNumber; }
darienf 20:6d2af70c92ab 419 public int sampleTime; // seconds
darienf 20:6d2af70c92ab 420 private int deviceNumber;
darienf 20:6d2af70c92ab 421 public override void AssignByIntArray(int[] intArray)
darienf 20:6d2af70c92ab 422 {
darienf 20:6d2af70c92ab 423 int i = 0;
darienf 20:6d2af70c92ab 424 sampleTime = intArray[i++];
darienf 20:6d2af70c92ab 425 }
darienf 20:6d2af70c92ab 426
darienf 20:6d2af70c92ab 427 public override int[] ToIntArray()
darienf 20:6d2af70c92ab 428 {
darienf 20:6d2af70c92ab 429 int i = 0;
darienf 20:6d2af70c92ab 430 List<int> intArray = new List<int>();
darienf 20:6d2af70c92ab 431 intArray.Add(sampleTime);
darienf 20:6d2af70c92ab 432 return intArray.ToArray();
darienf 20:6d2af70c92ab 433 }
darienf 20:6d2af70c92ab 434 }
darienf 20:6d2af70c92ab 435 // public cParametersTemp1 ParametersMAX31725_1 = new cParametersTemp1();
darienf 20:6d2af70c92ab 436
darienf 20:6d2af70c92ab 437 // public cParametersTemp2 ParametersMAX31725_2 = new cParametersTemp2();
darienf 20:6d2af70c92ab 438
darienf 20:6d2af70c92ab 439 public class cParametersPressure : cDeviceMethodParameters
darienf 20:6d2af70c92ab 440 {
darienf 20:6d2af70c92ab 441 public cParametersPressure(String className, String methodName) : base(className, methodName) { }
darienf 20:6d2af70c92ab 442 public int sampleTime; // seconds
darienf 20:6d2af70c92ab 443 public override void AssignByIntArray(int[] intArray)
darienf 20:6d2af70c92ab 444 {
darienf 20:6d2af70c92ab 445 int i = 0;
darienf 20:6d2af70c92ab 446 sampleTime = intArray[i++];
darienf 20:6d2af70c92ab 447 }
darienf 20:6d2af70c92ab 448
darienf 20:6d2af70c92ab 449 public override int[] ToIntArray()
darienf 20:6d2af70c92ab 450 {
darienf 20:6d2af70c92ab 451 int i = 0;
darienf 20:6d2af70c92ab 452 List<int> intArray = new List<int>();
darienf 20:6d2af70c92ab 453 intArray.Add(sampleTime);
darienf 20:6d2af70c92ab 454 return intArray.ToArray();
darienf 20:6d2af70c92ab 455 }
darienf 20:6d2af70c92ab 456 }
darienf 20:6d2af70c92ab 457 // public cParametersPressure ParametersBMP280 = new cParametersPressure();
darienf 20:6d2af70c92ab 458
darienf 20:6d2af70c92ab 459 public class cParametersAccel : cDeviceMethodParameters
darienf 20:6d2af70c92ab 460 {
darienf 20:6d2af70c92ab 461 public cParametersAccel(String className, String methodName) : base(className, methodName) { fifoDepth = 1; }
darienf 20:6d2af70c92ab 462 public int sampleRate; // Hz
darienf 20:6d2af70c92ab 463 public int fifoDepth;
darienf 20:6d2af70c92ab 464 public override void AssignByIntArray(int[] intArray)
darienf 20:6d2af70c92ab 465 {
darienf 20:6d2af70c92ab 466 int i = 0;
darienf 20:6d2af70c92ab 467 sampleRate = intArray[i++];
darienf 20:6d2af70c92ab 468 fifoDepth = intArray[i++];
darienf 20:6d2af70c92ab 469 }
darienf 20:6d2af70c92ab 470
darienf 20:6d2af70c92ab 471 public override int[] ToIntArray()
darienf 20:6d2af70c92ab 472 {
darienf 20:6d2af70c92ab 473 int i = 0;
darienf 20:6d2af70c92ab 474 List<int> intArray = new List<int>();
darienf 20:6d2af70c92ab 475 intArray.Add(sampleRate);
darienf 20:6d2af70c92ab 476 intArray.Add(fifoDepth);
darienf 20:6d2af70c92ab 477 return intArray.ToArray();
darienf 20:6d2af70c92ab 478 }
darienf 20:6d2af70c92ab 479 }
darienf 20:6d2af70c92ab 480 // public cParametersAccel ParametersLIS2DH = new cParametersAccel();
darienf 20:6d2af70c92ab 481
darienf 20:6d2af70c92ab 482 public class cParameterOpticalSpO2 : cDeviceMethodParameters
darienf 20:6d2af70c92ab 483 {
darienf 20:6d2af70c92ab 484 public cParameterOpticalSpO2(String className, String methodName) : base(className, methodName) { }
darienf 20:6d2af70c92ab 485 public int fifo_waterlevel_mark;
darienf 20:6d2af70c92ab 486 public int sample_avg;
darienf 20:6d2af70c92ab 487 public int sample_rate;
darienf 20:6d2af70c92ab 488 public int pulse_width;
darienf 20:6d2af70c92ab 489 public int red_led_current;
darienf 20:6d2af70c92ab 490 public int ir_led_current;
darienf 20:6d2af70c92ab 491 public override void AssignByIntArray(int[] intArray)
darienf 20:6d2af70c92ab 492 {
darienf 20:6d2af70c92ab 493 int i = 0;
darienf 20:6d2af70c92ab 494 fifo_waterlevel_mark = intArray[i++];
darienf 20:6d2af70c92ab 495 sample_avg = intArray[i++];
darienf 20:6d2af70c92ab 496 sample_rate = intArray[i++];
darienf 20:6d2af70c92ab 497 pulse_width = intArray[i++];
darienf 20:6d2af70c92ab 498 red_led_current = intArray[i++];
darienf 20:6d2af70c92ab 499 ir_led_current = intArray[i++];
darienf 20:6d2af70c92ab 500 }
darienf 20:6d2af70c92ab 501
darienf 20:6d2af70c92ab 502 public override int[] ToIntArray()
darienf 20:6d2af70c92ab 503 {
darienf 20:6d2af70c92ab 504 int i = 0;
darienf 20:6d2af70c92ab 505 List<int> intArray = new List<int>();
darienf 20:6d2af70c92ab 506 intArray.Add(fifo_waterlevel_mark);
darienf 20:6d2af70c92ab 507 intArray.Add(sample_avg);
darienf 20:6d2af70c92ab 508 intArray.Add(sample_rate);
darienf 20:6d2af70c92ab 509 intArray.Add(pulse_width);
darienf 20:6d2af70c92ab 510 intArray.Add(red_led_current);
darienf 20:6d2af70c92ab 511 intArray.Add(ir_led_current);
darienf 20:6d2af70c92ab 512 return intArray.ToArray();
darienf 20:6d2af70c92ab 513 }
darienf 20:6d2af70c92ab 514 }
darienf 20:6d2af70c92ab 515 // public cParameterOpticalSpO2 ParameterMAX30101SpO2 = new cParameterOpticalSpO2();
darienf 20:6d2af70c92ab 516
darienf 20:6d2af70c92ab 517 public class cParameterOpticalHR : cDeviceMethodParameters
darienf 20:6d2af70c92ab 518 {
darienf 20:6d2af70c92ab 519 public cParameterOpticalHR(String className, String methodName) : base(className, methodName) { }
darienf 20:6d2af70c92ab 520 public int fifo_waterlevel_mark;
darienf 20:6d2af70c92ab 521 public int sample_avg;
darienf 20:6d2af70c92ab 522 public int sample_rate;
darienf 20:6d2af70c92ab 523 public int pulse_width;
darienf 20:6d2af70c92ab 524 public int red_led_current;
darienf 20:6d2af70c92ab 525 public override void AssignByIntArray(int[] intArray)
darienf 20:6d2af70c92ab 526 {
darienf 20:6d2af70c92ab 527 int i = 0;
darienf 20:6d2af70c92ab 528 fifo_waterlevel_mark = intArray[i++];
darienf 20:6d2af70c92ab 529 sample_avg = intArray[i++];
darienf 20:6d2af70c92ab 530 sample_rate = intArray[i++];
darienf 20:6d2af70c92ab 531 pulse_width = intArray[i++];
darienf 20:6d2af70c92ab 532 red_led_current = intArray[i++];
darienf 20:6d2af70c92ab 533 }
darienf 20:6d2af70c92ab 534
darienf 20:6d2af70c92ab 535 public override int[] ToIntArray()
darienf 20:6d2af70c92ab 536 {
darienf 20:6d2af70c92ab 537 int i = 0;
darienf 20:6d2af70c92ab 538 List<int> intArray = new List<int>();
darienf 20:6d2af70c92ab 539 intArray.Add(fifo_waterlevel_mark);
darienf 20:6d2af70c92ab 540 intArray.Add(sample_avg);
darienf 20:6d2af70c92ab 541 intArray.Add(sample_rate);
darienf 20:6d2af70c92ab 542 intArray.Add(pulse_width);
darienf 20:6d2af70c92ab 543 intArray.Add(red_led_current);
darienf 20:6d2af70c92ab 544 return intArray.ToArray();
darienf 20:6d2af70c92ab 545 }
darienf 20:6d2af70c92ab 546 }
darienf 20:6d2af70c92ab 547 // public cParameterOpticalHR ParameterMAX30101HR = new cParameterOpticalHR();
darienf 20:6d2af70c92ab 548
darienf 20:6d2af70c92ab 549 public class cParameterOpticalMulti : cDeviceMethodParameters
darienf 20:6d2af70c92ab 550 {
darienf 20:6d2af70c92ab 551 public cParameterOpticalMulti(String className, String methodName) : base(className, methodName) { }
darienf 20:6d2af70c92ab 552 public int fifo_waterlevel_mark;
darienf 20:6d2af70c92ab 553 public int sample_avg;
darienf 20:6d2af70c92ab 554 public int sample_rate;
darienf 20:6d2af70c92ab 555 public int pulse_width;
darienf 20:6d2af70c92ab 556 public int red_led_current;
darienf 20:6d2af70c92ab 557 public int ir_led_current;
darienf 20:6d2af70c92ab 558 public int green_led_current;
darienf 20:6d2af70c92ab 559 public int slot_1;
darienf 20:6d2af70c92ab 560 public int slot_2;
darienf 20:6d2af70c92ab 561 public int slot_3;
darienf 20:6d2af70c92ab 562 public int slot_4;
darienf 20:6d2af70c92ab 563 public override void AssignByIntArray(int[] intArray)
darienf 20:6d2af70c92ab 564 {
darienf 20:6d2af70c92ab 565 int i = 0;
darienf 20:6d2af70c92ab 566 fifo_waterlevel_mark = intArray[i++];
darienf 20:6d2af70c92ab 567 sample_avg = intArray[i++];
darienf 20:6d2af70c92ab 568 sample_rate = intArray[i++];
darienf 20:6d2af70c92ab 569 pulse_width = intArray[i++];
darienf 20:6d2af70c92ab 570 red_led_current = intArray[i++];
darienf 20:6d2af70c92ab 571 ir_led_current = intArray[i++];
darienf 20:6d2af70c92ab 572 green_led_current = intArray[i++];
darienf 20:6d2af70c92ab 573 slot_1 = intArray[i++];
darienf 20:6d2af70c92ab 574 slot_2 = intArray[i++];
darienf 20:6d2af70c92ab 575 slot_3 = intArray[i++];
darienf 20:6d2af70c92ab 576 slot_4 = intArray[i++];
darienf 20:6d2af70c92ab 577 }
darienf 20:6d2af70c92ab 578
darienf 20:6d2af70c92ab 579 public override int[] ToIntArray()
darienf 20:6d2af70c92ab 580 {
darienf 20:6d2af70c92ab 581 int i = 0;
darienf 20:6d2af70c92ab 582 List<int> intArray = new List<int>();
darienf 20:6d2af70c92ab 583 intArray.Add(fifo_waterlevel_mark);
darienf 20:6d2af70c92ab 584 intArray.Add(sample_avg);
darienf 20:6d2af70c92ab 585 intArray.Add(sample_rate);
darienf 20:6d2af70c92ab 586 intArray.Add(pulse_width);
darienf 20:6d2af70c92ab 587 intArray.Add(red_led_current);
darienf 20:6d2af70c92ab 588 intArray.Add(ir_led_current);
darienf 20:6d2af70c92ab 589 intArray.Add(green_led_current);
darienf 20:6d2af70c92ab 590 intArray.Add(slot_1);
darienf 20:6d2af70c92ab 591 intArray.Add(slot_2);
darienf 20:6d2af70c92ab 592 intArray.Add(slot_3);
darienf 20:6d2af70c92ab 593 intArray.Add(slot_4);
darienf 20:6d2af70c92ab 594 return intArray.ToArray();
darienf 20:6d2af70c92ab 595 }
darienf 20:6d2af70c92ab 596 }
darienf 20:6d2af70c92ab 597
darienf 20:6d2af70c92ab 598 public class cParametersRbiasFmstr : cDeviceMethodParameters
darienf 20:6d2af70c92ab 599 {
darienf 20:6d2af70c92ab 600 public cParametersRbiasFmstr(String className, String methodName) : base(className, methodName) { }
darienf 20:6d2af70c92ab 601
darienf 20:6d2af70c92ab 602 public int en_rbias;
darienf 20:6d2af70c92ab 603 public int rbias;
darienf 20:6d2af70c92ab 604 public int rbiasp;
darienf 20:6d2af70c92ab 605 public int rbiasn;
darienf 20:6d2af70c92ab 606 public int fmstr;
darienf 20:6d2af70c92ab 607
darienf 20:6d2af70c92ab 608 public override void AssignByIntArray(int[] intArray)
darienf 20:6d2af70c92ab 609 {
darienf 20:6d2af70c92ab 610 int i = 0;
darienf 20:6d2af70c92ab 611 en_rbias = intArray[i++];
darienf 20:6d2af70c92ab 612 rbias = intArray[i++];
darienf 20:6d2af70c92ab 613 rbiasp = intArray[i++];
darienf 20:6d2af70c92ab 614 rbiasn = intArray[i++];
darienf 20:6d2af70c92ab 615 fmstr = intArray[i++];
darienf 20:6d2af70c92ab 616 }
darienf 20:6d2af70c92ab 617
darienf 20:6d2af70c92ab 618 public override int[] ToIntArray()
darienf 20:6d2af70c92ab 619 {
darienf 20:6d2af70c92ab 620 int i = 0;
darienf 20:6d2af70c92ab 621
darienf 20:6d2af70c92ab 622 List<int> intArray = new List<int>();
darienf 20:6d2af70c92ab 623 intArray.Add(en_rbias);
darienf 20:6d2af70c92ab 624 intArray.Add(rbias);
darienf 20:6d2af70c92ab 625 intArray.Add(rbiasp);
darienf 20:6d2af70c92ab 626 intArray.Add(rbiasn);
darienf 20:6d2af70c92ab 627 intArray.Add(fmstr);
darienf 20:6d2af70c92ab 628
darienf 20:6d2af70c92ab 629 return intArray.ToArray();
darienf 20:6d2af70c92ab 630 }
darienf 20:6d2af70c92ab 631
darienf 20:6d2af70c92ab 632 }
darienf 20:6d2af70c92ab 633
darienf 20:6d2af70c92ab 634 //PreCommand
darienf 20:6d2af70c92ab 635 public class cRawRPCCommand : cDeviceMethodParameters
darienf 20:6d2af70c92ab 636 {
darienf 20:6d2af70c92ab 637 public String cmdString;
darienf 20:6d2af70c92ab 638 public cRawRPCCommand(String className, String methodName) : base(className, methodName) { }
darienf 20:6d2af70c92ab 639 public void Define(String str)
darienf 20:6d2af70c92ab 640 {
darienf 20:6d2af70c92ab 641 String inStr = str.Trim();
darienf 20:6d2af70c92ab 642 if (inStr.CompareTo("null") == 0) str = "";
darienf 20:6d2af70c92ab 643 cmdString = str;
darienf 20:6d2af70c92ab 644 }
darienf 20:6d2af70c92ab 645 public override void AssignByIntArray(int[] intArray)
darienf 20:6d2af70c92ab 646 {
darienf 20:6d2af70c92ab 647 throw new NotImplementedException();
darienf 20:6d2af70c92ab 648 }
darienf 20:6d2af70c92ab 649
darienf 20:6d2af70c92ab 650 public override int[] ToIntArray()
darienf 20:6d2af70c92ab 651 {
darienf 20:6d2af70c92ab 652 throw new NotImplementedException();
darienf 20:6d2af70c92ab 653 }
darienf 20:6d2af70c92ab 654 public override String GenerateRpcCommandString()
darienf 20:6d2af70c92ab 655 {
darienf 20:6d2af70c92ab 656 String str = cmdString;
darienf 20:6d2af70c92ab 657 if (String.IsNullOrWhiteSpace(cmdString)) str = "null";
darienf 20:6d2af70c92ab 658 String cmd = String.Format("\"{0}\"", str);
darienf 20:6d2af70c92ab 659 //Console.WriteLine("cmd string = '" + cmd + "'");
darienf 20:6d2af70c92ab 660 //Console.WriteLine("cmd string length = " + cmd.Length.ToString());
darienf 20:6d2af70c92ab 661 return cmd;
darienf 20:6d2af70c92ab 662 }
darienf 20:6d2af70c92ab 663 }
darienf 20:6d2af70c92ab 664 public cParametersEcg MAX30001_Ecg = new cParametersEcg("MAX30001", "ECG_InitStart");
darienf 20:6d2af70c92ab 665 public cParametersBioz MAX30001_Bioz = new cParametersBioz("MAX30001", "BIOZ_InitStart");
darienf 20:6d2af70c92ab 666 public cParametersRtoR MAX30001_RtoR = new cParametersRtoR("MAX30001", "RtoR_InitStart");
darienf 20:6d2af70c92ab 667 public cParametersPace MAX30001_Pace = new cParametersPace("MAX30001", "PACE_InitStart");
darienf 20:6d2af70c92ab 668 public cParametersCal MAX30001_Cal = new cParametersCal("MAX30001", "CAL_InitStart");
darienf 20:6d2af70c92ab 669 public cRawRPCCommand MAX30001_Rbias = new cRawRPCCommand("", "");
darienf 20:6d2af70c92ab 670 public cParametersRbiasFmstr MAX30001_Rbias_Fmstr = new cParametersRbiasFmstr("MAX30001", "Rbias_FMSTR_Init");
darienf 20:6d2af70c92ab 671 public cParametersTemp MAX31725_1 = new cParametersTemp("MAX30205_1", "InitStart", 1);
darienf 20:6d2af70c92ab 672 public cParametersTemp MAX31725_2 = new cParametersTemp("MAX30205_2", "InitStart", 2);
darienf 20:6d2af70c92ab 673 public cParametersPressure BMP280 = new cParametersPressure("BMP280", "InitStart");
darienf 20:6d2af70c92ab 674 public cParametersAccel LIS2DH = new cParametersAccel("LIS2DH", "InitStart");
darienf 20:6d2af70c92ab 675 public cParameterOpticalSpO2 MAX30101_SpO2 = new cParameterOpticalSpO2("MAX30101", "SpO2mode_InitStart");
darienf 20:6d2af70c92ab 676 public cParameterOpticalHR MAX30101_HR = new cParameterOpticalHR("MAX30101", "HRmode_InitStart");
darienf 20:6d2af70c92ab 677 public cParameterOpticalMulti MAX30101_Multi = new cParameterOpticalMulti("MAX30101", "Multimode_InitStart");
darienf 20:6d2af70c92ab 678 public cRawRPCCommand PreCommand = new cRawRPCCommand("", "");
darienf 20:6d2af70c92ab 679 public cRawRPCCommand PostCommand = new cRawRPCCommand("", "");
darienf 20:6d2af70c92ab 680
darienf 20:6d2af70c92ab 681 const string CLASSNAME = "Logging";
darienf 20:6d2af70c92ab 682 public DataLogging(RPCClient client)
darienf 20:6d2af70c92ab 683 : base(client)
darienf 20:6d2af70c92ab 684 {
darienf 20:6d2af70c92ab 685 InitRpcCommandList();
darienf 20:6d2af70c92ab 686 }
darienf 20:6d2af70c92ab 687 /*
darienf 20:6d2af70c92ab 688 public void StartLoggingUsb()
darienf 20:6d2af70c92ab 689 {
darienf 20:6d2af70c92ab 690 string reply;
darienf 20:6d2af70c92ab 691 reply = Call(CLASSNAME, "StartLoggingUsb");
darienf 20:6d2af70c92ab 692 }
darienf 20:6d2af70c92ab 693 */
darienf 20:6d2af70c92ab 694 private void InitStreaming()
darienf 20:6d2af70c92ab 695 {
darienf 20:6d2af70c92ab 696 client.pipeline.Discard();
darienf 20:6d2af70c92ab 697 client.streaming.Init(client.pipeline);
darienf 20:6d2af70c92ab 698 client.streaming.Start();
darienf 20:6d2af70c92ab 699 //Call(CLASSNAME, "StreamTest");
darienf 20:6d2af70c92ab 700 //CallNoReply(CLASSNAME, "StreamTest");
darienf 20:6d2af70c92ab 701 }
darienf 20:6d2af70c92ab 702
darienf 20:6d2af70c92ab 703 public void StartStreaming()
darienf 20:6d2af70c92ab 704 {
darienf 20:6d2af70c92ab 705 client.pipeline.Discard();
darienf 20:6d2af70c92ab 706 InitStreaming();
darienf 20:6d2af70c92ab 707 CallNoReply(CLASSNAME, "StartLoggingUsb");
darienf 20:6d2af70c92ab 708 //Call(CLASSNAME, "StartTest");
darienf 20:6d2af70c92ab 709 }
darienf 20:6d2af70c92ab 710
darienf 20:6d2af70c92ab 711 public void StopStreaming()
darienf 20:6d2af70c92ab 712 {
darienf 20:6d2af70c92ab 713 StopStreaming(true);
darienf 20:6d2af70c92ab 714 }
darienf 20:6d2af70c92ab 715
darienf 20:6d2af70c92ab 716 public void StopStreaming(bool connected)
darienf 20:6d2af70c92ab 717 {
darienf 20:6d2af70c92ab 718 //if (connected)
darienf 20:6d2af70c92ab 719 client.pipeline.SendSingleByte(' ');
darienf 20:6d2af70c92ab 720
darienf 20:6d2af70c92ab 721 client.streaming.Stop();
darienf 20:6d2af70c92ab 722
darienf 20:6d2af70c92ab 723 //if (connected)
darienf 20:6d2af70c92ab 724 {
darienf 20:6d2af70c92ab 725 client.pipeline.Discard();
darienf 20:6d2af70c92ab 726 Thread.Sleep(500);
darienf 20:6d2af70c92ab 727 client.pipeline.Discard();
darienf 20:6d2af70c92ab 728 }
darienf 20:6d2af70c92ab 729 }
darienf 20:6d2af70c92ab 730
darienf 20:6d2af70c92ab 731 public void MissionRead()
darienf 20:6d2af70c92ab 732 {
darienf 20:6d2af70c92ab 733 int val;
darienf 20:6d2af70c92ab 734 string reply;
darienf 20:6d2af70c92ab 735
darienf 20:6d2af70c92ab 736 reply = Call(CLASSNAME, "ReadMission");
darienf 20:6d2af70c92ab 737 reply = reply.Trim(new char[] { '\n', '\r', ' ', ':' });
darienf 20:6d2af70c92ab 738 String[] cmds = reply.Split(new char[] { ':' });
darienf 20:6d2af70c92ab 739 int i = 1;
darienf 20:6d2af70c92ab 740 foreach (String str in cmds)
darienf 20:6d2af70c92ab 741 {
darienf 20:6d2af70c92ab 742 String cmd = str.Trim();
darienf 20:6d2af70c92ab 743 if (!String.IsNullOrEmpty(cmd))
darienf 20:6d2af70c92ab 744 {
darienf 20:6d2af70c92ab 745 Console.WriteLine(i.ToString() + ": " + cmd);
darienf 20:6d2af70c92ab 746 i++;
darienf 20:6d2af70c92ab 747 }
darienf 20:6d2af70c92ab 748 }
darienf 20:6d2af70c92ab 749 //reply = Call(CLASSNAME, "ReadMission");
darienf 20:6d2af70c92ab 750 //reply = "/MAX30001/ECG_InitStart 01 01 01 00 02 03 1F 00 02 00 01\r\n/BMP280/InitStart 01\r\n";
darienf 20:6d2af70c92ab 751
darienf 20:6d2af70c92ab 752 // clear where it exists in mission flag
darienf 20:6d2af70c92ab 753 foreach (cDeviceMethodParameters cmd in rpcCommandList)
darienf 20:6d2af70c92ab 754 {
darienf 20:6d2af70c92ab 755 cmd.ClearExistsInDeviceMission();
darienf 20:6d2af70c92ab 756 }
darienf 20:6d2af70c92ab 757 PreCommand.ClearExistsInDeviceMission();
darienf 20:6d2af70c92ab 758 PostCommand.ClearExistsInDeviceMission();
darienf 20:6d2af70c92ab 759 //reply[0]
darienf 20:6d2af70c92ab 760 ParseRPCReadSequence(reply);
darienf 20:6d2af70c92ab 761 }
darienf 20:6d2af70c92ab 762
darienf 20:6d2af70c92ab 763 public string[] MissionStrings()
darienf 20:6d2af70c92ab 764 {
darienf 20:6d2af70c92ab 765 string reply;
darienf 20:6d2af70c92ab 766
darienf 20:6d2af70c92ab 767 reply = Call(CLASSNAME, "ReadMission");
darienf 20:6d2af70c92ab 768 reply = reply.Trim(new char[] { '\n', '\r', ' ', ':' });
darienf 20:6d2af70c92ab 769 string[] cmds = reply.Split(new string[] { ": " }, StringSplitOptions.RemoveEmptyEntries);
darienf 20:6d2af70c92ab 770
darienf 20:6d2af70c92ab 771 return cmds;
darienf 20:6d2af70c92ab 772 }
darienf 20:6d2af70c92ab 773
darienf 20:6d2af70c92ab 774 int debugMissionCmdCount;
darienf 20:6d2af70c92ab 775 public void MissionStartDefinition()
darienf 20:6d2af70c92ab 776 {
darienf 20:6d2af70c92ab 777 string reply;
darienf 20:6d2af70c92ab 778 reply = Call(CLASSNAME, "StartMissionDefine");
darienf 20:6d2af70c92ab 779 debugMissionCmdCount = 0;
darienf 20:6d2af70c92ab 780 }
darienf 20:6d2af70c92ab 781 public void MissionAppend(cDeviceMethodParameters device)
darienf 20:6d2af70c92ab 782 {
darienf 20:6d2af70c92ab 783 String cmd;
darienf 20:6d2af70c92ab 784 cmd = device.GenerateRpcCommandString();
darienf 20:6d2af70c92ab 785 Call(CLASSNAME, "AppendMissionCmd", cmd);
darienf 20:6d2af70c92ab 786 debugMissionCmdCount++;
darienf 20:6d2af70c92ab 787 Console.WriteLine(debugMissionCmdCount.ToString() + ": " + cmd);
darienf 20:6d2af70c92ab 788 }
darienf 20:6d2af70c92ab 789 public void MissionAppend(String cmdStr)
darienf 20:6d2af70c92ab 790 {
darienf 20:6d2af70c92ab 791 Call(CLASSNAME, "AppendMissionCmd", "\"" + cmdStr + "\"");
darienf 20:6d2af70c92ab 792 debugMissionCmdCount++;
darienf 20:6d2af70c92ab 793 Console.WriteLine(debugMissionCmdCount.ToString() + ": " + cmdStr);
darienf 20:6d2af70c92ab 794 }
darienf 20:6d2af70c92ab 795 public void MissionWrite()
darienf 20:6d2af70c92ab 796 {
darienf 20:6d2af70c92ab 797 int val;
darienf 20:6d2af70c92ab 798 string cmd;
darienf 20:6d2af70c92ab 799 string reply;
darienf 20:6d2af70c92ab 800 StringBuilder sbTest = new StringBuilder();
darienf 20:6d2af70c92ab 801
darienf 20:6d2af70c92ab 802 reply = Call(CLASSNAME, "EndMissionDefine");
darienf 20:6d2af70c92ab 803 reply = Call(CLASSNAME, "WriteMission");
darienf 20:6d2af70c92ab 804 //reply = Call(CLASSNAME, "ReadReg", addr.ToString("X2"));
darienf 20:6d2af70c92ab 805 //int.TryParse(reply, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out val);
darienf 20:6d2af70c92ab 806 // Console.WriteLine(sbTest.ToString());
darienf 20:6d2af70c92ab 807 }
darienf 20:6d2af70c92ab 808
darienf 20:6d2af70c92ab 809 // "/MAX30001/ECG_InitStart 01 01 01 00 02 03 1F 00 02 00 01/r/n/BMP280/InitStart 01 01 01 00 02 03 1F 00 02 00 01/r/n"
darienf 20:6d2af70c92ab 810 private void ParseRPCReadSequence(String cmds)
darienf 20:6d2af70c92ab 811 {
darienf 20:6d2af70c92ab 812 int count = 0;
darienf 20:6d2af70c92ab 813 cmds = cmds.Trim(new char[] { '\n', '\r', ' ', ':' });
darienf 20:6d2af70c92ab 814 String[] cmdStrings = cmds.Split(new char[] { ':' });
darienf 20:6d2af70c92ab 815 int lastCount = cmdStrings.Length - 1;
darienf 20:6d2af70c92ab 816 foreach (String cmd in cmdStrings)
darienf 20:6d2af70c92ab 817 {
darienf 20:6d2af70c92ab 818 if (count == 0)
darienf 20:6d2af70c92ab 819 {
darienf 20:6d2af70c92ab 820 PreCommand.Define(cmd);
darienf 20:6d2af70c92ab 821 PreCommand.existsInDeviceMission = true;
darienf 20:6d2af70c92ab 822 }
darienf 20:6d2af70c92ab 823 else
darienf 20:6d2af70c92ab 824 if (count == lastCount)
darienf 20:6d2af70c92ab 825 {
darienf 20:6d2af70c92ab 826 PostCommand.Define(cmd);
darienf 20:6d2af70c92ab 827 PostCommand.existsInDeviceMission = true;
darienf 20:6d2af70c92ab 828 }
darienf 20:6d2af70c92ab 829 else
darienf 20:6d2af70c92ab 830 ProcessRPCCmd(cmd);
darienf 20:6d2af70c92ab 831 count++;
darienf 20:6d2af70c92ab 832 }
darienf 20:6d2af70c92ab 833 }
darienf 20:6d2af70c92ab 834
darienf 20:6d2af70c92ab 835 List<cDeviceMethodParameters> rpcCommandList = new List<cDeviceMethodParameters>();
darienf 20:6d2af70c92ab 836
darienf 20:6d2af70c92ab 837 private void InitRpcCommandList()
darienf 20:6d2af70c92ab 838 {
darienf 20:6d2af70c92ab 839 rpcCommandList.Add(MAX30001_Ecg);
darienf 20:6d2af70c92ab 840 rpcCommandList.Add(MAX30001_Bioz);
darienf 20:6d2af70c92ab 841 rpcCommandList.Add(MAX30001_RtoR);
darienf 20:6d2af70c92ab 842 rpcCommandList.Add(MAX30001_Pace);
darienf 20:6d2af70c92ab 843 rpcCommandList.Add(MAX30001_Cal);
darienf 20:6d2af70c92ab 844 rpcCommandList.Add(MAX31725_1);
darienf 20:6d2af70c92ab 845 rpcCommandList.Add(MAX31725_2);
darienf 20:6d2af70c92ab 846 rpcCommandList.Add(BMP280);
darienf 20:6d2af70c92ab 847 rpcCommandList.Add(LIS2DH);
darienf 20:6d2af70c92ab 848 rpcCommandList.Add(MAX30101_SpO2);
darienf 20:6d2af70c92ab 849 rpcCommandList.Add(MAX30101_HR);
darienf 20:6d2af70c92ab 850 rpcCommandList.Add(MAX30101_Multi);
darienf 20:6d2af70c92ab 851 rpcCommandList.Add(MAX30001_Rbias_Fmstr);
darienf 20:6d2af70c92ab 852 }
darienf 20:6d2af70c92ab 853
darienf 20:6d2af70c92ab 854 private void ProcessRPCCmd(String str)
darienf 20:6d2af70c92ab 855 {
darienf 20:6d2af70c92ab 856 if (String.IsNullOrEmpty(str)) return;
darienf 20:6d2af70c92ab 857 String trimmed = str.Trim(new char[] { '\r', '\n', ' ' });
darienf 20:6d2af70c92ab 858 if (String.IsNullOrEmpty(trimmed)) return;
darienf 20:6d2af70c92ab 859 if (trimmed[0] != '/') return;
darienf 20:6d2af70c92ab 860 String trimmed2 = trimmed.Trim(new char[] { '\r', '\n', '/', ' ' });
darienf 20:6d2af70c92ab 861 String[] parts = trimmed2.Split(new char[] { '/' });
darienf 20:6d2af70c92ab 862 String className = parts[0];
darienf 20:6d2af70c92ab 863 String methodNameParameters = parts[1];
darienf 20:6d2af70c92ab 864 String methodName = methodNameParameters.Substring(0,methodNameParameters.IndexOf(' '));
darienf 20:6d2af70c92ab 865 String parameters = methodNameParameters.Substring(methodNameParameters.IndexOf(' ')).Trim();
darienf 20:6d2af70c92ab 866 foreach (cDeviceMethodParameters cmd in rpcCommandList)
darienf 20:6d2af70c92ab 867 {
darienf 20:6d2af70c92ab 868 if (cmd.AssignIfMatch(className, methodName, parameters) == true) break;
darienf 20:6d2af70c92ab 869 }
darienf 20:6d2af70c92ab 870 }
darienf 20:6d2af70c92ab 871
darienf 20:6d2af70c92ab 872 private int[] ParseHexString(String hexStr)
darienf 20:6d2af70c92ab 873 {
darienf 20:6d2af70c92ab 874 int val;
darienf 20:6d2af70c92ab 875 List<int> intList = new List<int>();
darienf 20:6d2af70c92ab 876 String[] strings = hexStr.Split(new char[] { ' ' });
darienf 20:6d2af70c92ab 877 foreach (String str in strings)
darienf 20:6d2af70c92ab 878 {
darienf 20:6d2af70c92ab 879 if (int.TryParse(str, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out val))
darienf 20:6d2af70c92ab 880 {
darienf 20:6d2af70c92ab 881 intList.Add(val);
darienf 20:6d2af70c92ab 882 }
darienf 20:6d2af70c92ab 883 else
darienf 20:6d2af70c92ab 884 {
darienf 20:6d2af70c92ab 885 throw new Exception(String.Format("Error In hex string \"{0}\" in \"{1}\"", str, hexStr));
darienf 20:6d2af70c92ab 886 }
darienf 20:6d2af70c92ab 887 }
darienf 20:6d2af70c92ab 888 return intList.ToArray();
darienf 20:6d2af70c92ab 889 }
darienf 20:6d2af70c92ab 890
darienf 20:6d2af70c92ab 891 public void EraseMission()
darienf 20:6d2af70c92ab 892 {
darienf 20:6d2af70c92ab 893 int val;
darienf 20:6d2af70c92ab 894 string cmd;
darienf 20:6d2af70c92ab 895 string reply;
darienf 20:6d2af70c92ab 896
darienf 20:6d2af70c92ab 897 reply = Call(CLASSNAME, "EraseMission");
darienf 20:6d2af70c92ab 898 }
darienf 20:6d2af70c92ab 899
darienf 20:6d2af70c92ab 900 public void TestMission()
darienf 20:6d2af70c92ab 901 {
darienf 20:6d2af70c92ab 902 int val;
darienf 20:6d2af70c92ab 903 string cmd;
darienf 20:6d2af70c92ab 904 string reply;
darienf 20:6d2af70c92ab 905
darienf 20:6d2af70c92ab 906 reply = Call(CLASSNAME, "TestStartMission");
darienf 20:6d2af70c92ab 907 }
darienf 20:6d2af70c92ab 908
darienf 20:6d2af70c92ab 909 public void TestWriteLog()
darienf 20:6d2af70c92ab 910 {
darienf 20:6d2af70c92ab 911 throw new NotImplementedException();
darienf 20:6d2af70c92ab 912 }
darienf 20:6d2af70c92ab 913
darienf 20:6d2af70c92ab 914 public void TestReadLog()
darienf 20:6d2af70c92ab 915 {
darienf 20:6d2af70c92ab 916 throw new NotImplementedException();
darienf 20:6d2af70c92ab 917 }
darienf 20:6d2af70c92ab 918
darienf 20:6d2af70c92ab 919 public void TestBulkErase()
darienf 20:6d2af70c92ab 920 {
darienf 20:6d2af70c92ab 921 throw new NotImplementedException();
darienf 20:6d2af70c92ab 922 }
darienf 20:6d2af70c92ab 923
darienf 20:6d2af70c92ab 924 public void TestLogSectorsErase()
darienf 20:6d2af70c92ab 925 {
darienf 20:6d2af70c92ab 926 throw new NotImplementedException();
darienf 20:6d2af70c92ab 927 }
darienf 20:6d2af70c92ab 928
darienf 20:6d2af70c92ab 929 public string ReadPageToString(int page, out bool allOnes)
darienf 20:6d2af70c92ab 930 {
darienf 20:6d2af70c92ab 931 String returnStr = "";
darienf 20:6d2af70c92ab 932 returnStr = CallBinary("S25FS512", "ReadPagesBinary", out allOnes, new String[] { page.ToString("X2"), page.ToString("X2") });
darienf 20:6d2af70c92ab 933 return returnStr;
darienf 20:6d2af70c92ab 934 }
darienf 20:6d2af70c92ab 935
darienf 20:6d2af70c92ab 936 public void EraseWrittenSectors()
darienf 20:6d2af70c92ab 937 {
darienf 20:6d2af70c92ab 938 int val;
darienf 20:6d2af70c92ab 939 string cmd;
darienf 20:6d2af70c92ab 940 string reply;
darienf 20:6d2af70c92ab 941
darienf 20:6d2af70c92ab 942 reply = Call(CLASSNAME, "EraseWrittenSectors");
darienf 20:6d2af70c92ab 943 }
darienf 20:6d2af70c92ab 944 }
darienf 20:6d2af70c92ab 945
darienf 20:6d2af70c92ab 946 public abstract class cDeviceMethodParameters
darienf 20:6d2af70c92ab 947 {
darienf 20:6d2af70c92ab 948 public String className;
darienf 20:6d2af70c92ab 949 public String methodName;
darienf 20:6d2af70c92ab 950 public abstract void AssignByIntArray(int[] intArray);
darienf 20:6d2af70c92ab 951 public abstract int[] ToIntArray();
darienf 20:6d2af70c92ab 952 public bool existsInDeviceMission;
darienf 20:6d2af70c92ab 953 public bool IsExistsInDeviceMission()
darienf 20:6d2af70c92ab 954 {
darienf 20:6d2af70c92ab 955 return existsInDeviceMission;
darienf 20:6d2af70c92ab 956 }
darienf 20:6d2af70c92ab 957 public void ClearExistsInDeviceMission()
darienf 20:6d2af70c92ab 958 {
darienf 20:6d2af70c92ab 959 existsInDeviceMission = false;
darienf 20:6d2af70c92ab 960 }
darienf 20:6d2af70c92ab 961 public String ParametersToString()
darienf 20:6d2af70c92ab 962 {
darienf 20:6d2af70c92ab 963 StringBuilder sb = new StringBuilder();
darienf 20:6d2af70c92ab 964 int[] intArray = ToIntArray();
darienf 20:6d2af70c92ab 965 foreach (int val in intArray)
darienf 20:6d2af70c92ab 966 {
darienf 20:6d2af70c92ab 967 sb.Append(val.ToString("X2") + " ");
darienf 20:6d2af70c92ab 968 }
darienf 20:6d2af70c92ab 969 return sb.ToString().Trim(new char[] { ' ', ',' });
darienf 20:6d2af70c92ab 970 }
darienf 20:6d2af70c92ab 971 public virtual String GenerateRpcCommandString()
darienf 20:6d2af70c92ab 972 {
darienf 20:6d2af70c92ab 973 String cmd = String.Format("\"/{0}/{1} {2}\"", className, methodName, ParametersToString());
darienf 20:6d2af70c92ab 974 //Console.WriteLine("cmd string = '" + cmd + "'");
darienf 20:6d2af70c92ab 975 //Console.WriteLine("cmd string length = " + cmd.Length.ToString());
darienf 20:6d2af70c92ab 976 return cmd;
darienf 20:6d2af70c92ab 977 }
darienf 20:6d2af70c92ab 978 public cDeviceMethodParameters(String className, String methodName)
darienf 20:6d2af70c92ab 979 {
darienf 20:6d2af70c92ab 980 existsInDeviceMission = false;
darienf 20:6d2af70c92ab 981 this.className = className;
darienf 20:6d2af70c92ab 982 this.methodName = methodName;
darienf 20:6d2af70c92ab 983 }
darienf 20:6d2af70c92ab 984 public bool AssignIfMatch(String className, String methodName, String parameterStr)
darienf 20:6d2af70c92ab 985 {
darienf 20:6d2af70c92ab 986 bool match = false;
darienf 20:6d2af70c92ab 987 if (this.className.Equals(className) && this.methodName.Equals(methodName))
darienf 20:6d2af70c92ab 988 {
darienf 20:6d2af70c92ab 989 match = true;
darienf 20:6d2af70c92ab 990 existsInDeviceMission = true;
darienf 20:6d2af70c92ab 991 AssignByIntArray(ParseHexString(parameterStr));
darienf 20:6d2af70c92ab 992 }
darienf 20:6d2af70c92ab 993 return match;
darienf 20:6d2af70c92ab 994 }
darienf 20:6d2af70c92ab 995 private int[] ParseHexString(String hexStr)
darienf 20:6d2af70c92ab 996 {
darienf 20:6d2af70c92ab 997 int val;
darienf 20:6d2af70c92ab 998 List<int> intList = new List<int>();
darienf 20:6d2af70c92ab 999 String[] strings = hexStr.Split(new char[] { ' ' });
darienf 20:6d2af70c92ab 1000 foreach (String str in strings)
darienf 20:6d2af70c92ab 1001 {
darienf 20:6d2af70c92ab 1002 if (int.TryParse(str, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out val))
darienf 20:6d2af70c92ab 1003 {
darienf 20:6d2af70c92ab 1004 intList.Add(val);
darienf 20:6d2af70c92ab 1005 }
darienf 20:6d2af70c92ab 1006 else
darienf 20:6d2af70c92ab 1007 {
darienf 20:6d2af70c92ab 1008 throw new Exception(String.Format("Error In hex string \"{0}\" in \"{1}\"", str, hexStr));
darienf 20:6d2af70c92ab 1009 }
darienf 20:6d2af70c92ab 1010 }
darienf 20:6d2af70c92ab 1011 return intList.ToArray();
darienf 20:6d2af70c92ab 1012 }
darienf 20:6d2af70c92ab 1013 }
darienf 20:6d2af70c92ab 1014 }