Skip to content

Commit

Permalink
Merge pull request #69 from JuhaVainio/update-automation-section-refe…
Browse files Browse the repository at this point in the history
…rences

Rewrite Automation section after w3c/sensors#470
  • Loading branch information
anssiko authored Oct 26, 2023
2 parents 2b1256c + feb72a1 commit d76c769
Showing 1 changed file with 34 additions and 30 deletions.
64 changes: 34 additions & 30 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ urlPrefix: https://w3c.github.io/sensors/; spec: GENERIC-SENSOR
text: keystroke monitoring; url: keystroke-monitoring
text: sensor permission name; url: sensor-permission-names
text: supported sensor options
text: automation
text: mock sensor type
text: mock sensor reading values
urlPrefix: https://w3c.github.io/accelerometer/; spec: ACCELEROMETER
type: dfn
text: device coordinate system
Expand Down Expand Up @@ -384,38 +381,45 @@ Abstract Operations {#abstract-opertaions}

Automation {#automation}
==========
This section extends the [=automation=] section defined in the Generic Sensor API [[GENERIC-SENSOR]]
to provide mocking information about the [=magnetic field=] in the X, Y and Z axis
for the purposes of testing a user agent's implementation of {{Magnetometer}} and {{UncalibratedMagnetometer}} APIs.

<h3 id="mock-magnetometer-type">Mock Sensor Type</h3>
This section extends [[GENERIC-SENSOR#automation]] by providing [=Magnetometer=]-specific virtual sensor metadata.

The {{Magnetometer}} class has an associated [=mock sensor type=] which is
<a for="MockSensorType" enum-value>"magnetometer"</a>, its [=mock sensor reading values=]
dictionary is defined as follows:
Magnetometer automation {#magnetometer-automation}
-----------------------

<pre class="idl">
dictionary MagnetometerReadingValues {
required double? x;
required double? y;
required double? z;
};
</pre>
The [=per-type virtual sensor metadata=] [=map=] must have the following [=map/entry=]:
: [=map/key=]
:: "`magnetometer`"
: [=map/value=]
:: A [=virtual sensor metadata=] whose [=virtual sensor metadata/virtual sensor type=] is [=Magnetometer=] and [=reading parsing algorithm=] is [=parse XYZ reading=].

The {{UncalibratedMagnetometer}} class has an associated [=mock sensor type=] which is
<a for="MockSensorType" enum-value>"uncalibrated-magnetometer"</a>, its [=mock sensor reading values=]
dictionary is defined as follows:
Uncalibrated Magnetometer automation {#uncalibrated-magnetometer-automation}
------------------------------------

<pre class="idl">
dictionary UncalibratedMagnetometerReadingValues {
required double? x;
required double? y;
required double? z;
required double? xBias;
required double? yBias;
required double? zBias;
};
</pre>
The [=per-type virtual sensor metadata=] [=map=] must have the following [=map/entry=]:
: [=map/key=]
:: "`uncalibrated-magnetometer`"
: [=map/value=]
:: A [=virtual sensor metadata=] whose [=virtual sensor metadata/virtual sensor type=] is [=Uncalibrated Magnetometer=] and [=reading parsing algorithm=] is the [=uncalibrated magnetometer reading parsing algorithm=].

<h4 dfn>Uncalibrated Magnetometer reading parsing algorithm</h4>
<div algorithm="uncalibrated magnetometer reading parsing algorithm">
: input
:: |parameters|, a JSON {{Object}}
: output
:: A [=sensor reading=] or **undefined**

1. Let |reading| be the result of [=parse XYZ reading=] with |parameters|.
1. If |reading| is **undefined**.
1. Return **undefined**.
1. Let |keys| be the [=/list=] « "`xBias`", "`yBias`", "`zBias`" ».
1. [=list/For each=] |key| of |keys|
1. Let |value| be the result of invoking [=parse single-value number reading=] with |parameters| and |key|.
1. If |value| is **undefined**.
1. Return **undefined**.
1. [=map/Set=] |reading|[|key|] to |value|[|key|].
1. Return |reading|.
</div>

Limitations of Magnetometer Sensors {#limitations-magnetometer}
==============
Expand Down

0 comments on commit d76c769

Please sign in to comment.