Author: remi
Date: 2009-03-31 12:40:57 +0200 (Tue, 31 Mar 2009)
New Revision: 4278

Modified:
   
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/01_robot_system/resourceGadgetFramework.py
   
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/Gadget.py
Log:
* framework support a new notification type (result)
  - This notification type will be used for the "check" command of the gadgets.

Modified: 
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/01_robot_system/resourceGadgetFramework.py
===================================================================
--- 
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/01_robot_system/resourceGadgetFramework.py
 2009-03-31 10:13:17 UTC (rev 4277)
+++ 
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/01_robot_system/resourceGadgetFramework.py
 2009-03-31 10:40:57 UTC (rev 4278)
@@ -19,6 +19,7 @@
 ST_NAME_FW_GADGET_MESSAGE = "framework_gadget_message"
 ST_NAME_FW_GADGET_ERROR = "framework_gadget_error"
 ST_NAME_FW_GADGET_TRACE = "framework_gadget_trace"
+ST_NAME_FW_GADGET_RESULT = "framework_gadget_result"
 ST_NAME_FW_GADGET_NOTIFICATION = "framework_gadget_notification"
 ST_NAME_FW_GADGET_STARTING = "framework_gadget_starting"
 ST_NAME_FW_GADGET_STOPPED = "framework_gadget_stopped"
@@ -33,6 +34,7 @@
     ST_NAME_FW_GADGET_MESSAGE, # Is not sent to clients
     ST_NAME_FW_GADGET_ERROR, # Is not sent to clients
     ST_NAME_FW_GADGET_TRACE, # Is not sent to clients
+    ST_NAME_FW_GADGET_RESULT, # Is not sent to clients
     ST_NAME_FW_GADGET_NOTIFICATION, # Is not sent to clients
     ST_NAME_FW_GADGET_STARTING, # Is sent to clients
     ST_NAME_FW_GADGET_STOPPED, # Is sent to clients
@@ -130,6 +132,7 @@
         gadget.setOnGadgetMessageCallback(self.__onGadgetMessage)
         gadget.setOnGadgetErrorCallback(self.__onGadgetError)
         gadget.setOnGadgetTraceCallback(self.__onGadgetTrace)
+        gadget.setOnGadgetResultCallback(self.__onGadgetResult)
         gadget.setOnGadgetStartingCallback(self.__onGadgetStarting)
         gadget.setOnGadgetStoppedCallback(self.__onGadgetStopped)
         self.logger.logDebug("Gadget deployed [%s] to [%s]" % (
@@ -204,6 +207,12 @@
         self.__publishEvents(False, ST_NAME_FW_GADGET_TRACE, [
             gadget.getDescription().getUuid(), "0", messageStr])
 
+    def __onGadgetResult(self, gadget, instanceParameters, gadgetResult):
+        self.logger.logDebug("Gadget RESULT [%s] (%s)" % (
+            gadget.getDescription().getName(), str(gadgetResult)))
+        self.__publishEvents(False, ST_NAME_FW_GADGET_RESULT, [
+            gadget.getDescription().getUuid(), "0", str(gadgetResult)])
+
     def __onGadgetStarting(self, gadget, instanceParameters, instanceCommand,
         instanceIsDaemon):
         uuid = gadget.getDescription().getUuid()
@@ -215,6 +224,8 @@
         instanceIsDaemon):
         uuid = gadget.getDescription().getUuid()
         if instanceIsDaemon:
+            self.logger.logInfo("Gadget stopped [%s]" % (
+            gadget.getDescription().getName()))
             self.__publishEvents(True, ST_NAME_FW_GADGET_STOPPED, [uuid, "FW"])
             self.__publishEvents(True, ST_NAME_FW_GADGET_STOPPED, [uuid, 
"TTS"])
         else:

Modified: 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/Gadget.py
===================================================================
--- 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/Gadget.py
      2009-03-31 10:13:17 UTC (rev 4277)
+++ 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/Gadget.py
      2009-03-31 10:40:57 UTC (rev 4278)
@@ -134,6 +134,7 @@
         self.__onGadgetMessageCallback = None
         self.__onGadgetErrorCallback = None
         self.__onGadgetTraceCallback = None
+        self.__onGadgetResultCallback = None
         self.__onGadgetStartingCallback = None
         self.__onGadgetStoppedCallback = None
 
@@ -373,6 +374,18 @@
         self.__onGadgetTraceCallback = funct
 
     # 
--------------------------------------------------------------------------
+    # Set the gadget result event callback.
+    # 
--------------------------------------------------------------------------
+    def setOnGadgetResultCallback(self, funct):
+        """Set the gadget result event callback.
+        @param funct: Function pointer.
+        Function prototype:
+        def onGadgetResult(gadget, instanceParameters, gadgetResult):
+            pass
+        """
+        self.__onGadgetResultCallback = funct
+
+    # 
--------------------------------------------------------------------------
     # Set the gadget starting event callback.
     # 
--------------------------------------------------------------------------
     def setOnGadgetStartingCallback(self, funct):
@@ -438,6 +451,17 @@
             if self.__onGadgetErrorCallback != None:
                 self.__onGadgetErrorCallback(self,
                     self.__gadgetInstanceParameters, *args)
+        elif messageId == "check_result":
+            if self.__onGadgetResultCallback != None:
+                if len(args) > 0:
+                    if args[0] == "true":
+                        checkResult = True
+                    else:
+                        checkResult = False
+                else:
+                    checkResult = False
+                self.__onGadgetResultCallback(self,
+                    self.__gadgetInstanceParameters, checkResult)
         else:
             if self.__onGadgetNotificationCallback != None:
                 self.__onGadgetNotificationCallback(self,


------------------------------------------------------------------------------
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to