def setUp(self):
        self._dfp = DFP()
        self._dfp._poa._get_the_POAManager().activate()

        self._pec = PeriodicExecutionContext()
        self._pec.add_component(self._dfp.getRef())
        self._pec.start()
  def setUp(self):
    self._dfp = DFP()
    self._dfp._poa._get_the_POAManager().activate()

    self._pec = PeriodicExecutionContext(self._dfp._ref, 10)
    self._pec.add_component(self._dfp.getRef())
    self._pec.start()
class TestPeriodicExecutionContext(unittest.TestCase):
  def setUp(self):
    self._dfp = DFP()
    self._dfp._poa._get_the_POAManager().activate()

    self._pec = PeriodicExecutionContext(self._dfp._ref, 10)
    self._pec.add_component(self._dfp.getRef())
    self._pec.start()
  
  def tearDown(self):
    self._pec.stop()
    # import gc
    self._pec.__del__()
    self._pec = None
    OpenRTM_aist.Manager.instance().shutdownManager()

  def getState(self, state):
    if state == 0:
      return "INACTIVE_STATE"
    elif state == 1:
      return "ACTIVE_STATE"
    elif state == 2:
      return "ERROR_STATE"
    elif state == 3:
      return "UNKNOWN_STATE"

    return "INVALID_STATE"
    

  def test_case(self):
    print "rate: ", self._pec.get_rate()
    print "kind: ", self._pec.get_kind()
    self._pec.activate_component(self._dfp.getRef())
    #for i in range(3):
    # state = self._pec.get_component_state(self._dfp.getRef())
    # print self.getState(state)
    #self._pec.stop()
    #print "is_running : ", self._pec.is_running()
    import time
    time.sleep(1)

  
  def test_set_rate(self):
    self._pec.set_rate(1000)
    print "get rate: ", self._pec.get_rate()

  
  def test_activate_component(self):
    #self._pec.activate_component(self._dfp.getRef())
    #self._pec.deactivate_component(self._dfp.getRef())
    pass



  def test_reset_component(self):
    self._pec.reset_component(self._dfp.getRef())
    print "reset state: ", self._pec.get_component_state(self._dfp.getRef())
    self._pec.activate_component(self._dfp.getRef())
    print "activate state: ", self._pec.get_component_state(self._dfp.getRef())

  
  def test_remove(self):
    self._pec.remove_component(self._dfp.getRef())
    self._pec.activate_component(self._dfp.getRef())
    print "activate state: ", self._pec.get_component_state(self._dfp.getRef())


  def test_get_profile(self):
    print "get_profile.kind: ", self._pec.get_profile().kind
class TestPeriodicExecutionContext(unittest.TestCase):
    def setUp(self):
        self._dfp = DFP()
        self._dfp._poa._get_the_POAManager().activate()

        self._pec = PeriodicExecutionContext()
        self._pec.add_component(self._dfp.getRef())
        self._pec.start()

    def tearDown(self):
        self._pec.stop()
        # import gc
        self._pec.__del__()
        self._pec = None
        OpenRTM_aist.Manager.instance().shutdownManager()

    def getState(self, state):
        if state == 0:
            return "INACTIVE_STATE"
        elif state == 1:
            return "ACTIVE_STATE"
        elif state == 2:
            return "ERROR_STATE"
        elif state == 3:
            return "UNKNOWN_STATE"

        return "INVALID_STATE"

    def test_case(self):
        print "rate: ", self._pec.get_rate()
        print "kind: ", self._pec.get_kind()
        self._pec.activate_component(self._dfp.getRef())
        #for i in range(3):
        # state = self._pec.get_component_state(self._dfp.getRef())
        # print self.getState(state)
        #self._pec.stop()
        #print "is_running : ", self._pec.is_running()
        import time
        time.sleep(1)

    def test_set_rate(self):
        self._pec.set_rate(1000)
        print "get rate: ", self._pec.get_rate()

    def test_activate_component(self):
        #self._pec.activate_component(self._dfp.getRef())
        #self._pec.deactivate_component(self._dfp.getRef())
        pass

    def test_reset_component(self):
        self._pec.reset_component(self._dfp.getRef())
        print "reset state: ", self._pec.get_component_state(
            self._dfp.getRef())
        self._pec.activate_component(self._dfp.getRef())
        print "activate state: ", self._pec.get_component_state(
            self._dfp.getRef())

    def test_remove(self):
        self._pec.remove_component(self._dfp.getRef())
        self._pec.activate_component(self._dfp.getRef())
        print "activate state: ", self._pec.get_component_state(
            self._dfp.getRef())

    def test_get_profile(self):
        print "get_profile.kind: ", self._pec.get_profile().kind