[pkg-fso-commits] [SCM] framworkd debian packageing branch, master, updated. milestone2-110-g76700a0

Michael 'Mickey' Lauer mickey at vanille-media.de
Tue Sep 2 10:34:57 UTC 2008


The following commit has been merged in the master branch:
commit 3e07f8280afb3e466192562ad63a2cd889830266
Author: Michael 'Mickey' Lauer <mickey at vanille-media.de>
Date:   Wed Aug 27 16:43:42 2008 +0200

    oeventsd: add triggers and rules for power management
    (NOTE: after MS3 we need to separate the device specific stuff from the generic stuff here!)

diff --git a/ChangeLog b/ChangeLog
index 575aa7f..3aae1c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2008-08-27	Michael Lauer	<mickey at openmoko.org>
 
 	* [odeviced] Implement power status notifications using netlink socket
+	* [oeventsd] add triggers and rule for power management and LEDs
 
 2008-08-26	Michael Lauer	<mickey at openmoko.org>
 
diff --git a/etc/freesmartphone/oevents/rules.yaml b/etc/freesmartphone/oevents/rules.yaml
index 0f81e16..4ccb20d 100644
--- a/etc/freesmartphone/oevents/rules.yaml
+++ b/etc/freesmartphone/oevents/rules.yaml
@@ -10,6 +10,7 @@
 #
 # We define the following functions :
 # - CallStatus()            : create a trigger object activated on a call status event 
+# - PowerStatus()           : create a trigger object activated on a power status event
 # - HasAttr(name, value)    : create a filter that accept signal with a given attribute
 # - Not(filter)             : create a neg filter
 # - PlaySound(file)         : Action that starts to play an audio file
@@ -41,4 +42,22 @@
     filters: HasAttr(status, "release"))
     actions: SetScenario(stereoout)
 -
+    trigger: PowerStatus()
+    filters: HasAttr(status, "Charging"))
+    actions: 
+            - SetLed("gta02_power_blue","light")
+            - SetLed("gta02_power_orange","dark")
+-
+    trigger: PowerStatus()
+    filters: HasAttr(status, "Discharging"))
+    actions:
+            - SetLed("gta02_power_blue","dark")
+            - SetLed("gta02_power_orange","dark")
+-
+    trigger: PowerStatus()
+    filters: HasAttr(status, "Full"))
+    actions: 
+             - SetLed("gta02_power_blue","dark")
+             - SetLed("gta02_power_orange","light")
+
 
diff --git a/framework/subsystems/oeventsd/action.py b/framework/subsystems/oeventsd/action.py
index 5847385..00f0ac6 100644
--- a/framework/subsystems/oeventsd/action.py
+++ b/framework/subsystems/oeventsd/action.py
@@ -114,10 +114,27 @@ class AudioScenarioAction(DBusAction):
             logger.error( "unhandled action for Audio scenario" )
 
 #============================================================================#
+class LedAction(DBusAction):
+#============================================================================#
+    """
+    A dbus action on an Openmoko Neo LED device
+    """
+    # FIXME device specific, needs to go away from here
+    def __init__(self, device, action):
+        bus = dbus.SystemBus()
+        service = 'org.freesmartphone.odeviced'
+        obj = '/org/freesmartphone/Device/LED/%s' % device
+        interface = 'org.freesmartphone.Device.LED'
+        if action == 'light':
+            super(LedAction, self).__init__(bus, service, obj, interface, 'SetBrightness', 100)
+        else:
+            super(LedAction, self).__init__(bus, service, obj, interface, 'SetBrightness', 0)
+
+#============================================================================#
 class VibratorAction(DBusAction):
 #============================================================================#
     """
-    A dbus action on the Neo1973 vibrator device
+    A dbus action on the Openmoko Neo Vibrator device
     """
     # FIXME device specific, needs to go away from here
     def __init__(self, target = 'neo1973_vibrator', action = 'start'):
diff --git a/framework/subsystems/oeventsd/parser.py b/framework/subsystems/oeventsd/parser.py
index f8151dc..a412eaf 100644
--- a/framework/subsystems/oeventsd/parser.py
+++ b/framework/subsystems/oeventsd/parser.py
@@ -15,9 +15,9 @@ logger = logging.getLogger('oeventsd')
 import yaml
 import re
 
-from trigger import Trigger, CallStatusTrigger, TimeTrigger
+from trigger import Trigger, CallStatusTrigger, PowerStatusTrigger, TimeTrigger
 from filter import Filter, AttributeFilter
-from action import Action, AudioAction, AudioScenarioAction, VibratorAction, DebugAction
+from action import Action, AudioAction, AudioScenarioAction, LedAction, VibratorAction, DebugAction
 from ring_tone_action import RingToneAction
 from rule import Rule
 
@@ -80,6 +80,11 @@ class CallStatus(Function):
     def __call__(self):
         return CallStatusTrigger()
 
+class PowerStatus(Function):
+    name = 'PowerStatus'
+    def __call__(self):
+        return PowerStatusTrigger()
+
 class PlaySound(Function):
     name = 'PlaySound'
     def __call__(self, file):
@@ -100,6 +105,11 @@ class RingTone(Function):
     def __call__(self, cmd):
         return RingToneAction(cmd)
 
+class SetLed(Function):
+    name = 'SetLed'
+    def __call__(self, led, cmd):
+        return LedAction(led, cmd)
+
 class StartVibration(Function):
     name = 'StartVibration'
     def __call__(self):
diff --git a/framework/subsystems/oeventsd/trigger.py b/framework/subsystems/oeventsd/trigger.py
index 0f98e30..26b0a21 100644
--- a/framework/subsystems/oeventsd/trigger.py
+++ b/framework/subsystems/oeventsd/trigger.py
@@ -111,6 +111,26 @@ class CallStatusTrigger(DBusTrigger):
         return "CallStatus"
 
 #============================================================================#
+class PowerStatusTrigger(DBusTrigger):
+#============================================================================#
+    """Just a sugar trigger for a Power management status change"""
+    def __init__(self):
+        bus = dbus.SystemBus()
+        super(PowerStatusTrigger, self).__init__(
+            bus,
+            'org.freesmartphone.odeviced',
+            None,
+            'org.freesmartphone.Device.PowerSupply',
+            'PowerStatus'
+        )
+    def on_signal(self, status):
+        logger.info("Receive PowerStatus, status = %s", status)
+        self(status=status)
+
+    def __repr__(self):
+        return "PowerStatus"
+
+#============================================================================#
 class TimeTrigger(DBusTrigger):
 #============================================================================#
     def __init__(self, hour, minute):

-- 
framworkd debian packageing



More information about the pkg-fso-commits mailing list