W3C home > Mailing lists > Public > public-device-apis@w3.org > September 2011

Re: [battery] Still some questions on battery status

From: Anssi Kostiainen <anssi.kostiainen@nokia.com>
Date: Mon, 12 Sep 2011 14:52:43 +0300
Message-Id: <13CADF4C-3D12-4C3A-A0D2-5AB664B163BC@nokia.com>
To: "public-device-apis@w3.org WG" <public-device-apis@w3.org>, "ext Cathy.Chan@nokia.com" <Cathy.Chan@nokia.com>

On 9.9.2011, at 23.59, ext Cathy.Chan@nokia.com wrote:

> I don't necessarily argue with that design and usage, but I would argue that
> it's not clearly presented. If there's room for misinterpretation, there's
> probably room for improvement.
> IMHO the confusion comes from basing the definition of a state (the status
> attribute) on the definition of a state change (the battery critical/low/ok
> events). To me, that seems a bit backward. I would rather define the exact
> conditions under which the status attribute is assigned each of the defined
> values, and define that the events are triggered when the value of the
> status attribute changes.

The spec is written with the following processing model in mind:

1. isPlugged and/or level changes, values are set
2. if the stated conditions are met status attribute changes its value to "low", "critical" or "ok" and a battery{low|critical|ok} event is dispatched  
3. a batterystatus event is dispatched

I'd guess that if you're implementing this API, you'd be listening to some platform-level API in step 0 for isPlugged and level changes (in the playground demo I was listening to change events on input elements).

Would it make things clearer if the above-mentioned processing model would be in the spec?

> Based on Robin's explanation and Anssi's battery
> events playground (which is very useful by the way, so thanks Anssi), my
> understanding is that for the status attribute:
> 	critical: isPlugged is false and level < critical_threshold
> 	low: isPlugged is false and critical_threshold < level <
> low_threshold
> 	ok: isPlugged is true or level > low_threshold
> 	null: level is null
> Those conditions should go into the definition for the status attribute.

Thanks, I added this to the spec as a table under the status attribute definition.

> If I were allowed to pick one more nit, I would also say that the status
> attribute does more than "represents how much of the internal power source
> remains", as isPlugged also plays a role in its value. 

Changed to: "Represents the battery status of the hosting device".

Thanks for the feedback.

Received on Monday, 12 September 2011 11:53:46 UTC

This archive was generated by hypermail 2.3.1 : Monday, 23 October 2017 14:53:50 UTC