Ejemplo n.º 1
0
  def test_pushSkip(self):
    _pn = PublisherPeriodic()
    prop = OpenRTM_aist.Properties()
    cinfo = OpenRTM_aist.ConnectorInfo("",
                                       "",
                                       [],
                                       prop)
    self.assertEqual(_pn.setListener(cinfo,OpenRTM_aist.ConnectorListeners()),
                     OpenRTM_aist.DataPortStatus.PORT_OK)
    prop = OpenRTM_aist.Properties()
    prop.setProperty("publisher.push_policy","skip")
    prop.setProperty("publisher.skip_count","0")
    prop.setProperty("thread_type","default")
    prop.setProperty("measurement.exec_time","enable")
    prop.setProperty("measurement.exec_count","0")
    prop.setProperty("measurement.period_time","enable")
    prop.setProperty("measurement.period_count","0")
    retcode = _pn.init(prop)
    cons = ConsumerMock()
    self.assertEqual(_pn.setConsumer(cons),OpenRTM_aist.DataPortStatus.PORT_OK)
    _pn.setBuffer(OpenRTM_aist.CdrRingBuffer())
    _pn.activate()

    self.assertEqual(_pn.write(123,0,0),OpenRTM_aist.DataPortStatus.PORT_OK)
    self.assertEqual(_pn.write(123,0,0),OpenRTM_aist.DataPortStatus.PORT_OK)
    self.assertEqual(_pn.write(123,0,0),OpenRTM_aist.DataPortStatus.PORT_OK)
    self.assertEqual(_pn.write(123,0,0),OpenRTM_aist.DataPortStatus.PORT_OK)
    self.assertEqual(_pn.write(123,0,0),OpenRTM_aist.DataPortStatus.PORT_OK)
    self.assertEqual(_pn.write(123,0,0),OpenRTM_aist.DataPortStatus.PORT_OK)
    self.assertEqual(_pn.write(123,0,0),OpenRTM_aist.DataPortStatus.PORT_OK)
    self.assertEqual(_pn.write(123,0,0),OpenRTM_aist.DataPortStatus.PORT_OK)
    _pn.deactivate()
    _pn.__del__()
    return
 def test_write(self):
   _pn = PublisherPeriodic()
   prop = OpenRTM_aist.Properties()
   retcode = _pn.init(prop)
   _pn.setBuffer(OpenRTM_aist.RingBuffer())
   #self.assertEqual(_pn.write(123,0,0),OpenRTM_aist.DataPortStatus.PORT_OK)
   return
Ejemplo n.º 3
0
 def test_write(self):
   _pn = PublisherPeriodic()
   prop = OpenRTM_aist.Properties()
   retcode = _pn.init(prop)
   _pn.setBuffer(OpenRTM_aist.RingBuffer())
   _pn.__del__()
   #self.assertEqual(_pn.write(123,0,0),OpenRTM_aist.DataPortStatus.PORT_OK)
   return
 def test_activate_deactivate_isActive(self):
   _pn = PublisherPeriodic()
   prop = OpenRTM_aist.Properties()
   retcode = _pn.init(prop)
   self.assertEqual(_pn.isActive(),False)
   cons = ConsumerMock()
   self.assertEqual(_pn.setConsumer(cons),OpenRTM_aist.DataPortStatus.PORT_OK)
   _pn.setBuffer(OpenRTM_aist.CdrRingBuffer())
   self.assertEqual(_pn.activate(),OpenRTM_aist.DataPortStatus.PORT_OK)
   self.assertEqual(_pn.isActive(),True)
   self.assertEqual(_pn.deactivate(),OpenRTM_aist.DataPortStatus.PORT_OK)
   self.assertEqual(_pn.isActive(),False)
   return
Ejemplo n.º 5
0
 def test_activate_deactivate_isActive(self):
   _pn = PublisherPeriodic()
   prop = OpenRTM_aist.Properties()
   retcode = _pn.init(prop)
   self.assertEqual(_pn.isActive(),False)
   cons = ConsumerMock()
   self.assertEqual(_pn.setConsumer(cons),OpenRTM_aist.DataPortStatus.PORT_OK)
   _pn.setBuffer(OpenRTM_aist.CdrRingBuffer())
   self.assertEqual(_pn.activate(),OpenRTM_aist.DataPortStatus.PORT_OK)
   self.assertEqual(_pn.isActive(),True)
   self.assertEqual(_pn.deactivate(),OpenRTM_aist.DataPortStatus.PORT_OK)
   self.assertEqual(_pn.isActive(),False)
   _pn.__del__()
   return
