def TestRun(self): """Test run mtsPeriodicTask""" # create the task period = 0.05 periodicTask = cisstMultiTaskPythonTest.mtsPeriodicTaskTest(period) periodicTask.UpdateFromC() # get the task manager taskManager = cisstMultiTask.mtsManagerLocal_GetInstance() self.failUnless(isinstance(taskManager, cisstMultiTask.mtsManagerLocal)) # add the task self.failUnless(taskManager.AddComponent(periodicTask)) # create and start the task(s) taskManager.CreateAll() taskManager.StartAll() # and now use the task ... # -1- set all to zero and check result periodicTask.MainInterface.ZeroAll() time.sleep(2 * period) result1 = cisstMultiTask.mtsDouble() executionResult = periodicTask.MainInterface.GetDouble.Execute(result1) self.failUnless(executionResult.IsOK()) timestamp1 = result1.GetTimestamp() self.failUnless(result1.Data == 0.0) resultVector = periodicTask.MainInterface.GetVector() data = resultVector.Data() size = data.size expected = numpy.zeros(size) self.failUnless((data == expected).all()) # -2- use the AddDouble to modify all and test periodicTask.MainInterface.AddDouble(1.0) time.sleep(2 * period) result2 = cisstMultiTask.mtsDouble() executionResult = periodicTask.MainInterface.GetDouble.Execute(result2) self.failUnless(executionResult.IsOK()) timestamp2 = result2.GetTimestamp() self.failUnless(result2.Data == 1.0) resultVector = periodicTask.MainInterface.GetVector() data = resultVector.Data() size = data.size expected = numpy.ones(size) self.failUnless((data == expected).all()) # -3- set to zero again and test periodicTask.MainInterface.ZeroAll() time.sleep(2 * period) result3 = cisstMultiTask.mtsDouble() executionResult = periodicTask.MainInterface.GetDouble.Execute(result3) self.failUnless(executionResult.IsOK()) timestamp3 = result3.GetTimestamp() self.failUnless(result3.Data == 0.0) resultVector = periodicTask.MainInterface.GetVector() data = resultVector.Data() size = data.size expected = numpy.zeros(size) self.failUnless((data == expected).all()) # ... and now check the timestamps self.failUnless(timestamp1 < timestamp2) self.failUnless(timestamp2 < timestamp3) # kill all taskManager.KillAll()
def Test_mtsDouble(self): """Test mtsDouble""" variable = cisstMultiTaskPython.mtsDouble(4.0) # check type self.failUnless(isinstance(variable, cisstMultiTaskPython.mtsDouble)) self.failUnless(isinstance(variable, cisstMultiTaskPython.mtsGenericObject)) self.failUnless(isinstance(variable, cisstCommonPython.cmnGenericObject)) # check default value and modify self.failUnless(variable.Data == 4.0) variable.Data = 8.0 self.failUnless(variable.Data == 8.0)
def Test_mtsDouble(self): """Test mtsDouble""" variable = cisstMultiTaskPython.mtsDouble(4.0) # check type self.failUnless(isinstance(variable, cisstMultiTaskPython.mtsDouble)) self.failUnless( isinstance(variable, cisstMultiTaskPython.mtsGenericObject)) self.failUnless( isinstance(variable, cisstCommonPython.cmnGenericObject)) # check default value and modify self.failUnless(variable.Data == 4.0) variable.Data = 8.0 self.failUnless(variable.Data == 8.0)
Pointer = False stealth.RequiredForPointer.UpdateFromC() print "After adding Pointer Interface" while not bool(stealth.RequiredForFrame.GetConnectedInterface()): Frame = False stealth.RequiredForFrame.UpdateFromC() print "After adding Frame Interface" while not bool(stealth.RequiredForRegistration.GetConnectedInterface()): Registration = False stealth.RequiredForRegistration.UpdateFromC() print "After adding Registration Interface" pose = stealth.RequiredForPointer.GetPositionCartesian() print "Pointer: ", pose.Position() pose = stealth.RequiredForFrame.GetMarkerCartesian() print "Frame: ", pose.Position() transform = stealth.RequiredForRegistration.GetTransformation() print "Registration: ", transform zero = mts.mtsDouble(0.0) collector.StartCollection(zero) print "start collection" time.sleep(5.0) collector.StopCollection(zero) print "stop collection" # manager.KillAll() # manager.Cleanup() print "finished sawMedtronicStealthlinkClientComponent.py..."
Pointer = False stealth.RequiredForPointer.UpdateFromC() print 'After adding Pointer Interface' while not bool(stealth.RequiredForFrame.GetConnectedInterface()): Frame = False stealth.RequiredForFrame.UpdateFromC() print 'After adding Frame Interface' while not bool(stealth.RequiredForRegistration.GetConnectedInterface()): Registration = False stealth.RequiredForRegistration.UpdateFromC() print 'After adding Registration Interface' pose = stealth.RequiredForPointer.GetPositionCartesian() print 'Pointer: ', pose.Position() pose = stealth.RequiredForFrame.GetMarkerCartesian() print 'Frame: ', pose.Position() transform = stealth.RequiredForRegistration.GetTransformation() print 'Registration: ', transform zero = mts.mtsDouble(0.0) collector.StartCollection(zero) print 'start collection' time.sleep(5.0) collector.StopCollection(zero) print 'stop collection' #manager.KillAll() #manager.Cleanup() print 'finished sawMedtronicStealthlinkClientComponent.py...'