/* Ċ Ġ* ĠCopyright Ġ( C ) Ġ 2 0 2 2 ĠAl berto ĠIr ur ue ta ĠCar ro Ġ( al berto @ ir ur ue ta . com ) Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ package Ġcom . ir ur ue ta . android . navigation . in ert ial . calibration Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . hardware . Sensor Ċ import Ġandroid . location . Location Ċ import Ġandroid . os . System Clock Ċ import Ġandroidx . test . core . app . Application Provider Ċ import Ġcom . ir ur ue ta . algebra . Matrix Ċ import Ġcom . ir ur ue ta . algebra . Wrong Size Exception Ċ import Ġcom . ir ur ue ta . android . navigation . in ert ial . calibration . intervals . Interval Detector Ċ import Ġcom . ir ur ue ta . android . navigation . in ert ial . calibration . intervals . Error Reason Ċ import Ġcom . ir ur ue ta . android . navigation . in ert ial . calibration . intervals . Mag net ometer Interval Detector Ċ import Ġcom . ir ur ue ta . android . navigation . in ert ial . call Private Func With Result Ċ import Ġcom . ir ur ue ta . android . navigation . in ert ial . collect ors . Mag net ometer Sensor Collector Ċ import Ġcom . ir ur ue ta . android . navigation . in ert ial . collect ors . Sensor Accuracy Ċ import Ġcom . ir ur ue ta . android . navigation . in ert ial . collect ors . Sensor Delay Ċ import Ġcom . ir ur ue ta . android . navigation . in ert ial . get Private Property Ċ import Ġcom . ir ur ue ta . android . navigation . in ert ial . set Private Property Ċ import Ġcom . ir ur ue ta . android . navigation . in ert ial . to N ED Position Ċ import Ġcom . ir ur ue ta . navigation . Navigation Exception Ċ import Ġcom . ir ur ue ta . navigation . frames . Coordinate Transformation Ċ import Ġcom . ir ur ue ta . navigation . frames . Frame Type Ċ import Ġcom . ir ur ue ta . navigation . in ert ial . Body Mag netic Flux Density Ċ import Ġcom . ir ur ue ta . navigation . in ert ial . calibration . Body Mag netic Flux Density Generator Ċ import Ġcom . ir ur ue ta . navigation . in ert ial . calibration . Mag netic Flux Density Tri ad Ċ import Ġcom . ir ur ue ta . navigation . in ert ial . calibration . Standard De viation Body Mag netic Flux Density Ċ import Ġcom . ir ur ue ta . navigation . in ert ial . calibration . accel erometer . Accel erometer Non Linear Cal ibr ator Ċ import Ġcom . ir ur ue ta . navigation . in ert ial . calibration . intervals . Tri ad Static Interval Detector Ċ import Ġcom . ir ur ue ta . navigation . in ert ial . calibration . intervals . threshold factor . Quality Score Mapper Ċ import Ġcom . ir ur ue ta . navigation . in ert ial . calibration . mag net ometer .* Ċ import Ġcom . ir ur ue ta . navigation . in ert ial . estimators . Body Mag netic Flux Density Estimator Ċ import Ġcom . ir ur ue ta . navigation . in ert ial . w mm . WM ME arth Mag netic Flux Density Estimator Ċ import Ġcom . ir ur ue ta . navigation . in ert ial . w mm . World Mag netic Model Ċ import Ġcom . ir ur ue ta . num erical . rob ust . Rob ust Estimator Method Ċ import Ġcom . ir ur ue ta . statistics . Gaussian Random izer Ċ import Ġcom . ir ur ue ta . statistics . Uniform Random izer Ċ import Ġcom . ir ur ue ta . units . Mag netic Flux Density Ċ import Ġcom . ir ur ue ta . units . Mag netic Flux Density Unit Ċ import Ġcom . ir ur ue ta . units . Time Ċ import Ġcom . ir ur ue ta . units . TimeUnit Ċ import Ġio . mock k .* Ċ import Ġorg . junit . Assert .* Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . ro bo lectric . Ro bo lectric TestRunner Ċ import Ġjava . lang . reflect . Invocation TargetException Ċ import Ġjava . util .* Ċ import Ġkotlin . math . pow Ċ import Ġkotlin . math . sqrt Ċ Ċ @ RunWith ( Ro bo lectric TestRunner :: class ) Ċ class ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator Test Ġ{ ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġconstructor _ when Context _ returns Default Values () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalues ĊĠĠĠĠĠĠĠ ĠassertSame ( context , Ġcal ibr ator . context ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . location ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . timestamp ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . world Mag netic Model ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Initial Mag netic Flux Density Norm Measured ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mag net ometer Sensor Collector . Sensor Type . MAG NET O METER , Ġcal ibr ator . sensor Type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Sensor Delay . FAST EST , Ġcal ibr ator . sensor Delay ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . solve Calibration When En ough Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initialization Started Listener ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initialization Completed Listener ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . error Listener ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Available Listener ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . new Calibration Measurement Available Listener ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . ready ToS olve Calibration Listener ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . calibration Sol ving Started Listener ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . calibration Completed Listener ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . stopped Listener ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . quality Score Mapper ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . measure ments . isEmpty ()) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ready ToS olve Calibration ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Mag netic Flux Density Norm ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron X ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Y ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Z ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron X As Measurement ) ĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Initial Hard I ron X As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Y As Measurement ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Initial Hard I ron Y As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Z As Measurement ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Initial Hard I ron Z As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron As Tri ad ) ĊĠĠĠĠĠĠĠ Ġval Ġtri ad Ġ= ĠMag netic Flux Density Tri ad () ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Initial Hard I ron As Tri ad ( tri ad )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . running ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . mag net ometer Sensor ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Tri ad Static Interval Detector . DEFAULT _ WINDOW _ SIZE , Ġcal ibr ator . window Size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTri ad Static Interval Detector . DEFAULT _ INITIAL _ STATIC _ SAMPLES , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . initial Static Samples ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTri ad Static Interval Detector . DEFAULT _ THRESHOLD _ FACTOR , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . threshold Factor , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTri ad Static Interval Detector . DEFAULT _ INST ANT AN EO US _ NO ISE _ LEVEL _ FACTOR , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . instant aneous Noise Level Factor , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTri ad Static Interval Detector . DEFAULT _ BASE _ NO ISE _ LEVEL _ AB SOL UTE _ THRESHOLD , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . base Noise Level Absolute Threshold , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level 1 Ġ= Ġcal ibr ator . base Noise Level Absolute Threshold As Measurement ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . base Noise Level Absolute Threshold , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbase Noise Level 1 . value . toDouble (), ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mag netic Flux Density Unit . TES LA , Ġbase Noise Level 1 . unit ) ĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level 2 Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . getBase Noise Level Absolute Threshold As Measurement ( base Noise Level 2 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( base Noise Level 1 , Ġbase Noise Level 2 ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . base Noise Level ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . base Noise Level As Measurement ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . getBase Noise Level As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . base Noise Level P sd ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . base Noise Level Root P sd ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . threshold ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . threshold As Measurement ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Threshold As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . average Time Interval ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . average Time Interval As Time ) ĊĠĠĠĠĠĠĠ Ġval Ġtime Ġ= ĠTime ( 0 . 0 , ĠTimeUnit . SECOND ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Average Time Interval As Time ( time )) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . time Interval Variance ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . time Interval Standard De viation ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . time Interval Standard De viation As Time ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . getTime Interval Standard De viation As Time ( time )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġmm 1 Ġ= ĠMatrix ( MM _ SIZE , ĠMM _ SIZE ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( mm 1 , Ġcal ibr ator . initial Mm ) ĊĠĠĠĠĠĠĠ Ġval Ġmm 2 Ġ= ĠMatrix . identity ( MM _ SIZE , ĠMM _ SIZE ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . get Initial Mm ( mm 2 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( mm 1 , Ġmm 2 ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator . UNKNOWN _ HARD _ IRON _ MIN IMUM _ MEAS UREMENT S _ GENERAL , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator . UNKNOWN _ HARD _ IRON _ MIN IMUM _ MEAS UREMENT S _ GENERAL , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator . RO BU ST _ DEFAULT _ CONF ID ENCE , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator . RO BU ST _ DEFAULT _ MAX _ ITER ATIONS , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator . UNKNOWN _ HARD _ IRON _ MIN IMUM _ MEAS UREMENT S _ GENERAL , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator . DEFAULT _ RO BU ST _ THRESHOLD _ FACTOR , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator . DEFAULT _ RO BU ST _ STOP _ THRESHOLD _ FACTOR , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Stop Threshold Factor , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Mm ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Sx ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Sy ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Sz ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated M xy ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated M xz ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated My x ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated My z ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Mz x ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated M zy ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Co variance ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Chi Sq ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated M se ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Hard I ron X ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Hard I ron Y ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Hard I ron Z ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Hard I ron X As Measurement ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Est imated Hard I ron X As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Hard I ron Y As Measurement ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Est imated Hard I ron Y As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Hard I ron Z As Measurement ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Est imated Hard I ron Z As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Hard I ron As Tri ad ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Est imated Hard I ron As Tri ad ( tri ad )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġconstructor _ when All Parameters _ returns Expected Values () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġinitialization Started Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Initialization Started Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>() ĊĠĠĠĠĠĠĠ Ġval Ġinitialization Completed Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Initialization Completed Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>() ĊĠĠĠĠĠĠĠ Ġval Ġerror Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . OnError Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>() ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Available Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Mag net ometer Cal ibr ator . On Initial Hard I ron Available Listener >() ĊĠĠĠĠĠĠĠ Ġval Ġnew Calibration Measurement Available Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On New Calibration Measurement Available Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator , ĠStandard De viation Body Mag netic Flux Density >>() ĊĠĠĠĠĠĠĠ Ġval Ġready ToS olve Calibration Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Ready ToS olve Calibration Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>() ĊĠĠĠĠĠĠĠ Ġval Ġcalibration Sol ving Started Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Calibration Sol ving Started Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>() ĊĠĠĠĠĠĠĠ Ġval Ġcalibration Completed Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Calibration Completed Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>() ĊĠĠĠĠĠĠĠ Ġval Ġstopped Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Stopped Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>() ĊĠĠĠĠĠĠĠ Ġval Ġquality Score Mapper Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Quality Score Mapper < Standard De viation Body Mag netic Flux Density >>() ĊĠĠĠĠĠĠĠ Ġval Ġlocation Ġ= Ġget Location () ĊĠĠĠĠĠĠĠ Ġval Ġtimestamp Ġ= ĠDate () ĊĠĠĠĠĠĠĠ Ġval Ġworld Mag netic Model Ġ= ĠWorld Mag netic Model () ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlocation , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġtimestamp , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġworld Mag netic Model , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMag net ometer Sensor Collector . Sensor Type . MAG NET O METER _ UN CAL IB R ATED , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠSensor Delay . NORMAL , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġsolve Calibration When En ough Measure ments Ġ= Ġfalse , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġinitialization Started Listener , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġinitialization Completed Listener , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġerror Listener , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Hard I ron Available Listener , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġnew Calibration Measurement Available Listener , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġready ToS olve Calibration Listener , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcalibration Sol ving Started Listener , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcalibration Completed Listener , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġstopped Listener , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġquality Score Mapper ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalues ĊĠĠĠĠĠĠĠ ĠassertSame ( context , Ġcal ibr ator . context ) ĊĠĠĠĠĠĠĠ ĠassertSame ( location , Ġcal ibr ator . location ) ĊĠĠĠĠĠĠĠ ĠassertSame ( timestamp , Ġcal ibr ator . timestamp ) ĊĠĠĠĠĠĠĠ ĠassertSame ( world Mag netic Model , Ġcal ibr ator . world Mag netic Model ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Initial Mag netic Flux Density Norm Measured ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠMag net ometer Sensor Collector . Sensor Type . MAG NET O METER _ UN CAL IB R ATED , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . sensor Type ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Sensor Delay . NORMAL , Ġcal ibr ator . sensor Delay ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . solve Calibration When En ough Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertSame ( initialization Started Listener , Ġcal ibr ator . initialization Started Listener ) ĊĠĠĠĠĠĠĠ ĠassertSame ( initialization Completed Listener , Ġcal ibr ator . initialization Completed Listener ) ĊĠĠĠĠĠĠĠ ĠassertSame ( error Listener , Ġcal ibr ator . error Listener ) ĊĠĠĠĠĠĠĠ ĠassertSame ( initial Hard I ron Available Listener , Ġcal ibr ator . initial Hard I ron Available Listener ) ĊĠĠĠĠĠĠĠ ĠassertSame ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnew Calibration Measurement Available Listener , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . new Calibration Measurement Available Listener ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( ready ToS olve Calibration Listener , Ġcal ibr ator . ready ToS olve Calibration Listener ) ĊĠĠĠĠĠĠĠ ĠassertSame ( calibration Sol ving Started Listener , Ġcal ibr ator . calibration Sol ving Started Listener ) ĊĠĠĠĠĠĠĠ ĠassertSame ( calibration Completed Listener , Ġcal ibr ator . calibration Completed Listener ) ĊĠĠĠĠĠĠĠ ĠassertSame ( stopped Listener , Ġcal ibr ator . stopped Listener ) ĊĠĠĠĠĠĠĠ ĠassertSame ( quality Score Mapper , Ġcal ibr ator . quality Score Mapper ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . measure ments . isEmpty ()) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ready ToS olve Calibration ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Mag netic Flux Density Norm ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron X ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Y ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Z ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron X As Measurement ) ĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Initial Hard I ron X As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Y As Measurement ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Initial Hard I ron Y As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Z As Measurement ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Initial Hard I ron Z As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron As Tri ad ) ĊĠĠĠĠĠĠĠ Ġval Ġtri ad Ġ= ĠMag netic Flux Density Tri ad () ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Initial Hard I ron As Tri ad ( tri ad )) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . running ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . mag net ometer Sensor ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Tri ad Static Interval Detector . DEFAULT _ WINDOW _ SIZE , Ġcal ibr ator . window Size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTri ad Static Interval Detector . DEFAULT _ INITIAL _ STATIC _ SAMPLES , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . initial Static Samples ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTri ad Static Interval Detector . DEFAULT _ THRESHOLD _ FACTOR , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . threshold Factor , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTri ad Static Interval Detector . DEFAULT _ INST ANT AN EO US _ NO ISE _ LEVEL _ FACTOR , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . instant aneous Noise Level Factor , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTri ad Static Interval Detector . DEFAULT _ BASE _ NO ISE _ LEVEL _ AB SOL UTE _ THRESHOLD , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . base Noise Level Absolute Threshold , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level 1 Ġ= Ġcal ibr ator . base Noise Level Absolute Threshold As Measurement ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . base Noise Level Absolute Threshold , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbase Noise Level 1 . value . toDouble (), ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mag netic Flux Density Unit . TES LA , Ġbase Noise Level 1 . unit ) ĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level 2 Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . getBase Noise Level Absolute Threshold As Measurement ( base Noise Level 2 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( base Noise Level 1 , Ġbase Noise Level 2 ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . base Noise Level ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . base Noise Level As Measurement ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . getBase Noise Level As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . base Noise Level P sd ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . base Noise Level Root P sd ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . threshold ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . threshold As Measurement ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Threshold As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . average Time Interval ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . average Time Interval As Time ) ĊĠĠĠĠĠĠĠ Ġval Ġtime Ġ= ĠTime ( 0 . 0 , ĠTimeUnit . SECOND ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Average Time Interval As Time ( time )) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . time Interval Variance ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . time Interval Standard De viation ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . time Interval Standard De viation As Time ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . getTime Interval Standard De viation As Time ( time )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġmm 1 Ġ= ĠMatrix ( MM _ SIZE , ĠMM _ SIZE ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( mm 1 , Ġcal ibr ator . initial Mm ) ĊĠĠĠĠĠĠĠ Ġval Ġmm 2 Ġ= ĠMatrix . identity ( MM _ SIZE , ĠMM _ SIZE ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . get Initial Mm ( mm 2 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( mm 1 , Ġmm 2 ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator . KNOWN _ HARD _ IRON _ MIN IMUM _ MEAS UREMENT S _ GENERAL , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator . KNOWN _ HARD _ IRON _ MIN IMUM _ MEAS UREMENT S _ GENERAL , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator . RO BU ST _ DEFAULT _ CONF ID ENCE , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator . RO BU ST _ DEFAULT _ MAX _ ITER ATIONS , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator . KNOWN _ HARD _ IRON _ MIN IMUM _ MEAS UREMENT S _ GENERAL , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator . DEFAULT _ RO BU ST _ THRESHOLD _ FACTOR , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator . DEFAULT _ RO BU ST _ STOP _ THRESHOLD _ FACTOR , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Stop Threshold Factor , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Mm ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Sx ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Sy ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Sz ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated M xy ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated M xz ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated My x ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated My z ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Mz x ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated M zy ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Co variance ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Chi Sq ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated M se ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Hard I ron X ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Hard I ron Y ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Hard I ron Z ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Hard I ron X As Measurement ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Est imated Hard I ron X As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Hard I ron Y As Measurement ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Est imated Hard I ron Y As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Hard I ron Z As Measurement ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Est imated Hard I ron Z As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Hard I ron As Tri ad ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Est imated Hard I ron As Tri ad ( tri ad )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinitialization Started Listener _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initialization Started Listener ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġinitialization Started Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Initialization Started Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>() ĊĠĠĠĠĠĠĠ Ġcal ibr ator . initialization Started Listener Ġ= Ġinitialization Started Listener ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertSame ( initialization Started Listener , Ġcal ibr ator . initialization Started Listener ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinitialization Completed Listener _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initialization Completed Listener ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġinitialization Completed Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Initialization Completed Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>() ĊĠĠĠĠĠĠĠ Ġcal ibr ator . initialization Completed Listener Ġ= Ġinitialization Completed Listener ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertSame ( initialization Completed Listener , Ġcal ibr ator . initialization Completed Listener ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġerror Listener _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . error Listener ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġerror Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . OnError Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>() ĊĠĠĠĠĠĠĠ Ġcal ibr ator . error Listener Ġ= Ġerror Listener ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertSame ( error Listener , Ġcal ibr ator . error Listener ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinitial Hard I ron Available Listener _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Available Listener ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Available Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Mag net ometer Cal ibr ator . On Initial Hard I ron Available Listener >() ĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial Hard I ron Available Listener Ġ= Ġinitial Hard I ron Available Listener ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertSame ( initial Hard I ron Available Listener , Ġcal ibr ator . initial Hard I ron Available Listener ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġnew Calibration Measurement Available Listener _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . new Calibration Measurement Available Listener ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġnew Calibration Measurement Available Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On New Calibration Measurement Available Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator , ĠStandard De viation Body Mag netic Flux Density >>() ĊĠĠĠĠĠĠĠ Ġcal ibr ator . new Calibration Measurement Available Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnew Calibration Measurement Available Listener ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertSame ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnew Calibration Measurement Available Listener , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . new Calibration Measurement Available Listener ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġready ToS olve Calibration Listener _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . ready ToS olve Calibration Listener ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġready ToS olve Calibration Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Ready ToS olve Calibration Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>() ĊĠĠĠĠĠĠĠ Ġcal ibr ator . ready ToS olve Calibration Listener Ġ= Ġready ToS olve Calibration Listener ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertSame ( ready ToS olve Calibration Listener , Ġcal ibr ator . ready ToS olve Calibration Listener ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcalibration Sol ving Started Listener _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . calibration Sol ving Started Listener ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġcalibration Sol ving Started Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Calibration Sol ving Started Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>() ĊĠĠĠĠĠĠĠ Ġcal ibr ator . calibration Sol ving Started Listener Ġ= Ġcalibration Sol ving Started Listener ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertSame ( calibration Sol ving Started Listener , Ġcal ibr ator . calibration Sol ving Started Listener ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcalibration Completed Listener _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . calibration Completed Listener ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġcalibration Completed Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Calibration Completed Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>() ĊĠĠĠĠĠĠĠ Ġcal ibr ator . calibration Completed Listener Ġ= Ġcalibration Completed Listener ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertSame ( calibration Completed Listener , Ġcal ibr ator . calibration Completed Listener ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġstopped Listener _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . stopped Listener ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġstopped Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Stopped Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>() ĊĠĠĠĠĠĠĠ Ġcal ibr ator . stopped Listener Ġ= Ġstopped Listener ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertSame ( stopped Listener , Ġcal ibr ator . stopped Listener ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġis Ground Truth Initial Hard I ron _ when Valid _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġis Ground Truth Initial Hard I ron _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġlocation _ when Not Running _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . location ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġlocation Ġ= Ġget Location () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . location Ġ= Ġlocation ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertSame ( location , Ġcal ibr ator . location ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġlocation _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . location Ġ= Ġget Location () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtimestamp _ when Not Running _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . timestamp ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġtimestamp Ġ= ĠDate () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . timestamp Ġ= Ġtimestamp ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertSame ( timestamp , Ġcal ibr ator . timestamp ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġtimestamp _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . timestamp Ġ= ĠDate () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġworld Mag netic Model _ when Not Running _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . world Mag netic Model ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġworld Mag netic Model Ġ= ĠWorld Mag netic Model () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . world Mag netic Model Ġ= Ġworld Mag netic Model ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertSame ( world Mag netic Model , Ġcal ibr ator . world Mag netic Model ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġworld Mag netic Model _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . world Mag netic Model Ġ= ĠWorld Mag netic Model () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġis Initial Mag netic Flux Density Norm Measured _ returns Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalues ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Initial Mag netic Flux Density Norm Measured ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . location ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . timestamp ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġlocation ĊĠĠĠĠĠĠĠ Ġval Ġlocation Ġ= Ġget Location () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . location Ġ= Ġlocation ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Initial Mag netic Flux Density Norm Measured ) ĊĠĠĠĠĠĠĠ ĠassertSame ( location , Ġcal ibr ator . location ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . timestamp ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġunset Ġtimestamp ĊĠĠĠĠĠĠĠ Ġcal ibr ator . timestamp Ġ= Ġnull ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Initial Mag netic Flux Density Norm Measured ) ĊĠĠĠĠĠĠĠ ĠassertSame ( location , Ġcal ibr ator . location ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . timestamp ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwindow Size _ when Valid _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Tri ad Static Interval Detector . DEFAULT _ WINDOW _ SIZE , Ġcal ibr ator . window Size ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġcal ibr ator . window Size Ġ= ĠWINDO W _ SIZE ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( WINDOW _ SIZE , Ġcal ibr ator . window Size ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġwindow Size _ when Invalid _ throws IllegalArgumentException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . window Size Ġ= Ġ 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġwindow Size _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . window Size Ġ= ĠWINDO W _ SIZE ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinitial Static Samples _ when Valid _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTri ad Static Interval Detector . DEFAULT _ INITIAL _ STATIC _ SAMPLES , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . initial Static Samples ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial Static Samples Ġ= ĠINITIAL _ STATIC _ SAMPLES ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( INITIAL _ STATIC _ SAMPLES , Ġcal ibr ator . initial Static Samples ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġinitial Static Samples _ when Invalid _ throws IllegalArgumentException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial Static Samples Ġ= Ġ 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġinitial Static Samples _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial Static Samples Ġ= ĠINITIAL _ STATIC _ SAMPLES ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġthreshold Factor _ when Valid _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTri ad Static Interval Detector . DEFAULT _ THRESHOLD _ FACTOR , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . threshold Factor , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġcal ibr ator . threshold Factor Ġ= ĠTH RESH OLD _ FACTOR ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( THRESHOLD _ FACTOR , Ġcal ibr ator . threshold Factor , Ġ 0 . 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġthreshold Factor _ when Invalid _ throws IllegalArgumentException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . threshold Factor Ġ= Ġ 0 . 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġthreshold Factor _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . threshold Factor Ġ= ĠTH RESH OLD _ FACTOR ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinstant aneous Noise Level Factor _ when Valid _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTri ad Static Interval Detector . DEFAULT _ INST ANT AN EO US _ NO ISE _ LEVEL _ FACTOR , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . instant aneous Noise Level Factor , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġcal ibr ator . instant aneous Noise Level Factor Ġ= ĠINST ANT AN EO US _ NO ISE _ LEVEL _ FACTOR ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠINST ANT AN EO US _ NO ISE _ LEVEL _ FACTOR , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . instant aneous Noise Level Factor , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġinstant aneous Noise Level Factor _ when Invalid _ throws IllegalArgumentException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . instant aneous Noise Level Factor Ġ= Ġ 0 . 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġinstant aneous Noise Level Factor _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . instant aneous Noise Level Factor Ġ= ĠINST ANT AN EO US _ NO ISE _ LEVEL _ FACTOR ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbase Noise Level Absolute Threshold _ when Valid _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTri ad Static Interval Detector . DEFAULT _ BASE _ NO ISE _ LEVEL _ AB SOL UTE _ THRESHOLD , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . base Noise Level Absolute Threshold , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġcal ibr ator . base Noise Level Absolute Threshold Ġ= ĠBASE _ NO ISE _ LEVEL _ AB SOL UTE _ THRESHOLD ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBASE _ NO ISE _ LEVEL _ AB SOL UTE _ THRESHOLD , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . base Noise Level Absolute Threshold , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġbase Noise Level Absolute Threshold _ when Invalid _ throws IllegalArgumentException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . base Noise Level Absolute Threshold Ġ= Ġ 0 . 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġbase Noise Level Absolute Threshold _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . base Noise Level Absolute Threshold Ġ= ĠBASE _ NO ISE _ LEVEL _ AB SOL UTE _ THRESHOLD ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbase Noise Level Absolute Threshold As Measurement _ when Valid _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġvalue 1 Ġ= Ġcal ibr ator . base Noise Level Absolute Threshold As Measurement ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTri ad Static Interval Detector . DEFAULT _ BASE _ NO ISE _ LEVEL _ AB SOL UTE _ THRESHOLD , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġvalue 1 . value . toDouble (), ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mag netic Flux Density Unit . TES LA , Ġvalue 1 . unit ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġvalue 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠMag netic Flux Density ( BASE _ NO ISE _ LEVEL _ AB SOL UTE _ THRESHOLD , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . base Noise Level Absolute Threshold As Measurement Ġ= Ġvalue 2 ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġvalue 3 Ġ= Ġcal ibr ator . base Noise Level Absolute Threshold As Measurement ĊĠĠĠĠĠĠĠ ĠassertEquals ( value 2 , Ġvalue 3 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġbase Noise Level Absolute Threshold As Measurement _ when Invalid _ throws IllegalArgumentException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġval Ġvalue Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . base Noise Level Absolute Threshold As Measurement Ġ= Ġvalue ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġbase Noise Level Absolute Threshold As Measurement _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġval Ġvalue Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠMag netic Flux Density ( BASE _ NO ISE _ LEVEL _ AB SOL UTE _ THRESHOLD , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . base Noise Level Absolute Threshold As Measurement Ġ= Ġvalue ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Base Noise Level Absolute Threshold As Measurement _ gets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġvalue 1 Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . getBase Noise Level Absolute Threshold As Measurement ( value 1 ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTri ad Static Interval Detector . DEFAULT _ BASE _ NO ISE _ LEVEL _ AB SOL UTE _ THRESHOLD , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġvalue 1 . value . toDouble (), ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mag netic Flux Density Unit . TES LA , Ġvalue 1 . unit ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġvalue 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠMag netic Flux Density ( BASE _ NO ISE _ LEVEL _ AB SOL UTE _ THRESHOLD , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . base Noise Level Absolute Threshold As Measurement Ġ= Ġvalue 2 ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġvalue 3 Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . getBase Noise Level Absolute Threshold As Measurement ( value 3 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( value 2 , Ġvalue 3 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinitial Sx _ when Not Running _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Sx , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial Sx Ġ= Ġinitial Sx ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġcal ibr ator . initial Sx , Ġ 0 . 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġinitial Sx _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial Sx Ġ= Ġ 0 . 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinitial Sy _ when Not Running _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Sy , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial Sy Ġ= Ġinitial Sy ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġcal ibr ator . initial Sy , Ġ 0 . 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġinitial Sy _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial Sy Ġ= Ġ 0 . 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinitial Sz _ when Not Running _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Sz , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial Sz Ġ= Ġinitial Sz ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġcal ibr ator . initial Sz , Ġ 0 . 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġinitial Sz _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial Sz Ġ= Ġ 0 . 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinitial M xy _ when Not Running _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial M xy , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial M xy Ġ= Ġinitial M xy ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġcal ibr ator . initial M xy , Ġ 0 . 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġinitial M xy _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial M xy Ġ= Ġ 0 . 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinitial M xz _ when Not Running _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial M xz , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial M xz Ġ= Ġinitial M xz ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġcal ibr ator . initial M xz , Ġ 0 . 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġinitial M xz _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial M xz Ġ= Ġ 0 . 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinitial My x _ when Not Running _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial My x , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial My x Ġ= Ġinitial My x ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġcal ibr ator . initial My x , Ġ 0 . 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġinitial My x _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial My x Ġ= Ġ 0 . 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinitial My z _ when Not Running _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial My z , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial My z Ġ= Ġinitial My z ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġcal ibr ator . initial My z , Ġ 0 . 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġinitial My z _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial My z Ġ= Ġ 0 . 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinitial Mz x _ when Not Running _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Mz x , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial Mz x Ġ= Ġinitial Mz x ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġcal ibr ator . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġinitial Mz x _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial Mz x Ġ= Ġ 0 . 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinitial M zy _ when Not Running _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial M zy , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial M zy Ġ= Ġinitial M zy ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġcal ibr ator . initial M zy , Ġ 0 . 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġinitial M zy _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial M zy Ġ= Ġ 0 . 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġset Initial Scaling Factors _ when Not Running _ sets Expected Values () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalues ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Sz , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors ( initial Sx , Ġinitial Sy , Ġinitial Sz ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġcal ibr ator . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġcal ibr ator . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġcal ibr ator . initial Sz , Ġ 0 . 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġset Initial Scaling Factors _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors ( initial Sx , Ġinitial Sy , Ġinitial Sz ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġset Initial Cross Coup ling Errors _ when Not Running _ sets Expected Values () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalues ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial M zy , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġcal ibr ator . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġcal ibr ator . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġcal ibr ator . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġcal ibr ator . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġcal ibr ator . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġcal ibr ator . initial M zy , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Sz , Ġ 0 . 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġset Initial Cross Coup ling Errors _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġset Initial Scaling Factors And Cross Coup ling Errors _ when Not Running _ sets Expected Values () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalues ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial M zy , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġcal ibr ator . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġcal ibr ator . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġcal ibr ator . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġcal ibr ator . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġcal ibr ator . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġcal ibr ator . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġcal ibr ator . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġcal ibr ator . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġcal ibr ator . initial M zy , Ġ 0 . 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġset Initial Scaling Factor And Cross Coup ling Errors _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinitial Mm _ when Valid _ sets Expected Values () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertEquals ( Matrix ( MM _ SIZE , ĠMM _ SIZE ), Ġcal ibr ator . initial Mm ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġcal ibr ator . initial M zy , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĊĠĠĠĠĠĠĠ Ġval Ġmm Ġ= ĠMatrix ( MM _ SIZE , ĠMM _ SIZE ) ĊĠĠĠĠĠĠĠ Ġmm . set Element AtIndex ( 0 , Ġinitial Sx ) ĊĠĠĠĠĠĠĠ Ġmm . set Element AtIndex ( 1 , Ġinitial My x ) ĊĠĠĠĠĠĠĠ Ġmm . set Element AtIndex ( 2 , Ġinitial Mz x ) ĊĊĠĠĠĠĠĠĠ Ġmm . set Element AtIndex ( 3 , Ġinitial M xy ) ĊĠĠĠĠĠĠĠ Ġmm . set Element AtIndex ( 4 , Ġinitial Sy ) ĊĠĠĠĠĠĠĠ Ġmm . set Element AtIndex ( 5 , Ġinitial M zy ) ĊĊĠĠĠĠĠĠĠ Ġmm . set Element AtIndex ( 6 , Ġinitial M xz ) ĊĠĠĠĠĠĠĠ Ġmm . set Element AtIndex ( 7 , Ġinitial My z ) ĊĠĠĠĠĠĠĠ Ġmm . set Element AtIndex ( 8 , Ġinitial Sz ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial Mm Ġ= Ġmm ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( mm , Ġcal ibr ator . initial Mm ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġcal ibr ator . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġcal ibr ator . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġcal ibr ator . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġcal ibr ator . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġcal ibr ator . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġcal ibr ator . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġcal ibr ator . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġcal ibr ator . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġcal ibr ator . initial M zy , Ġ 0 . 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġinitial Mm _ when Invalid Row Size _ throws IllegalArgumentException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmm Ġ= ĠMatrix ( 1 , ĠMM _ SIZE ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial Mm Ġ= Ġmm ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġinitial Mm _ when Invalid Columns Size _ throws IllegalArgumentException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmm Ġ= ĠMatrix ( MM _ SIZE , Ġ 1 ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial Mm Ġ= Ġmm ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġinitial Mm _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . initial Mm Ġ= ĠMatrix ( MM _ SIZE , ĠMM _ SIZE ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Initial Mm _ returns Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġmm Ġ= ĠMatrix ( MM _ SIZE , ĠMM _ SIZE ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . get Initial Mm ( mm ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġmm . getElement AtIndex ( 0 ), Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġmm . getElement AtIndex ( 1 ), Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġmm . getElement AtIndex ( 2 ), Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġmm . getElement AtIndex ( 3 ), Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġmm . getElement AtIndex ( 4 ), Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġmm . getElement AtIndex ( 5 ), Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġmm . getElement AtIndex ( 6 ), Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġmm . getElement AtIndex ( 7 ), Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġmm . getElement AtIndex ( 8 ), Ġ 0 . 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġget Initial Mm _ when Invalid Row Size _ throws IllegalArgumentException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmm Ġ= ĠMatrix ( 1 , ĠMM _ SIZE ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . get Initial Mm ( mm ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġget Initial Mm _ when Invalid Column Size _ throws IllegalArgumentException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmm Ġ= ĠMatrix ( MM _ SIZE , Ġ 1 ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . get Initial Mm ( mm ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġis Common Axis Used _ when Not Running _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Common Axis Used ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġtrue ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Common Axis Used ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġis Common Axis Used _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġtrue ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġrequired Measure ments _ when Valid _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator . UNKNOWN _ HARD _ IRON _ MIN IMUM _ MEAS UREMENT S _ GENERAL , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġcal ibr ator . required Measure ments Ġ= ĠREQUIRED _ MEAS UREMENT S ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( REQUIRED _ MEAS UREMENT S , Ġcal ibr ator . required Measure ments ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġrequired Measure ments _ when Invalid _ throws IllegalArgumentException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . required Measure ments Ġ= Ġ 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġrequired Measure ments _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . required Measure ments Ġ= ĠREQUIRED _ MEAS UREMENT S ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġrobust Method _ when Not Running _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . rob ust Method ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . RAN S AC ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . RAN S AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġrobust Method _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . RAN S AC ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġrobust Confidence _ when Valid _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator . RO BU ST _ DEFAULT _ CONF ID ENCE , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġrobust Confidence _ when Invalid Lower Bound _ throws IllegalArgumentException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= Ġ- 1 . 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġrobust Confidence _ when Invalid Upper Bound _ throws IllegalArgumentException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= Ġ 2 . 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġrobust Confidence _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġrobust Max Iterations _ when Valid _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator . RO BU ST _ DEFAULT _ MAX _ ITER ATIONS , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġrobust Max Iterations _ when Invalid _ throws IllegalArgumentException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= Ġ 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġrobust Max Iterations _ when Running _ throws IllegalArgumentException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġrobust Pre limin ary Sub setSize _ when Valid _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator . UNKNOWN _ HARD _ IRON _ MIN IMUM _ MEAS UREMENT S _ GENERAL , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġrobust Pre limin ary Sub setSize _ when Invalid _ throws IllegalArgumentException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= Ġ 1 2 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġrobust Pre limin ary Sub setSize _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġrobust Threshold _ when Valid _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . rob ust Threshold ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= ĠRO BU ST _ THRESHOLD ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġrobust Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= Ġnull ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . rob ust Threshold ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġrobust Threshold _ when Invalid _ throws IllegalArgumentException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= Ġ 0 . 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġrobust Threshold _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= ĠRO BU ST _ THRESHOLD ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġrobust Threshold Factor _ when Valid _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator . DEFAULT _ RO BU ST _ THRESHOLD _ FACTOR , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= ĠRO BU ST _ THRESHOLD _ FACTOR ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġrobust Threshold Factor _ when Invalid _ throws IllegalArgumentException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= Ġ 0 . 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġrobust Threshold Factor _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= ĠRO BU ST _ THRESHOLD _ FACTOR ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġrobust Stop Threshold Factor _ when Valid _ sets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator . DEFAULT _ RO BU ST _ STOP _ THRESHOLD _ FACTOR , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Stop Threshold Factor , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Stop Threshold Factor Ġ= ĠRO BU ST _ STOP _ THRESHOLD _ FACTOR ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ STOP _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Stop Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalArgumentException :: class ) ĊĠĠĠ Ġfun Ġrobust Stop Threshold Factor _ when Invalid _ throws IllegalArgumentException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Stop Threshold Factor Ġ= Ġ 0 . 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġrobust Stop Threshold Factor _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Stop Threshold Factor Ġ= ĠRO BU ST _ STOP _ THRESHOLD _ FACTOR ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Initialization Started _ when No Listener Available _ m akes No Action () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Initialization Started Listener : ĠInterval Detector . On Initialization Started Listener < Mag net ometer Interval Detector >? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġget Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Cal ibr ator :: class , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" interval Detector Initialization Started Listener " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector Initialization Started Listener ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Ġ= Ġmock k < Mag net ometer Interval Detector >() ĊĠĠĠĠĠĠĠ Ġinterval Detector Initialization Started Listener . on Initialization Started ( interval Detector ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Initialization Started _ when Listener Available _ not ifies () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġinitialization Started Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Initialization Started Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrelax Unit Fun Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitialization Started Listener Ġ= Ġinitialization Started Listener ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Initialization Started Listener : ĠInterval Detector . On Initialization Started Listener < Mag net ometer Interval Detector >? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġget Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Cal ibr ator :: class , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" interval Detector Initialization Started Listener " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector Initialization Started Listener ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Ġ= Ġmock k < Mag net ometer Interval Detector >() ĊĠĠĠĠĠĠĠ Ġinterval Detector Initialization Started Listener . on Initialization Started ( interval Detector ) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinitialization Started Listener . on Initialization Started ( cal ibr ator ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Initialization Completed _ when No Listener Available _ m akes No Action () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Initialization Completed Listener : ĠInterval Detector . On Initialization Completed Listener < Mag net ometer Interval Detector >? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġget Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Cal ibr ator :: class , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" interval Detector Initialization Completed Listener " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector Initialization Completed Listener ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Ġ= Ġmock k < Mag net ometer Interval Detector >() ĊĠĠĠĠĠĠĠ Ġinterval Detector Initialization Completed Listener . on Initialization Completed ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinterval Detector , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbase Noise Level ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Initialization Completed _ when Listener Available _ not ifies () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġinitialization Completed Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Initialization Completed Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrelax Unit Fun Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitialization Completed Listener Ġ= Ġinitialization Completed Listener ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Initialization Completed Listener : ĠInterval Detector . On Initialization Completed Listener < Mag net ometer Interval Detector >? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġget Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Cal ibr ator :: class , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" interval Detector Initialization Completed Listener " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector Initialization Completed Listener ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Ġ= Ġmock k < Mag net ometer Interval Detector >() ĊĠĠĠĠĠĠĠ Ġinterval Detector Initialization Completed Listener . on Initialization Completed ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinterval Detector , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbase Noise Level ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinitialization Completed Listener . on Initialization Completed ( cal ibr ator ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠonError _ when No Listeners _ stops Collector () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . running ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Error Listener : ĠInterval Detector . OnError Listener < Mag net ometer Interval Detector >? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġget Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Cal ibr ator :: class , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" interval Detector Error Listener " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector Error Listener ) ĊĊĠĠĠĠĠĠĠ Ġinterval Detector Error Listener . onError ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinterval Detector Spy , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠError Reason . UN RE LI ABLE _ SENSOR ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . running ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinterval Detector Spy . stop () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠonError _ when Listeners Available _ stops And Not ifies () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġerror Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . OnError Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrelax Unit Fun Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġstopped Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Stopped Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrelax Unit Fun Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġerror Listener Ġ= Ġerror Listener , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstopped Listener Ġ= Ġstopped Listener ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . running ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Error Listener : ĠInterval Detector . OnError Listener < Mag net ometer Interval Detector >? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġget Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Cal ibr ator :: class , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" interval Detector Error Listener " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector Error Listener ) ĊĊĠĠĠĠĠĠĠ Ġinterval Detector Error Listener . onError ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinterval Detector Spy , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠError Reason . UN RE LI ABLE _ SENSOR ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . running ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinterval Detector Spy . stop () Ġ} ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġerror Listener . onError ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠCal ibr ator Error Reason . UN RE LI ABLE _ SENSOR ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġstopped Listener . on Stopped ( cal ibr ator ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Dynamic Interval Detected _ adds One Measurement () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . measure ments . isEmpty ()) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Dynamic Interval Detected Listener : ĠInterval Detector . On Dynamic Interval Detected Listener < Mag net ometer Interval Detector >? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector Dynamic Interval Detected Listener ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector Dynamic Interval Detected Listener ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Ġ= Ġmock k < Mag net ometer Interval Detector >() ĊĠĠĠĠĠĠĠ Ġinterval Detector Dynamic Interval Detected Listener . on Dynamic Interval Detected ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinterval Detector , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 2 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 3 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 4 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 5 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 6 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 7 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 8 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 9 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 0 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 1 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 2 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġcal ibr ator . measure ments . size ) ĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġcal ibr ator . measure ments [ 0 ] ĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= Ġmeasurement . mag netic Flux Density ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 7 . 0 , Ġb . bx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 8 . 0 , Ġb . by , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 9 . 0 , Ġb . bz , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġstd Norm Ġ= Ġsqrt ( 1 0 . 0 . pow ( 2 . 0 ) Ġ+ Ġ 1 1 . 0 . pow ( 2 . 0 ) Ġ+ Ġ 1 2 . 0 . pow ( 2 . 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( std Norm , Ġmeasurement . mag netic Flux Density Standard De viation , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ready ToS olve Calibration ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Dynamic Interval Detected _ when No Initial Mag netic Flux Density Norm And No Location _ sets Initial Mag netic Flux Density Norm () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Mag netic Flux Density Norm ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . location ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Initial Mag netic Flux Density Norm Measured ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Dynamic Interval Detected Listener : ĠInterval Detector . On Dynamic Interval Detected Listener < Mag net ometer Interval Detector >? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector Dynamic Interval Detected Listener ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector Dynamic Interval Detected Listener ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Ġ= Ġmock k < Mag net ometer Interval Detector >() ĊĠĠĠĠĠĠĠ Ġinterval Detector Dynamic Interval Detected Listener . on Dynamic Interval Detected ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinterval Detector , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 2 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 3 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 4 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 5 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 6 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 7 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 8 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 9 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 0 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 1 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 2 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġnorm Ġ= Ġsqrt ( 7 . 0 . pow ( 2 . 0 ) Ġ+ Ġ 8 . 0 . pow ( 2 . 0 ) Ġ+ Ġ 9 . 0 . pow ( 2 . 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Dynamic Interval Detected _ when Initial Mag netic Flux Density Norm And No Location _ keep s Initial Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Mag netic Flux Density Norm ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . location ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Initial Mag netic Flux Density Norm Measured ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Dynamic Interval Detected Listener : ĠInterval Detector . On Dynamic Interval Detected Listener < Mag net ometer Interval Detector >? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector Dynamic Interval Detected Listener ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector Dynamic Interval Detected Listener ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Ġ= Ġmock k < Mag net ometer Interval Detector >() ĊĠĠĠĠĠĠĠ Ġinterval Detector Dynamic Interval Detected Listener . on Dynamic Interval Detected ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinterval Detector , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 2 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 3 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 4 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 5 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 6 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 7 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 8 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 9 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 0 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 1 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 2 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġnorm Ġ= Ġsqrt ( 7 . 0 . pow ( 2 . 0 ) Ġ+ Ġ 8 . 0 . pow ( 2 . 0 ) Ġ+ Ġ 9 . 0 . pow ( 2 . 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcall Ġagain Ġwith Ġnew Ġvalues ĊĠĠĠĠĠĠĠ Ġinterval Detector Dynamic Interval Detected Listener . on Dynamic Interval Detected ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinterval Detector , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġthat Ġvalue Ġis Ġpreserved ĊĠĠĠĠĠĠĠ ĠassertEquals ( norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Dynamic Interval Detected _ when No Initial Mag netic Flux Density Norm And Location _ does Not Set Initial Mag netic Flux Density Norm () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlocation Ġ= Ġget Location () ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context , Ġlocation ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Mag netic Flux Density Norm ) ĊĠĠĠĠĠĠĠ ĠassertSame ( location , Ġcal ibr ator . location ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Initial Mag netic Flux Density Norm Measured ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Dynamic Interval Detected Listener : ĠInterval Detector . On Dynamic Interval Detected Listener < Mag net ometer Interval Detector >? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector Dynamic Interval Detected Listener ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector Dynamic Interval Detected Listener ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Ġ= Ġmock k < Mag net ometer Interval Detector >() ĊĠĠĠĠĠĠĠ Ġinterval Detector Dynamic Interval Detected Listener . on Dynamic Interval Detected ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinterval Detector , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 2 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 3 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 4 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 5 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 6 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 7 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 8 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 9 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 0 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 1 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 2 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Mag netic Flux Density Norm ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Dynamic Interval Detected _ when New Calibration Measurement Available _ not ifies () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġnew Calibration Measurement Available Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On New Calibration Measurement Available Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator , ĠStandard De viation Body Mag netic Flux Density >>( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrelax Unit Fun Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnew Calibration Measurement Available Listener Ġ= Ġnew Calibration Measurement Available Listener ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Dynamic Interval Detected Listener : ĠInterval Detector . On Dynamic Interval Detected Listener < Mag net ometer Interval Detector >? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector Dynamic Interval Detected Listener ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector Dynamic Interval Detected Listener ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Ġ= Ġmock k < Mag net ometer Interval Detector >() ĊĠĠĠĠĠĠĠ Ġinterval Detector Dynamic Interval Detected Listener . on Dynamic Interval Detected ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinterval Detector , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 2 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 3 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 4 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 5 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 6 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 7 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 8 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 9 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 0 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 1 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 2 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġcal ibr ator . measure ments . size ) ĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġcal ibr ator . measure ments [ 0 ] ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Size Ġ= Ġcal ibr ator . measure ments . size ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġmeasurement Size ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrequired Measure ments Ġ= Ġcal ibr ator . required Measure ments ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġrequired Measure ments ) ĊĠĠĠĠĠĠĠ Ġval Ġminimum Required Measure ments Ġ= Ġcal ibr ator . minimum Required Measure ments ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġminimum Required Measure ments ) ĊĠĠĠĠĠĠĠ Ġval Ġreq Measure ments Ġ= Ġrequired Measure ments . coerce At Least ( minimum Required Measure ments ) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnew Calibration Measurement Available Listener . on New Calibration Measurement Available ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmeasurement , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmeasurement Size , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġreq Measure ments ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ready ToS olve Calibration ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Dynamic Interval Detected _ when En ough Measure ments And Not Solve Cal ibr ator _ stops Collector And Build Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsolve Calibration When En ough Measure ments Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrequired Measure ments Ġ= Ġcal ibr ator . required Measure ments ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġrequired Measure ments ) ĊĠĠĠĠĠĠĠ Ġval Ġminimum Required Measure ments Ġ= Ġcal ibr ator . minimum Required Measure ments ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġminimum Required Measure ments ) ĊĠĠĠĠĠĠĠ Ġval Ġreq Measure ments Ġ= Ġrequired Measure ments . coerce At Least ( minimum Required Measure ments ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 1 : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ ĠassertNull ( internal Cal ibr ator 1 ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . running ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Dynamic Interval Detected Listener : ĠInterval Detector . On Dynamic Interval Detected Listener < Mag net ometer Interval Detector >? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector Dynamic Interval Detected Listener ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector Dynamic Interval Detected Listener ) ĊĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. req Measure ments ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinterval Detector Dynamic Interval Detected Listener . on Dynamic Interval Detected ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġinterval Detector , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 1 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 2 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 3 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 4 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 5 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 6 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 7 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 8 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 9 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 1 0 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 1 1 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 1 2 . 0 ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( req Measure ments , Ġcal ibr ator . measure ments . size ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . running ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinterval Detector Spy . stop () Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ ĠassertNotNull ( internal Cal ibr ator 2 ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ready ToS olve Calibration ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Dynamic Interval Detected _ when Listeners Available _ not ifies () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġready ToS olve Calibration Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Ready ToS olve Calibration Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrelax Unit Fun Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġstopped Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Stopped Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrelax Unit Fun Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsolve Calibration When En ough Measure ments Ġ= Ġfalse , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġready ToS olve Calibration Listener Ġ= Ġready ToS olve Calibration Listener , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstopped Listener Ġ= Ġstopped Listener ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrequired Measure ments Ġ= Ġcal ibr ator . required Measure ments ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġrequired Measure ments ) ĊĠĠĠĠĠĠĠ Ġval Ġminimum Required Measure ments Ġ= Ġcal ibr ator . minimum Required Measure ments ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġminimum Required Measure ments ) ĊĠĠĠĠĠĠĠ Ġval Ġreq Measure ments Ġ= Ġrequired Measure ments . coerce At Least ( minimum Required Measure ments ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 1 : ĠAcc eler ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ ĠassertNull ( internal Cal ibr ator 1 ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . running ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Dynamic Interval Detected Listener : ĠInterval Detector . On Dynamic Interval Detected Listener < Mag net ometer Interval Detector >? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector Dynamic Interval Detected Listener ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector Dynamic Interval Detected Listener ) ĊĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. req Measure ments ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinterval Detector Dynamic Interval Detected Listener . on Dynamic Interval Detected ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġinterval Detector , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 1 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 2 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 3 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 4 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 5 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 6 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 7 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 8 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 9 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 1 0 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 1 1 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 1 2 . 0 ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( req Measure ments , Ġcal ibr ator . measure ments . size ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . running ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġready ToS olve Calibration Listener . on Ready ToS olve Calibration ( cal ibr ator ) Ġ} ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġstopped Listener . on Stopped ( cal ibr ator ) Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ready ToS olve Calibration ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Dynamic Interval Detected _ when Solve Calibration Enabled _ sol ves Calibration () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġw mm Estimator Ġ= ĠWM ME arth Mag netic Flux Density Estimator () ĊĊĠĠĠĠĠĠĠ Ġval Ġlocation Ġ= Ġget Location () ĊĠĠĠĠĠĠĠ Ġval Ġtimestamp Ġ= ĠDate () ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsolve Calibration When En ough Measure ments Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĊĠĠĠĠĠĠĠ Ġval Ġn ed Position Ġ= Ġlocation . to N ED Position () ĊĊĠĠĠĠĠĠĠ Ġval Ġrequired Measure ments Ġ= Ġcal ibr ator . required Measure ments ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġrequired Measure ments ) ĊĠĠĠĠĠĠĠ Ġval Ġminimum Required Measure ments Ġ= Ġcal ibr ator . minimum Required Measure ments ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġminimum Required Measure ments ) ĊĠĠĠĠĠĠĠ Ġval Ġreq Measure ments Ġ= Ġrequired Measure ments . coerce At Least ( minimum Required Measure ments ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Dynamic Interval Detected Listener : ĠInterval Detector . On Dynamic Interval Detected Listener < Mag net ometer Interval Detector >? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector Dynamic Interval Detected Listener ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector Dynamic Interval Detected Listener ) ĊĊĠĠĠĠĠĠĠ Ġval Ġhard I ron Ġ= Ġgenerate Hard I ron () ĊĠĠĠĠĠĠĠ Ġval Ġmm Ġ= Ġgenerate Soft I ron () ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. req Measure ments ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġroll Ġ= ĠMath . to Radians ( random izer . next Double ( MIN _ ANGLE _ DE GRE ES , ĠMAX _ ANGLE _ DE GRE ES )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġpitch Ġ= ĠMath . to Radians ( random izer . next Double ( MIN _ ANGLE _ DE GRE ES , ĠMAX _ ANGLE _ DE GRE ES )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġyaw Ġ= ĠMath . to Radians ( random izer . next Double ( MIN _ ANGLE _ DE GRE ES , ĠMAX _ ANGLE _ DE GRE ES )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġc nb Ġ= ĠCoordinate Transformation ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġroll , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġpitch , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġyaw , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠFrame Type . LOCAL _ NAV IG ATION _ FRAME , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠFrame Type . BODY _ FRAME ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġearth B Ġ= Ġw mm Estimator . estimate ( ned Position , Ġtimestamp ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġtruth Mag netic Ġ= ĠBody Mag netic Flux Density Estimator . estimate ( earth B , Ġc nb ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġmeasured Mag netic Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠBody Mag netic Flux Density Generator . generate ( truth Mag netic , Ġhard I ron , Ġmm ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġnoise Random izer Ġ= ĠGaussian Random izer ( Random (), Ġ 0 . 0 , ĠMAG NET O METER _ NO ISE _ STD ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmeasured Mag netic . bx Ġ= Ġmeasured Mag netic . bx Ġ+ Ġnoise Random izer . next Double () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmeasured Mag netic . by Ġ= Ġmeasured Mag netic . by Ġ+ Ġnoise Random izer . next Double () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmeasured Mag netic . bz Ġ= Ġmeasured Mag netic . bz Ġ+ Ġnoise Random izer . next Double () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġstd Ġ= Ġnoise Random izer . standard De viation ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġinterval Detector Dynamic Interval Detected Listener . on Dynamic Interval Detected ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġinterval Detector , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 1 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 2 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 3 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 4 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 5 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 6 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmeasured Mag netic . bx , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmeasured Mag netic . by , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmeasured Mag netic . bz , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġstd , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġstd , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġstd ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Mm ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Sx ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Sy ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Sz ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated M xy ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated M xz ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated My x ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated My z ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Mz x ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated M zy ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Co variance ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Chi Sq ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated M se ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Hard I ron X ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Hard I ron Y ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Hard I ron Z ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Hard I ron X As Measurement ) ĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . get Est imated Hard I ron X As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Hard I ron Y As Measurement ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . get Est imated Hard I ron Y As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Hard I ron Z As Measurement ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . get Est imated Hard I ron Z As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Hard I ron As Tri ad ) ĊĠĠĠĠĠĠĠ Ġval Ġtri ad Ġ= ĠMag netic Flux Density Tri ad () ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . get Est imated Hard I ron As Tri ad ( tri ad )) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ready ToS olve Calibration ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Dynamic Interval Detected _ when Solve Calibration Enabled And Listener Available _ sol ves Calibration And Not ifies () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġready ToS olve Calibration Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Ready ToS olve Calibration Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrelax Unit Fun Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġstopped Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Stopped Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrelax Unit Fun Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġcalibration Sol ving Started Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Calibration Sol ving Started Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrelax Unit Fun Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġcalibration Completed Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Calibration Completed Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrelax Unit Fun Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġerror Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . OnError Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrelax Unit Fun Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġw mm Estimator Ġ= ĠWM ME arth Mag netic Flux Density Estimator () ĊĊĠĠĠĠĠĠĠ Ġval Ġlocation Ġ= Ġget Location () ĊĠĠĠĠĠĠĠ Ġval Ġtimestamp Ġ= ĠDate () ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsolve Calibration When En ough Measure ments Ġ= Ġtrue , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġready ToS olve Calibration Listener Ġ= Ġready ToS olve Calibration Listener , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstopped Listener Ġ= Ġstopped Listener , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcalibration Sol ving Started Listener Ġ= Ġcalibration Sol ving Started Listener , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcalibration Completed Listener Ġ= Ġcalibration Completed Listener , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġerror Listener Ġ= Ġerror Listener ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĊĠĠĠĠĠĠĠ Ġval Ġn ed Position Ġ= Ġlocation . to N ED Position () ĊĊĠĠĠĠĠĠĠ Ġval Ġrequired Measure ments Ġ= Ġcal ibr ator . required Measure ments ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġrequired Measure ments ) ĊĠĠĠĠĠĠĠ Ġval Ġminimum Required Measure ments Ġ= Ġcal ibr ator . minimum Required Measure ments ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġminimum Required Measure ments ) ĊĠĠĠĠĠĠĠ Ġval Ġreq Measure ments Ġ= Ġrequired Measure ments . coerce At Least ( minimum Required Measure ments ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Dynamic Interval Detected Listener : ĠInterval Detector . On Dynamic Interval Detected Listener < Mag net ometer Interval Detector >? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector Dynamic Interval Detected Listener ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector Dynamic Interval Detected Listener ) ĊĊĠĠĠĠĠĠĠ Ġval Ġhard I ron Ġ= Ġgenerate Hard I ron () ĊĠĠĠĠĠĠĠ Ġval Ġmm Ġ= Ġgenerate Soft I ron () ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. req Measure ments ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġroll Ġ= ĠMath . to Radians ( random izer . next Double ( MIN _ ANGLE _ DE GRE ES , ĠMAX _ ANGLE _ DE GRE ES )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġpitch Ġ= ĠMath . to Radians ( random izer . next Double ( MIN _ ANGLE _ DE GRE ES , ĠMAX _ ANGLE _ DE GRE ES )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġyaw Ġ= ĠMath . to Radians ( random izer . next Double ( MIN _ ANGLE _ DE GRE ES , ĠMAX _ ANGLE _ DE GRE ES )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġc nb Ġ= ĠCoordinate Transformation ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġroll , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġpitch , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġyaw , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠFrame Type . LOCAL _ NAV IG ATION _ FRAME , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠFrame Type . BODY _ FRAME ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġearth B Ġ= Ġw mm Estimator . estimate ( ned Position , Ġtimestamp ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġtruth Mag netic Ġ= ĠBody Mag netic Flux Density Estimator . estimate ( earth B , Ġc nb ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġmeasured Mag netic Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠBody Mag netic Flux Density Generator . generate ( truth Mag netic , Ġhard I ron , Ġmm ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġnoise Random izer Ġ= ĠGaussian Random izer ( Random (), Ġ 0 . 0 , ĠMAG NET O METER _ NO ISE _ STD ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmeasured Mag netic . bx Ġ= Ġmeasured Mag netic . bx Ġ+ Ġnoise Random izer . next Double () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmeasured Mag netic . by Ġ= Ġmeasured Mag netic . by Ġ+ Ġnoise Random izer . next Double () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmeasured Mag netic . bz Ġ= Ġmeasured Mag netic . bz Ġ+ Ġnoise Random izer . next Double () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġstd Ġ= Ġnoise Random izer . standard De viation ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġinterval Detector Dynamic Interval Detected Listener . on Dynamic Interval Detected ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġinterval Detector , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 1 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 2 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 3 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 4 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 5 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 6 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmeasured Mag netic . bx , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmeasured Mag netic . by , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmeasured Mag netic . bz , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġstd , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġstd , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġstd ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Mm ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Sx ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Sy ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Sz ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated M xy ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated M xz ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated My x ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated My z ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Mz x ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated M zy ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Co variance ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Chi Sq ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated M se ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Hard I ron X ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Hard I ron Y ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Hard I ron Z ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Hard I ron X As Measurement ) ĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . get Est imated Hard I ron X As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Hard I ron Y As Measurement ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . get Est imated Hard I ron Y As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Hard I ron Z As Measurement ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . get Est imated Hard I ron Z As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . estimated Hard I ron As Tri ad ) ĊĠĠĠĠĠĠĠ Ġval Ġtri ad Ġ= ĠMag netic Flux Density Tri ad () ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . get Est imated Hard I ron As Tri ad ( tri ad )) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġready ToS olve Calibration Listener . on Ready ToS olve Calibration ( cal ibr ator ) Ġ} ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġstopped Listener . on Stopped ( cal ibr ator ) Ġ} ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcalibration Sol ving Started Listener . on Calibration Sol ving Started ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġcalibration Completed Listener . on Calibration Completed ( cal ibr ator ) Ġ} ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġerror Listener Ġwas Not ĠCalled Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ready ToS olve Calibration ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Measurement _ when First Measurement _ updates Initial Hard I ron s () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron X ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Y ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Z ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . numberOf Processed Measure ments Ġ}. returns ( 0 ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Measurement Listener : ĠMag net ometer Sensor Collector . On Measurement Listener ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector Measurement Listener ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector Measurement Listener ) ĊĊĠĠĠĠĠĠĠ Ġinterval Detector Measurement Listener . on Measurement ( ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 2 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 3 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 4 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 5 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 6 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSystem Clock . elapsed Realtime Nan os (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSensor Accuracy . HIGH ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron X Ġ= Ġcal ibr ator . initial Hard I ron X ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( initial Hard I ron X ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Y Ġ= Ġcal ibr ator . initial Hard I ron Y ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( initial Hard I ron Y ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Z Ġ= Ġcal ibr ator . initial Hard I ron Z ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( initial Hard I ron Z ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 4 . 0 e - 6 , Ġinitial Hard I ron X , ĠSMALL _ AB SOL UTE _ ERROR ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 5 . 0 e - 6 , Ġinitial Hard I ron Y , ĠSMALL _ AB SOL UTE _ ERROR ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 6 . 0 e - 6 , Ġinitial Hard I ron Z , ĠSMALL _ AB SOL UTE _ ERROR ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Measurement _ when First Measurement And No Hard I ron X _ updates Initial Hard I ron s () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron X ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Y ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Z ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . numberOf Processed Measure ments Ġ}. returns ( 0 ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Measurement Listener : ĠMag net ometer Sensor Collector . On Measurement Listener ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector Measurement Listener ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector Measurement Listener ) ĊĊĠĠĠĠĠĠĠ Ġinterval Detector Measurement Listener . on Measurement ( ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 2 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 3 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnull , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 5 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 6 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSystem Clock . elapsed Realtime Nan os (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSensor Accuracy . HIGH ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron X Ġ= Ġcal ibr ator . initial Hard I ron X ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( initial Hard I ron X ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Y Ġ= Ġcal ibr ator . initial Hard I ron Y ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( initial Hard I ron Y ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Z Ġ= Ġcal ibr ator . initial Hard I ron Z ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( initial Hard I ron Z ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinitial Hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinitial Hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinitial Hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Measurement _ when First Measurement And No Hard I ron Y _ updates Initial Hard I ron s () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron X ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Y ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Z ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . numberOf Processed Measure ments Ġ}. returns ( 0 ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Measurement Listener : ĠMag net ometer Sensor Collector . On Measurement Listener ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector Measurement Listener ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector Measurement Listener ) ĊĊĠĠĠĠĠĠĠ Ġinterval Detector Measurement Listener . on Measurement ( ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 2 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 3 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 4 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnull , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 6 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSystem Clock . elapsed Realtime Nan os (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSensor Accuracy . HIGH ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron X Ġ= Ġcal ibr ator . initial Hard I ron X ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( initial Hard I ron X ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Y Ġ= Ġcal ibr ator . initial Hard I ron Y ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( initial Hard I ron Y ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Z Ġ= Ġcal ibr ator . initial Hard I ron Z ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( initial Hard I ron Z ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinitial Hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinitial Hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinitial Hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Measurement _ when First Measurement And No Hard I ron Z _ updates Initial Hard I ron s () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron X ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Y ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Z ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . numberOf Processed Measure ments Ġ}. returns ( 0 ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Measurement Listener : ĠMag net ometer Sensor Collector . On Measurement Listener ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector Measurement Listener ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector Measurement Listener ) ĊĊĠĠĠĠĠĠĠ Ġinterval Detector Measurement Listener . on Measurement ( ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 2 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 3 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 4 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 5 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnull , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSystem Clock . elapsed Realtime Nan os (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSensor Accuracy . HIGH ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron X Ġ= Ġcal ibr ator . initial Hard I ron X ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( initial Hard I ron X ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Y Ġ= Ġcal ibr ator . initial Hard I ron Y ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( initial Hard I ron Y ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Z Ġ= Ġcal ibr ator . initial Hard I ron Z ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( initial Hard I ron Z ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinitial Hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinitial Hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinitial Hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Measurement _ when First Measurement And Listener _ updates Initial Bi ases And Not ifies () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Available Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Mag net ometer Cal ibr ator . On Initial Hard I ron Available Listener >( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrelax Unit Fun Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Hard I ron Available Listener Ġ= Ġinitial Hard I ron Available Listener ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron X ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Y ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Z ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . numberOf Processed Measure ments Ġ}. returns ( 0 ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Measurement Listener : ĠMag net ometer Sensor Collector . On Measurement Listener ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector Measurement Listener ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector Measurement Listener ) ĊĊĠĠĠĠĠĠĠ Ġinterval Detector Measurement Listener . on Measurement ( ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 2 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 3 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnull , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnull , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnull , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSystem Clock . elapsed Realtime Nan os (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSensor Accuracy . HIGH ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron X Ġ= Ġcal ibr ator . initial Hard I ron X ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( initial Hard I ron X ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Y Ġ= Ġcal ibr ator . initial Hard I ron Y ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( initial Hard I ron Y ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Z Ġ= Ġcal ibr ator . initial Hard I ron Z ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( initial Hard I ron Z ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinitial Hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinitial Hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinitial Hard I ron Z , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Hard I ron Available Listener . on Initial Hard I ron Available ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Measurement _ when Not First Measurement _ m akes No Action () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron X ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Y ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Z ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . numberOf Processed Measure ments Ġ}. returns ( 2 ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Measurement Listener : ĠMag net ometer Sensor Collector . On Measurement Listener ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector Measurement Listener ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector Measurement Listener ) ĊĊĠĠĠĠĠĠĠ Ġinterval Detector Measurement Listener . on Measurement ( ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 2 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 3 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 4 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 5 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 6 . 0 f , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSystem Clock . elapsed Realtime Nan os (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSensor Accuracy . HIGH ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron X ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Y ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Z ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinitial Hard I ron X _ gets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron X ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron X ", Ġinitial Hard I ron X ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron X , Ġcal ibr ator . initial Hard I ron X ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinitial Hard I ron Y _ gets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Y ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Y ", Ġinitial Hard I ron Y ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Y , Ġcal ibr ator . initial Hard I ron Y ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinitial Hard I ron Z _ gets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Z ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Z ", Ġinitial Hard I ron Z ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Z , Ġcal ibr ator . initial Hard I ron Z ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinitial Hard I ron X As Measurement _ gets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron X As Measurement ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron X ", Ġinitial Hard I ron X ) ĊĊĠĠĠĠĠĠĠ Ġval Ġhard I ron Ġ= Ġcal ibr ator . initial Hard I ron X As Measurement ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron X , Ġhard I ron . value . toDouble (), Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mag netic Flux Density Unit . TES LA , Ġhard I ron . unit ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Initial Hard I ron X As Measurement _ gets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġhard I ron Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Initial Hard I ron X As Measurement ( hard I ron )) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron X ", Ġinitial Hard I ron X ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . get Initial Hard I ron X As Measurement ( hard I ron )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron X , Ġhard I ron . value . toDouble (), Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mag netic Flux Density Unit . TES LA , Ġhard I ron . unit ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinitial Hard I ron Y As Measurement _ gets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Y As Measurement ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Y ", Ġinitial Hard I ron Y ) ĊĊĠĠĠĠĠĠĠ Ġval Ġhard I ron Ġ= Ġcal ibr ator . initial Hard I ron Y As Measurement ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Y , Ġhard I ron . value . toDouble (), Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mag netic Flux Density Unit . TES LA , Ġhard I ron . unit ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Initial Hard I ron Y As Measurement _ gets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġhard I ron Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Initial Hard I ron Y As Measurement ( hard I ron )) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Y ", Ġinitial Hard I ron Y ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . get Initial Hard I ron Y As Measurement ( hard I ron )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Y , Ġhard I ron . value . toDouble (), Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mag netic Flux Density Unit . TES LA , Ġhard I ron . unit ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinitial Hard I ron Z As Measurement _ gets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Z As Measurement ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Z ", Ġinitial Hard I ron Z ) ĊĊĠĠĠĠĠĠĠ Ġval Ġhard I ron Ġ= Ġcal ibr ator . initial Hard I ron Z As Measurement ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Z , Ġhard I ron . value . toDouble (), Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mag netic Flux Density Unit . TES LA , Ġhard I ron . unit ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Initial Hard I ron Z As Measurement _ gets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġhard I ron Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Initial Hard I ron Z As Measurement ( hard I ron )) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Z ", Ġinitial Hard I ron Z ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . get Initial Hard I ron Z As Measurement ( hard I ron )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Z , Ġhard I ron . value . toDouble (), Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mag netic Flux Density Unit . TES LA , Ġhard I ron . unit ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinitial Hard I ron As Tri ad _ gets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron As Tri ad ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron X ", Ġinitial Hard I ron X ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron As Tri ad ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Y ", Ġinitial Hard I ron Y ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron As Tri ad ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Z ", Ġinitial Hard I ron Z ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġtri ad Ġ= Ġcal ibr ator . initial Hard I ron As Tri ad ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( tri ad ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron X , Ġtri ad . value X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Y , Ġtri ad . value Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Z , Ġtri ad . value Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mag netic Flux Density Unit . TES LA , Ġtri ad . unit ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Initial Hard I ron As Tri ad _ gets Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġtri ad Ġ= ĠMag netic Flux Density Tri ad () ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Initial Hard I ron As Tri ad ( tri ad )) ĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġnew Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron X ", Ġinitial Hard I ron X ) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Initial Hard I ron As Tri ad ( tri ad )) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Y ", Ġinitial Hard I ron Y ) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Initial Hard I ron As Tri ad ( tri ad )) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Z ", Ġinitial Hard I ron Z ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . get Initial Hard I ron As Tri ad ( tri ad )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron X , Ġtri ad . value X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Y , Ġtri ad . value Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Z , Ġtri ad . value Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mag netic Flux Density Unit . TES LA , Ġtri ad . unit ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġmag net ometer Sensor _ gets Interval Detector Sensor () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġsensor Ġ= Ġmock k < Sensor >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . sensor Ġ}. returns ( sensor ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertSame ( sensor , Ġcal ibr ator . mag net ometer Sensor ) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinterval Detector Spy . sensor Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbase Noise Level _ gets Interval Detector Base Noise Level () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . base Noise Level Ġ}. returns ( base Noise Level ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( base Noise Level , Ġcal ibr ator . base Noise Level ) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinterval Detector Spy . base Noise Level Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbase Noise Level As Measurement _ gets Interval Detector Base Noise Level () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . base Noise Level As Measurement ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level 1 Ġ= ĠMag netic Flux Density ( base Noise Level , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . base Noise Level As Measurement Ġ}. returns ( base Noise Level 1 ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level 2 Ġ= Ġcal ibr ator . base Noise Level As Measurement ĊĠĠĠĠĠĠĠ ĠassertSame ( base Noise Level 1 , Ġbase Noise Level 2 ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinterval Detector Spy . base Noise Level As Measurement Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Base Noise Level As Measurement _ gets Interval Detector Base Noise Level () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . getBase Noise Level As Measurement ( b )) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . getBase Noise Level As Measurement ( any ()) Ġ}. answers Ġ{ Ġanswer Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġanswer . invocation . args [ 0 ] Ġas ĠMag netic Flux Density ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . value Ġ= Ġbase Noise Level ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . unit Ġ= ĠMag netic Flux Density Unit . TES LA ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn @ answers Ġtrue ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . getBase Noise Level As Measurement ( b )) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertEquals ( base Noise Level , Ġb . value . toDouble (), Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mag netic Flux Density Unit . TES LA , Ġb . unit ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinterval Detector Spy . getBase Noise Level As Measurement ( b ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbase Noise Level P sd _ gets Interval Detector Base Noise Level P sd () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . base Noise Level P sd ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level P sd Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . base Noise Level P sd Ġ}. returns ( base Noise Level P sd ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( base Noise Level P sd , Ġcal ibr ator . base Noise Level P sd ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinterval Detector Spy . base Noise Level P sd Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbase Noise Level Root P sd _ gets Interval Detector Base Noise Level Root P sd () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . base Noise Level Root P sd ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level Root P sd Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . base Noise Level Root P sd Ġ}. returns ( base Noise Level Root P sd ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( base Noise Level Root P sd , Ġcal ibr ator . base Noise Level Root P sd ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinterval Detector Spy . base Noise Level Root P sd Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġthreshold _ gets Interval Detector Threshold () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . threshold ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġthreshold Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . threshold Ġ}. returns ( threshold ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( threshold , Ġcal ibr ator . threshold ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinterval Detector Spy . threshold Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġthreshold As Measurement _ gets Interval Detector Threshold As Measurement () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . threshold As Measurement ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġthreshold Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= ĠMag netic Flux Density ( threshold , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . threshold As Measurement Ġ}. returns ( b ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertSame ( b , Ġcal ibr ator . threshold As Measurement ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinterval Detector Spy . threshold As Measurement Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Threshold As Measurement _ gets Interval Detector Threshold As Measurement () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Threshold As Measurement ( b )) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġthreshold Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . get Threshold As Measurement ( any ()) Ġ}. answers Ġ{ Ġanswer Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġanswer . invocation . args [ 0 ] Ġas ĠMag netic Flux Density ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . value Ġ= Ġthreshold ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . unit Ġ= ĠMag netic Flux Density Unit . TES LA ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn @ answers Ġtrue ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . get Threshold As Measurement ( b )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( threshold , Ġb . value . toDouble (), Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mag netic Flux Density Unit . TES LA , Ġb . unit ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinterval Detector Spy . get Threshold As Measurement ( b ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġaverage Time Interval _ gets Interval Detector Average Time Interval () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . average Time Interval ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġaverage Time Interval Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . average Time Interval Ġ}. returns ( average Time Interval ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( average Time Interval , Ġcal ibr ator . average Time Interval ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinterval Detector Spy . average Time Interval Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġaverage Time Interval As Time _ gets Interval Detector Average Time Interval () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . average Time Interval As Time ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġaverage Time Interval Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġtime Ġ= ĠTime ( average Time Interval , ĠTimeUnit . SECOND ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . average Time Interval As Time Ġ}. returns ( time ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertSame ( time , Ġcal ibr ator . average Time Interval As Time ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinterval Detector Spy . average Time Interval As Time Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Average Time Interval As Time _ gets Interval Detector Average Time Interval () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġtime Ġ= ĠTime ( 0 . 0 , ĠTimeUnit . SECOND ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Average Time Interval As Time ( time )) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġaverage Time Interval Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . get Average Time Interval As Time ( any ()) Ġ}. answers Ġ{ Ġanswer Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġanswer . invocation . args [ 0 ] Ġas ĠTime ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . value Ġ= Ġaverage Time Interval ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . unit Ġ= ĠTimeUnit . SECOND ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn @ answers Ġtrue ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . get Average Time Interval As Time ( time )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( average Time Interval , Ġtime . value . toDouble (), Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( TimeUnit . SECOND , Ġtime . unit ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinterval Detector Spy . get Average Time Interval As Time ( time ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtime Interval Variance _ gets Interval Detector Time Interval Variance () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . time Interval Variance ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġtime Interval Variance Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . time Interval Variance Ġ}. returns ( time Interval Variance ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( time Interval Variance , Ġcal ibr ator . time Interval Variance ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinterval Detector Spy . time Interval Variance Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtime Interval Standard De viation _ gets Interval Detector Time Interval Standard De viation () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . time Interval Standard De viation ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġtime Interval Standard De viation Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . time Interval Standard De viation Ġ}. returns ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtime Interval Standard De viation ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( time Interval Standard De viation , Ġcal ibr ator . time Interval Standard De viation ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinterval Detector Spy . time Interval Standard De viation Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtime Interval Standard De viation As Time _ gets Interval Detector Time Interval Standard De viation () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . time Interval Standard De viation As Time ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġvalue Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġtime Ġ= ĠTime ( value , ĠTimeUnit . SECOND ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . time Interval Standard De viation As Time Ġ}. returns ( time ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertSame ( time , Ġcal ibr ator . time Interval Standard De viation As Time ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinterval Detector Spy . time Interval Standard De viation As Time Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠgetTime Interval Standard De viation As Time _ gets Interval Detector Time Interval Standard De viation () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck Ġdefault Ġvalue ĊĠĠĠĠĠĠĠ Ġval Ġtime Ġ= ĠTime ( 0 . 0 , ĠTimeUnit . SECOND ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . getTime Interval Standard De viation As Time ( time )) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġvalue Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . getTime Interval Standard De viation As Time ( any ()) Ġ}. answers Ġ{ Ġanswer Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġanswer . invocation . args [ 0 ] Ġas ĠTime ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . value Ġ= Ġvalue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . unit Ġ= ĠTimeUnit . SECOND ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn @ answers Ġtrue ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . getTime Interval Standard De viation As Time ( time )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( value , Ġtime . value . toDouble (), Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( TimeUnit . SECOND , Ġtime . unit ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinterval Detector Spy . getTime Interval Standard De viation As Time ( time ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġminimum Required Measure ments _ when Common Axis And Known Hard I ron _ returns Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 7 , Ġcal ibr ator . minimum Required Measure ments ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġminimum Required Measure ments _ when Common Axis And Unknown Hard I ron _ returns Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 , Ġcal ibr ator . minimum Required Measure ments ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġminimum Required Measure ments _ when Not Common Axis And Known Hard I ron _ returns Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 , Ġcal ibr ator . minimum Required Measure ments ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġminimum Required Measure ments _ when Not Common Axis And Unknown Hard I ron _ returns Expected Value () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġcal ibr ator . minimum Required Measure ments ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġstart _ when Not Running _ resets And Starts Interval Detector () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . running ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurements Ġ= Ġcal ibr ator . measure ments ĊĠĠĠĠĠĠĠ Ġval Ġmeasurements Spy Ġ= Ġspy k ( measure ments ) ĊĠĠĠĠĠĠĠ Ġset Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle Sensor Static Interval Cal ibr ator :: class , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" measure ments ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmeasurements Spy ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron X ", Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Y ", Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Z ", Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Mag netic Flux Density Norm ", Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Ġ= Ġmock k < Mag net ometer Non Linear Cal ibr ator >() ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġjust Run Ġ{ Ġinterval Detector Spy . start () Ġ} ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . start () ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġmeasurements Spy . clear () Ġ} ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron X ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Y ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Hard I ron Z ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Mag netic Flux Density Norm ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . get Private Property (" internal Cal ibr ator ")) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . running ) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinterval Detector Spy . start () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġstart _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . running ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . start () ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . running ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . start () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġstop _ stops Interval Detector () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġjust Run Ġ{ Ġinterval Detector Spy . stop () Ġ} ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . running ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . stop () ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . running ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinterval Detector Spy . stop () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġstop _ when Listener Available _ not ifies () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġstopped Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Stopped Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrelax Unit Fun Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstopped Listener Ġ= Ġstopped Listener ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġjust Run Ġ{ Ġinterval Detector Spy . stop () Ġ} ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ Ġset Private Property ( Single Sensor Static Interval Cal ibr ator :: class , Ġcal ibr ator , Ġ" running ", Ġtrue ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . running ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . stop () ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . running ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġinterval Detector Spy . stop () Ġ} ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġstopped Listener . on Stopped ( cal ibr ator ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġcal ibrate _ when Not Ready ToS olve Calibration _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . cal ibrate () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠIllegalStateException :: class ) ĊĠĠĠ Ġfun Ġcal ibrate _ when Running _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" running ", Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . cal ibrate () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcal ibrate _ when Ready Not Running And No Internal Cal ibr ator _ m akes No Action () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ready ToS olve Calibration ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . running ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . cal ibrate ()) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . running ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcal ibrate _ when Ready Not Running And Internal Cal ibr ator And Listeners _ calls Internal Cal ibr ator And Not ifies () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcalibration Sol ving Started Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Calibration Sol ving Started Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrelax Unit Fun Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġcalibration Completed Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . On Calibration Completed Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrelax Unit Fun Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcalibration Sol ving Started Listener Ġ= Ġcalibration Sol ving Started Listener , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcalibration Completed Listener Ġ= Ġcalibration Completed Listener ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ready ToS olve Calibration ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . running ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Ġ= Ġmock k < Mag net ometer Non Linear Cal ibr ator >() ĊĠĠĠĠĠĠĠ Ġjust Run Ġ{ Ġinternal Cal ibr ator . cal ibrate () Ġ} ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . cal ibrate ()) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . running ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcalibration Sol ving Started Listener . on Calibration Sol ving Started ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġcalibration Completed Listener . on Calibration Completed ( cal ibr ator ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcal ibrate _ when Failure _ sets As Not Running () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ready ToS olve Calibration ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . running ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Ġ= Ġmock k < Mag net ometer Non Linear Cal ibr ator >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator . cal ibrate () Ġ}. throws ( Navigation Exception ()) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . cal ibrate ()) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . running ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcal ibrate _ when Failure And Error Listener _ sets As Not Running () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġerror Listener Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock k < Single Sensor Static Interval Cal ibr ator . OnError Listener < Single Sensor Static Interval Mag net ometer Cal ibr ator >>( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrelax Unit Fun Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġerror Listener Ġ= Ġerror Listener ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ready ToS olve Calibration ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . running ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Ġ= Ġmock k < Mag net ometer Non Linear Cal ibr ator >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator . cal ibrate () Ġ}. throws ( Navigation Exception ()) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . cal ibrate ()) ĊĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . running ) ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġerror Listener . onError ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠCal ibr ator Error Reason . NUM ER ICAL _ INST ABILITY _ D UR ING _ CAL IB RATION ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġestimated Hard I ron X _ when No Interval Cal ibr ator _ returns Null () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . get Private Property (" internal Cal ibr ator ")) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Hard I ron X ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġestimated Hard I ron X _ when Unknown Hard I ron Internal Cal ibr ator _ calls Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Spy Ġ= Ġspy k ( Known Position And Instant Mag net ometer Cal ibr ator ()) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator Spy . estimated Hard I ron X Ġ}. returns ( estimated Hard I ron X ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( estimated Hard I ron X , Ġcal ibr ator . estimated Hard I ron X ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġestimated Hard I ron X _ when Known Hard I ron Internal Cal ibr ator _ calls Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Spy Ġ= Ġspy k ( Known Hard I ron Position And Instant Mag net ometer Cal ibr ator ()) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator Spy . hard I ron X Ġ}. returns ( estimated Hard I ron X ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( estimated Hard I ron X , Ġcal ibr ator . estimated Hard I ron X ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġestimated Hard I ron Y _ when No Interval Cal ibr ator _ returns Null () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . get Private Property (" internal Cal ibr ator ")) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Hard I ron Y ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġestimated Hard I ron Y _ when Unknown Hard I ron Internal Cal ibr ator _ calls Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Spy Ġ= Ġspy k ( Known Position And Instant Mag net ometer Cal ibr ator ()) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator Spy . estimated Hard I ron Y Ġ}. returns ( estimated Hard I ron Y ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( estimated Hard I ron Y , Ġcal ibr ator . estimated Hard I ron Y ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġestimated Hard I ron Y _ when Known Hard I ron Internal Cal ibr ator _ calls Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Spy Ġ= Ġspy k ( Known Hard I ron Position And Instant Mag net ometer Cal ibr ator ()) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator Spy . hard I ron Y Ġ}. returns ( estimated Hard I ron Y ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( estimated Hard I ron Y , Ġcal ibr ator . estimated Hard I ron Y ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġestimated Hard I ron Z _ when No Interval Cal ibr ator _ returns Null () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . get Private Property (" internal Cal ibr ator ")) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Hard I ron Z ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġestimated Hard I ron Z _ when Unknown Hard I ron Internal Cal ibr ator _ calls Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Spy Ġ= Ġspy k ( Known Position And Instant Mag net ometer Cal ibr ator ()) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator Spy . estimated Hard I ron Z Ġ}. returns ( estimated Hard I ron Z ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( estimated Hard I ron Z , Ġcal ibr ator . estimated Hard I ron Z ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġestimated Hard I ron Z _ when Known Hard I ron Internal Cal ibr ator _ calls Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Spy Ġ= Ġspy k ( Known Hard I ron Position And Instant Mag net ometer Cal ibr ator ()) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator Spy . hard I ron Z Ġ}. returns ( estimated Hard I ron Z ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( estimated Hard I ron Z , Ġcal ibr ator . estimated Hard I ron Z ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġestimated Hard I ron X As Measurement _ when No Interval Cal ibr ator _ returns Null () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . get Private Property (" internal Cal ibr ator ")) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Hard I ron X As Measurement ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġestimated Hard I ron X As Measurement _ when Unknown Hard I ron Internal Cal ibr ator _ calls Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Spy Ġ= Ġspy k ( Known Position And Instant Mag net ometer Cal ibr ator ()) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= ĠMag netic Flux Density ( estimated Hard I ron X , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator Spy . estimated Hard I ron X As Mag netic Flux Density Ġ}. returns ( b ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertSame ( b , Ġcal ibr ator . estimated Hard I ron X As Measurement ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġestimated Hard I ron X As Measurement _ when Known Hard I ron Internal Cal ibr ator _ calls Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Spy Ġ= Ġspy k ( Known Hard I ron Position And Instant Mag net ometer Cal ibr ator ()) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= ĠMag netic Flux Density ( estimated Hard I ron X , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator Spy . hard I ron X As Mag netic Flux Density Ġ}. returns ( b ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertSame ( b , Ġcal ibr ator . estimated Hard I ron X As Measurement ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Est imated Hard I ron X As Measurement _ when No Internal Cal ibr ator _ returns False () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . get Private Property (" internal Cal ibr ator ")) ĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Est imated Hard I ron X As Measurement ( b )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Est imated Hard I ron X As Measurement _ when Unknown Hard I ron Internal Cal ibr ator _ calls Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Spy Ġ= Ġspy k ( Known Position And Instant Mag net ometer Cal ibr ator ()) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator Spy . get Est imated Hard I ron X As Mag netic Flux Density ( any ()) Ġ}. answers Ġ{ Ġanswer Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġanswer . invocation . args [ 0 ] Ġas ĠMag netic Flux Density ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . value Ġ= Ġestimated Hard I ron X ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . unit Ġ= ĠMag netic Flux Density Unit . TES LA ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn @ answers Ġtrue ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator Spy ) ĊĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . get Est imated Hard I ron X As Measurement ( b )) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( estimated Hard I ron X , Ġb . value . toDouble (), Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mag netic Flux Density Unit . TES LA , Ġb . unit ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Est imated Hard I ron X As Measurement _ when Known Hard I ron Internal Cal ibr ator _ calls Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Spy Ġ= Ġspy k ( Known Hard I ron Position And Instant Mag net ometer Cal ibr ator ()) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator Spy . get Hard I ron X As Mag netic Flux Density ( any ()) Ġ}. answers Ġ{ Ġanswer Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġanswer . invocation . args [ 0 ] Ġas ĠMag netic Flux Density ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . value Ġ= Ġestimated Hard I ron X ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . unit Ġ= ĠMag netic Flux Density Unit . TES LA ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator Spy ) ĊĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . get Est imated Hard I ron X As Measurement ( b )) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( estimated Hard I ron X , Ġb . value . toDouble (), Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mag netic Flux Density Unit . TES LA , Ġb . unit ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġestimated Hard I ron Y As Measurement _ when No Internal Cal ibr ator _ returns Null () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . get Private Property (" internal Cal ibr ator ")) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Hard I ron Y As Measurement ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġestimated Hard I ron Y As Measurement _ when Unknown Hard I ron Internal Cal ibr ator _ calls Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Spy Ġ= Ġspy k ( Known Position And Instant Mag net ometer Cal ibr ator ()) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= ĠMag netic Flux Density ( estimated Hard I ron Y , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator Spy . estimated Hard I ron Y As Mag netic Flux Density Ġ}. returns ( b ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertSame ( b , Ġcal ibr ator . estimated Hard I ron Y As Measurement ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġestimated Hard I ron Y As Measurement _ when Known Hard I ron Internal Cal ibr ator _ calls Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Spy Ġ= Ġspy k ( Known Hard I ron Position And Instant Mag net ometer Cal ibr ator ()) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= ĠMag netic Flux Density ( estimated Hard I ron Y , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator Spy . hard I ron Y As Mag netic Flux Density Ġ}. returns ( b ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertSame ( b , Ġcal ibr ator . estimated Hard I ron Y As Measurement ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Est imated Hard I ron Y As Measurement _ when No Internal Cal ibr ator _ returns False () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . get Private Property (" internal Cal ibr ator ")) ĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Est imated Hard I ron Y As Measurement ( b )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Est imated Hard I ron Y As Measurement _ when Unknown Hard I ron Internal Cal ibr ator _ calls Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Spy Ġ= Ġspy k ( Known Position And Instant Mag net ometer Cal ibr ator ()) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator Spy . get Est imated Hard I ron Y As Mag netic Flux Density ( any ()) Ġ}. answers Ġ{ Ġanswer Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġanswer . invocation . args [ 0 ] Ġas ĠMag netic Flux Density ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . value Ġ= Ġestimated Hard I ron Y ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . unit Ġ= ĠMag netic Flux Density Unit . TES LA ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn @ answers Ġtrue ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator Spy ) ĊĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . get Est imated Hard I ron Y As Measurement ( b )) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( estimated Hard I ron Y , Ġb . value . toDouble (), Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mag netic Flux Density Unit . TES LA , Ġb . unit ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Est imated Hard I ron Y As Measurement _ when Known Hard I ron Internal Cal ibr ator _ calls Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Spy Ġ= Ġspy k ( Known Hard I ron Position And Instant Mag net ometer Cal ibr ator ()) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator Spy . get Hard I ron Y As Mag netic Flux Density ( any ()) Ġ}. answers Ġ{ Ġanswer Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġanswer . invocation . args [ 0 ] Ġas ĠMag netic Flux Density ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . value Ġ= Ġestimated Hard I ron Y ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . unit Ġ= ĠMag netic Flux Density Unit . TES LA ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator Spy ) ĊĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . get Est imated Hard I ron Y As Measurement ( b )) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( estimated Hard I ron Y , Ġb . value . toDouble (), Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mag netic Flux Density Unit . TES LA , Ġb . unit ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġestimated Hard I ron Z As Measurement _ when No Internal Cal ibr ator _ returns Null () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . get Private Property (" internal Cal ibr ator ")) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Hard I ron Z As Measurement ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġestimated Hard I ron Z As Measurement _ when Unknown Hard I ron Internal Cal ibr ator _ calls Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Spy Ġ= Ġspy k ( Known Position And Instant Mag net ometer Cal ibr ator ()) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= ĠMag netic Flux Density ( estimated Hard I ron Z , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator Spy . estimated Hard I ron Z As Mag netic Flux Density Ġ}. returns ( b ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertSame ( b , Ġcal ibr ator . estimated Hard I ron Z As Measurement ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġestimated Hard I ron Z As Measurement _ when Known Hard I ron Internal Cal ibr ator _ calls Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Spy Ġ= Ġspy k ( Known Hard I ron Position And Instant Mag net ometer Cal ibr ator ()) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= ĠMag netic Flux Density ( estimated Hard I ron Z , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator Spy . hard I ron Z As Mag netic Flux Density Ġ}. returns ( b ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertSame ( b , Ġcal ibr ator . estimated Hard I ron Z As Measurement ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Est imated Hard I ron Z As Measurement _ when No Internal Cal ibr ator _ returns False () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . get Private Property (" internal Cal ibr ator ")) ĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Est imated Hard I ron Z As Measurement ( b )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Est imated Hard I ron Z As Measurement _ when Unknown Hard I ron Internal Cal ibr ator _ calls Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Spy Ġ= Ġspy k ( Known Position And Instant Mag net ometer Cal ibr ator ()) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator Spy . get Est imated Hard I ron Z As Mag netic Flux Density ( any ()) Ġ}. answers Ġ{ Ġanswer Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġanswer . invocation . args [ 0 ] Ġas ĠMag netic Flux Density ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . value Ġ= Ġestimated Hard I ron Z ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . unit Ġ= ĠMag netic Flux Density Unit . TES LA ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn @ answers Ġtrue ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator Spy ) ĊĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . get Est imated Hard I ron Z As Measurement ( b )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Est imated Hard I ron Z As Measurement _ when Known Hard I ron Internal Cal ibr ator _ calls Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Spy Ġ= Ġspy k ( Known Hard I ron Position And Instant Mag net ometer Cal ibr ator ()) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator Spy . get Hard I ron Z As Mag netic Flux Density ( any ()) Ġ}. answers Ġ{ Ġanswer Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġanswer . invocation . args [ 0 ] Ġas ĠMag netic Flux Density ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . value Ġ= Ġestimated Hard I ron Z ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . unit Ġ= ĠMag netic Flux Density Unit . TES LA ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator Spy ) ĊĊĠĠĠĠĠĠĠ Ġval Ġb Ġ= ĠMag netic Flux Density ( 0 . 0 , ĠMag netic Flux Density Unit . TES LA ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . get Est imated Hard I ron Z As Measurement ( b )) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( estimated Hard I ron Z , Ġb . value . toDouble (), Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mag netic Flux Density Unit . TES LA , Ġb . unit ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġestimated Hard I ron As Tri ad _ when No Internal Cal ibr ator _ returns Null () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . get Private Property (" internal Cal ibr ator ")) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . estimated Hard I ron As Tri ad ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġestimated Hard I ron As Tri ad _ when Unknown Hard I ron Internal Cal ibr ator _ calls Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Spy Ġ= Ġspy k ( Known Position And Instant Mag net ometer Cal ibr ator ()) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġtri ad Ġ= ĠMag netic Flux Density Tri ad ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠMag netic Flux Density Unit . TES LA , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġestimated Hard I ron X , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġestimated Hard I ron Y , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġestimated Hard I ron Z ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator Spy . estimated Hard I ron As Tri ad Ġ}. returns ( tri ad ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertSame ( tri ad , Ġcal ibr ator . estimated Hard I ron As Tri ad ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġestimated Hard I ron As Tri ad _ when Known Hard I ron Internal Cal ibr ator _ calls Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Spy Ġ= Ġspy k ( Known Hard I ron Position And Instant Mag net ometer Cal ibr ator ()) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġtri ad Ġ= ĠMag netic Flux Density Tri ad ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠMag netic Flux Density Unit . TES LA , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġestimated Hard I ron X , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġestimated Hard I ron Y , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġestimated Hard I ron Z ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator Spy . hard I ron As Tri ad Ġ}. returns ( tri ad ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertSame ( tri ad , Ġcal ibr ator . estimated Hard I ron As Tri ad ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Est imated Hard I ron As Tri ad _ when No Internal Cal ibr ator _ returns False () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . get Private Property (" internal Cal ibr ator ")) ĊĊĠĠĠĠĠĠĠ Ġval Ġtri ad Ġ= ĠMag netic Flux Density Tri ad () ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . get Est imated Hard I ron As Tri ad ( tri ad )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Est imated Hard I ron As Tri ad _ when Unknown Hard I ron Internal Cal ibr ator _ calls Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Spy Ġ= Ġspy k ( Known Position And Instant Mag net ometer Cal ibr ator ()) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator Spy . get Est imated Hard I ron As Tri ad ( any ()) Ġ}. answers Ġ{ Ġanswer Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġanswer . invocation . args [ 0 ] Ġas ĠMag netic Flux Density Tri ad ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . setValue Coordinates And Unit ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġestimated Hard I ron X , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġestimated Hard I ron Y , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġestimated Hard I ron Z , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMag netic Flux Density Unit . TES LA ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn @ answers Ġtrue ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator Spy ) ĊĊĠĠĠĠĠĠĠ Ġval Ġtri ad Ġ= ĠMag netic Flux Density Tri ad () ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . get Est imated Hard I ron As Tri ad ( tri ad )) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( estimated Hard I ron X , Ġtri ad . value X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( estimated Hard I ron Y , Ġtri ad . value Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( estimated Hard I ron Z , Ġtri ad . value Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mag netic Flux Density Unit . TES LA , Ġtri ad . unit ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Est imated Hard I ron As Tri ad _ when Known Hard I ron Internal Cal ibr ator _ calls Internal Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator Spy Ġ= Ġspy k ( Known Hard I ron Position And Instant Mag net ometer Cal ibr ator ()) ĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġestimated Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinternal Cal ibr ator Spy . get Hard I ron As Tri ad ( any ()) Ġ}. answers Ġ{ Ġanswer Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġanswer . invocation . args [ 0 ] Ġas ĠMag netic Flux Density Tri ad ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . setValue Coordinates And Unit ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġestimated Hard I ron X , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġestimated Hard I ron Y , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġestimated Hard I ron Z , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMag netic Flux Density Unit . TES LA ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" internal Cal ibr ator ", Ġinternal Cal ibr ator Spy ) ĊĊĠĠĠĠĠĠĠ Ġval Ġtri ad Ġ= ĠMag netic Flux Density Tri ad () ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . get Est imated Hard I ron As Tri ad ( tri ad )) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( estimated Hard I ron X , Ġtri ad . value X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( estimated Hard I ron Y , Ġtri ad . value Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( estimated Hard I ron Z , Ġtri ad . value Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( Mag netic Flux Density Unit . TES LA , Ġtri ad . unit ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when No Initial Mag netic Flux Density Norm And No Location _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( context ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġex Ġ= ĠassertThrows ( Invocation TargetException :: class . java ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ")) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertTrue ( ex . cause Ġis Ġjava . lang . IllegalStateException ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when Location _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlocation Ġ= Ġget Location () ĊĠĠĠĠĠĠĠ Ġval Ġworld Mag netic Model Ġ= ĠWorld Mag netic Model () ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlocation , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġworld Mag netic Model Ġ= Ġworld Mag netic Model , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Mag netic Flux Density Norm ) ĊĠĠĠĠĠĠĠ ĠassertSame ( location , Ġcal ibr ator . location ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( cal ibr ator . timestamp ) ĊĠĠĠĠĠĠĠ ĠassertSame ( world Mag netic Model , Ġcal ibr ator . world Mag netic Model ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Initial Mag netic Flux Density Norm Measured ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron X ", Ġinitial Hard I ron X ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Y ", Ġinitial Hard I ron Y ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Z ", Ġinitial Hard I ron Z ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠKnown Hard I ron Position And Instant Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertNull ( internal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( location . to N ED Position (). equals ( internal Cal ibr ator 2 . ned Position , ĠA BS OL UTE _ ERROR )) ĊĠĠĠĠĠĠĠ Ġval Ġcalendar Ġ= ĠG regorian Calendar () ĊĠĠĠĠĠĠĠ Ġval Ġtimestamp Ġ= Ġcal ibr ator . timestamp ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( timestamp ) ĊĠĠĠĠĠĠĠ Ġcalendar . time Ġ= Ġtimestamp ĊĠĠĠĠĠĠĠ Ġval Ġyear Ġ= ĠWM ME arth Mag netic Flux Density Estimator . convert Time ( calendar ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( year , Ġinternal Cal ibr ator 2 . year , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertSame ( world Mag netic Model , Ġinternal Cal ibr ator 2 . mag netic Model ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron X , Ġinternal Cal ibr ator 2 . hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Y , Ġinternal Cal ibr ator 2 . hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Z , Ġinternal Cal ibr ator 2 . hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when Non Rob ust Ground Truth Hard I ron Set And No Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron X ", Ġinitial Hard I ron X ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Y ", Ġinitial Hard I ron Y ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Z ", Ġinitial Hard I ron Z ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠKnown Hard I ron Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron X , Ġinternal Cal ibr ator 2 . hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Y , Ġinternal Cal ibr ator 2 . hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Z , Ġinternal Cal ibr ator 2 . hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when Non Rob ust Ground Truth Hard I ron Set And Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġtrue ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠKnown Hard I ron Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 7 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when Non Rob ust Ground Truth Hard I ron Not Set And No Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠKnown Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when Non Rob ust Ground Truth Hard I ron Not Set And Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠKnown Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when RAN S AC Ground Truth Hard I ron Not Set And No Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . RAN S AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= ĠRO BU ST _ THRESHOLD ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . RAN S AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġrobust Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠR ANS AC Rob ust Known Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġinternal Cal ibr ator 2 . threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when RAN S AC Ground Truth Hard I ron Not Set And Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġtrue ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . RAN S AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= ĠRO BU ST _ THRESHOLD ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . RAN S AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġrobust Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠR ANS AC Rob ust Known Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġinternal Cal ibr ator 2 . threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when RAN S AC Ground Truth Hard I ron Set And No Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron X ", Ġinitial Hard I ron X ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Y ", Ġinitial Hard I ron Y ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Z ", Ġinitial Hard I ron Z ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . RAN S AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= ĠRO BU ST _ THRESHOLD ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . RAN S AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġrobust Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠR ANS AC Rob ust Known Hard I ron Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron X , Ġinternal Cal ibr ator 2 . hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Y , Ġinternal Cal ibr ator 2 . hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Z , Ġinternal Cal ibr ator 2 . hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġinternal Cal ibr ator 2 . threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when RAN S AC Ground Truth Hard I ron Set And Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġtrue ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron X ", Ġinitial Hard I ron X ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Y ", Ġinitial Hard I ron Y ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Z ", Ġinitial Hard I ron Z ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . RAN S AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= ĠRO BU ST _ THRESHOLD ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . RAN S AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġrobust Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠR ANS AC Rob ust Known Hard I ron Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron X , Ġinternal Cal ibr ator 2 . hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Y , Ġinternal Cal ibr ator 2 . hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Z , Ġinternal Cal ibr ator 2 . hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġinternal Cal ibr ator 2 . threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 7 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when RAN S AC Ground Truth Hard I ron Not Set And No Rob ust Threshold _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . RAN S AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= ĠRO BU ST _ THRESHOLD _ FACTOR ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . base Noise Level Ġ}. returns ( base Noise Level ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . RAN S AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ ĠassertNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( base Noise Level , Ġcal ibr ator . base Noise Level ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠR ANS AC Rob ust Known Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR Ġ* Ġbase Noise Level , Ġinternal Cal ibr ator 2 . threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when RAN S AC Ground Truth Hard I ron Set And No Rob ust Threshold _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . RAN S AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= ĠRO BU ST _ THRESHOLD _ FACTOR ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . base Noise Level Ġ}. returns ( base Noise Level ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . RAN S AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ ĠassertNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( base Noise Level , Ġcal ibr ator . base Noise Level ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠR ANS AC Rob ust Known Hard I ron Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR Ġ* Ġbase Noise Level , Ġinternal Cal ibr ator 2 . threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when RAN S AC Ground Truth Hard I ron Not Set No Rob ust Threshold And Missing Base Noise Level _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . RAN S AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= ĠRO BU ST _ THRESHOLD _ FACTOR ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . RAN S AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ ĠassertNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . base Noise Level ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġex Ġ= ĠassertThrows ( Invocation TargetException :: class . java ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ")) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertTrue ( ex . cause Ġis ĠIllegalStateException ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when RAN S AC Ground Truth Hard I ron Set No Rob ust Threshold And Missing Base Noise Level _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . RAN S AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= ĠRO BU ST _ THRESHOLD _ FACTOR ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . RAN S AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ ĠassertNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . base Noise Level ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġex Ġ= ĠassertThrows ( Invocation TargetException :: class . java ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ")) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertTrue ( ex . cause Ġis ĠIllegalStateException ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when MS AC Ground Truth Hard I ron Not Set And No Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . MS AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= ĠRO BU ST _ THRESHOLD ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . MS AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġrobust Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠMS AC Rob ust Known Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġinternal Cal ibr ator 2 . threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when MS AC Ground Truth Hard I ron Not Set And Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġtrue ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . MS AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= ĠRO BU ST _ THRESHOLD ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . MS AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġrobust Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠMS AC Rob ust Known Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġinternal Cal ibr ator 2 . threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when MS AC Ground Truth Hard I ron Set And No Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron X ", Ġinitial Hard I ron X ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Y ", Ġinitial Hard I ron Y ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Z ", Ġinitial Hard I ron Z ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . MS AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= ĠRO BU ST _ THRESHOLD ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . MS AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġrobust Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠMS AC Rob ust Known Hard I ron Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron X , Ġinternal Cal ibr ator 2 . hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Y , Ġinternal Cal ibr ator 2 . hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Z , Ġinternal Cal ibr ator 2 . hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġinternal Cal ibr ator 2 . threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when MS AC Ground Truth Hard I ron Set And Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġtrue ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron X ", Ġinitial Hard I ron X ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Y ", Ġinitial Hard I ron Y ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Z ", Ġinitial Hard I ron Z ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . MS AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= ĠRO BU ST _ THRESHOLD ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . MS AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġrobust Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠMS AC Rob ust Known Hard I ron Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron X , Ġinternal Cal ibr ator 2 . hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Y , Ġinternal Cal ibr ator 2 . hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Z , Ġinternal Cal ibr ator 2 . hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġinternal Cal ibr ator 2 . threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 7 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when MS AC Ground Truth Hard I ron Not Set And No Rob ust Threshold _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . MS AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= ĠRO BU ST _ THRESHOLD _ FACTOR ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . base Noise Level Ġ}. returns ( base Noise Level ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . MS AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ ĠassertNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( base Noise Level , Ġcal ibr ator . base Noise Level ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠMS AC Rob ust Known Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR Ġ* Ġbase Noise Level , Ġinternal Cal ibr ator 2 . threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when MS AC Ground Truth Hard I ron Set And No Rob ust Threshold _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . MS AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= ĠRO BU ST _ THRESHOLD _ FACTOR ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . base Noise Level Ġ}. returns ( base Noise Level ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . MS AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ ĠassertNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( base Noise Level , Ġcal ibr ator . base Noise Level ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠMS AC Rob ust Known Hard I ron Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR Ġ* Ġbase Noise Level , Ġinternal Cal ibr ator 2 . threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when MS AC Ground Truth Hard I ron Not Set No Rob ust Threshold And Missing Base Noise Level _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . MS AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= ĠRO BU ST _ THRESHOLD _ FACTOR ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . MS AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ ĠassertNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . base Noise Level ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġex Ġ= ĠassertThrows ( Invocation TargetException :: class . java ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ")) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertTrue ( ex . cause Ġis ĠIllegalStateException ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when MS AC Ground Truth Hard I ron Set No Rob ust Threshold And Missing Base Noise Level _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . MS AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= ĠRO BU ST _ THRESHOLD _ FACTOR ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . MS AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ ĠassertNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . base Noise Level ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġex Ġ= ĠassertThrows ( Invocation TargetException :: class . java ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ")) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertTrue ( ex . cause Ġis ĠIllegalStateException ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when PRO S AC Ground Truth Hard I ron Not Set And No Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġmagnetic Flux Density Standard De viation Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġmeasurement . mag netic Flux Density Standard De viation Ġ}. returns ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmagnetic Flux Density Standard De viation ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . PRO S AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= ĠRO BU ST _ THRESHOLD ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . PRO S AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġrobust Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠPRO S AC Rob ust Known Hard I ron Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġinternal Cal ibr ator 2 . threshold , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( cal ibr ator . measure ments . size , Ġinternal Cal ibr ator 2 . quality Scores . size ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when PRO S AC Ground Truth Hard I ron Not Set And Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġmagnetic Flux Density Standard De viation Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġmeasurement . mag netic Flux Density Standard De viation Ġ}. returns ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmagnetic Flux Density Standard De viation ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . PRO S AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= ĠRO BU ST _ THRESHOLD ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . PRO S AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġrobust Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠPRO S AC Rob ust Known Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġinternal Cal ibr ator 2 . threshold , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( cal ibr ator . measure ments . size , Ġinternal Cal ibr ator 2 . quality Scores . size ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when PRO S AC Ground Truth Hard I ron Set And No Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġmagnetic Flux Density Standard De viation Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġmeasurement . mag netic Flux Density Standard De viation Ġ}. returns ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmagnetic Flux Density Standard De viation ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron X ", Ġinitial Hard I ron X ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Y ", Ġinitial Hard I ron Y ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Z ", Ġinitial Hard I ron Z ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . PRO S AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= ĠRO BU ST _ THRESHOLD ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . PRO S AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġrobust Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠPRO S AC Rob ust Known Hard I ron Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron X , Ġinternal Cal ibr ator 2 . hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Y , Ġinternal Cal ibr ator 2 . hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Z , Ġinternal Cal ibr ator 2 . hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġinternal Cal ibr ator 2 . threshold , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( cal ibr ator . measure ments . size , Ġinternal Cal ibr ator 2 . quality Scores . size ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when PRO S AC Ground Truth Hard I ron Set And Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġmagnetic Flux Density Standard De viation Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġmeasurement . mag netic Flux Density Standard De viation Ġ}. returns ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmagnetic Flux Density Standard De viation ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġtrue ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . PRO S AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= ĠRO BU ST _ THRESHOLD ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . PRO S AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġrobust Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠPRO S AC Rob ust Known Hard I ron Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġinternal Cal ibr ator 2 . threshold , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( cal ibr ator . measure ments . size , Ġinternal Cal ibr ator 2 . quality Scores . size ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 7 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when PRO S AC Ground Truth Hard I ron Not Set And No Rob ust Threshold _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġmagnetic Flux Density Standard De viation Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġmeasurement . mag netic Flux Density Standard De viation Ġ}. returns ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmagnetic Flux Density Standard De viation ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . PRO S AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= ĠRO BU ST _ THRESHOLD _ FACTOR ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . base Noise Level Ġ}. returns ( base Noise Level ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . PRO S AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ ĠassertNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( base Noise Level , Ġcal ibr ator . base Noise Level ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠPRO S AC Rob ust Known Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR Ġ* Ġbase Noise Level , Ġinternal Cal ibr ator 2 . threshold , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( cal ibr ator . measure ments . size , Ġinternal Cal ibr ator 2 . quality Scores . size ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when PRO S AC Ground Truth Hard I ron Set And No Rob ust Threshold _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġmagnetic Flux Density Standard De viation Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġmeasurement . mag netic Flux Density Standard De viation Ġ}. returns ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmagnetic Flux Density Standard De viation ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . PRO S AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= ĠRO BU ST _ THRESHOLD _ FACTOR ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . base Noise Level Ġ}. returns ( base Noise Level ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . PRO S AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ ĠassertNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( base Noise Level , Ġcal ibr ator . base Noise Level ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠPRO S AC Rob ust Known Hard I ron Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR Ġ* Ġbase Noise Level , Ġinternal Cal ibr ator 2 . threshold , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( cal ibr ator . measure ments . size , Ġinternal Cal ibr ator 2 . quality Scores . size ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when PRO S AC Ground Truth Hard I ron Not Set No Rob ust Threshold And Missing Base Noise Level _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġmagnetic Flux Density Standard De viation Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġmeasurement . mag netic Flux Density Standard De viation Ġ}. returns ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmagnetic Flux Density Standard De viation ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . PRO S AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= ĠRO BU ST _ THRESHOLD _ FACTOR ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . PRO S AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ ĠassertNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . base Noise Level ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġex Ġ= ĠassertThrows ( Invocation TargetException :: class . java ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ")) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertTrue ( ex . cause Ġis ĠIllegalStateException ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when PRO S AC Ground Truth Hard I ron Set No Rob ust Threshold And Missing Base Noise Level _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġmagnetic Flux Density Standard De viation Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġmeasurement . mag netic Flux Density Standard De viation Ġ}. returns ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmagnetic Flux Density Standard De viation ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . PRO S AC ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= ĠRO BU ST _ THRESHOLD _ FACTOR ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . PRO S AC , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ ĠassertNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . base Noise Level ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġex Ġ= ĠassertThrows ( Invocation TargetException :: class . java ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ")) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertTrue ( ex . cause Ġis ĠIllegalStateException ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when L Med SG round Truth Hard I ron Not Set And No Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . L Med S ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= ĠRO BU ST _ THRESHOLD ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . L Med S , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġrobust Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠL Med SR ob ust Known Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġinternal Cal ibr ator 2 . stop Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when L Med SG round Truth Hard I ron Not Set And Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġtrue ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . L Med S ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= ĠRO BU ST _ THRESHOLD ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . L Med S , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġrobust Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠL Med SR ob ust Known Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġinternal Cal ibr ator 2 . stop Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when L Med SG round Truth Hard I ron Set And No Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron X ", Ġinitial Hard I ron X ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Y ", Ġinitial Hard I ron Y ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Z ", Ġinitial Hard I ron Z ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . L Med S ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= ĠRO BU ST _ THRESHOLD ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . L Med S , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġrobust Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠL Med SR ob ust Known Hard I ron Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron X , Ġinternal Cal ibr ator 2 . hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Y , Ġinternal Cal ibr ator 2 . hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Z , Ġinternal Cal ibr ator 2 . hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġinternal Cal ibr ator 2 . stop Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when L Med SG round Truth Hard I ron Set And Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġtrue ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron X ", Ġinitial Hard I ron X ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Y ", Ġinitial Hard I ron Y ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Z ", Ġinitial Hard I ron Z ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . L Med S ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= ĠRO BU ST _ THRESHOLD ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . L Med S , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġrobust Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠL Med SR ob ust Known Hard I ron Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron X , Ġinternal Cal ibr ator 2 . hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Y , Ġinternal Cal ibr ator 2 . hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Z , Ġinternal Cal ibr ator 2 . hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġinternal Cal ibr ator 2 . stop Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 7 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when L Med SG round Truth Hard I ron Not Set And No Rob ust Threshold _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . L Med S ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= ĠRO BU ST _ THRESHOLD _ FACTOR ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Stop Threshold Factor Ġ= ĠRO BU ST _ STOP _ THRESHOLD _ FACTOR ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . base Noise Level Ġ}. returns ( base Noise Level ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . L Med S , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ ĠassertNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( base Noise Level , Ġcal ibr ator . base Noise Level ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠL Med SR ob ust Known Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRO BU ST _ THRESHOLD _ FACTOR Ġ* ĠRO BU ST _ STOP _ THRESHOLD _ FACTOR Ġ* Ġbase Noise Level , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . stop Threshold , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when L Med SG round Truth Hard I ron Set And No Rob ust Threshold _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . L Med S ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= ĠRO BU ST _ THRESHOLD _ FACTOR ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Stop Threshold Factor Ġ= ĠRO BU ST _ STOP _ THRESHOLD _ FACTOR ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . base Noise Level Ġ}. returns ( base Noise Level ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . L Med S , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ ĠassertNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( base Noise Level , Ġcal ibr ator . base Noise Level ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠL Med SR ob ust Known Hard I ron Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRO BU ST _ THRESHOLD _ FACTOR Ġ* ĠRO BU ST _ STOP _ THRESHOLD _ FACTOR Ġ* Ġbase Noise Level , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . stop Threshold , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when L Med SG round Truth Hard I ron Not Set No Rob ust Threshold And Missing Base Noise Level _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . L Med S ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= ĠRO BU ST _ THRESHOLD _ FACTOR ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Stop Threshold Factor Ġ= ĠRO BU ST _ STOP _ THRESHOLD _ FACTOR ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . L Med S , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ ĠassertNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . base Noise Level ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġex Ġ= ĠassertThrows ( Invocation TargetException :: class . java ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ")) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertTrue ( ex . cause Ġis ĠIllegalStateException ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when L Med SG round Truth Hard I ron Set No Rob ust Threshold And Missing Base Noise Level _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . L Med S ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= ĠRO BU ST _ THRESHOLD _ FACTOR ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Stop Threshold Factor Ġ= ĠRO BU ST _ STOP _ THRESHOLD _ FACTOR ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . L Med S , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ ĠassertNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . base Noise Level ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġex Ġ= ĠassertThrows ( Invocation TargetException :: class . java ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ")) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertTrue ( ex . cause Ġis ĠIllegalStateException ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when PRO Med SG round Truth Hard I ron Not Set And No Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġmagnetic Flux Density Standard De viation Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġmeasurement . mag netic Flux Density Standard De viation Ġ}. returns ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmagnetic Flux Density Standard De viation ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . PRO Med S ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= ĠRO BU ST _ THRESHOLD ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . PRO Med S , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġrobust Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠP ROM ed SR ob ust Known Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġinternal Cal ibr ator 2 . stop Threshold , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( cal ibr ator . measure ments . size , Ġinternal Cal ibr ator 2 . quality Scores . size ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when PRO Med SG round Truth Hard I ron Not Set And Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġmagnetic Flux Density Standard De viation Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġmeasurement . mag netic Flux Density Standard De viation Ġ}. returns ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmagnetic Flux Density Standard De viation ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġtrue ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . PRO Med S ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= ĠRO BU ST _ THRESHOLD ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . PRO Med S , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġrobust Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠP ROM ed SR ob ust Known Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġinternal Cal ibr ator 2 . stop Threshold , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( cal ibr ator . measure ments . size , Ġinternal Cal ibr ator 2 . quality Scores . size ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when PRO Med SG round Truth Hard I ron Set And No Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġmagnetic Flux Density Standard De viation Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġmeasurement . mag netic Flux Density Standard De viation Ġ}. returns ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmagnetic Flux Density Standard De viation ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron X ", Ġinitial Hard I ron X ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Y ", Ġinitial Hard I ron Y ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Z ", Ġinitial Hard I ron Z ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . PRO Med S ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= ĠRO BU ST _ THRESHOLD ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . PRO Med S , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġrobust Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠP ROM ed SR ob ust Known Hard I ron Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron X , Ġinternal Cal ibr ator 2 . hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Y , Ġinternal Cal ibr ator 2 . hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Z , Ġinternal Cal ibr ator 2 . hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġinternal Cal ibr ator 2 . stop Threshold , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( cal ibr ator . measure ments . size , Ġinternal Cal ibr ator 2 . quality Scores . size ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when PRO Med SG round Truth Hard I ron Set And Common Axis _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġmagnetic Flux Density Standard De viation Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġmeasurement . mag netic Flux Density Standard De viation Ġ}. returns ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmagnetic Flux Density Standard De viation ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġtrue ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron X Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Y Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Hard I ron Z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron X ", Ġinitial Hard I ron X ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Y ", Ġinitial Hard I ron Y ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" initial Hard I ron Z ", Ġinitial Hard I ron Z ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . PRO Med S ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= ĠRO BU ST _ THRESHOLD ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . PRO Med S , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġrobust Threshold , Ġ 0 . 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠP ROM ed SR ob ust Known Hard I ron Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron X , Ġinternal Cal ibr ator 2 . hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Y , Ġinternal Cal ibr ator 2 . hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Hard I ron Z , Ġinternal Cal ibr ator 2 . hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD , Ġinternal Cal ibr ator 2 . stop Threshold , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( cal ibr ator . measure ments . size , Ġinternal Cal ibr ator 2 . quality Scores . size ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 7 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when PRO Med SG round Truth Hard I ron Not Set And No Rob ust Threshold _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġmagnetic Flux Density Standard De viation Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġmeasurement . mag netic Flux Density Standard De viation Ġ}. returns ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmagnetic Flux Density Standard De viation ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . PRO Med S ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= ĠRO BU ST _ THRESHOLD _ FACTOR ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Stop Threshold Factor Ġ= ĠRO BU ST _ STOP _ THRESHOLD _ FACTOR ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . base Noise Level Ġ}. returns ( base Noise Level ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . PRO Med S , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ ĠassertNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ STOP _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Stop Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( base Noise Level , Ġcal ibr ator . base Noise Level ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠP ROM ed SR ob ust Known Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . initial Hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRO BU ST _ THRESHOLD _ FACTOR Ġ* ĠRO BU ST _ STOP _ THRESHOLD _ FACTOR Ġ* Ġbase Noise Level , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . stop Threshold , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( cal ibr ator . measure ments . size , Ġinternal Cal ibr ator 2 . quality Scores . size ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 3 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when PRO Med SG round Truth Hard I ron Set And No Rob ust Threshold _ builds Expected Cal ibr ator () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġmagnetic Flux Density Standard De viation Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġmeasurement . mag netic Flux Density Standard De viation Ġ}. returns ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmagnetic Flux Density Standard De viation ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . PRO Med S ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= ĠRO BU ST _ THRESHOLD _ FACTOR ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Stop Threshold Factor Ġ= ĠRO BU ST _ STOP _ THRESHOLD _ FACTOR ĊĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector : ĠMag net ometer Interval Detector ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . get Private Property (" interval Detector ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġinterval Detector Spy Ġ= Ġspy k ( interval Detector ) ĊĠĠĠĠĠĠĠ Ġval Ġbase Noise Level Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġinterval Detector Spy . base Noise Level Ġ}. returns ( base Noise Level ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property (" interval Detector ", Ġinterval Detector Spy ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . PRO Med S , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ ĠassertNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ STOP _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Stop Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( base Noise Level , Ġcal ibr ator . base Noise Level ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator : ĠMag net ometer Non Linear Cal ibr ator ? Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ") ĊĠĠĠĠĠĠĠ Ġrequire NotNull ( internal Cal ibr ator ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcheck ĊĠĠĠĠĠĠĠ Ġval Ġinternal Cal ibr ator 2 Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator Ġas ĠP ROM ed SR ob ust Known Hard I ron Mag netic Flux Density Norm Mag net ometer Cal ibr ator ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . ground Truth Mag netic Flux Density Norm , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertSame ( cal ibr ator . measure ments , Ġinternal Cal ibr ator 2 . measure ments ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( internal Cal ibr ator 2 . is Common Axis Used ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron X , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron Y , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 . 0 , Ġinternal Cal ibr ator 2 . hard I ron Z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sx , Ġinternal Cal ibr ator 2 . initial Sx , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sy , Ġinternal Cal ibr ator 2 . initial Sy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Sz , Ġinternal Cal ibr ator 2 . initial Sz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xy , Ġinternal Cal ibr ator 2 . initial M xy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M xz , Ġinternal Cal ibr ator 2 . initial M xz , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My x , Ġinternal Cal ibr ator 2 . initial My x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial My z , Ġinternal Cal ibr ator 2 . initial My z , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mz x , Ġinternal Cal ibr ator 2 . initial Mz x , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( initial M zy , Ġinternal Cal ibr ator 2 . initial M zy , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġinternal Cal ibr ator 2 . confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġinternal Cal ibr ator 2 . max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġinternal Cal ibr ator 2 . pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRO BU ST _ THRESHOLD _ FACTOR Ġ* ĠRO BU ST _ STOP _ THRESHOLD _ FACTOR Ġ* Ġbase Noise Level , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . stop Threshold , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 . 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( cal ibr ator . measure ments . size , Ġinternal Cal ibr ator 2 . quality Scores . size ) ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( internal Cal ibr ator 2 . is Ready ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 , Ġinternal Cal ibr ator 2 . minimum Required Measure ments ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . minimum Required Measure ments , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinternal Cal ibr ator 2 . minimum Required Measure ments ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when PRO Med SG round Truth Hard I ron Not Set No Rob ust Threshold And Missing Base Noise Level _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġmagnetic Flux Density Standard De viation Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġmeasurement . mag netic Flux Density Standard De viation Ġ}. returns ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmagnetic Flux Density Standard De viation ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . PRO Med S ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= ĠRO BU ST _ THRESHOLD _ FACTOR ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . PRO Med S , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertFalse ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ ĠassertNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . base Noise Level ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġex Ġ= ĠassertThrows ( Invocation TargetException :: class . java ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ")) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertTrue ( ex . cause Ġis ĠIllegalStateException ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild Internal Cal ibr ator _ when PRO Med SG round Truth Hard I ron Set No Rob ust Threshold And Missing Base Noise Level _ throws IllegalStateException () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠĠĠĠĠ Ġval Ġcal ibr ator Ġ= ĠSingle Sensor Static Interval Mag net ometer Cal ibr ator ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Ground Truth Initial Hard I ron Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠ Ġval Ġmagnetic Flux Density Standard De viation Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġmeasurement Ġ= Ġmock k < Standard De viation Body Mag netic Flux Density >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġmeasurement . mag netic Flux Density Standard De viation Ġ}. returns ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmagnetic Flux Density Standard De viation ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 1 .. 1 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcal ibr ator . measure ments . add ( measurement ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġcal ibr ator . is Common Axis Used Ġ= Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Sx Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Sz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M xz Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial My z Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial Mz x Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġval Ġinitial M zy Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . setInitial Scaling Factors And Cross Coup ling Errors ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sx , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Sz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xy , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M xz , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial My z , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mz x , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial M zy ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Method Ġ= ĠRob ust Estimator Method . PRO Med S ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Confidence Ġ= ĠRO BU ST _ CONF ID ENCE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Max Iterations Ġ= ĠRO BU ST _ MAX _ ITER ATIONS ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Pre limin ary Sub setSize Ġ= ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġcal ibr ator . rob ust Threshold Factor Ġ= ĠRO BU ST _ THRESHOLD _ FACTOR ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( Rob ust Estimator Method . PRO Med S , Ġcal ibr ator . rob ust Method ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( cal ibr ator . is Ground Truth Initial Hard I ron ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ CONF ID ENCE , Ġcal ibr ator . rob ust Confidence , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ MAX _ ITER ATIONS , Ġcal ibr ator . rob ust Max Iterations ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE , Ġcal ibr ator . rob ust Pre limin ary Sub setSize ) ĊĠĠĠĠĠĠĠ Ġval Ġrobust Threshold Ġ= Ġcal ibr ator . rob ust Threshold ĊĠĠĠĠĠĠĠ ĠassertNull ( rob ust Threshold ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( RO BU ST _ THRESHOLD _ FACTOR , Ġcal ibr ator . rob ust Threshold Factor , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . base Noise Level ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinitial Mag netic Flux Density Norm Ġ= Ġrandom izer . next Double () ĊĠĠĠĠĠĠĠ Ġcal ibr ator . set Private Property ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" initial Mag netic Flux Density Norm ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinitial Mag netic Flux Density Norm ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( initial Mag netic Flux Density Norm , Ġcal ibr ator . initial Mag netic Flux Density Norm ) ĊĊĠĠĠĠĠĠĠ Ġval Ġex Ġ= ĠassertThrows ( Invocation TargetException :: class . java ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNull ( cal ibr ator . call Private Func With Result (" build Internal Cal ibr ator ")) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertTrue ( ex . cause Ġis ĠIllegalStateException ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġconst Ġval ĠMM _ SIZE Ġ= Ġ 3 ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠINITIAL _ STATIC _ SAMPLES Ġ= Ġ 2 5 0 0 ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠTH RESH OLD _ FACTOR Ġ= Ġ 3 . 0 ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠINST ANT AN EO US _ NO ISE _ LEVEL _ FACTOR Ġ= Ġ 3 . 0 ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠBASE _ NO ISE _ LEVEL _ AB SOL UTE _ THRESHOLD Ġ= Ġ 1 e - 5 ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠMIN _ LAT IT UDE _ DE GRE ES Ġ= Ġ- 9 0 . 0 ĊĠĠĠĠĠĠĠ Ġconst Ġval ĠMAX _ LAT IT UDE _ DE GRE ES Ġ= Ġ 9 0 . 0 ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠMIN _ LONG IT UDE _ DE GRE ES Ġ= Ġ- 1 8 0 . 0 ĊĠĠĠĠĠĠĠ Ġconst Ġval ĠMAX _ LONG IT UDE _ DE GRE ES Ġ= Ġ 1 8 0 . 0 ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠMIN _ HEIGHT Ġ= Ġ- 1 0 0 . 0 ĊĠĠĠĠĠĠĠ Ġconst Ġval ĠMAX _ HEIGHT Ġ= Ġ 3 0 0 0 . 0 ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠWINDO W _ SIZE Ġ= Ġ 5 1 ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠREQUIRED _ MEAS UREMENT S Ġ= Ġ 3 0 ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠRO BU ST _ CONF ID ENCE Ġ= Ġ 0 . 9 ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠRO BU ST _ MAX _ ITER ATIONS Ġ= Ġ 1 0 0 0 ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠRO BU ST _ PRE LI MIN ARY _ SUB SET _ SIZE Ġ= Ġ 1 5 ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠRO BU ST _ THRESHOLD Ġ= Ġ 1 e - 5 ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠRO BU ST _ THRESHOLD _ FACTOR Ġ= Ġ 2 . 0 ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠRO BU ST _ STOP _ THRESHOLD _ FACTOR Ġ= Ġ 1 e - 3 ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠMIN _ HARD _ IRON Ġ= Ġ- 1 e - 5 ĊĠĠĠĠĠĠĠ Ġconst Ġval ĠMAX _ HARD _ IRON Ġ= Ġ 1 e - 5 ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠMIN _ SOFT _ IRON Ġ= Ġ- 1 e - 6 ĊĠĠĠĠĠĠĠ Ġconst Ġval ĠMAX _ SOFT _ IRON Ġ= Ġ 1 e - 6 ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠMIN _ ANGLE _ DE GRE ES Ġ= Ġ- 4 5 . 0 ĊĠĠĠĠĠĠĠ Ġconst Ġval ĠMAX _ ANGLE _ DE GRE ES Ġ= Ġ 4 5 . 0 ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠMAG NET O METER _ NO ISE _ STD Ġ= Ġ 2 0 0 e - 9 ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠSMALL _ AB SOL UTE _ ERROR Ġ= Ġ 1 e - 1 2 ĊĊĠĠĠĠĠĠĠ Ġconst Ġval ĠA BS OL UTE _ ERROR Ġ= Ġ 1 e - 6 ĊĊĠĠĠĠĠĠĠ Ġfun Ġget Location (): ĠLocation Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġlatitude Degrees Ġ= Ġrandom izer . next Double ( MIN _ LAT IT UDE _ DE GRE ES , ĠMAX _ LAT IT UDE _ DE GRE ES ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġlongitude Degrees Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrandom izer . next Double ( MIN _ LONG IT UDE _ DE GRE ES , ĠMAX _ LONG IT UDE _ DE GRE ES ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġheight Ġ= Ġrandom izer . next Double ( MIN _ HEIGHT , ĠMAX _ HEIGHT ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġlocation Ġ= Ġmock k < Location >() ĊĠĠĠĠĠĠĠĠĠĠĠ Ġevery Ġ{ Ġlocation . latitude Ġ}. returns ( latitude Degrees ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġevery Ġ{ Ġlocation . longitude Ġ}. returns ( longitude Degrees ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġevery Ġ{ Ġlocation . altitude Ġ}. returns ( height ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġlocation ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġfun Ġgenerate Hard I ron (): ĠDouble Array Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠDouble Array ( Body Mag netic Flux Density . COMPONENTS ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġrandom izer Ġ= ĠUniform Random izer () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrandom izer . fill ( result , ĠMIN _ HARD _ IRON , ĠMAX _ HARD _ IRON ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġresult ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġfun Ġgenerate Soft I ron (): ĠMatrix ? Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMatrix . create With Uniform Random Values ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠBody Mag netic Flux Density . COMPONENTS , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠBody Mag netic Flux Density . COMPONENTS , ĠMIN _ SOFT _ IRON , ĠMAX _ SOFT _ IRON ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( ignore : ĠWrong Size Exception ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ// Ġnever Ġhappens ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġnull ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }