[openrtm-commit:00743] r675 - trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC

openrtm @ openrtm.org openrtm @ openrtm.org
2012年 2月 24日 (金) 18:06:14 JST


Author: kurihara
Date: 2012-02-24 18:06:13 +0900 (Fri, 24 Feb 2012)
New Revision: 675

Modified:
   trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java
Log:
refs #2350

Modified: trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java	2012-02-16 01:10:53 UTC (rev 674)
+++ trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/RTObject_impl.java	2012-02-24 09:06:13 UTC (rev 675)
@@ -662,77 +662,42 @@
         if( !m_created ) {
             return ReturnCode_t.PRECONDITION_NOT_MET;
         }
-      
-        String ec_args = new String();
 
-        String ec_type = m_properties.getProperty("exec_cxt.periodic.type");
-        ec_args += m_properties.getProperty("exec_cxt.periodic.type");
-        ec_args += "?";
-        ec_args += "rate=" + m_properties.getProperty("exec_cxt.periodic.rate");
-
-        ExecutionContextFactory<ExecutionContextBase,String> factory 
-                                        = ExecutionContextFactory.instance();
-        ExecutionContextBase ec;
-        ec = factory.createObject(ec_type);
-        if (ec == null) {
-            rtcout.println(Logbuf.ERROR,"EC ("
-                                            + ec_type
-                                            + ") creation failed.");
-            Set ecs = ExecutionContextFactory.instance().getIdentifiers();
-            rtcout.println(Logbuf.DEBUG,"Available EC list: "
-                                            + ecs.toString() );
-            return ReturnCode_t.RTC_ERROR;
-/*
-            coil::vstring ecs;
-            ecs = RTC::ExecutionContextFactory::instance().getIdentifiers();
-            RTC_DEBUG(("Available EC list: %s",
-                       coil::flatten(ecs).c_str()));
-            return RTC::RTC_ERROR;
-*/
+        // EC creation
+        ArrayList<Properties> ec_args = new ArrayList<Properties>() ;
+        if (getContextOptions(ec_args)!=ReturnCode_t.RTC_OK )
+        {
+            rtcout.println(Logbuf.ERROR,"Vaild EC options are nao available. Aborting");
+            return ReturnCode_t.BAD_PARAMETER;
+            
         }
-        rtcout.println(Logbuf.DEBUG,"EC (" + ec_type + ") created.");
-//        RTC_DEBUG(("EC (%s) created.", ec_type.c_str()));
-/*
-        ec = Manager.instance().createContext(ec_args);
-        if (ec == null) {
-            return ReturnCode_t.RTC_ERROR;
+        if(createContexts(ec_args)!=ReturnCode_t.RTC_OK)
+        {
+            rtcout.println(Logbuf.ERROR,"EC creation failed. Maybe out of resources. Aborting.");
+            return ReturnCode_t.OUT_OF_RESOURCES;
         }
-*/
-        //ec.getObjRef().set_rate(Double.valueOf(m_properties.getProperty("exec_cxt.periodic.rate")).doubleValue());
-        m_eclist.add(ec);
-        ExecutionContextService ecv;
-        ecv = ec.getObjRef();
-        if (ecv == null) {
-            rtcout.println(Logbuf.ERROR,
-                                    "Getting object reference of ec failed.");
-            return ReturnCode_t.RTC_ERROR;
-        }
-        double ec_rate = Double.valueOf(m_properties.getProperty("exec_cxt.periodic.rate")).doubleValue();
-        ecv.set_rate(ec_rate);
-        rtcout.println(Logbuf.DEBUG,"Execution context rate is set to " 
-                                            + ec_rate + ".");
 
-        ec.bindComponent(this);
+        // -- entering alive state --
+        rtcout.println(Logbuf.INFO,m_ecMine.value.length
+                + " execution context"
+                + (m_ecMine.value.length == 1 ?  "was created." :"s were created." ));
 
         ReturnCode_t ret;
         ret = on_initialize();
         m_created = false;
         if( ret!=ReturnCode_t.RTC_OK ) {
+            rtcout.println(Logbuf.ERROR, "on_Initialize() failed.");
             return ret;
         }
 
-        // -- entering alive state --
-        // at least one EC must be attached
-        if (m_ecMine.value.length == 0) {
-            rtcout.println(Logbuf.ERROR, "No EC of this RTC.");
-            return ReturnCode_t.PRECONDITION_NOT_MET;
-        }
+        rtcout.println(Logbuf.DEBUG,"on_initialize() was properly done.");
         for(int intIdx=0; intIdx < m_ecMine.value.length; ++intIdx) {
             rtcout.println(Logbuf.DEBUG, "EC[" + intIdx + "] starting");
             m_ecMine.value[intIdx].start();
         }
 
         // ret must be RTC_OK
+        assert(ret == ReturnCode_t.RTC_OK);
         return ret;
     }
 



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