当前位置: 首页>>代码示例>>Python>>正文


Python OpenRTM_aist.normalize方法代码示例

本文整理汇总了Python中OpenRTM_aist.normalize方法的典型用法代码示例。如果您正苦于以下问题:Python OpenRTM_aist.normalize方法的具体用法?Python OpenRTM_aist.normalize怎么用?Python OpenRTM_aist.normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenRTM_aist的用法示例。


在下文中一共展示了OpenRTM_aist.normalize方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: initProviders

# 需要导入模块: import OpenRTM_aist [as 别名]
# 或者: from OpenRTM_aist import normalize [as 别名]
  def initProviders(self):
    self._rtcout.RTC_TRACE("initProviders()")

    # create InPort providers
    factory = OpenRTM_aist.InPortProviderFactory.instance()
    provider_types = factory.getIdentifiers()

    self._rtcout.RTC_DEBUG("available providers: %s",
                           OpenRTM_aist.flatten(provider_types))

    if self._properties.hasKey("provider_types") and \
          OpenRTM_aist.normalize(self._properties.getProperty("provider_types")) != "all":
      self._rtcout.RTC_DEBUG("allowed providers: %s",
                             self._properties.getProperty("provider_types"))

      temp_types = provider_types
      provider_types = []
      active_types = OpenRTM_aist.split(self._properties.getProperty("provider_types"), ",")

      temp_types.sort()
      active_types.sort()

      set_ptypes = set(temp_types).intersection(set(active_types))
      provider_types = provider_types + list(set_ptypes)

    # InPortProvider supports "push" dataflow type
    if len(provider_types) > 0:
      self._rtcout.RTC_DEBUG("dataflow_type push is supported")
      self.appendProperty("dataport.dataflow_type", "push")
      self.appendProperty("dataport.interface_type",
                          OpenRTM_aist.flatten(provider_types))

    self._providerTypes = provider_types
    return
开发者ID:thomas-moulard,项目名称:python-openrtm-aist-deb,代码行数:36,代码来源:InPortBase.py

示例2: initConsumers

# 需要导入模块: import OpenRTM_aist [as 别名]
# 或者: from OpenRTM_aist import normalize [as 别名]
  def initConsumers(self):
    self._rtcout.RTC_TRACE("initConsumers()")

    # create OuPort consumers
    factory = OpenRTM_aist.OutPortConsumerFactory.instance()
    consumer_types = factory.getIdentifiers()
    self._rtcout.RTC_DEBUG("available consumers: %s",
                           OpenRTM_aist.flatten(consumer_types))

    if self._properties.hasKey("consumer_types") and \
          OpenRTM_aist.normalize(self._properties.getProperty("consumer_types")) != "all":
      self._rtcout.RTC_DEBUG("allowed consumers: %s",
                             self._properties.getProperty("consumer_types"))

      temp_types = consumer_types
      consumer_types = []
      active_types = OpenRTM_aist.split(self._properties.getProperty("consumer_types"), ",")

      temp_types.sort()
      active_types.sort()

      set_ctypes = set(temp_types).intersection(set(active_types))
      consumer_types = consumer_types + list(set_ctypes)

    # OutPortConsumer supports "pull" dataflow type
    if len(consumer_types) > 0:
      self._rtcout.RTC_PARANOID("dataflow_type pull is supported")
      self.appendProperty("dataport.dataflow_type", "pull")
      self.appendProperty("dataport.interface_type",
                          OpenRTM_aist.flatten(consumer_types))

    self._consumerTypes = consumer_types
    return
开发者ID:thomas-moulard,项目名称:python-openrtm-aist-deb,代码行数:35,代码来源:InPortBase.py

示例3: publishInterfaces

