Loading Common/Interfaces/MinorServoInterface/test/functional/commands/test_servoSetup.py +4 −2 Original line number Diff line number Diff line Loading @@ -9,7 +9,6 @@ import MinorServo import Management import Antenna from PyMinorServoTest import simunittest from Acspy.Clients.SimpleClient import PySimpleClient from MinorServoErrors import MinorServoErrorsEx from Acspy.Common.TimeHelper import getTimeStamp Loading @@ -21,8 +20,10 @@ class TestServoSetupCmd(unittest2.TestCase): """Test the servoSetup command""" def setUp(self): self.telescope = os.getenv('TARGETSYS') self.client = PySimpleClient() self.boss = self.client.getComponent('MINORSERVO/Boss') self.setup_code = "CCB" if self.telescope == "SRT" else "CCC" def tearDown(self): self.client.releaseComponent('MINORSERVO/Boss') Loading @@ -32,7 +33,7 @@ class TestServoSetupCmd(unittest2.TestCase): self.assertFalse(success) def test_right_code(self): success, answer = self.boss.command('servoSetup=CCB') success, answer = self.boss.command('servoSetup=' + self.setup_code) self.assertTrue(success) Loading @@ -40,4 +41,5 @@ if __name__ == '__main__': if 'Configuration' in os.getenv('ACS_CDB'): unittest2.main() # Real test using the antenna CDB else: from PyMinorServoTest import simunittest simunittest.run(TestServoSetupCmd) Common/Interfaces/MinorServoInterface/test/functional/commands/test_setServoElevationTracking.py +2 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,6 @@ import MinorServo import Management import Antenna from PyMinorServoTest import simunittest from Acspy.Clients.SimpleClient import PySimpleClient from MinorServoErrors import MinorServoErrorsEx from Acspy.Common.TimeHelper import getTimeStamp Loading @@ -29,6 +28,7 @@ class TestSetServoElevationTrackingCmd(unittest2.TestCase): self.assertFalse(success) def test_right_flag(self): #FIXME: we need servoSetup before this success, answer = self.boss.command('setServoElevationTracking=on') self.assertTrue(success) Loading @@ -37,4 +37,5 @@ if __name__ == '__main__': if 'Configuration' in os.getenv('ACS_CDB'): unittest2.main() # Real test using the antenna CDB else: from PyMinorServoTest import simunittest simunittest.run(TestSetServoElevationTrackingCmd) Common/Interfaces/MinorServoInterface/test/functional/test_getAxesInfo.py +4 −2 Original line number Diff line number Diff line Loading @@ -11,7 +11,6 @@ import MinorServo import Management import Antenna from PyMinorServoTest import simunittest from Acspy.Clients.SimpleClient import PySimpleClient from MinorServoErrors import MinorServoErrorsEx from Acspy.Common.TimeHelper import getTimeStamp Loading @@ -22,8 +21,10 @@ __author__ = "Marco Buttu <mbuttu@oa-cagliari.inaf.it>" class TestGetAxesInfo(unittest2.TestCase): def setUp(self): self.telescope = os.getenv('TARGETSYS') self.client = PySimpleClient() self.boss = self.client.getComponent('MINORSERVO/Boss') self.setup_code = "CCB" if self.telescope == "SRT" else "CCC" def tearDown(self): self.client.releaseComponent('MINORSERVO/Boss') Loading @@ -35,7 +36,7 @@ class TestGetAxesInfo(unittest2.TestCase): def test_ready(self): """Get the axes information""" self.boss.setup('CCB') self.boss.setup(self.setup_code) counter = 0 # Seconds now = time_ref = datetime.datetime.now() while not self.boss.isReady() or (time_ref - now).seconds < 20: Loading @@ -52,5 +53,6 @@ if __name__ == '__main__': if 'Configuration' in os.getenv('ACS_CDB'): unittest2.main() # Real test using the antenna CDB else: from PyMinorServoTest import simunittest simunittest.run(TestGetAxesInfo) Common/Interfaces/MinorServoInterface/test/functional/test_getAxesPosition.py +4 −2 Original line number Diff line number Diff line Loading @@ -11,7 +11,6 @@ import MinorServo import Management import Antenna from PyMinorServoTest import simunittest from Acspy.Clients.SimpleClient import PySimpleClient from MinorServoErrors import MinorServoErrorsEx from Acspy.Common.TimeHelper import getTimeStamp Loading @@ -22,8 +21,10 @@ __author__ = "Marco Buttu <mbuttu@oa-cagliari.inaf.it>" class TestGetAxesPosition(unittest2.TestCase): def setUp(self): self.telescope = os.getenv('TARGETSYS') self.client = PySimpleClient() self.boss = self.client.getComponent('MINORSERVO/Boss') self.setup_code = "CCB" if self.telescope == "SRT" else "CCC" def tearDown(self): self.client.releaseComponent('MINORSERVO/Boss') Loading @@ -35,7 +36,7 @@ class TestGetAxesPosition(unittest2.TestCase): def test_ready(self): """Get the axes position""" self.boss.setup('CCB') self.boss.setup(self.setup_code) counter = 0 # Seconds now = time_ref = datetime.datetime.now() while not self.boss.isReady() or (time_ref - now).seconds < 20: Loading @@ -50,5 +51,6 @@ if __name__ == '__main__': if 'Configuration' in os.getenv('ACS_CDB'): unittest2.main() # Real test using the antenna CDB else: from PyMinorServoTest import simunittest simunittest.run(TestGetAxesPosition) Common/Interfaces/MinorServoInterface/test/functional/test_position.py 0 → 100644 +103 −0 Original line number Diff line number Diff line from __future__ import with_statement import random import math import time import os from datetime import datetime import unittest2 # https://pypi.python.org/pypi/unittest2 import Management import MinorServo import Antenna from MinorServoErrors import MinorServoErrorsEx from Acspy.Common.TimeHelper import getTimeStamp from Acspy.Clients.SimpleClient import PySimpleClient from Acspy.Util import ACSCorba __author__ = "Marco Buttu <mbuttu@oa-cagliari.inaf.it>" class PositionTest(unittest2.TestCase): @classmethod def setUpClass(cls): cls.client = PySimpleClient() cls.boss = cls.client.getComponent('MINORSERVO/Boss') @classmethod def tearDownClass(cls): cls.client.releaseComponent('MINORSERVO/Boss') def setUp(self): self.telescope = os.getenv('TARGETSYS') self.axis_code='SRP_TZ' if self.telescope == 'SRT' else 'Z' setupCode = 'KKG' if self.telescope == 'SRT' else 'CCC' # Wait (maximum one minute) in case the boss is parking if self.boss.isParking(): t0 = datetime.now() while self.boss.isParking() and (datetime.now() - t0).seconds < 60: time.sleep(2) if self.boss.isParking(): self.fail('The system can not exit form a parking state') if self.boss.getActualSetup() != setupCode: self.boss.setup(setupCode) # Wait (maximum 5 minutes) in case the boss is starting t0 = datetime.now() while not self.boss.isReady() and (datetime.now() - t0).seconds < 60*5: time.sleep(2) if not self.boss.isReady(): self.fail('The system is not ready for executing the tests') self.boss.setElevationTracking('OFF') self.boss.setASConfiguration('OFF') axes, units = self.boss.getAxesInfo() self.idx = axes.index(self.axis_code) def tearDown(self): self.boss.clearUserOffset(self.axis_code) self.wait_tracking() def test_get_current_position(self): timestamp = getTimeStamp().value position = self.get_position() position_now = self.get_position(timestamp) self.assertAlmostEqual(position, position_now, 0.1) def test_get_offset_position(self): position = self.get_position() self.boss.setUserOffset(self.axis_code, 10) self.wait_tracking() position_now = self.get_position() self.assertAlmostEqual(position_now, position + 10, 0.1) def test_get_past_position(self): timestamp = getTimeStamp().value position = self.get_position() self.boss.setUserOffset(self.axis_code, 10) self.wait_tracking() position_past = self.get_position(timestamp) self.assertAlmostEqual(position, position_past, 0.1) def test_get_past_position_with_sleep(self): timestamp = getTimeStamp().value position = self.get_position() self.boss.setUserOffset(self.axis_code, 10) self.wait_tracking() time.sleep(10) position_past = self.get_position(timestamp) self.assertAlmostEqual(position, position_past, 0.1) def wait_tracking(self): while not self.boss.isTracking(): time.sleep(0.1) def get_position(self, timestamp=0): return self.boss.getAxesPosition(timestamp)[self.idx] if __name__ == '__main__': if 'Configuration' in os.getenv('ACS_CDB'): unittest2.main(verbosity=2, failfast=True) # Real test using the antenna CDB else: from PyMinorServoTest import simunittest simunittest.run(PositionTest) Loading
Common/Interfaces/MinorServoInterface/test/functional/commands/test_servoSetup.py +4 −2 Original line number Diff line number Diff line Loading @@ -9,7 +9,6 @@ import MinorServo import Management import Antenna from PyMinorServoTest import simunittest from Acspy.Clients.SimpleClient import PySimpleClient from MinorServoErrors import MinorServoErrorsEx from Acspy.Common.TimeHelper import getTimeStamp Loading @@ -21,8 +20,10 @@ class TestServoSetupCmd(unittest2.TestCase): """Test the servoSetup command""" def setUp(self): self.telescope = os.getenv('TARGETSYS') self.client = PySimpleClient() self.boss = self.client.getComponent('MINORSERVO/Boss') self.setup_code = "CCB" if self.telescope == "SRT" else "CCC" def tearDown(self): self.client.releaseComponent('MINORSERVO/Boss') Loading @@ -32,7 +33,7 @@ class TestServoSetupCmd(unittest2.TestCase): self.assertFalse(success) def test_right_code(self): success, answer = self.boss.command('servoSetup=CCB') success, answer = self.boss.command('servoSetup=' + self.setup_code) self.assertTrue(success) Loading @@ -40,4 +41,5 @@ if __name__ == '__main__': if 'Configuration' in os.getenv('ACS_CDB'): unittest2.main() # Real test using the antenna CDB else: from PyMinorServoTest import simunittest simunittest.run(TestServoSetupCmd)
Common/Interfaces/MinorServoInterface/test/functional/commands/test_setServoElevationTracking.py +2 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,6 @@ import MinorServo import Management import Antenna from PyMinorServoTest import simunittest from Acspy.Clients.SimpleClient import PySimpleClient from MinorServoErrors import MinorServoErrorsEx from Acspy.Common.TimeHelper import getTimeStamp Loading @@ -29,6 +28,7 @@ class TestSetServoElevationTrackingCmd(unittest2.TestCase): self.assertFalse(success) def test_right_flag(self): #FIXME: we need servoSetup before this success, answer = self.boss.command('setServoElevationTracking=on') self.assertTrue(success) Loading @@ -37,4 +37,5 @@ if __name__ == '__main__': if 'Configuration' in os.getenv('ACS_CDB'): unittest2.main() # Real test using the antenna CDB else: from PyMinorServoTest import simunittest simunittest.run(TestSetServoElevationTrackingCmd)
Common/Interfaces/MinorServoInterface/test/functional/test_getAxesInfo.py +4 −2 Original line number Diff line number Diff line Loading @@ -11,7 +11,6 @@ import MinorServo import Management import Antenna from PyMinorServoTest import simunittest from Acspy.Clients.SimpleClient import PySimpleClient from MinorServoErrors import MinorServoErrorsEx from Acspy.Common.TimeHelper import getTimeStamp Loading @@ -22,8 +21,10 @@ __author__ = "Marco Buttu <mbuttu@oa-cagliari.inaf.it>" class TestGetAxesInfo(unittest2.TestCase): def setUp(self): self.telescope = os.getenv('TARGETSYS') self.client = PySimpleClient() self.boss = self.client.getComponent('MINORSERVO/Boss') self.setup_code = "CCB" if self.telescope == "SRT" else "CCC" def tearDown(self): self.client.releaseComponent('MINORSERVO/Boss') Loading @@ -35,7 +36,7 @@ class TestGetAxesInfo(unittest2.TestCase): def test_ready(self): """Get the axes information""" self.boss.setup('CCB') self.boss.setup(self.setup_code) counter = 0 # Seconds now = time_ref = datetime.datetime.now() while not self.boss.isReady() or (time_ref - now).seconds < 20: Loading @@ -52,5 +53,6 @@ if __name__ == '__main__': if 'Configuration' in os.getenv('ACS_CDB'): unittest2.main() # Real test using the antenna CDB else: from PyMinorServoTest import simunittest simunittest.run(TestGetAxesInfo)
Common/Interfaces/MinorServoInterface/test/functional/test_getAxesPosition.py +4 −2 Original line number Diff line number Diff line Loading @@ -11,7 +11,6 @@ import MinorServo import Management import Antenna from PyMinorServoTest import simunittest from Acspy.Clients.SimpleClient import PySimpleClient from MinorServoErrors import MinorServoErrorsEx from Acspy.Common.TimeHelper import getTimeStamp Loading @@ -22,8 +21,10 @@ __author__ = "Marco Buttu <mbuttu@oa-cagliari.inaf.it>" class TestGetAxesPosition(unittest2.TestCase): def setUp(self): self.telescope = os.getenv('TARGETSYS') self.client = PySimpleClient() self.boss = self.client.getComponent('MINORSERVO/Boss') self.setup_code = "CCB" if self.telescope == "SRT" else "CCC" def tearDown(self): self.client.releaseComponent('MINORSERVO/Boss') Loading @@ -35,7 +36,7 @@ class TestGetAxesPosition(unittest2.TestCase): def test_ready(self): """Get the axes position""" self.boss.setup('CCB') self.boss.setup(self.setup_code) counter = 0 # Seconds now = time_ref = datetime.datetime.now() while not self.boss.isReady() or (time_ref - now).seconds < 20: Loading @@ -50,5 +51,6 @@ if __name__ == '__main__': if 'Configuration' in os.getenv('ACS_CDB'): unittest2.main() # Real test using the antenna CDB else: from PyMinorServoTest import simunittest simunittest.run(TestGetAxesPosition)
Common/Interfaces/MinorServoInterface/test/functional/test_position.py 0 → 100644 +103 −0 Original line number Diff line number Diff line from __future__ import with_statement import random import math import time import os from datetime import datetime import unittest2 # https://pypi.python.org/pypi/unittest2 import Management import MinorServo import Antenna from MinorServoErrors import MinorServoErrorsEx from Acspy.Common.TimeHelper import getTimeStamp from Acspy.Clients.SimpleClient import PySimpleClient from Acspy.Util import ACSCorba __author__ = "Marco Buttu <mbuttu@oa-cagliari.inaf.it>" class PositionTest(unittest2.TestCase): @classmethod def setUpClass(cls): cls.client = PySimpleClient() cls.boss = cls.client.getComponent('MINORSERVO/Boss') @classmethod def tearDownClass(cls): cls.client.releaseComponent('MINORSERVO/Boss') def setUp(self): self.telescope = os.getenv('TARGETSYS') self.axis_code='SRP_TZ' if self.telescope == 'SRT' else 'Z' setupCode = 'KKG' if self.telescope == 'SRT' else 'CCC' # Wait (maximum one minute) in case the boss is parking if self.boss.isParking(): t0 = datetime.now() while self.boss.isParking() and (datetime.now() - t0).seconds < 60: time.sleep(2) if self.boss.isParking(): self.fail('The system can not exit form a parking state') if self.boss.getActualSetup() != setupCode: self.boss.setup(setupCode) # Wait (maximum 5 minutes) in case the boss is starting t0 = datetime.now() while not self.boss.isReady() and (datetime.now() - t0).seconds < 60*5: time.sleep(2) if not self.boss.isReady(): self.fail('The system is not ready for executing the tests') self.boss.setElevationTracking('OFF') self.boss.setASConfiguration('OFF') axes, units = self.boss.getAxesInfo() self.idx = axes.index(self.axis_code) def tearDown(self): self.boss.clearUserOffset(self.axis_code) self.wait_tracking() def test_get_current_position(self): timestamp = getTimeStamp().value position = self.get_position() position_now = self.get_position(timestamp) self.assertAlmostEqual(position, position_now, 0.1) def test_get_offset_position(self): position = self.get_position() self.boss.setUserOffset(self.axis_code, 10) self.wait_tracking() position_now = self.get_position() self.assertAlmostEqual(position_now, position + 10, 0.1) def test_get_past_position(self): timestamp = getTimeStamp().value position = self.get_position() self.boss.setUserOffset(self.axis_code, 10) self.wait_tracking() position_past = self.get_position(timestamp) self.assertAlmostEqual(position, position_past, 0.1) def test_get_past_position_with_sleep(self): timestamp = getTimeStamp().value position = self.get_position() self.boss.setUserOffset(self.axis_code, 10) self.wait_tracking() time.sleep(10) position_past = self.get_position(timestamp) self.assertAlmostEqual(position, position_past, 0.1) def wait_tracking(self): while not self.boss.isTracking(): time.sleep(0.1) def get_position(self, timestamp=0): return self.boss.getAxesPosition(timestamp)[self.idx] if __name__ == '__main__': if 'Configuration' in os.getenv('ACS_CDB'): unittest2.main(verbosity=2, failfast=True) # Real test using the antenna CDB else: from PyMinorServoTest import simunittest simunittest.run(PositionTest)