[openrtm-commit:02079] r2789 - in branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer: . test test/idl

openrtm @ openrtm.org openrtm @ openrtm.org
2016年 10月 27日 (木) 00:47:26 JST


Author: n-ando
Date: 2016-10-27 00:47:26 +0900 (Thu, 27 Oct 2016)
New Revision: 2789

Added:
   branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/idl/
   branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/idl/ComponentObserver.idl
   branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/idl/Makefile
   branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/idl/SDOPackage.idl
   branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/observer.py
   branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/rtc.conf
Modified:
   branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.cpp
   branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.h
   branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/test.sh
Log:
[FSM4RTC,ext,example] Now component observer is connected to the FSM state change operation.

Modified: branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.cpp
===================================================================
--- branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.cpp	2016-10-26 15:32:34 UTC (rev 2788)
+++ branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.cpp	2016-10-26 15:47:26 UTC (rev 2789)
@@ -763,6 +763,10 @@
    */
   void ComponentObserverConsumer::setFSMStructureListeners()
   {
+    m_fsmaction.fsmActionListener = 
+      m_rtobj->addPreFsmActionListener(PRE_ON_STATE_CHANGE,
+                                       m_fsmaction,
+                                       &FSMAction::updateFsmStatus);
   }
 
   /*!

Modified: branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.h
===================================================================
--- branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.h	2016-10-26 15:32:34 UTC (rev 2788)
+++ branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/ComponentObserverConsumer.h	2016-10-26 15:47:26 UTC (rev 2789)
@@ -26,6 +26,7 @@
 #include <rtm/SdoServiceConsumerBase.h>
 #include <rtm/CorbaConsumer.h>
 #include <rtm/ComponentActionListener.h>
+#include <rtm/FsmActionListener.h>
 #include <rtm/idl/SDOPackageStub.h>
 #include "ComponentObserverStub.h"
 
@@ -625,8 +626,14 @@
       FSMAction(ComponentObserverConsumer& coc)
         : m_coc(coc) {}
       // Action callback functions here
+      void updateFsmStatus(const char* state)
+      {
+        std::cout << "ComponentObserver::updateFsmStatus(" << state << ")" << std::endl; 
+        m_coc.updateStatus(RTC::FSM_STATUS, state);
+      }
       
       // Listener object's pointer holder
+      PreFsmActionListener* fsmActionListener;
 
     private:
       ComponentObserverConsumer& m_coc;

Added: branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/idl/ComponentObserver.idl
===================================================================
--- branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/idl/ComponentObserver.idl	                        (rev 0)
+++ branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/idl/ComponentObserver.idl	2016-10-26 15:47:26 UTC (rev 2789)
@@ -0,0 +1,36 @@
+#ifndef _COMPONENT_OBSERVER_IDL_
+#define _COMPONENT_OBSERVER_IDL_
+
+#include <SDOPackage.idl>
+
+#pragma prefix "omg.org"
+
+module RTC
+{
+    enum StatusKind
+    {
+        COMPONENT_PROFILE,
+        RTC_STATUS,
+        EC_STATUS,
+        PORT_PROFILE,
+        CONFIGURATION,
+        RTC_HEARTBEAT,
+        EC_HEARTBEAT,
+        FSM_PROFILE,
+        FSM_STATUS,
+        FSM_STRUCTURE,
+        USER_DEFINED,
+        STATUS_KIND_NUM
+    };
+    #pragma version StatusKind 1.0
+
+    interface ComponentObserver : SDOPackage::SDOService
+    {
+        oneway void update_status(in StatusKind status_kind,
+                                  in string     hint);
+    };
+    #pragma version ComponentObserver 1.0
+};
+
+#endif // _COMPONENT_OBSERVER_IDL_
+

Added: branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/idl/Makefile
===================================================================
--- branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/idl/Makefile	                        (rev 0)
+++ branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/idl/Makefile	2016-10-26 15:47:26 UTC (rev 2789)
@@ -0,0 +1,10 @@
+all:
+	touch __init__.py
+	omniidl -bpython -I. SDOPackage.idl
+	omniidl -bpython -I. ComponentObserver.idl
+
+clean:
+	rm -f *.py *.pyc
+	rm -rf SDOPackage SDOPackage__POA 
+	rm -rf RTC RTC__POA
+

Added: branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/idl/SDOPackage.idl
===================================================================
--- branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/idl/SDOPackage.idl	                        (rev 0)
+++ branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/idl/SDOPackage.idl	2016-10-26 15:47:26 UTC (rev 2789)
@@ -0,0 +1,296 @@
+//Platform Independent Model (PIM) and Platform Specific Model (PSM)
+//for Super Distributed Objects (SDO) Specification, v1.1 - OMG IDL Summary File
+//Object Management Group, Inc.
+//Copyright (c) 2003, Fraunhofer FOKUS
+//Copyright (c) 2003, Hitachi, Ltd.
+//The companies listed above have granted to the Object Management Group, Inc. 
+//(OMG) a nonexclusive, royalty-free, paid up, worldwide license to copy and 
+//distribute this document and to modify this document and distribute copies of 
+//the modified version. Each of the copyright holders listed above has agreed 
+//that no person shall be deemed to have infringed the copyright in the included 
+//material of any such copyright holder by reason of having used the 
+//specification set forth herein or having conformed any computer software to 
+//the specification. 
+//
+//This file contains OMG IDL from the Naming Service Specification, v1.2.
+//OMG regularly publishes a summary file that contains all the "code" parts of 
+//an OMG formal document. Every formal document line that is IDL, PIDL, or 
+//language code is included in the summary file. The reason for such a listing 
+//is to give readers an electronic version of the "code" so that they can 
+//extract pieces of it. Readers might want to test an example, include it in 
+//their own code, or use it for documentation purposes. Having the code lines 
+//available electronically means there is less likelihood of a transcription 
+//error. 
+//
+// ver 1.0  formal/2004-11-02
+// ver 1.1  (RTF report: dtc/2008-03-05)
+//
+//SDOPackage.idl
+
+#ifndef    _SDO_PACKAGE_IDL_
+#define    _SDO_PACKAGE_IDL_
+
+#ifdef TAO_IDL
+#include <orb.idl>
+#endif
+#ifdef USE_MONITORING
+#include <CosNotifyComm.idl>
+#endif
+
+/** CORBA specific model for SDOs */
+
+#pragma prefix "org.omg"
+#define exception_body { string description; }
+
+module SDOPackage
+{
+  interface SDO;
+  interface SDOService;
+  interface SDOSystemElement;
+  interface Configuration;
+  interface Monitoring;
+  interface Organization;
+
+  /** ------- Data Types -------*/
+  typedef sequence<string>       StringList;
+  typedef sequence<SDO>          SDOList;
+  typedef sequence<Organization> OrganizationList;
+  typedef string                 UniqueIdentifier;
+
+  struct NameValue
+  {
+    string name;
+    any value;
+  };
+
+  typedef sequence<NameValue>   NVList;
+
+  enum NumericType
+  {
+    SHORT_TYPE,
+    LONG_TYPE,
+    FLOAT_TYPE,
+    DOUBLE_TYPE
+  };
+
+  union Numeric switch (NumericType)
+  {
+  case SHORT_TYPE:  short short_value;
+  case LONG_TYPE: long long_value;
+  case FLOAT_TYPE: float float_value;
+  case DOUBLE_TYPE: double double_value;
+  };
+
+  struct EnumerationType
+  {
+    StringList enumerated_values;
+  };
+
+  struct RangeType
+  {
+    Numeric min;
+    Numeric max;
+    boolean min_inclusive;
+    boolean max_inclusive;
+  };
+
+  struct IntervalType
+  {
+    Numeric min;
+    Numeric max;
+    boolean min_inclusive;
+    boolean max_inclusive;
+    Numeric step;
+  };
+
+  enum ComplexDataType
+  {
+    ENUMERATION, RANGE, INTERVAL
+  };
+
+  union AllowedValues switch (ComplexDataType)
+  {
+  case ENUMERATION:    EnumerationType allowed_enum;
+  case INTERVAL:       IntervalType allowed_interval;
+  case RANGE:          RangeType   allowed_range;
+  };
+
+  struct Parameter
+  {
+    string         name;
+#ifdef __ORBIT_IDL__
+    TypeCode type;
+#else
+    CORBA::TypeCode type;
+#endif
+    AllowedValues  allowed_values;
+  };
+
+  typedef sequence<Parameter> ParameterList;
+  struct OrganizationProperty
+  {
+    NVList properties;
+  };
+  enum DependencyType
+  {
+    OWN,
+    OWNED,
+    NO_DEPENDENCY
+  };
+
+  struct DeviceProfile
+  {
+    string device_type;
+    string manufacturer;
+    string model;
+    string version;
+    NVList properties;
+  };
+
+  struct ServiceProfile
+  {
+    string id;
+    string interface_type;
+    NVList properties;
+    SDOService service;
+  };
+
+  typedef sequence <ServiceProfile> ServiceProfileList;
+  struct ConfigurationSet
+  {
+    string id;
+    string description;
+    NVList configuration_data;
+  };
+
+  typedef sequence<ConfigurationSet> ConfigurationSetList;
+
+
+  /** ------- Exceptions -------*/
+  exception NotAvailable             exception_body;
+  exception InterfaceNotImplemented  exception_body;
+  exception InvalidParameter         exception_body;
+  exception InternalError            exception_body;
+
+  /** ------- Interfaces -------*/
+  interface SDOSystemElement
+  {
+    OrganizationList get_owned_organizations()
+      raises (NotAvailable,InternalError);
+  };
+  interface SDO : SDOSystemElement
+  {
+    UniqueIdentifier get_sdo_id()
+      raises (NotAvailable, InternalError);
+    string get_sdo_type()
+      raises (NotAvailable, InternalError);
+    DeviceProfile get_device_profile ()
+      raises (NotAvailable, InternalError);
+    ServiceProfileList get_service_profiles ()
+      raises (NotAvailable, InternalError);
+    ServiceProfile get_service_profile (in UniqueIdentifier id)
+      raises (InvalidParameter, NotAvailable, InternalError);
+    SDOService get_sdo_service (in UniqueIdentifier id) 
+      raises (InvalidParameter, NotAvailable, InternalError);
+    Configuration get_configuration ()
+      raises (InterfaceNotImplemented, NotAvailable, InternalError);
+    Monitoring get_monitoring ()
+      raises (InterfaceNotImplemented, NotAvailable, InternalError);
+    OrganizationList get_organizations ()
+      raises (NotAvailable, InternalError);
+    NVList get_status_list ()
+      raises (NotAvailable, InternalError);
+    any get_status (in string nme)
+      raises (InvalidParameter, NotAvailable, InternalError);
+  };
+
+
+  interface Configuration
+  {
+    boolean set_device_profile (in DeviceProfile dProfile)
+      raises (InvalidParameter, NotAvailable, InternalError);
+    boolean add_service_profile (in ServiceProfile sProfile)
+      raises (InvalidParameter, NotAvailable, InternalError);
+    boolean add_organization (in Organization organization_object)
+      raises (InvalidParameter, NotAvailable, InternalError);
+    boolean remove_service_profile (in UniqueIdentifier id)
+      raises (InvalidParameter, NotAvailable, InternalError);
+    boolean remove_organization (in UniqueIdentifier organization_id)
+      raises (InvalidParameter, NotAvailable, InternalError);
+    ParameterList get_configuration_parameters ()
+      raises (NotAvailable, InternalError);
+    NVList get_configuration_parameter_values ()
+      raises (NotAvailable, InternalError);
+    any get_configuration_parameter_value (in string name)
+      raises (InvalidParameter, NotAvailable, InternalError);
+    boolean set_configuration_parameter (in string name,
+                                         in any value)
+      raises (InvalidParameter, NotAvailable, InternalError);
+    ConfigurationSetList get_configuration_sets ()
+      raises (NotAvailable, InternalError);
+    ConfigurationSet get_configuration_set (in UniqueIdentifier config_id)
+      raises (NotAvailable, InternalError);
+    boolean set_configuration_set_values (in ConfigurationSet configuration_set)
+      raises (InvalidParameter, NotAvailable, InternalError);
+    ConfigurationSet get_active_configuration_set ()
+      raises (NotAvailable, InternalError);
+    boolean add_configuration_set (in ConfigurationSet configuration_set)
+      raises (InvalidParameter, NotAvailable, InternalError);
+    boolean remove_configuration_set (in UniqueIdentifier config_id)
+      raises (InvalidParameter, NotAvailable, InternalError);
+    boolean activate_configuration_set (in UniqueIdentifier config_id)
+      raises (InvalidParameter, NotAvailable, InternalError);
+  };
+
+
+#ifdef USE_MONITORING
+  interface Monitoring : CosNotifyComm::StructuredPushConsumer,
+    CosNotifyComm::StructuredPushSupplier
+  {
+    any get_monitoring_parameter_value (in string name)
+      raises (InvalidParameter, NotAvailable, InternalError);
+    ParameterList get_monitoring_parameters ()
+      raises (NotAvailable, InternalError);
+    NVList get_monitoring_parameter_values ()
+      raises (NotAvailable, InternalError);
+  };
+#else
+  interface Monitoring {};
+#endif
+
+  interface SDOService {};
+
+  interface Organization
+  {
+    UniqueIdentifier get_organization_id ()
+      raises (InvalidParameter, NotAvailable, InternalError);
+    OrganizationProperty get_organization_property ()
+      raises (NotAvailable, InternalError);
+    any get_organization_property_value (in string name)
+      raises (InvalidParameter, NotAvailable, InternalError);
+    boolean add_organization_property (in OrganizationProperty organization_property)
+      raises (InvalidParameter, NotAvailable, InternalError);
+    boolean set_organization_property_value (in string name,
+                                             in any value)
+      raises (InvalidParameter, NotAvailable, InternalError);
+    boolean remove_organization_property ( in string name )
+      raises (InvalidParameter, NotAvailable, InternalError);
+    SDOSystemElement get_owner ()
+      raises (NotAvailable, InternalError);
+    boolean set_owner (in SDOSystemElement sdo) 
+      raises (InvalidParameter, NotAvailable, InternalError);
+    SDOList get_members ()
+      raises (NotAvailable, InternalError);
+    boolean set_members (in SDOList sdos) 
+      raises (InvalidParameter, NotAvailable, InternalError);
+    boolean add_members ( in SDOList sdo_list)
+      raises (InvalidParameter, NotAvailable, InternalError);
+    boolean remove_member (in UniqueIdentifier id)
+      raises (InvalidParameter, NotAvailable, InternalError);
+    DependencyType get_dependency()
+      raises (NotAvailable, InternalError);
+    boolean set_dependency (in DependencyType dependency) 
+      raises (NotAvailable, InternalError);
+  };
+};
+#endif //_SDO_PACKAGE_IDL_

