Esempio n. 1
0
 def test_stop(self):
     cmdlinestop = "dacontrol.py --port=%s --stop" % PORT
     ret = dacontrol.main(cmdlinestop.split())
     self.assertEqual(ret, 0, "Error while trying to run '%s'" % cmdlinestop)
     
     cmdline = "dacontrol.py --port=%s --stage-x=100 --stage-y=-100" % PORT
     ret = dacontrol.main(cmdline.split())
     self.assertEqual(ret, 0, "Error while trying to run '%s'" % cmdline)
     
     cmdlinestop = "dacontrol.py --port=%s --stop" % PORT
     ret = dacontrol.main(cmdlinestop.split())
     self.assertEqual(ret, 0, "Error while trying to run '%s'" % cmdlinestop)
Esempio n. 2
0
 def test_sync(self):
     # For moves big enough, sync should always take more time than async
     delta = 0.0001 # s
     
     cmdline = "dacontrol.py --port=%s --stage-x=100 --stage-y=-100" % PORT
     start = time.time()
     ret = dacontrol.main(cmdline.split())
     dur_async = time.time() - start
     self.assertEqual(ret, 0, "Error while trying to run '%s'" % cmdline)
     
     cmdline = "dacontrol.py --port=%s --stage-x=-100 --stage-y=100 --sync" % PORT 
     start = time.time()
     ret = dacontrol.main(cmdline.split())
     dur_sync = time.time() - start
     self.assertEqual(ret, 0, "Error while trying to run '%s'" % cmdline)
     
     self.assertGreater(dur_sync, dur_async - delta, "Sync should take more time than async.")
Esempio n. 3
0
 def test_simple(self):
     cmdline = ("dacontrol.py --device=%s --width=%d --height=%d --exp=0.01"
                " --output=%s" % (self.device, self.size[0], self.size[1], self.picture_name)) 
     ret = dacontrol.main(cmdline.split())
     self.assertEqual(ret, 0, "Error while trying to run '%s'" % cmdline)
     
     st = os.stat(self.picture_name) # this test also that the file is created
     self.assertGreater(st.st_size, 0)
     im = Image.open(self.picture_name)
     self.assertEqual(im.format, "TIFF")
     self.assertEqual(im.size, self.size)
Esempio n. 4
0
 def test_list(self):
     """
     Check --list => should at least return a couple of lines
     """
     # need to observe the stdout 
     saved_stdout = sys.stdout
     try:
         out = StringIO.StringIO()
         sys.stdout = out
         cmdline = ("dacontrol.py --list")
         ret = dacontrol.main(cmdline.split())
     finally:
         sys.stdout = saved_stdout
         
     self.assertEqual(ret, 0, "Error while trying to run '%s'" % cmdline)
     assert len(out.getvalue().split("\n")) > 1
Esempio n. 5
0
 def test_exposure(self):
     """
     The command should take always longer than the exposure time.
     """
     exposure = 2 #s
     cmdline = ("dacontrol.py --device=%s --width=%d --height=%d"
                " --exp=%f --output=%s" % (self.device, self.size[0], self.size[1],
                                           exposure, self.picture_name))
     
     start = time.time() 
     ret = dacontrol.main(cmdline.split())
     duration = time.time() - start
     self.assertEqual(ret, 0, "Error while trying to run '%s'" % cmdline)
     self.assertGreaterEqual(duration, exposure, "Error execution took %f s, less than exposure time %d." % (duration, exposure))
     
     st = os.stat(self.picture_name) # this test also that the file is created
     self.assertGreater(st.st_size, 0)
     im = Image.open(self.picture_name)
     self.assertEqual(im.format, "TIFF")
Esempio n. 6
0
 def test_simple(self):
     cmdline = "dacontrol.py --port=%s --stage-x=0.01 --stage-y=-0.01" % PORT
     ret = dacontrol.main(cmdline.split())
     self.assertEqual(ret, 0, "Error while trying to run '%s'" % cmdline)