Merge lp:~charlesk/indicator-power/lp-1221871 into lp:indicator-power/14.04

Proposed by Charles Kerr
Status: Merged
Approved by: Lars Karlitski
Approved revision: 206
Merged at revision: 214
Proposed branch: lp:~charlesk/indicator-power/lp-1221871
Merge into: lp:indicator-power/14.04
Diff against target: 1001 lines (+128/-778)
3 files modified
src/Makefile.am (+0/-19)
src/device-provider-upower.c (+128/-54)
src/org.freedesktop.UPower.Device.xml (+0/-705)
To merge this branch: bzr merge lp:~charlesk/indicator-power/lp-1221871
Reviewer Review Type Date Requested Status
Lars Karlitski (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+193661@code.launchpad.net

Description of the change

We really only need to keep a handful of properties up-to-date for each upower device. Given that upower requires us to refetch all properties with GetAll whenever it signals that it's changed, we really don't need to keep bus proxies alive for each device.

Removing the autogenerated proxy code and just using a couple of the direct GDBusConnection API calls cuts out some unnecessary overhead according to health-check. See the before & after profile logs attached to the ticket.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Lars Karlitski (larsu) wrote :

Nice fix. A few nitpicks:

on_device_properties_ready:
 - use g_error_matches()
 - "Error acquiring bus" is not very descriptive (copy and paste?). I'd prefer ("Error getting properties for '%s': %s", path, message")

on_bus_ready:
 - use g_error_matches()ö

review: Needs Fixing
Revision history for this message
Charles Kerr (charlesk) wrote :

Thanks for the improvements!

> on_device_properties_ready: use g_error_matches()

Fixed r284.

> "Error acquiring bus" is not very descriptive (copy and paste?). I'd prefer ("Error getting properties for '%s': %s", path, message")

Yes, copypasta error.

Fixed r205.

> on_bus_ready:use g_error_matches()

Fixed r206.

204. By Charles Kerr

in on_device_properties_ready(), use g_error_matches

205. By Charles Kerr

in on_device_properties_ready(), improve the g_warning() text to be more useful.

206. By Charles Kerr

in on_bus_ready(), use g_error_matches().

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Lars Karlitski (larsu) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Makefile.am'
2--- src/Makefile.am 2013-08-20 03:43:15 +0000
3+++ src/Makefile.am 2013-11-04 00:05:23 +0000
4@@ -27,31 +27,12 @@
5
6 ###
7 ###
8-
9-upower_device_dbus_sources = \
10- dbus-upower-device.c \
11- dbus-upower-device.h
12-
13-$(upower_device_dbus_sources): org.freedesktop.UPower.Device.xml
14- $(AM_V_GEN) gdbus-codegen \
15- --c-namespace Dbus \
16- --interface-prefix org.freedesktop.UPower \
17- --generate-c-code dbus-upower-device \
18- $^
19-
20-BUILT_SOURCES += $(upower_device_dbus_sources)
21-CLEANFILES += $(upower_device_dbus_sources)
22-EXTRA_DIST += org.freedesktop.UPower.Device.xml
23-
24-###
25-###
26 ###
27
28 noinst_LIBRARIES = libindicatorpower-upower.a libindicatorpower-service.a
29
30 libindicatorpower_upower_a_SOURCES = \
31 $(upower_dbus_sources) \
32- $(upower_device_dbus_sources) \
33 device-provider-upower.c \
34 device-provider-upower.h
35
36
37=== modified file 'src/device-provider-upower.c'
38--- src/device-provider-upower.c 2013-10-01 18:50:48 +0000
39+++ src/device-provider-upower.c 2013-11-04 00:05:23 +0000
40@@ -20,7 +20,6 @@
41 #include "config.h"
42
43 #include "dbus-upower.h"
44-#include "dbus-upower-device.h"
45 #include "device.h"
46 #include "device-provider.h"
47 #include "device-provider-upower.h"
48@@ -34,6 +33,8 @@
49
50 struct _IndicatorPowerDeviceProviderUPowerPriv
51 {
52+ GDBusConnection * bus;
53+
54 DbusUPower * upower_proxy;
55 GHashTable * devices; /* dbus object path --> IndicatorPowerDevice */
56 GCancellable * cancellable;
57@@ -65,6 +66,12 @@
58 **** UPOWER DBUS
59 ***/
60
61+struct device_get_all_data
62+{
63+ char * path;
64+ IndicatorPowerDeviceProviderUPower * self;
65+};
66+
67 static void
68 emit_devices_changed (IndicatorPowerDeviceProviderUPower * self)
69 {
70@@ -72,65 +79,97 @@
71 }
72
73 static void
74-on_upower_device_proxy_ready (GObject * o, GAsyncResult * res, gpointer gself)
75+on_device_properties_ready (GObject * o, GAsyncResult * res, gpointer gdata)
76 {
77- GError * err;
78- DbusDevice * tmp;
79+ GError * error;
80+ GVariant * response;
81+ struct device_get_all_data * data = gdata;
82
83- err = NULL;
84- tmp = dbus_device_proxy_new_for_bus_finish (res, &err);
85- if (err != NULL)
86+ error = NULL;
87+ response = g_dbus_connection_call_finish (G_DBUS_CONNECTION(o), res, &error);
88+ if (error != NULL)
89 {
90- g_warning ("Unable to get UPower Device Proxy: %s", err->message);
91- g_error_free (err);
92+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
93+ g_warning ("Error getting properties for UPower device '%s': %s",
94+ data->path, error->message);
95+
96+ g_error_free (error);
97 }
98 else
99 {
100- /* use this proxy's properties to update our own IndicatorPowerDevice */
101-
102+ guint32 kind = 0;
103+ guint32 state = 0;
104+ gdouble percentage = 0;
105+ gint64 time_to_empty = 0;
106+ gint64 time_to_full = 0;
107+ time_t time;
108 IndicatorPowerDevice * device;
109- IndicatorPowerDeviceProviderUPower * self;
110- priv_t * p;
111-
112- self = INDICATOR_POWER_DEVICE_PROVIDER_UPOWER (gself);
113- p = self->priv;
114-
115- const guint kind = dbus_device_get_type_ (tmp);
116- const gdouble percentage = dbus_device_get_percentage (tmp);
117- const guint state = dbus_device_get_state (tmp);
118- const gint64 time_to_empty = dbus_device_get_time_to_empty (tmp);
119- const gint64 time_to_full = dbus_device_get_time_to_full (tmp);
120- const time_t time = time_to_empty ? time_to_empty : time_to_full;
121- const char * path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (tmp));
122-
123- device = indicator_power_device_new (path,
124- kind,
125- percentage,
126- state,
127- time);
128-
129- g_hash_table_insert (p->devices,
130- g_strdup (path),
131- g_object_ref (device));
132-
133- emit_devices_changed (self);
134-
135- g_object_unref (device);
136- g_object_unref (tmp);
137+ IndicatorPowerDeviceProviderUPowerPriv * p = data->self->priv;
138+ GVariant * dict = g_variant_get_child_value (response, 0);
139+
140+ g_variant_lookup (dict, "Type", "u", &kind);
141+ g_variant_lookup (dict, "State", "u", &state);
142+ g_variant_lookup (dict, "Percentage", "d", &percentage);
143+ g_variant_lookup (dict, "TimeToEmpty", "x", &time_to_empty);
144+ g_variant_lookup (dict, "TimeToFull", "x", &time_to_full);
145+ time = time_to_empty ? time_to_empty : time_to_full;
146+
147+ if ((device = g_hash_table_lookup (p->devices, data->path)))
148+ {
149+ g_object_set (device, INDICATOR_POWER_DEVICE_KIND, (gint)kind,
150+ INDICATOR_POWER_DEVICE_STATE, (gint)state,
151+ INDICATOR_POWER_DEVICE_OBJECT_PATH, data->path,
152+ INDICATOR_POWER_DEVICE_PERCENTAGE, percentage,
153+ INDICATOR_POWER_DEVICE_TIME, (guint64)time,
154+ NULL);
155+ }
156+ else
157+ {
158+ device = indicator_power_device_new (data->path,
159+ kind,
160+ percentage,
161+ state,
162+ time);
163+
164+ g_hash_table_insert (p->devices,
165+ g_strdup (data->path),
166+ g_object_ref (device));
167+
168+ g_object_unref (device);
169+ }
170+
171+ emit_devices_changed (data->self);
172+ g_variant_unref (dict);
173+ g_variant_unref (response);
174 }
175+
176+ g_free (data->path);
177+ g_slice_free (struct device_get_all_data, data);
178 }
179
180 static void
181 update_device_from_object_path (IndicatorPowerDeviceProviderUPower * self,
182 const char * path)
183 {
184- dbus_device_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
185- G_DBUS_PROXY_FLAGS_NONE,
186- BUS_NAME,
187- path,
188- self->priv->cancellable,
189- on_upower_device_proxy_ready,
190- self);
191+ priv_t * p = self->priv;
192+ struct device_get_all_data * data;
193+
194+ data = g_slice_new (struct device_get_all_data);
195+ data->path = g_strdup (path);
196+ data->self = self;
197+
198+ g_dbus_connection_call (p->bus,
199+ BUS_NAME,
200+ path,
201+ "org.freedesktop.DBus.Properties",
202+ "GetAll",
203+ g_variant_new ("(s)", "org.freedesktop.UPower.Device"),
204+ G_VARIANT_TYPE("(a{sv})"),
205+ G_DBUS_CALL_FLAGS_NO_AUTO_START,
206+ -1, /* default timeout */
207+ p->cancellable,
208+ on_device_properties_ready,
209+ data);
210 }
211
212 /*
213@@ -273,7 +312,7 @@
214 DbusUPower * proxy;
215
216 err = NULL;
217- proxy = dbus_upower_proxy_new_for_bus_finish (res, &err);
218+ proxy = dbus_upower_proxy_new_finish (res, &err);
219 if (err != NULL)
220 {
221 g_warning ("Unable to get UPower proxy: %s", err->message);
222@@ -304,6 +343,42 @@
223 }
224 }
225
226+static void
227+on_bus_ready (GObject * source_object G_GNUC_UNUSED,
228+ GAsyncResult * res,
229+ gpointer gself)
230+{
231+ GError * error;
232+ GDBusConnection * tmp;
233+
234+ error = NULL;
235+ tmp = g_bus_get_finish (res, &error);
236+ if (error != NULL)
237+ {
238+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
239+ g_warning ("Error acquiring bus: %s", error->message);
240+ g_error_free (error);
241+ }
242+ else
243+ {
244+ IndicatorPowerDeviceProviderUPower * self;
245+ priv_t * p;
246+
247+ self = INDICATOR_POWER_DEVICE_PROVIDER_UPOWER (gself);
248+ p = self->priv;
249+
250+ p->bus = tmp;
251+
252+ dbus_upower_proxy_new (p->bus,
253+ G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES,
254+ BUS_NAME,
255+ BUS_PATH,
256+ p->cancellable,
257+ on_upower_proxy_ready,
258+ self);
259+ }
260+}
261+
262 /***
263 **** IndicatorPowerDeviceProvider virtual functions
264 ***/
265@@ -357,6 +432,8 @@
266
267 g_hash_table_remove_all (p->devices);
268
269+ g_clear_object (&p->bus);
270+
271 G_OBJECT_CLASS (indicator_power_device_provider_upower_parent_class)->dispose (o);
272 }
273
274@@ -420,13 +497,10 @@
275 g_free,
276 NULL);
277
278- dbus_upower_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
279- G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES,
280- BUS_NAME,
281- BUS_PATH,
282- p->cancellable,
283- on_upower_proxy_ready,
284- self);
285+ g_bus_get (G_BUS_TYPE_SYSTEM,
286+ p->cancellable,
287+ on_bus_ready,
288+ self);
289 }
290
291 /***
292
293=== removed file 'src/org.freedesktop.UPower.Device.xml'
294--- src/org.freedesktop.UPower.Device.xml 2013-06-17 04:03:23 +0000
295+++ src/org.freedesktop.UPower.Device.xml 1970-01-01 00:00:00 +0000
296@@ -1,705 +0,0 @@
297-<!DOCTYPE node PUBLIC
298-"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
299-"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd" [
300- <!ENTITY ERROR_GENERAL "org.freedesktop.UPower.Device.GeneralError">
301-]>
302-<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
303- <interface name="org.freedesktop.UPower.Device">
304- <doc:doc>
305- <doc:description>
306- <doc:para>
307- Objects implementing this interface are usually discovered through
308- the <doc:tt>org.freedesktop.UPower</doc:tt> interface on
309- the <doc:tt>/org/freedesktop/UPower</doc:tt> object on
310- the D-Bus system bus service with the well-known
311- name <doc:tt>org.freedesktop.UPower</doc:tt> using
312- the
313- <doc:ref type="method" to="Power.EnumerateDevices">EnumerateDevices</doc:ref>
314- method.
315- </doc:para>
316- <doc:para>
317- <doc:example language="shell" title="simple example">
318- <doc:code>
319-$ dbus-send --print-reply \
320- --system \
321- --dest=org.freedesktop.UPower \
322- /org/freedesktop/UPower/devices/battery_BAT0 \
323- org.freedesktop.DBus.Properties.GetAll \
324- string:org.freedesktop.UPower.Device
325-
326-method return sender=:1.386 -> dest=:1.477 reply_serial=2
327- array [
328- dict entry(
329- string "native-path"
330- variant string "/sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:01/PNP0C09:00/PNP0C0A:00/power_supply/BAT0"
331- )
332- dict entry(
333- string "vendor"
334- variant string "SONY"
335- )
336- dict entry(
337- string "model"
338- variant string "42T4568"
339- )
340- dict entry(
341- string "serial"
342- variant string "4179"
343- )
344- dict entry(
345- string "update-time"
346- variant uint64 1226417875
347- )
348- dict entry(
349- string "type"
350- variant uint 2
351- )
352- dict entry(
353- string "power-supply"
354- variant boolean true
355- )
356- dict entry(
357- string "has-history"
358- variant boolean true
359- )
360- dict entry(
361- string "has-statistics"
362- variant boolean true
363- )
364- dict entry(
365- string "online"
366- variant boolean false
367- )
368- dict entry(
369- string "energy"
370- variant double 72.85
371- )
372- dict entry(
373- string "energy-empty"
374- variant double 0
375- )
376- dict entry(
377- string "energy-full"
378- variant double 74.55
379- )
380- dict entry(
381- string "energy-full-design"
382- variant double 74.88
383- )
384- dict entry(
385- string "energy-rate"
386- variant double 0
387- )
388- dict entry(
389- string "voltage"
390- variant double 16.415
391- )
392- dict entry(
393- string "time-to-empty"
394- variant int64 0
395- )
396- dict entry(
397- string "time-to-full"
398- variant int64 0
399- )
400- dict entry(
401- string "percentage"
402- variant double 97.7197
403- )
404- dict entry(
405- string "is-present"
406- variant boolean true
407- )
408- dict entry(
409- string "state"
410- variant uint 3
411- )
412- dict entry(
413- string "is-rechargeable"
414- variant boolean true
415- )
416- dict entry(
417- string "capacity"
418- variant double 100
419- )
420- dict entry(
421- string "technology"
422- variant uint 1
423- )
424- ]
425- </doc:code>
426- </doc:example>
427- </doc:para>
428- <doc:para>
429- Unless otherwise noted, an empty string or the value 0 in a
430- property on this interface means not set.
431- </doc:para>
432- </doc:description>
433- </doc:doc>
434-
435-
436- <!-- ************************************************************ -->
437- <method name="Refresh">
438- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
439- <doc:doc>
440- <doc:description>
441- <doc:para>
442- Refreshes the data collected from the power source.
443- </doc:para>
444- </doc:description>
445- <doc:permission>Callers need the org.freedesktop.upower.refresh-power-source authorization</doc:permission>
446- <doc:errors>
447- <doc:error name="&ERROR_GENERAL;">if an error occured while refreshing</doc:error>
448- </doc:errors>
449- </doc:doc>
450- </method>
451-
452- <!-- ************************************************************ -->
453- <signal name="Changed">
454- <doc:doc>
455- <doc:description>
456- <doc:para>
457- Some value on the power source changed.
458- </doc:para>
459- </doc:description>
460- </doc:doc>
461- </signal>
462-
463- <!-- ************************************************************ -->
464- <method name="GetHistory">
465- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
466- <arg name="type" direction="in" type="s">
467- <doc:doc><doc:summary>The type of history.
468- Valid types are <doc:tt>rate</doc:tt> or <doc:tt>charge</doc:tt>.</doc:summary></doc:doc>
469- </arg>
470- <arg name="timespan" direction="in" type="u">
471- <doc:doc><doc:summary>The amount of data to return in seconds, or 0 for all.</doc:summary></doc:doc>
472- </arg>
473- <arg name="resolution" direction="in" type="u">
474- <doc:doc>
475- <doc:summary>
476- The approximate number of points to return.
477- A higher resolution is more accurate, at the expense of plotting speed.
478- </doc:summary>
479- </doc:doc>
480- </arg>
481- <arg name="data" direction="out" type="a(udu)">
482- <doc:doc><doc:summary>
483- The history data for the power device, if the device supports history.
484- Data is ordered from the earliest in time, to the newest data point.
485- Each element contains the following members:
486- <doc:list>
487- <doc:item>
488- <doc:term>time</doc:term>
489- <doc:definition>
490- The time value in seconds from the <doc:tt>gettimeofday()</doc:tt> method.
491- </doc:definition>
492- </doc:item>
493- <doc:item>
494- <doc:term>value</doc:term>
495- <doc:definition>
496- The data value, for instance the rate in W or the charge in %.
497- </doc:definition>
498- </doc:item>
499- <doc:item>
500- <doc:term>state</doc:term>
501- <doc:definition>
502- The state of the device, for instance <doc:tt>charging</doc:tt> or
503- <doc:tt>discharging</doc:tt>.
504- </doc:definition>
505- </doc:item>
506- </doc:list>
507- </doc:summary></doc:doc>
508- </arg>
509- <doc:doc>
510- <doc:description>
511- <doc:para>
512- Gets history for the power device that is persistent across reboots.
513- </doc:para>
514- </doc:description>
515- </doc:doc>
516- </method>
517-
518- <!-- ************************************************************ -->
519- <method name="GetStatistics">
520- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
521- <arg name="type" direction="in" type="s">
522- <doc:doc><doc:summary>The mode for the statistics.
523- Valid types are <doc:tt>charging</doc:tt> or <doc:tt>discharging</doc:tt>.</doc:summary></doc:doc>
524- </arg>
525- <arg name="data" direction="out" type="a(dd)">
526- <doc:doc><doc:summary>
527- The statistics data for the power device.
528- Each element contains the following members:
529- <doc:list>
530- <doc:item>
531- <doc:term>value</doc:term>
532- <doc:definition>
533- The value of the percentage point, usually in seconds
534- </doc:definition>
535- </doc:item>
536- <doc:item>
537- <doc:term>accuracy</doc:term>
538- <doc:definition>
539- The accuracy of the prediction in percent.
540- </doc:definition>
541- </doc:item>
542- </doc:list>
543- </doc:summary></doc:doc>
544- </arg>
545- <doc:doc>
546- <doc:description>
547- <doc:para>
548- Gets statistics for the power device that may be interesting
549- to show on a graph in the session.
550- </doc:para>
551- </doc:description>
552- </doc:doc>
553- </method>
554-
555- <!-- ************************************************************ -->
556- <property name="NativePath" type="s" access="read">
557- <doc:doc>
558- <doc:description>
559- <doc:para>
560- OS specific native path of the power source. On Linux this
561- is the sysfs path, for
562- example <doc:tt>/sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0</doc:tt>. Is
563- blank if the device is being driven by a user space
564- driver.
565- </doc:para>
566- </doc:description>
567- </doc:doc>
568- </property>
569-
570- <property name="Vendor" type="s" access="read">
571- <doc:doc>
572- <doc:description>
573- <doc:para>
574- Name of the vendor of the battery.
575- </doc:para>
576- </doc:description>
577- </doc:doc>
578- </property>
579-
580- <property name="Model" type="s" access="read">
581- <doc:doc>
582- <doc:description>
583- <doc:para>
584- Name of the model of this battery.
585- </doc:para>
586- </doc:description>
587- </doc:doc>
588- </property>
589-
590- <property name="Serial" type="s" access="read">
591- <doc:doc>
592- <doc:description>
593- <doc:para>
594- Unique serial number of the battery.
595- </doc:para>
596- </doc:description>
597- </doc:doc>
598- </property>
599-
600- <property name="UpdateTime" type="t" access="read">
601- <doc:doc>
602- <doc:description>
603- <doc:para>
604- The point in time (seconds since the Epoch Jan 1, 1970
605- 0:00 UTC) that data was read from the power source.
606- </doc:para>
607- </doc:description>
608- </doc:doc>
609- </property>
610-
611- <property name="Type" type="u" access="read">
612- <doc:doc>
613- <doc:description>
614- <doc:para>
615- Type of power source.
616- </doc:para>
617- <doc:list>
618- <doc:item>
619- <doc:term>0</doc:term><doc:definition>Unknown</doc:definition>
620- </doc:item>
621- <doc:item>
622- <doc:term>1</doc:term><doc:definition>Line Power</doc:definition>
623- </doc:item>
624- <doc:item>
625- <doc:term>2</doc:term><doc:definition>Battery</doc:definition>
626- </doc:item>
627- <doc:item>
628- <doc:term>3</doc:term><doc:definition>Ups</doc:definition>
629- </doc:item>
630- <doc:item>
631- <doc:term>4</doc:term><doc:definition>Monitor</doc:definition>
632- </doc:item>
633- <doc:item>
634- <doc:term>5</doc:term><doc:definition>Mouse</doc:definition>
635- </doc:item>
636- <doc:item>
637- <doc:term>6</doc:term><doc:definition>Keyboard</doc:definition>
638- </doc:item>
639- <doc:item>
640- <doc:term>7</doc:term><doc:definition>Pda</doc:definition>
641- </doc:item>
642- <doc:item>
643- <doc:term>8</doc:term><doc:definition>Phone</doc:definition>
644- </doc:item>
645- </doc:list>
646- </doc:description>
647- </doc:doc>
648- </property>
649-
650- <property name="PowerSupply" type="b" access="read">
651- <doc:doc>
652- <doc:description>
653- <doc:para>
654- If the power device is used to supply the system.
655- This would be set TRUE for laptop batteries and UPS devices,
656- but set FALSE for wireless mice or PDAs.
657- </doc:para>
658- </doc:description>
659- </doc:doc>
660- </property>
661-
662- <property name="HasHistory" type="b" access="read">
663- <doc:doc>
664- <doc:description>
665- <doc:para>
666- If the power device has history.
667- </doc:para>
668- </doc:description>
669- </doc:doc>
670- </property>
671-
672- <property name="HasStatistics" type="b" access="read">
673- <doc:doc>
674- <doc:description>
675- <doc:para>
676- If the power device has statistics.
677- </doc:para>
678- </doc:description>
679- </doc:doc>
680- </property>
681-
682- <property name="Online" type="b" access="read">
683- <doc:doc>
684- <doc:description>
685- <doc:para>
686- Whether power is currently being provided through line power.
687- This property is only valid if the property
688- <doc:ref type="property" to="Source:Type">type</doc:ref>
689- has the value "line-power".
690- </doc:para>
691- </doc:description>
692- </doc:doc>
693- </property>
694-
695- <property name="Energy" type="d" access="read">
696- <doc:doc>
697- <doc:description>
698- <doc:para>
699- Amount of energy (measured in Wh) currently available in
700- the power source.
701- </doc:para><doc:para>
702- This property is only valid if the property
703- <doc:ref type="property" to="Source:Type">type</doc:ref>
704- has the value "battery".
705- </doc:para>
706- </doc:description>
707- </doc:doc>
708- </property>
709-
710- <property name="EnergyEmpty" type="d" access="read">
711- <doc:doc>
712- <doc:description>
713- <doc:para>
714- Amount of energy (measured in Wh) in the power source when
715- it's considered to be empty.
716- </doc:para><doc:para>
717- This property is only valid if the property
718- <doc:ref type="property" to="Source:Type">type</doc:ref>
719- has the value "battery".
720- </doc:para>
721- </doc:description>
722- </doc:doc>
723- </property>
724-
725- <property name="EnergyFull" type="d" access="read">
726- <doc:doc>
727- <doc:description>
728- <doc:para>
729- Amount of energy (measured in Wh) in the power source when
730- it's considered full.
731- </doc:para><doc:para>
732- This property is only valid if the property
733- <doc:ref type="property" to="Source:Type">type</doc:ref>
734- has the value "battery".
735- </doc:para>
736- </doc:description>
737- </doc:doc>
738- </property>
739-
740- <property name="EnergyFullDesign" type="d" access="read">
741- <doc:doc>
742- <doc:description>
743- <doc:para>
744- Amount of energy (measured in Wh) the power source is
745- designed to hold when it's considered full.
746- </doc:para><doc:para>
747- This property is only valid if the property
748- <doc:ref type="property" to="Source:Type">type</doc:ref>
749- has the value "battery".
750- </doc:para>
751- </doc:description>
752- </doc:doc>
753- </property>
754-
755- <property name="EnergyRate" type="d" access="read">
756- <doc:doc>
757- <doc:description>
758- <doc:para>
759- Amount of energy being drained from the source, measured
760- in W. If positive, the source is being discharged, if
761- negative it's being charged.
762- </doc:para><doc:para>
763- This property is only valid if the property
764- <doc:ref type="property" to="Source:Type">type</doc:ref>
765- has the value "battery".
766- </doc:para>
767- </doc:description>
768- </doc:doc>
769- </property>
770-
771- <property name="Voltage" type="d" access="read">
772- <doc:doc>
773- <doc:description>
774- <doc:para>
775- Voltage in the Cell or being recorded by the meter.
776- </doc:para>
777- </doc:description>
778- </doc:doc>
779- </property>
780-
781- <property name="TimeToEmpty" type="x" access="read">
782- <doc:doc>
783- <doc:description>
784- <doc:para>
785- Number of seconds until the power source is considered empty.
786- Is set to 0 if unknown.
787- </doc:para><doc:para>
788- This property is only valid if the property
789- <doc:ref type="property" to="Source:Type">type</doc:ref>
790- has the value "battery".
791- </doc:para>
792- </doc:description>
793- </doc:doc>
794- </property>
795-
796- <property name="TimeToFull" type="x" access="read">
797- <doc:doc>
798- <doc:description>
799- <doc:para>
800- Number of seconds until the power source is considered full.
801- Is set to 0 if unknown.
802- </doc:para><doc:para>
803- This property is only valid if the property
804- <doc:ref type="property" to="Source:Type">type</doc:ref>
805- has the value "battery".
806- </doc:para>
807- </doc:description>
808- </doc:doc>
809- </property>
810-
811- <property name="Percentage" type="d" access="read">
812- <doc:doc>
813- <doc:description>
814- <doc:para>
815- The amount of energy left in the power source expressed as
816- a percentage between 0 and 100. Typically this is the same as
817- (<doc:ref type="property" to="Source:Energy">energy</doc:ref> -
818- <doc:ref type="property" to="Source:EnergyEmpty">energy-empty</doc:ref>) /
819- (<doc:ref type="property" to="Source:EnergyFull">energy-full</doc:ref> -
820- <doc:ref type="property" to="Source:EnergyEmpty">energy-empty</doc:ref>).
821- However, some primitive power sources are capable of only
822- reporting percentages and in this case the energy-*
823- properties will be unset while this property is set.
824- </doc:para><doc:para>
825- This property is only valid if the property
826- <doc:ref type="property" to="Source:Type">type</doc:ref>
827- has the value "battery".
828- </doc:para>
829- </doc:description>
830- </doc:doc>
831- </property>
832-
833- <property name="IsPresent" type="b" access="read">
834- <doc:doc>
835- <doc:description>
836- <doc:para>
837- If the power source is present in the bay.
838- This field is required as some batteries are hot-removable, for example
839- expensive UPS and most laptop batteries.
840- </doc:para><doc:para>
841- This property is only valid if the property
842- <doc:ref type="property" to="Source:Type">type</doc:ref>
843- has the value "battery".
844- </doc:para>
845- </doc:description>
846- </doc:doc>
847- </property>
848-
849- <property name="State" type="u" access="read">
850- <doc:doc>
851- <doc:description>
852- <doc:para>
853- The battery power state.
854- </doc:para>
855- <doc:list>
856- <doc:item>
857- <doc:term>0</doc:term><doc:definition>Unknown</doc:definition>
858- </doc:item>
859- <doc:item>
860- <doc:term>1</doc:term><doc:definition>Charging</doc:definition>
861- </doc:item>
862- <doc:item>
863- <doc:term>2</doc:term><doc:definition>Discharging</doc:definition>
864- </doc:item>
865- <doc:item>
866- <doc:term>3</doc:term><doc:definition>Empty</doc:definition>
867- </doc:item>
868- <doc:item>
869- <doc:term>4</doc:term><doc:definition>Fully charged</doc:definition>
870- </doc:item>
871- <doc:item>
872- <doc:term>5</doc:term><doc:definition>Pending charge</doc:definition>
873- </doc:item>
874- <doc:item>
875- <doc:term>6</doc:term><doc:definition>Pending discharge</doc:definition>
876- </doc:item>
877- </doc:list>
878- <doc:para>
879- This property is only valid if the property
880- <doc:ref type="property" to="Source:Type">type</doc:ref>
881- has the value "battery".
882- </doc:para>
883- </doc:description>
884- </doc:doc>
885- </property>
886-
887- <property name="IsRechargeable" type="b" access="read">
888- <doc:doc>
889- <doc:description>
890- <doc:para>
891- If the power source is rechargeable.
892- </doc:para><doc:para>
893- This property is only valid if the property
894- <doc:ref type="property" to="Source:Type">type</doc:ref>
895- has the value "battery".
896- </doc:para>
897- </doc:description>
898- </doc:doc>
899- </property>
900-
901- <property name="Capacity" type="d" access="read">
902- <doc:doc>
903- <doc:description>
904- <doc:para>
905- The capacity of the power source expressed as a percentage between 0 and 100.
906- The capacity of the battery will reduce with age.
907- A capacity value less than 75% is usually a sign that you should renew your battery.
908- Typically this value is the same as
909- (<doc:ref type="property" to="Source:FullDesign">full-design</doc:ref> /
910- <doc:ref type="property" to="Source:Full">full</doc:ref>) * 100.
911- However, some primitive power sources are not capable reporting capacity
912- and in this case the capacity property will be unset.
913- </doc:para><doc:para>
914- This property is only valid if the property
915- <doc:ref type="property" to="Source:Type">type</doc:ref>
916- has the value "battery".
917- </doc:para>
918- </doc:description>
919- </doc:doc>
920- </property>
921-
922- <property name="Technology" type="u" access="read">
923- <doc:doc>
924- <doc:description>
925- <doc:para>
926- Technology used in the battery:
927- </doc:para>
928- <doc:list>
929- <doc:item>
930- <doc:term>0</doc:term><doc:definition>Unknown</doc:definition>
931- </doc:item>
932- <doc:item>
933- <doc:term>1</doc:term><doc:definition>Lithium ion</doc:definition>
934- </doc:item>
935- <doc:item>
936- <doc:term>2</doc:term><doc:definition>Lithium polymer</doc:definition>
937- </doc:item>
938- <doc:item>
939- <doc:term>3</doc:term><doc:definition>Lithium iron phosphate</doc:definition>
940- </doc:item>
941- <doc:item>
942- <doc:term>4</doc:term><doc:definition>Lead acid</doc:definition>
943- </doc:item>
944- <doc:item>
945- <doc:term>5</doc:term><doc:definition>Nickel cadmium</doc:definition>
946- </doc:item>
947- <doc:item>
948- <doc:term>6</doc:term><doc:definition>Nickel metal hydride</doc:definition>
949- </doc:item>
950- </doc:list>
951- <doc:para>
952- This property is only valid if the property
953- <doc:ref type="property" to="Source:Type">type</doc:ref>
954- has the value "battery".
955- </doc:para>
956- </doc:description>
957- </doc:doc>
958- </property>
959-
960- <property name="RecallNotice" type="b" access="read">
961- <doc:doc>
962- <doc:description>
963- <doc:para>
964- If the device may have been recalled by the vendor due to a suspected
965- fault.
966- This key does not imply the device is faulty, only that it approximatly
967- matches the description from the vendor of units that were recalled.
968- </doc:para>
969- </doc:description>
970- </doc:doc>
971- </property>
972-
973- <property name="RecallVendor" type="s" access="read">
974- <doc:doc>
975- <doc:description>
976- <doc:para>
977- The vendor that is handling the hardware recall.
978- </doc:para>
979- <doc:para>
980- This property is only valid if the property recall-notice is true.
981- </doc:para>
982- </doc:description>
983- </doc:doc>
984- </property>
985-
986- <property name="RecallUrl" type="s" access="read">
987- <doc:doc>
988- <doc:description>
989- <doc:para>
990- The URL to visit about the hardware recall.
991- </doc:para>
992- <doc:para>
993- This property is only valid if the property recall-notice is true.
994- </doc:para>
995- </doc:description>
996- </doc:doc>
997- </property>
998-
999- </interface>
1000-
1001-</node>

Subscribers

People subscribed via source and target branches