def test_write(self):
   _pn = PublisherNew()
   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
Esempio n. 2
0
 def test_activate_deactivate_isActive(self):
   _pn = PublisherNew()
   self.assertEqual(_pn.isActive(),False)
   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
Esempio n. 3
0
 def test_convertReturn(self):
   _pn = PublisherNew()
   self.assertEqual(_pn.convertReturn(OpenRTM_aist.BufferStatus.BUFFER_OK,0),
        OpenRTM_aist.DataPortStatus.PORT_OK)
   self.assertEqual(_pn.convertReturn(OpenRTM_aist.BufferStatus.BUFFER_FULL,0),
        OpenRTM_aist.DataPortStatus.BUFFER_FULL)
   self.assertEqual(_pn.convertReturn(OpenRTM_aist.BufferStatus.TIMEOUT,0),
        OpenRTM_aist.DataPortStatus.BUFFER_TIMEOUT)
   self.assertEqual(_pn.convertReturn(OpenRTM_aist.BufferStatus.PRECONDITION_NOT_MET,0),
        OpenRTM_aist.DataPortStatus.PRECONDITION_NOT_MET)
   self.assertEqual(_pn.convertReturn(100,0),
        OpenRTM_aist.DataPortStatus.PORT_ERROR)
   _pn.__del__()
   return
Esempio n. 4
0
 def test_write(self):
   _pn = PublisherNew()
   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)
   _pn.__del__()
   return
Esempio n. 5
0
 def test_init(self):
   _pn = PublisherNew()
   prop = OpenRTM_aist.Properties()
   # Propertiesが空の状態でも正常に動作することを確認する
   ret = _pn.init(prop)
   self.assertEqual(OpenRTM_aist.DataPortStatus.PORT_OK, ret)
   _pn.__del__()
   
   _pn = PublisherNew()
   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 = PublisherNew()
   #以下の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 = PublisherNew()
   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 = PublisherNew()
   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 = PublisherNew()
   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 = PublisherNew()
   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 = PublisherNew()
   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
Esempio n. 6
0
  def test_pushNew(self):
    _pn = PublisherNew()
    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","new")
    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
Esempio n. 7
0
 def test_setBuffer(self):
   _pn = PublisherNew()
   self.assertEqual(_pn.setBuffer(None),OpenRTM_aist.DataPortStatus.INVALID_ARGS)
   self.assertEqual(_pn.setBuffer(OpenRTM_aist.RingBuffer()),OpenRTM_aist.DataPortStatus.PORT_OK)
   _pn.__del__()
   return
 def test_setConsumer(self):
   _pn = PublisherNew()
   self.assertEqual(_pn.setConsumer(None),OpenRTM_aist.DataPortStatus.INVALID_ARGS)
   self.assertEqual(_pn.setConsumer(ConsumerMock()),OpenRTM_aist.DataPortStatus.PORT_OK)
   return