# 需要导入模块: import OpenRTM_aist [as 别名]
# 或者: from OpenRTM_aist import normalize [as 别名]
  def publishInterfaces(self, cprof):
    self._rtcout.RTC_TRACE("publishInterfaces()")
    
    retval = self._publishInterfaces()
    if retval != RTC.RTC_OK:
      return retval

    # prop: [port.outport].
    prop = copy.deepcopy(self._properties)

    conn_prop = OpenRTM_aist.Properties()

    OpenRTM_aist.NVUtil.copyToProperties(conn_prop, cprof.properties)
    prop.mergeProperties(conn_prop.getNode("dataport")) # marge ConnectorProfile

    """
    #  marge ConnectorProfile for buffer property.
    #  e.g.
    #      prof[buffer.write.full_policy]
    #           << cprof[dataport.outport.buffer.write.full_policy]
    #    
    """
    prop.mergeProperties(conn_prop.getNode("dataport.outport"))


    #
    # ここで, ConnectorProfile からの properties がマージされたため、
    # prop["dataflow_type"]: データフロータイプ
    # prop["interface_type"]: インターフェースタイプ
    # などがアクセス可能になる。
    dflow_type = OpenRTM_aist.normalize([prop.getProperty("dataflow_type")])

    if dflow_type == "push":
      self._rtcout.RTC_PARANOID("dataflow_type = push .... do nothing")
      return RTC.RTC_OK

    elif dflow_type == "pull":
      self._rtcout.RTC_PARANOID("dataflow_type = pull .... create PullConnector")

      provider = self.createProvider(cprof, prop)
      if not provider:
        return RTC.BAD_PARAMETER
        
      # create InPortPushConnector
      connector = self.createConnector(cprof, prop, provider_ = provider)
      if not connector:
        return RTC.RTC_ERROR

      # connector set
      provider.setConnector(connector)

      self._rtcout.RTC_DEBUG("publishInterface() successfully finished.")
      return RTC.RTC_OK

    self._rtcout.RTC_ERROR("unsupported dataflow_type")

    return RTC.BAD_PARAMETER
开发者ID:yosuke,项目名称:OpenRTM-aist-Python,代码行数:59,代码来源:OutPortBase.py

示例4: publishInterfaces

# 需要导入模块: import OpenRTM_aist [as 别名]
# 或者: from OpenRTM_aist import normalize [as 别名]
  def publishInterfaces(self, cprof):
    self._rtcout.RTC_TRACE("publishInterfaces()")

    retval = self._publishInterfaces()
    if retval != RTC.RTC_OK:
      return retval

    # prop: [port.outport].
    prop = copy.deepcopy(self._properties)

    conn_prop = OpenRTM_aist.Properties()
    OpenRTM_aist.NVUtil.copyToProperties(conn_prop, cprof.properties)
    prop.mergeProperties(conn_prop.getNode("dataport")) # marge ConnectorProfile

    # marge ConnectorProfile for buffer property.
    prop.mergeProperties(conn_prop.getNode("dataport.inport"))

    #
    # ここで, ConnectorProfile からの properties がマージされたため、
    # prop["dataflow_type"]: データフロータイプ
    # prop["interface_type"]: インターフェースタイプ
    # などがアクセス可能になる。
    #
    dflow_type = prop.getProperty("dataflow_type")
    dflow_type = OpenRTM_aist.normalize([dflow_type])

    if dflow_type == "push":
      self._rtcout.RTC_DEBUG("dataflow_type = push .... create PushConnector")

      # create InPortProvider
      provider = self.createProvider(cprof, prop)

      if not provider:
        self._rtcout.RTC_ERROR("InPort provider creation failed.")
        return RTC.BAD_PARAMETER

      # create InPortPushConnector
      connector = self.createConnector(cprof, prop, provider_=provider)
      if not connector:
        self._rtcout.RTC_ERROR("PushConnector creation failed.")
        return RTC.RTC_ERROR

      connector.setDataType(self._value)
      provider.setConnector(connector) # So that a provider gets endian information from a connector.

      self._rtcout.RTC_DEBUG("publishInterfaces() successfully finished.")
      return RTC.RTC_OK

    elif dflow_type == "pull":
      self._rtcout.RTC_DEBUG("dataflow_type = pull .... do nothing")
      return RTC.RTC_OK

    self._rtcout.RTC_ERROR("unsupported dataflow_type")
    return RTC.BAD_PARAMETER
开发者ID:thomas-moulard,项目名称:python-openrtm-aist-deb,代码行数:56,代码来源:InPortBase.py

示例5: __call__

