[openrtm-commit:00681] r2322 - trunk/OpenRTM-aist/src/ext/ec/logical_time/example

openrtm @ openrtm.org openrtm @ openrtm.org
2012年 2月 8日 (水) 10:58:14 JST


Author: n-ando
Date: 2012-02-08 10:58:14 +0900 (Wed, 08 Feb 2012)
New Revision: 2322

Modified:
   trunk/OpenRTM-aist/src/ext/ec/logical_time/example/Makefile.am
   trunk/OpenRTM-aist/src/ext/ec/logical_time/example/TickApp.py
   trunk/OpenRTM-aist/src/ext/ec/logical_time/example/run.sh
Log:
[compat,Makefile/scripts,bugfix] TriggerApp vcproj entry has been removed. TickApp.py has been updated. run.sh has been updated just to run TickApp.py.


Modified: trunk/OpenRTM-aist/src/ext/ec/logical_time/example/Makefile.am
===================================================================
--- trunk/OpenRTM-aist/src/ext/ec/logical_time/example/Makefile.am	2012-02-07 18:52:38 UTC (rev 2321)
+++ trunk/OpenRTM-aist/src/ext/ec/logical_time/example/Makefile.am	2012-02-08 01:58:14 UTC (rev 2322)
@@ -82,15 +82,6 @@
 		--source LTTSample.cpp                          \
 		--header LTTSample.h
 	qkc -sm $(win32_builddir)/LTTSampleDll_vc8.vcproj
-	$(top_builddir)/build/vcprojtool.py vcproj        \
-		--type EXE                                    \
-		--vcversion "8.00"                            \
-		--projectname "TriggerApp"                    \
-		--version $(RTM_VERSION)                      \
-		--out $(win32_builddir)/TriggerApp_vc8.vcproj \
-		--yaml ../rtc.vcproj.yaml                     \
-		--source TriggerApp.cpp
-	qkc -sm $(win32_builddir)/TriggerApp_vc8.vcproj
 
 vc9proj:
 	$(top_builddir)/build/vcprojtool.py vcproj       \
@@ -113,15 +104,6 @@
 		--source LTTSample.cpp                          \
 		--header LTTSample.h
 	qkc -sm $(win32_builddir)/LTTSampleDll_vc9.vcproj
-	$(top_builddir)/build/vcprojtool.py vcproj        \
-		--type EXE                                    \
-		--vcversion "9.00"                            \
-		--projectname "TriggerAppComp"                \
-		--version $(RTM_VERSION)                      \
-		--out $(win32_builddir)/TriggerApp_vc9.vcproj \
-		--yaml ../rtc.vcproj.yaml                     \
-		--source TriggerApp.cpp
-	qkc -sm $(win32_builddir)/TriggerApp_vc9.vcproj
 
 vc10proj:
 	$(top_builddir)/build/vcxprojtool.py vcxproj       \
@@ -144,20 +126,11 @@
 		--source LTTSample.cpp                            \
 		--header LTTSample.h
 	qkc -sm $(win32_builddir)/LTTSampleDll_vc10.vcxproj
-	$(top_builddir)/build/vcxprojtool.py vcxproj        \
-		--type EXE                                      \
-		--vcversion "10.00"                             \
-		--projectname "TriggerAppComp"                  \
-		--version $(RTM_VERSION)                        \
-		--out $(win32_builddir)/TriggerApp_vc10.vcxproj \
-		--yaml ../rtc.vcxproj.yaml                      \
-		--source TriggerApp.cpp
-	qkc -sm $(win32_builddir)/TriggerApp_vc10.vcxproj
 
 dist-hook: lst
 
 clean-local:
-	rm -f \
-	*.bak *.rpo *.sym lib*.*_pure_* *.lst \
-	Makefile.old *core *~ *.so *.log
+	rm -f *.bak *.rpo *.sym lib*.*_pure_* *.lst
+	rm -f Makefile.old *core *~ *.so *.log
 	rm -f $(example_PROGRAMS)
