Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
InitArgs.cs
00001 /******************************************************************************* 00002 * Copyright (C) 2016 Maxim Integrated Products, Inc., All rights Reserved. 00003 * 00004 * This software is protected by copyright laws of the United States and 00005 * of foreign countries. This material may also be protected by patent laws 00006 * and technology transfer regulations of the United States and of foreign 00007 * countries. This software is furnished under a license agreement and/or a 00008 * nondisclosure agreement and may only be used or reproduced in accordance 00009 * with the terms of those agreements. Dissemination of this information to 00010 * any party or parties not specified in the license agreement and/or 00011 * nondisclosure agreement is expressly prohibited. 00012 * 00013 * The above copyright notice and this permission notice shall be included 00014 * in all copies or substantial portions of the Software. 00015 * 00016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00017 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00018 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00019 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES 00020 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00021 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00022 * OTHER DEALINGS IN THE SOFTWARE. 00023 * 00024 * Except as contained in this notice, the name of Maxim Integrated 00025 * Products, Inc. shall not be used except as stated in the Maxim Integrated 00026 * Products, Inc. Branding Policy. 00027 * 00028 * The mere transfer of this software does not imply any licenses 00029 * of trade secrets, proprietary technology, copyrights, patents, 00030 * trademarks, maskwork rights, or any other form of intellectual 00031 * property whatsoever. Maxim Integrated Products, Inc. retains all 00032 * ownership rights. 00033 ******************************************************************************* 00034 */ 00035 00036 using System; 00037 using System.Collections.Generic; 00038 using System.Linq; 00039 using System.Text; 00040 00041 namespace HealthSensorPlatform.CustomControls 00042 { 00043 /// <summary> 00044 /// Data for initializing streaming or flash logging 00045 /// </summary> 00046 public class InitArgs 00047 { 00048 interface IInitArgs 00049 { 00050 string ToCommandString(); 00051 //IInitArgs FromIntArray(int[] array); 00052 } 00053 00054 public struct RbiasInit 00055 { 00056 public int En_rbias; 00057 public int Rbias; 00058 public int Rbiasp; 00059 public int Rbiasn; 00060 public int Fmstr; 00061 } 00062 00063 public class EcgInitStart : IInitArgs 00064 { 00065 public int En_ecg; 00066 public int Openp; 00067 public int Openn; 00068 public int Pol; 00069 public int Calp_sel; 00070 public int Caln_sel; 00071 public int E_fit; 00072 public int Rate; 00073 public int Gain; 00074 public int Dhpf; 00075 public int Dlpf; 00076 00077 public string ToCommandString() 00078 { 00079 StringBuilder command = new StringBuilder(); 00080 command.Append(En_ecg.ToString("X2")).Append(" "); 00081 command.Append(Openp.ToString("X2")).Append(" "); 00082 command.Append(Openn.ToString("X2")).Append(" "); 00083 command.Append(Pol.ToString("X2")).Append(" "); 00084 command.Append(Calp_sel.ToString("X2")).Append(" "); 00085 command.Append(Caln_sel.ToString("X2")).Append(" "); 00086 command.Append(E_fit.ToString("X2")).Append(" "); 00087 command.Append(Rate.ToString("X2")).Append(" "); 00088 command.Append(Gain.ToString("X2")).Append(" "); 00089 command.Append(Dhpf.ToString("X2")).Append(" "); 00090 command.Append(Dlpf.ToString("X2")); 00091 00092 return command.ToString(); 00093 } 00094 00095 public int[] ToArray() 00096 { 00097 int[] array = new int[11]; 00098 00099 array[0] = En_ecg; 00100 array[1] = Openp; 00101 array[2] = Openn; 00102 array[3] = Pol; 00103 array[4] = Calp_sel; 00104 array[5] = Caln_sel; 00105 array[6] = E_fit; 00106 array[7] = Rate; 00107 array[8] = Gain; 00108 array[9] = Dhpf; 00109 array[10] = Dlpf; 00110 00111 return array; 00112 } 00113 00114 public EcgInitStart FromIntArray(int[] array) 00115 { 00116 if (array.Length == 11) 00117 { 00118 En_ecg = array[0]; 00119 Openp = array[1]; 00120 Openn = array[2]; 00121 Pol = array[3]; 00122 Calp_sel = array[4]; 00123 Caln_sel = array[5]; 00124 E_fit = array[6]; 00125 Rate = array[7]; 00126 Gain = array[8]; 00127 Dhpf = array[9]; 00128 Dlpf = array[10]; 00129 } 00130 else 00131 { 00132 throw new InvalidOperationException("Array length incorrect"); 00133 } 00134 00135 return this; 00136 } 00137 } 00138 00139 public struct EcgFastInit 00140 { 00141 public int Clr_Fast; 00142 public int Fast; 00143 public int Fast_Th; 00144 } 00145 00146 public class FMSTRInitStart : IInitArgs 00147 { 00148 public int En_rbias; 00149 public int Rbiasv; 00150 public int Rbiasp; 00151 public int Rbiasn; 00152 public int Fmstr; 00153 00154 public string ToCommandString() 00155 { 00156 StringBuilder command = new StringBuilder(); 00157 command.Append(En_rbias.ToString("X2")).Append(" "); 00158 command.Append(Rbiasv.ToString("X2")).Append(" "); 00159 command.Append(Rbiasp.ToString("X2")).Append(" "); 00160 command.Append(Rbiasn.ToString("X2")).Append(" "); 00161 command.Append(Fmstr.ToString("X2")); 00162 00163 return command.ToString(); 00164 } 00165 00166 public FMSTRInitStart FromIntArray(int[] array) 00167 { 00168 if (array.Length == 5) 00169 { 00170 En_rbias = array[0]; 00171 Rbiasv = array[1]; 00172 Rbiasp = array[2]; 00173 Rbiasn = array[3]; 00174 Fmstr = array[4]; 00175 } 00176 else 00177 { 00178 throw new InvalidOperationException("Array length incorrect"); 00179 } 00180 00181 return this; 00182 } 00183 } 00184 00185 public class PACEInitStart : IInitArgs 00186 { 00187 public int En_pace; 00188 public int Clr_pedge; 00189 public int Pol; 00190 public int Gn_diff_off; 00191 public int Gain; 00192 public int Aout_lbw; 00193 public int Aout; 00194 public int Dacp; 00195 public int Dacn; 00196 00197 public string ToCommandString() 00198 { 00199 StringBuilder command = new StringBuilder(); 00200 command.Append(En_pace.ToString("X2")).Append(" "); 00201 command.Append(Clr_pedge.ToString("X2")).Append(" "); 00202 command.Append(Gn_diff_off.ToString("X2")).Append(" "); 00203 command.Append(Gain.ToString("X2")).Append(" "); 00204 command.Append(Aout_lbw.ToString("X2")).Append(" "); 00205 command.Append(Aout.ToString("X2")).Append(" "); 00206 command.Append(Dacp.ToString("X2")).Append(" "); 00207 command.Append(Dacn.ToString("X2")); 00208 00209 return command.ToString(); 00210 } 00211 00212 public int[] ToArray() 00213 { 00214 int[] array = new int[9]; 00215 00216 array[0] = En_pace; 00217 array[1] = Clr_pedge; 00218 array[2] = Pol; 00219 array[3] = Gn_diff_off; 00220 array[4] = Gain; 00221 array[5] = Aout_lbw; 00222 array[6] = Aout; 00223 array[7] = Dacp; 00224 array[8] = Dacn; 00225 00226 return array; 00227 } 00228 00229 public PACEInitStart FromIntArray(int[] array) 00230 { 00231 if (array.Length == 8) 00232 { 00233 En_pace = array[0]; 00234 Clr_pedge = array[1]; 00235 Pol = array[2]; 00236 Gn_diff_off = array[3]; 00237 Gain = array[4]; 00238 Aout_lbw = array[5]; 00239 Dacp = array[6]; 00240 Dacn = array[7]; 00241 } 00242 else 00243 { 00244 throw new InvalidOperationException("Array length incorrect"); 00245 } 00246 00247 return this; 00248 } 00249 } 00250 00251 public class BIOZInitStart : IInitArgs 00252 { 00253 public int En_bioz; 00254 public int Openp; 00255 public int Openn; 00256 public int Calp_sel; 00257 public int Caln_sel; 00258 public int CG_mode; 00259 public int B_fit; 00260 public int Rate; 00261 public int Ahpf; 00262 public int Ext_rbias; 00263 public int Gain; 00264 public int Dhpf; 00265 public int Dlpf; 00266 public int Fcgen; 00267 public int Cgmon; 00268 public int Cgmag; 00269 public int Phoff; 00270 00271 public string ToCommandString() 00272 { 00273 StringBuilder command = new StringBuilder(); 00274 command.Append(En_bioz.ToString("X2")).Append(" "); 00275 command.Append(Openp.ToString("X2")).Append(" "); 00276 command.Append(Openn.ToString("X2")).Append(" "); 00277 command.Append(Calp_sel.ToString("X2")).Append(" "); 00278 command.Append(Caln_sel.ToString("X2")).Append(" "); 00279 command.Append(CG_mode.ToString("X2")).Append(" "); 00280 command.Append(B_fit.ToString("X2")).Append(" "); 00281 command.Append(Rate.ToString("X2")).Append(" "); 00282 command.Append(Ahpf.ToString("X2")).Append(" "); 00283 command.Append(Ext_rbias.ToString("X2")).Append(" "); 00284 command.Append(Gain.ToString("X2")).Append(" "); 00285 command.Append(Dhpf.ToString("X2")).Append(" "); 00286 command.Append(Dlpf.ToString("X2")).Append(" "); 00287 command.Append(Fcgen.ToString("X2")).Append(" "); 00288 command.Append(Cgmon.ToString("X2")).Append(" "); 00289 command.Append(Cgmag.ToString("X2")).Append(" "); 00290 command.Append(Phoff.ToString("X2")); 00291 00292 return command.ToString(); 00293 } 00294 00295 public int[] ToArray() 00296 { 00297 int[] array = new int[17]; 00298 00299 array[0] = En_bioz; 00300 array[1] = Openp; 00301 array[2] = Openn; 00302 array[3] = Calp_sel; 00303 array[4] = Caln_sel; 00304 array[5] = CG_mode; 00305 array[6] = B_fit; 00306 array[7] = Rate; 00307 array[8] = Ahpf; 00308 array[9] = Ext_rbias; 00309 array[10] = Gain; 00310 array[11] = Dhpf; 00311 array[12] = Dlpf; 00312 array[13] = Fcgen; 00313 array[14] = Cgmon; 00314 array[15] = Cgmag; 00315 array[16] = Phoff; 00316 00317 return array; 00318 } 00319 00320 public BIOZInitStart FromIntArray(int[] array) 00321 { 00322 if (array.Length == 17) 00323 { 00324 En_bioz = array[0]; 00325 Openp = array[1]; 00326 Openn = array[2]; 00327 Calp_sel = array[3]; 00328 Caln_sel = array[4]; 00329 CG_mode = array[5]; 00330 B_fit = array[6]; 00331 Rate = array[7]; 00332 Ahpf = array[8]; 00333 Ext_rbias = array[9]; 00334 Gain = array[10]; 00335 Dhpf = array[11]; 00336 Dlpf = array[12]; 00337 Fcgen = array[13]; 00338 Cgmon = array[14]; 00339 Cgmag = array[15]; 00340 Phoff = array[16]; 00341 } 00342 else 00343 { 00344 throw new InvalidOperationException("Array size incorrect"); 00345 } 00346 00347 return this; 00348 } 00349 } 00350 00351 public class RToRInitStart : IInitArgs 00352 { 00353 public int En_rtor; 00354 public int Wndw; 00355 public int Gain; 00356 public int Pavg; 00357 public int Ptsf; 00358 public int Hoff; 00359 public int Ravg; 00360 public int Rhsf; 00361 public int Clr_rrint; 00362 00363 public string ToCommandString() 00364 { 00365 StringBuilder command = new StringBuilder(); 00366 command.Append(En_rtor.ToString("X2")).Append(" "); 00367 command.Append(Wndw.ToString("X2")).Append(" "); 00368 command.Append(Gain.ToString("X2")).Append(" "); 00369 command.Append(Pavg.ToString("X2")).Append(" "); 00370 command.Append(Ptsf.ToString("X2")).Append(" "); 00371 command.Append(Hoff.ToString("X2")).Append(" "); 00372 command.Append(Ravg.ToString("X2")).Append(" "); 00373 command.Append(Rhsf.ToString("X2")).Append(" "); 00374 command.Append(Clr_rrint.ToString("X2")); 00375 00376 return command.ToString(); 00377 } 00378 00379 public int[] ToArray() 00380 { 00381 int[] array = new int[9]; 00382 00383 array[0] = En_rtor; 00384 array[1] = Wndw; 00385 array[2] = Gain; 00386 array[3] = Pavg; 00387 array[4] = Ptsf; 00388 array[5] = Hoff; 00389 array[6] = Ravg; 00390 array[7] = Rhsf; 00391 array[8] = Clr_rrint; 00392 00393 return array; 00394 } 00395 00396 public RToRInitStart FromIntArray(int[] array) 00397 { 00398 if (array.Length == 9) 00399 { 00400 En_rtor = array[0]; 00401 Wndw = array[1]; 00402 Gain = array[2]; 00403 Pavg = array[3]; 00404 Ptsf = array[4]; 00405 Hoff = array[5]; 00406 Ravg = array[6]; 00407 Rhsf = array[7]; 00408 Clr_rrint = array[8]; 00409 } 00410 else 00411 { 00412 throw new InvalidOperationException("Array size incorrect"); 00413 } 00414 00415 return this; 00416 } 00417 } 00418 00419 public struct CalInitStart 00420 { 00421 public int Vmode; 00422 public int Vmag; 00423 public int Fcal; 00424 public int Thigh; 00425 public int Fifty; 00426 public int En_Vcal; 00427 } 00428 00429 public class SpO2HRModeInitStart : IInitArgs 00430 { 00431 public int FifoWaterlevelMark; 00432 public int SampleAverage; 00433 public int SampleRate; 00434 public int PulseWidth; 00435 public int RedLedCurrent; 00436 public int IRLedCurrent; 00437 00438 public string ToCommandString() 00439 { 00440 StringBuilder command = new StringBuilder(); 00441 command.Append(FifoWaterlevelMark.ToString("X2")).Append(" "); 00442 command.Append(SampleAverage.ToString("X2")).Append(" "); 00443 command.Append(SampleRate.ToString("X2")).Append(" "); 00444 command.Append(PulseWidth.ToString("X2")).Append(" "); 00445 command.Append(RedLedCurrent.ToString("X2")).Append(" "); 00446 command.Append(IRLedCurrent.ToString("X2")); 00447 00448 return command.ToString(); 00449 } 00450 00451 public SpO2HRModeInitStart FromIntArray(int[] array) 00452 { 00453 if (array.Length == 6) 00454 { 00455 FifoWaterlevelMark = array[0]; 00456 SampleAverage = array[1]; 00457 SampleRate = array[2]; 00458 PulseWidth = array[3]; 00459 RedLedCurrent = array[4]; 00460 IRLedCurrent = array[5]; 00461 } 00462 else if (array.Length == 5) 00463 { 00464 FifoWaterlevelMark = array[0]; 00465 SampleAverage = array[1]; 00466 SampleRate = array[2]; 00467 PulseWidth = array[3]; 00468 RedLedCurrent = array[4]; 00469 } 00470 else 00471 { 00472 throw new InvalidOperationException("Array size incorrect"); 00473 } 00474 00475 return this; 00476 } 00477 } 00478 00479 public class HRModeInitStart : IInitArgs 00480 { 00481 public int FifoWaterlevelMark; 00482 public int SampleAverage; 00483 public int SampleRate; 00484 public int PulseWidth; 00485 public int RedLedCurrent; 00486 public int IRLedCurrent; 00487 00488 public string ToCommandString() 00489 { 00490 StringBuilder command = new StringBuilder(); 00491 command.Append(FifoWaterlevelMark.ToString("X2")).Append(" "); 00492 command.Append(SampleAverage.ToString("X2")).Append(" "); 00493 command.Append(SampleRate.ToString("X2")).Append(" "); 00494 command.Append(PulseWidth.ToString("X2")).Append(" "); 00495 command.Append(RedLedCurrent.ToString("X2")); 00496 00497 return command.ToString(); 00498 } 00499 00500 public HRModeInitStart FromIntArray(int[] array) 00501 { 00502 if (array.Length == 5) 00503 { 00504 FifoWaterlevelMark = array[0]; 00505 SampleAverage = array[1]; 00506 SampleRate = array[2]; 00507 PulseWidth = array[3]; 00508 RedLedCurrent = array[4]; 00509 } 00510 else 00511 { 00512 throw new InvalidOperationException("Array size incorrect"); 00513 } 00514 00515 return this; 00516 } 00517 } 00518 00519 public class MultiModeInitStart : IInitArgs 00520 { 00521 public int FifoWaterlevelMark; 00522 public int SampleAverage; 00523 public int SampleRate; 00524 public int PulseWidth; 00525 public int RedLedCurrent; 00526 public int IRLedCurrent; 00527 public int GreenLedCurrent; 00528 public int Slot1; 00529 public int Slot2; 00530 public int Slot3; 00531 public int Slot4; 00532 00533 public string ToCommandString() 00534 { 00535 StringBuilder command = new StringBuilder(); 00536 command.Append(FifoWaterlevelMark.ToString("X2")).Append(" "); 00537 command.Append(SampleAverage.ToString("X2")).Append(" "); 00538 command.Append(SampleRate.ToString("X2")).Append(" "); 00539 command.Append(PulseWidth.ToString("X2")).Append(" "); 00540 command.Append(RedLedCurrent.ToString("X2")).Append(" "); 00541 command.Append(IRLedCurrent.ToString("X2")).Append(" "); 00542 command.Append(GreenLedCurrent.ToString("X2")).Append(" "); 00543 command.Append(Slot1.ToString("X2")).Append(" "); 00544 command.Append(Slot2.ToString("X2")).Append(" "); 00545 command.Append(Slot3.ToString("X2")).Append(" "); 00546 command.Append(Slot4.ToString("X2")); 00547 00548 return command.ToString(); 00549 } 00550 00551 public MultiModeInitStart FromIntArray(int[] array) 00552 { 00553 if (array.Length == 11) 00554 { 00555 FifoWaterlevelMark = array[0]; 00556 SampleAverage = array[1]; 00557 SampleRate = array[2]; 00558 PulseWidth = array[3]; 00559 RedLedCurrent = array[4]; 00560 IRLedCurrent = array[5]; 00561 GreenLedCurrent = array[6]; 00562 Slot1 = array[7]; 00563 Slot2 = array[8]; 00564 Slot3 = array[9]; 00565 Slot4 = array[10]; 00566 } 00567 else 00568 { 00569 throw new InvalidOperationException("Array size incorrect"); 00570 } 00571 00572 return this; 00573 } 00574 } 00575 } 00576 }
Generated on Tue Jul 12 2022 21:52:39 by
1.7.2