# 需要导入模块: import OpenRTM_aist [as 别名]
# 或者: from OpenRTM_aist import normalize [as 别名]
  def __call__(self, info, cdrdata, data):
    endian = info.properties.getProperty("serializer.cdr.endian","little")
    if endian is not "little" and endian is not None:
      endian = OpenRTM_aist.split(endian, ",") # Maybe endian is ["little","big"]
      endian = OpenRTM_aist.normalize(endian) # Maybe self._endian is "little" or "big"

    if endian == "little":
      endian = True
    elif endian == "big":
      endian = False
    else:
      endian = True

    _data = cdrUnmarshal(any.to_any(data).typecode(), cdrdata, endian)
    return _data
开发者ID:thomas-moulard,项目名称:python-openrtm-aist-deb,代码行数:17,代码来源:ConnectorListener.py

示例6: __init__

# 需要导入模块: import OpenRTM_aist [as 别名]
# 或者: from OpenRTM_aist import normalize [as 别名]
  def __init__(self, info, consumer, listeners, buffer = 0):
    OpenRTM_aist.OutPortConnector.__init__(self, info)

    self._buffer = buffer
    self._consumer = consumer
    self._listeners = listeners

    # publisher/buffer creation. This may throw std::bad_alloc;
    self._publisher = self.createPublisher(info)
    if not self._buffer:
      self._buffer = self.createBuffer(info)


    if not self._publisher or not self._buffer or not self._consumer:
      raise

    if self._publisher.init(info.properties) != self.PORT_OK:
      raise
        
    if self._profile.properties.hasKey("serializer"):
      endian = self._profile.properties.getProperty("serializer.cdr.endian")
      if not endian:
        self._rtcout.RTC_ERROR("write(): endian is not set.")
        raise
        
      endian = OpenRTM_aist.split(endian, ",") # Maybe endian is ["little","big"]
      endian = OpenRTM_aist.normalize(endian) # Maybe self._endian is "little" or "big"
      if endian == "little":
        self._endian = True
      elif endian == "big":
        self._endian = False
      else:
        self._endian = None

    else:
      self._endian = True # little endian

    self._buffer.init(info.properties.getNode("buffer"))
    self._consumer.init(info.properties)
    self._publisher.setConsumer(self._consumer)
    self._publisher.setBuffer(self._buffer)
    self._publisher.setListener(self._profile, self._listeners)

    self.onConnect()
    return
开发者ID:thomas-moulard,项目名称:python-openrtm-aist-deb,代码行数:47,代码来源:OutPortPushConnector.py

示例7: __initWritePolicy

# 需要导入模块: import OpenRTM_aist [as 别名]
# 或者: from OpenRTM_aist import normalize [as 别名]
  def __initWritePolicy(self, prop):
    policy = OpenRTM_aist.normalize([prop.getProperty("write.full_policy")])

    if policy == "overwrite":
      self._overwrite  = True
      self._timedwrite = False
    
    elif policy == "do_nothing":
      self._overwrite  = False
      self._timedwrite = False

    elif policy == "block":
      self._overwrite  = False
      self._timedwrite = True

      tm = [0.0]
      if OpenRTM_aist.stringTo(tm, prop.getProperty("write.timeout")):
        tm = tm[0]
        if not (tm < 0):
          self._wtimeout.set_time(tm)
开发者ID:thomas-moulard,项目名称:python-openrtm-aist-deb,代码行数:22,代码来源:RingBuffer.py

示例8: setPushPolicy

# 需要导入模块: import OpenRTM_aist [as 别名]
# 或者: from OpenRTM_aist import normalize [as 别名]
  def setPushPolicy(self, prop):
    push_policy = prop.getProperty("publisher.push_policy","new")
    self._rtcout.RTC_DEBUG("push_policy: %s", push_policy)

    push_policy = OpenRTM_aist.normalize([push_policy])

    if push_policy == "all":
      self._pushPolicy = self.ALL

    elif push_policy == "fifo":
      self._pushPolicy = self.FIFO

    elif push_policy == "skip":
      self._pushPolicy = self.SKIP

    elif push_policy == "new":
      self._pushPolicy = self.NEW

    else:
      self._rtcout.RTC_ERROR("invalid push_policy value: %s", push_policy)
      self._pushPolicy = self.NEW
  
    skip_count = prop.getProperty("publisher.skip_count","0")
    self._rtcout.RTC_DEBUG("skip_count: %s", skip_count)

    skipn = [self._skipn]
    ret = OpenRTM_aist.stringTo(skipn, skip_count)
    if ret:
      self._skipn = skipn[0]
    else:
      self._rtcout.RTC_ERROR("invalid skip_count value: %s", skip_count)
      self._skipn = 0

    if self._skipn < 0:
      self._rtcout.RTC_ERROR("invalid skip_count value: %d", self._skipn)
      self._skipn = 0

    return