+	rm -rf idl

Modified: trunk/OpenRTM-aist/src/ext/ec/logical_time/example/TickApp.py
===================================================================
--- trunk/OpenRTM-aist/src/ext/ec/logical_time/example/TickApp.py	2012-02-07 18:52:38 UTC (rev 2321)
+++ trunk/OpenRTM-aist/src/ext/ec/logical_time/example/TickApp.py	2012-02-08 01:58:14 UTC (rev 2322)
@@ -1,19 +1,45 @@
 #!/usr/bin/env python
+# -*- coding: euc-jp -*- 
+##
+# @file TickApp.py
+# @brief Example application for LogicalTimeTriggeredEC
+# @date$
+# @author Noriaki Ando <n-ando at aist.go.jp>
+#
+# Copyright (C) 2012
+#     Noriaki Ando
+#     Intelligent Systems Research Institute,
+#     National Institute of
+#         Advanced Industrial Science and Technology (AIST), Japan
+#     All rights reserved.
+#
+# Usage:
+# $ python TickApp.py
+#
+# This python script
+# - Launches LTTSampleComp component,
+# - Gets its object reference from LTTSample.rtc file in the current directory,
+# - Obtains EC from RTC
+# - When tick button is pushed, tick() operation of the EC is called
+# - And then call gettime() operation of the EC is called
+# - print current time
+# - When X button is pushed, tryp to terminate LTTSampleComp
+# - And kill all the process LTTSampleComp (and lt-LTTSampleComp)
+#
+# Requirement:
+# - LogicalTimeTriggeredEC.so as EC
+# - FileNameservice.so as local service
+# - SDOPackage.idl, RTC.idl and LogicalTimeTriggeredEC.idl in idl dir
+#
+# See details in rtc.conf
+#
 
 import Tkinter as Tk
 
-class SendTick:
-    def __init__(self):
-        pass
-
-def hoge():
-    print "hoge"
-    
 class Frame(Tk.Frame):
     def __init__(self, master = None):
         self.lttsample = LTTSample()
         self.time = 0.0
-#        self.protocol("WM_DELETE_WINDOW", self.closeEvent)
         Tk.Frame.__init__(self, master)
         self.master.title('Tick Application')
 
@@ -93,8 +119,8 @@
         import time
         time.sleep(1.0)
         import os
-        os.system("killall LTTSampleComp")
-        os.system("killall lt-LTTSampleComp")
+        os.popen("killall -q LTTSampleComp")
+        os.popen("killall -q lt-LTTSampleComp")
 
 import CORBA
 
@@ -106,11 +132,21 @@
         except:
             print "LTTSample0.rtc not found"
             import os
-            import time
-            print "Launching LTTSampleComp..."
+            import time, sys
+            write = sys.stdout.write
+            write("Launching LTTSampleComp...")
+            sys.stdout.flush()
             os.system("./LTTSampleComp&")
-            time.sleep(1.0)
-            self.ior = open("LTTSample0.rtc").read()
+            while True:
+                try:
+                    self.ior = open("LTTSample0.rtc").read()
+                    break;
+                except:
+                    write(".")
+                    sys.stdout.flush()
+                    time.sleep(0.01)
+                    pass
+            print "done"
         obj = self.orb.string_to_object(self.ior)
         if CORBA.is_nil(obj):
             print "Object in LTTSample0.rtc is nil. Restarting LTTSampleComp..."
@@ -126,7 +162,8 @@
 
         self.sdo_idl = omniORB.importIDL("idl/SDOPackage.idl")
         self.rtc_idl = omniORB.importIDL("idl/RTC.idl", ["-Iidl"])
-        self.ltt_idl = omniORB.importIDL("idl/LogicalTimeTriggeredEC.idl", ["-Iidl"])
+        self.ltt_idl = omniORB.importIDL("idl/LogicalTimeTriggeredEC.idl",
+                                         ["-Iidl"])
 
         RTC = sys.modules["RTC"]
         OpenRTM = sys.modules["OpenRTM"]
