[openrtm-commit:02527] r2975 - in branches/FSM4RTC/OpenRTM-aist/examples/StaticFsm: . idl

openrtm @ openrtm.org openrtm @ openrtm.org
2017年 3月 15日 (水) 19:41:16 JST


Author: n-ando
Date: 2017-03-15 19:41:16 +0900 (Wed, 15 Mar 2017)
New Revision: 2975

Added:
   branches/FSM4RTC/OpenRTM-aist/examples/StaticFsm/idl/
   branches/FSM4RTC/OpenRTM-aist/examples/StaticFsm/idl/ComponentObserver.idl
   branches/FSM4RTC/OpenRTM-aist/examples/StaticFsm/idl/Makefile
   branches/FSM4RTC/OpenRTM-aist/examples/StaticFsm/idl/SDOPackage.idl
   branches/FSM4RTC/OpenRTM-aist/examples/StaticFsm/observer.py
Log:
[FSM4RTC,sample] Component observer added.

Added: branches/FSM4RTC/OpenRTM-aist/examples/StaticFsm/idl/ComponentObserver.idl
===================================================================
--- branches/FSM4RTC/OpenRTM-aist/examples/StaticFsm/idl/ComponentObserver.idl	                        (rev 0)
+++ branches/FSM4RTC/OpenRTM-aist/examples/StaticFsm/idl/ComponentObserver.idl	2017-03-15 10:41:16 UTC (rev 2975)
@@ -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/examples/StaticFsm/idl/Makefile
===================================================================
--- branches/FSM4RTC/OpenRTM-aist/examples/StaticFsm/idl/Makefile	                        (rev 0)
+++ branches/FSM4RTC/OpenRTM-aist/examples/StaticFsm/idl/Makefile	2017-03-15 10:41:16 UTC (rev 2975)
@@ -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/examples/StaticFsm/idl/SDOPackage.idl
===================================================================
--- branches/FSM4RTC/OpenRTM-aist/examples/StaticFsm/idl/SDOPackage.idl	                        (rev 0)
+++ branches/FSM4RTC/OpenRTM-aist/examples/StaticFsm/idl/SDOPackage.idl	2017-03-15 10:41:16 UTC (rev 2975)
@@ -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/examples/StaticFsm/observer.py
===================================================================
--- branches/FSM4RTC/OpenRTM-aist/examples/StaticFsm/observer.py	                        (rev 0)
+++ branches/FSM4RTC/OpenRTM-aist/examples/StaticFsm/observer.py	2017-03-15 10:41:16 UTC (rev 2975)
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+# -*- Python -*-
+# -*- coding: utf-8 -*-
+
+#import sys
+#sys.path = sys.path
+
+from omniORB import CORBA, PortableServer, any
+import omniORB
+import sys
+import uuid
+
+print omniORB.importIDL("idl/SDOPackage.idl", ["-Iidl"])
+print omniORB.importIDL("idl/ComponentObserver.idl", ["-Iidl"])
+import SDOPackage
+import RTC__POA
+
+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("Microwave0.rtc", "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/examples/StaticFsm/observer.py
___________________________________________________________________
Added: svn:executable
   + *



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