Skip to content

Commit

Permalink
Rewrite Automation section after w3c/sensors#470
Browse files Browse the repository at this point in the history
The Automation section in the Generic Sensor API specification was rewritten and several terms and concepts have changed.

This commit adapts the Proximity Sensor spec to the changes:

Remove references to "mock sensor type", "mock sensor reading values" and the "MockSensorType" enum.
Define an entry in the per-type virtual sensor metadata map whose key is what used to be the "proximity" entry in MockSensorType and an appropriate virtual sensor metadata entry.
This is enough to integrate properly with the Generic Sensor spec and allow Proximity virtual sensors to be created and used.

Fixes #56.
  • Loading branch information
JuhaVainio committed Oct 25, 2023
1 parent 67c242f commit e89568c
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ urlPrefix: https://w3c.github.io/sensors; spec: GENERIC-SENSOR
text: fingerprinting; url: device-fingerprinting
text: user identifying; url: user-identifying
text: mitigation strategies; url: mitigation-strategies
text: automation
text: mock sensor type
text: mock sensor reading values
</pre>
<pre class="link-defaults">
spec:infra;
Expand Down Expand Up @@ -199,23 +196,30 @@ Abstract Operations {#abstract-operations}

Automation {#automation}
==========
This section extends the [=automation=] section defined in the Generic Sensor API [[GENERIC-SENSOR]]
to provide mocking information about the proximity level for the purposes of
testing a user agent's implementation of {{ProximitySensor}} API.

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

The {{ProximitySensor}} class has an associated [=mock sensor type=] which is
<a for="MockSensorType" enum-value>"proximity"</a>, its [=mock sensor reading values=]
dictionary is defined as follows:
The [=per-type virtual sensor metadata=] [=map=] must have the following [=map/entry=]:
: [=map/key=]
:: "`proximity`"
: [=map/value=]
:: A [=virtual sensor metadata=] whose [=virtual sensor metadata/virtual sensor type=] is [=Proximity Sensor=] and [=reading parsing algorithm=] is [=proximity reading parsing algorithm=].

<pre class="idl">
dictionary ProximityReadingValues {
required double? distance;
required double? max;
required boolean? near;
};
</pre>
<h3 dfn>Proximity reading parsing algorithm</h3>
<div algorithm="proximity reading parsing algorithm">
: input
:: |parameters|, a JSON {{Object}}
: output
:: A [=sensor reading=] or **undefined**

1. Let |reading| be a new [=sensor reading=].
1. Let |value| be a new [=sensor reading=].
1. Let |key| be the [=/list=] « "`distance`", "`max`", "`near`" ».
1. [=map/For each=] |key| → let |value| be the result of [=parse single-value number reading=] with |parameters| and |key|.
1. If |value| is "undefined".
1. Return "undefined".
1. [=map/Set=] |reading|[|key|] to |value|.
1. Return |reading|.

Limitations of Proximity Sensors {#limitations-proximity-sensors}
========================
Expand Down

0 comments on commit e89568c

Please sign in to comment.