开发者ID:thomas-moulard,项目名称:python-openrtm-aist-deb,代码行数:40,代码来源:PublisherNew.py

示例9: setConnectorInfo

# 需要导入模块: import OpenRTM_aist [as 别名]
# 或者: from OpenRTM_aist import normalize [as 别名]
  def setConnectorInfo(self, info):
    self._profile = info

    if self._profile.properties.hasKey("serializer"):
      endian = self._profile.properties.getProperty("serializer.cdr.endian")
      if not endian:
        self._rtcout.RTC_ERROR("InPortConnector.setConnectorInfo(): endian is not supported.")
        return RTC.RTC_ERROR
        
      endian = OpenRTM_aist.split(endian, ",") # Maybe endian is ["little","big"]
      endian = OpenRTM_aist.normalize(endian) # Maybe self._endian is "little" or "big"

      if endian == "little":
        self._endian = True
      elif endian == "big":
        self._endian = False
      else:
        self._endian = None
            
    else:
      self._endian = True # little endian

    return RTC.RTC_OK
开发者ID:yosuke,项目名称:OpenRTM-aist-Python,代码行数:25,代码来源:OutPortConnector.py

示例10: subscribeInterfaces

# 需要导入模块: import OpenRTM_aist [as 别名]
# 或者: from OpenRTM_aist import normalize [as 别名]
  def subscribeInterfaces(self, cprof):
    self._rtcout.RTC_TRACE("subscribeInterfaces()")

    # prop: [port.outport].
    prop = copy.deepcopy(self._properties)
    conn_prop = OpenRTM_aist.Properties()
    OpenRTM_aist.NVUtil.copyToProperties(conn_prop, cprof.properties)
    prop.mergeProperties(conn_prop.getNode("dataport")) # marge ConnectorProfile
    prop.mergeProperties(conn_prop.getNode("dataport.inport")) # marge ConnectorProfile for buffer property.
    
    #
    # ここで, ConnectorProfile からの properties がマージされたため、
    # prop["dataflow_type"]: データフロータイプ
    # prop["interface_type"]: インターフェースタイプ
    # などがアクセス可能になる。
    #
    dflow_type = prop.getProperty("dataflow_type")
    dtype = [dflow_type]
    OpenRTM_aist.normalize(dtype)
    dflow_type = dtype[0]
    
    profile = OpenRTM_aist.ConnectorInfo(cprof.name,
                                         cprof.connector_id,
                                         OpenRTM_aist.CORBA_SeqUtil.refToVstring(cprof.ports),
                                         prop)
    if dflow_type == "push":
      self._rtcout.RTC_DEBUG("dataflow_type = push .... do nothing")

      conn = self.getConnectorById(cprof.connector_id)

      if not conn:
        self._rtcout.RTC_ERROR("specified connector not found: %s",
                               cprof.connector_id)
        return RTC.RTC_ERROR

      ret = conn.setConnectorInfo(profile)
      if ret == RTC.RTC_OK:
        self._rtcout.RTC_DEBUG("subscribeInterfaces() successfully finished.")

      return ret

    elif dflow_type == "pull":
      self._rtcout.RTC_DEBUG("dataflow_type = pull .... create PullConnector")

      # create OutPortConsumer
      consumer = self.createConsumer(cprof, prop)
      if not consumer:
        return RTC.BAD_PARAMETER

      # create InPortPullConnector
      connector = self.createConnector(cprof, prop, consumer_=consumer)
      if not connector:
        return RTC.RTC_ERROR

      ret = connector.setConnectorInfo(profile)

      if ret == RTC.RTC_OK:
        self._rtcout.RTC_DEBUG("publishInterface() successfully finished.")

      return ret

    self._rtcout.RTC_ERROR("unsupported dataflow_type")
    return RTC.BAD_PARAMETER
开发者ID:thomas-moulard,项目名称:python-openrtm-aist-deb,代码行数:65,代码来源:InPortBase.py

示例11: main