Ejemplo n.º 6
0
  def test_init(self):
    _pn = PublisherPeriodic()
    prop = OpenRTM_aist.Properties()
    # Propertiesが空の状態でも正常に動作することを確認する
    ret = _pn.init(prop)
    self.assertEqual(OpenRTM_aist.DataPortStatus.PORT_OK, ret)
    time.sleep(0.1)
    _pn.__del__()

    _pn = PublisherPeriodic()
    prop.setProperty("publisher.push_policy","new")
    prop.setProperty("thread_type","bar")
    prop.setProperty("measurement.exec_time","default")
    prop.setProperty("measurement.period_count","1")
    
    #thread_type が不正の場合 INVALID_ARGS を返すことを確認する。
    ret = _pn.init(prop)
    self.assertEqual(OpenRTM_aist.DataPortStatus.INVALID_ARGS, ret)
    _pn.__del__()
    
    _pn = PublisherPeriodic()
    #以下のpropertiesの設定で動作することを確認する。
    prop.setProperty("publisher.push_policy","all")
    prop.setProperty("publisher.skip_count","0")
    prop.setProperty("thread_type","default")
    prop.setProperty("measurement.exec_time","enable")
    prop.setProperty("measurement.exec_count","0")
    prop.setProperty("measurement.period_time","enable")
    prop.setProperty("measurement.period_count","0")
    retcode = _pn.init(prop)
    self.assertEqual(OpenRTM_aist.DataPortStatus.PORT_OK, retcode)
    _pn.__del__()
    
    _pn = PublisherPeriodic()
    prop.setProperty("publisher.push_policy","fifo")
    prop.setProperty("publisher.skip_count","1")
    prop.setProperty("thread_type","default")
    prop.setProperty("measurement.exec_time","disable")
    prop.setProperty("measurement.exec_count","1")
    prop.setProperty("measurement.period_time","disable")
    prop.setProperty("measurement.period_count","0")
    retcode = _pn.init(prop)
    self.assertEqual(OpenRTM_aist.DataPortStatus.PORT_OK, retcode)
    _pn.__del__()
    
    _pn = PublisherPeriodic()
    prop.setProperty("publisher.push_policy","fifo")
    prop.setProperty("publisher.skip_count","1")
    prop.setProperty("thread_type","default")
    prop.setProperty("measurement.exec_time","disable")
    prop.setProperty("measurement.exec_count","1")
    prop.setProperty("measurement.period_time","disable")
    prop.setProperty("measurement.period_count","1")
    retcode = _pn.init(prop)
    self.assertEqual(OpenRTM_aist.DataPortStatus.PORT_OK, retcode)
    _pn.__del__()
    
    _pn = PublisherPeriodic()
    prop.setProperty("publisher.push_policy","skip")
    prop.setProperty("publisher.skip_count","-1")
    prop.setProperty("thread_type","default")
    prop.setProperty("measurement.exec_time","bar")
    prop.setProperty("measurement.exec_count","-1")
    prop.setProperty("measurement.period_time","bar")
    prop.setProperty("measurement.period_count","-1")
    retcode = _pn.init(prop)
    self.assertEqual(OpenRTM_aist.DataPortStatus.PORT_OK, retcode)
    _pn.__del__()
    
    _pn = PublisherPeriodic()
    prop.setProperty("publisher.push_policy","new")
    prop.setProperty("publisher.skip_count","1")
    prop.setProperty("thread_type","default")
    prop.setProperty("measurement.exec_time","enable")
    prop.setProperty("measurement.exec_count","1")
    prop.setProperty("measurement.period_time","enable")
    prop.setProperty("measurement.period_count","1")
    retcode = _pn.init(prop)
    self.assertEqual(OpenRTM_aist.DataPortStatus.PORT_OK, retcode)
    _pn.__del__()
    
    _pn = PublisherPeriodic()
    prop.setProperty("publisher.push_policy","bar")
    prop.setProperty("publisher.skip_count","0")
    prop.setProperty("thread_type","default")
    prop.setProperty("measurement.exec_time","enable")
    prop.setProperty("measurement.exec_count","0")
    prop.setProperty("measurement.period_time","enable")
    prop.setProperty("measurement.period_count","0")
    retcode = _pn.init(prop)
    self.assertEqual(OpenRTM_aist.DataPortStatus.PORT_OK, retcode)
    _pn.__del__()
    
    return