Added: branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/observer.py
===================================================================
--- branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/observer.py	                        (rev 0)
+++ branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/observer.py	2016-10-26 15:47:26 UTC (rev 2789)
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+# -*- Python -*-
+# -*- coding: utf-8 -*-
+
+#import sys
+#sys.path = sys.path
+
+import idl
+import RTC__POA
+import idl.ComponentObserver_idl
+import SDOPackage
+from omniORB import CORBA, PortableServer, any
+import omniORB
+import sys
+import uuid
+
+def dict_to_nvlist(dict):
+    '''Convert a dictionary into a CORBA namevalue list.'''
+    result = []
+    for item in list(dict.keys()):
+        result.append(SDOPackage.NameValue(item, omniORB.any.to_any(dict[item])))
+    return result
+
+class RTCObserver(RTC__POA.ComponentObserver):
+    def __init__(self):
+        pass
+        
+    def update_status(self, kind, hint):
+        kind = str(kind)
+        print "kind: " + kind + " hint: " + hint
+
+
+orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
+poa = orb.resolve_initial_references("RootPOA")
+poa._get_the_POAManager().activate()
+
+fd = open("comp.ior", "r")
+ior = fd.readline()
+fd.close()
+
+print ior
+
+obj = orb.string_to_object(ior)
+sdo = obj._narrow(SDOPackage.SDO)
+conf = sdo.get_configuration()
+
+obs = RTCObserver()
+uuid_val = uuid.uuid4().get_bytes()
+intf_type = obs._this()._NP_RepositoryId
+props = dict_to_nvlist({'heartbeat.enable': 'YES',
+                        'heartbeat.interval': '1.0',
+                        'observed_status': 'ALL'})
+
+sprof = SDOPackage.ServiceProfile(id=uuid_val,
+                                  interface_type=intf_type,
+                                  service=obs._this(),
+                                  properties=props)
+res = conf.add_service_profile(sprof)
+orb.run()
+print res