# 需要导入模块: import OpenRTM_aist [as 别名]
# 或者: from OpenRTM_aist import normalize [as 别名]
def main():

  # initialization of ORB
  orb = CORBA.ORB_init(sys.argv)

  # get NamingService
  naming = OpenRTM_aist.CorbaNaming(orb, "localhost")
    
  conin = OpenRTM_aist.CorbaConsumer()
  conout = OpenRTM_aist.CorbaConsumer()

  # find ConsoleIn0 component
  conin.setObject(naming.resolve("ConsoleIn0.rtc"))

  # get ports
  inobj = conin.getObject()._narrow(RTC.RTObject)
  pin = inobj.get_ports()
  pin[0].disconnect_all()


  # find ConsoleOut0 component
  conout.setObject(naming.resolve("ConsoleOut0.rtc"))

  # get ports
  outobj = conout.getObject()._narrow(RTC.RTObject)
  pout = outobj.get_ports()
  pout[0].disconnect_all()


  # subscription type
  subs_type = "flush"
  period = "1.0"
  push_policy = "new"
  skip_count = "0"

  for arg in sys.argv[1:]:
    if arg == "--flush":
      subs_type = "flush"
      break

    elif arg == "--new":
      subs_type = "new"
      if len(sys.argv) > 2:
        push_policy = OpenRTM_aist.normalize([sys.argv[3]])
      if push_policy == "skip":
        skip_count = sys.argv[5]
      break

    elif arg == "--periodic":
      subs_type = "periodic"
      period = sys.argv[2]
      if len(sys.argv) > 3:
        push_policy = OpenRTM_aist.normalize([sys.argv[4]])
      if push_policy == "skip":
        skip_count = sys.argv[6]
      break

    # elif sbus_type == "periodic" and type(arg) == float:
    #    period = srt(arg)
    #    break

    else:
      usage()
            
  print "Subscription Type: ", subs_type
  print "Period: ", period, " [Hz]"
  print "push policy: ", push_policy
  print "skip count: ", skip_count

  # connect ports
  conprof = RTC.ConnectorProfile("connector0", "", [pin[0],pout[0]], [])
  OpenRTM_aist.CORBA_SeqUtil.push_back(conprof.properties,
                                       OpenRTM_aist.NVUtil.newNV("dataport.interface_type",
                                                                 "corba_cdr"))

  OpenRTM_aist.CORBA_SeqUtil.push_back(conprof.properties,
                                       OpenRTM_aist.NVUtil.newNV("dataport.dataflow_type",
                                                                 "push"))

  OpenRTM_aist.CORBA_SeqUtil.push_back(conprof.properties,
                                       OpenRTM_aist.NVUtil.newNV("dataport.subscription_type",
                                                                 subs_type))

  if subs_type == "periodic":
    OpenRTM_aist.CORBA_SeqUtil.push_back(conprof.properties,
                                         OpenRTM_aist.NVUtil.newNV("dataport.publisher.push_rate",
                                                                       period))
  OpenRTM_aist.CORBA_SeqUtil.push_back(conprof.properties,
                                       OpenRTM_aist.NVUtil.newNV("dataport.publisher.push_policy",
                                                                 push_policy))
  if push_policy == "skip":
    OpenRTM_aist.CORBA_SeqUtil.push_back(conprof.properties,
                                         OpenRTM_aist.NVUtil.newNV("dataport.publisher.skip_count",
                                                                   skip_count))


  ret,conprof = pin[0].connect(conprof)
    
  # activate ConsoleIn0
  eclistin = inobj.get_owned_contexts()
#.........这里部分代码省略.........
开发者ID:thomas-moulard,项目名称:python-openrtm-aist-deb,代码行数:103,代码来源:Connector.py

示例12: createPublisher

# 需要导入模块: import OpenRTM_aist [as 别名]
# 或者: from OpenRTM_aist import normalize [as 别名]
 def createPublisher(self, info):
   pub_type = info.properties.getProperty("subscription_type","flush")
   pub_type = OpenRTM_aist.normalize([pub_type])
   return OpenRTM_aist.PublisherFactory.instance().createObject(pub_type)
开发者ID:thomas-moulard,项目名称:python-openrtm-aist-deb,代码行数:6,代码来源:OutPortPushConnector.py


注:本文中的OpenRTM_aist.normalize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。