@@ -145,7 +182,20 @@
         cxts = self.rtobj.get_owned_contexts()
         self.lttcxt = cxts[0]._narrow(OpenRTM.LogicalTimeTriggeredEC)
         profile = self.lttcxt.get_profile()
-        print profile
+        p = {}
+        p["kind"] = profile.kind
+        p["rate"] = profile.rate
+        p["owner"] = profile.owner
+        from omniORB import any
+        for prop in profile.properties:
+            p[prop.name] = any.from_any(prop.value)
+        print "ExecutionContext:"
+        print "      type:", p.pop("type")
+        print "      name:", p.pop("name")
+        print "      kind:", p.pop("kind")
+        print "      rate:", p.pop("rate")
+        print "     owner:", p.pop("owner")
+        print "properties:", p
 
     def tick(self, ticktime):
         sec = int(ticktime)
@@ -157,11 +207,20 @@
 
     def shutdown(self):
         self.rtobj.exit()
+        import time, sys
+        write = sys.stdout.write
+        write("Waiting RTC termination.")
+        try:
+            while True:
+                self.rtobj._non_existent()
+                write(".")
+                sys.stdout.flush()
+                time.sleep(0.01)
+        except:
+            pass
+        print "done"
 
-
 if __name__ == '__main__':
-#    root = Tk.Tk()
-#    root.protocol("WM_DELETE_WINDOW", on_close(root))
     f = Frame()
     f.pack()
     f.mainloop()

Modified: trunk/OpenRTM-aist/src/ext/ec/logical_time/example/run.sh
===================================================================
--- trunk/OpenRTM-aist/src/ext/ec/logical_time/example/run.sh	2012-02-07 18:52:38 UTC (rev 2321)
+++ trunk/OpenRTM-aist/src/ext/ec/logical_time/example/run.sh	2012-02-08 01:58:14 UTC (rev 2322)
@@ -1,56 +1,3 @@
 #!/bin/sh
-#
-# @file run.sh
-# @brief SimpleIO example startup script
-# @date $Date: 2007-04-27 06:12:53 $
-#
-# Copyright (c) 2003-2007 Noriaki Ando <n-ando at aist.go.jp>
-#          Task-intelligence Research Group,
-#          Intelligent System Research Institute,
-#          National Institute of Industrial Science (AIST), Japan
-#          All rights reserved.
-#
-# $Id: run.sh 1421 2009-07-01 07:19:36Z hakuta $
-#
 
-nsport='9876'
-hostname=`hostname`
-
-
-term=`which kterm`
-
-if test "x$term" = "x" ; then
-    term=`which xterm`
-fi
-
-if test "x$term" = "x" ; then
-    term=`which uxterm`
-fi
-
-if test "x$term" = "x" ; then
-    term=`which gnome-terminal`
-fi
-
-if test "x$term" = "x" ; then
-    echo "No terminal program (kterm/xterm/gnome-terminal) exists."
-    exit
-fi
-
-../../utils/rtm-naming/rtm-naming $nsport
-
-echo 'corba.nameservers: '$hostname':'$nsport > ./rtc.conf
-echo 'naming.formats: %n.rtc' >> ./rtc.conf
-echo 'logger.log_level: TRACE' >> ./rtc.conf
-echo 'exec_cxt.periodic.type: ExtTrigExecutionContext' >> ./rtc.conf
-echo 'exec_cxt.periodic.rate: 1000' >> ./rtc.conf
-
-$term -e ./ConsoleInCompExt &
-$term -e ./ConsoleOutCompExt &
-
-sleep 5
-./ConnectorCompExt 
-
-#sleep 10
-#nspid=`ps -ax | grep 9876 | awk '{print $1}'`
-#kill $nspid
-#echo 'Naming service was stopped.'
+python TickApp.py



openrtm-commit メーリングリストの案内