Property changes on: branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/observer.py
___________________________________________________________________
Added: svn:executable
   + *

Added: branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/rtc.conf
===================================================================
--- branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/rtc.conf	                        (rev 0)
+++ branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/rtc.conf	2016-10-26 15:47:26 UTC (rev 2789)
@@ -0,0 +1,12 @@
+logger.enable: YES
+logger.log_level: TRACE
+naming.formats: comp.ior
+
+manager.local_service.org.openrtm.local_service.nameservice.file_nameservice.base_path: ./ 
+manager.local_service.org.openrtm.local_service.nameservice.file_nameservice.file_structure: flat 
+manager.local_service.org.openrtm.local_service.nameservice.file_nameservice.context_delimiter: .
+
+manager.local_service.modules: \
+    ../.libs/ComponentObserverConsumer.so(ComponentObserverConsumerInit), \
+    ../../../local_service/nameservice_file/.libs/FileNameservice.so(FileNameserviceInit)
+

Modified: branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/test.sh
===================================================================
--- branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/test.sh	2016-10-26 15:32:34 UTC (rev 2788)
+++ branches/FSM4RTC/OpenRTM-aist/src/ext/sdo/fsm4rtc_observer/test/test.sh	2016-10-26 15:47:26 UTC (rev 2789)
@@ -1,4 +1,5 @@
 #!/bin/sh
 rm *.log
-../../../../../examples/SimpleIO/ConsoleInComp -o "logger.log_level:DEBUG" -o "manager.local_service.modules:../.libs/ComponentObserverConsumer.so(ComponentObserverConsumerInit)"
+../../../../../examples/Fsm/FsmComp -f ./rtc.conf
 
+



More information about the openrtm-commit mailing list