Loading Common/Servers/DewarPositioner/test/AntennaSimulator/AntennaSimulatorImpl.py +1 −1 Original line number Original line Diff line number Diff line Loading @@ -94,7 +94,7 @@ class History(object): self.history.append(data) self.history.append(data) self.history.sort(key=operator.itemgetter(0)) self.history.sort(key=operator.itemgetter(0)) self.history = self.history[-2**15:] # Last 2**15 positions self.history = self.history[-2**15:] # Last 2**15 positions print 'position %s inserted in the history' %position print 'position inserted in the history: ', position def clean(self, since=0): def clean(self, since=0): target_time = since if since else getTimeStamp().value target_time = since if since else getTimeStamp().value Loading Common/Servers/DewarPositioner/test/DerotatorSimulator/DerotatorSimulatorImpl.py +5 −3 Original line number Original line Diff line number Diff line Loading @@ -63,8 +63,9 @@ class DerotatorSimulatorImpl(SRTKBandDerotator, cc, services, lcycle): def setPosition(self, position): def setPosition(self, position): self.cmd_position = position self.cmd_position = position act_pos = self.getActPosition() p = Process(target=DerotatorSimulatorImpl._set_position_process, p = Process(target=DerotatorSimulatorImpl._set_position_process, args=(self.status, position, self.getSpeed())) args=(self.status, act_pos, position, self.getSpeed())) p.start() p.start() if self.getMinLimit() < position < self.getMaxLimit(): if self.getMinLimit() < position < self.getMaxLimit(): self.history.insert(position) self.history.insert(position) Loading Loading @@ -94,9 +95,10 @@ class DerotatorSimulatorImpl(SRTKBandDerotator, cc, services, lcycle): self.status = Status() self.status = Status() @staticmethod @staticmethod def _set_position_process(status, position, speed): def _set_position_process(status, act_pos, position, speed): status.is_slewing.value = True status.is_slewing.value = True time.sleep(position/speed*1.0) # Speed degrees per second distance = float(abs(act_pos - position)) time.sleep(distance/speed) # Speed degrees per second status.is_slewing.value = False status.is_slewing.value = False Loading Common/Servers/DewarPositioner/test/functional/test_startUpdating.py 0 → 100644 +84 −0 Original line number Original line Diff line number Diff line from __future__ import with_statement import unittest2 import time import math from DewarPositioner.posgenerator import PosGenerator from Antenna import ANT_HORIZONTAL, ANT_NORTH from Management import MNG_TRACK from Acspy.Clients.SimpleClient import PySimpleClient from ComponentErrors import ComponentErrorsEx class StartUpdatingTest(unittest2.TestCase): """Test the DewarPositioner.rewind() method""" def setUp(self): self.client = PySimpleClient() self.device = self.client.getComponent('RECEIVERS/SRTKBandDerotator') self.antenna = self.client.getComponent('ANTENNA/BossSimulator') self.positioner = self.client.getComponent('RECEIVERS/DewarPositioner') self.positioner.setup('KKG') self.positioner.setConfiguration('custom') def tearDown(self): if self.positioner.isReady(): self.positioner.park() time.sleep(0.5) self.client.releaseComponent('RECEIVERS/DewarPositioner') self.client.releaseComponent('ANTENNA/BossSimulator') self.device = self.client.releaseComponent('RECEIVERS/SRTKBandDerotator') def test_rewind_offset_properly_cleared(self): """Verify the startUpdating() clears previous rewinding offsets. For instance, in the following case: - startUpdating() out of range -> rewind - new startUpdating() with (Pis + parallactic) in range In the first startUpdating() we want the position to be:: Pis + Pip + Pid + rewinding_offset In the second startUpdating() the position must be:: Pis + Pip + Pid """ latitude = 0.689 # 39.5 degrees # First step: we choose (az, el) in order to have a parallactic angle # out of range. That means the derotator has to rewind az, el = 1.2217, 0.6109 # 70 degrees, 35 degrees parallactic = PosGenerator.getParallacticAngle(latitude, az, el) # -63 min_limit = self.device.getMinLimit() # -85.77 degrees for the K Band Pis = -30 # Final angle -93, lower than the min limit (-85.77) self.positioner.setPosition(Pis) self.antenna.setOffsets(az, el, ANT_HORIZONTAL) target = Pis + parallactic self.assertLess(target, min_limit) # We expect a rewind of 180 degrees: -93 + 180 -> 87 expected = target + 180 self.positioner.startUpdating(MNG_TRACK, ANT_NORTH, az, el, 0, 0) time.sleep(0.11) self.assertAlmostEqual(expected, self.device.getActPosition(), delta=0.1) # Second step: we do not call stopUpdating(), and we choose (az, el) # in order to have a parallactic angle in range az, el = 5, 0.5 # In radians parallactic = PosGenerator.getParallacticAngle(latitude, az, el) # 58.5 self.antenna.setOffsets(az, el, ANT_HORIZONTAL) target = Pis + parallactic self.assertGreater(target, min_limit) # We do not expect a rewind expected = target self.positioner.startUpdating(MNG_TRACK, ANT_NORTH, az, el, 0, 0) time.sleep(0.11) self.assertAlmostEqual(expected, self.device.getActPosition(), delta=0.1) self.positioner.stopUpdating() if __name__ == '__main__': unittest2.main() SRT/CDB/MACI/Components/ANTENNA/BossSimulator/BossSimulator.xml +1 −1 Original line number Original line Diff line number Diff line Loading @@ -7,7 +7,7 @@ Name="Boss" Name="Boss" Code="AntennaSimulator.AntennaSimulatorImpl" Code="AntennaSimulator.AntennaSimulatorImpl" Type="IDL:alma/Antenna/AntennaBoss:1.0" Type="IDL:alma/Antenna/AntennaBoss:1.0" Container="AntennaSimContainer" Container="AntennaBossSimulatorContainer" Default="true" Default="true" KeepAliveTime="-1" KeepAliveTime="-1" ImplLang="py" ImplLang="py" Loading Loading
Common/Servers/DewarPositioner/test/AntennaSimulator/AntennaSimulatorImpl.py +1 −1 Original line number Original line Diff line number Diff line Loading @@ -94,7 +94,7 @@ class History(object): self.history.append(data) self.history.append(data) self.history.sort(key=operator.itemgetter(0)) self.history.sort(key=operator.itemgetter(0)) self.history = self.history[-2**15:] # Last 2**15 positions self.history = self.history[-2**15:] # Last 2**15 positions print 'position %s inserted in the history' %position print 'position inserted in the history: ', position def clean(self, since=0): def clean(self, since=0): target_time = since if since else getTimeStamp().value target_time = since if since else getTimeStamp().value Loading
Common/Servers/DewarPositioner/test/DerotatorSimulator/DerotatorSimulatorImpl.py +5 −3 Original line number Original line Diff line number Diff line Loading @@ -63,8 +63,9 @@ class DerotatorSimulatorImpl(SRTKBandDerotator, cc, services, lcycle): def setPosition(self, position): def setPosition(self, position): self.cmd_position = position self.cmd_position = position act_pos = self.getActPosition() p = Process(target=DerotatorSimulatorImpl._set_position_process, p = Process(target=DerotatorSimulatorImpl._set_position_process, args=(self.status, position, self.getSpeed())) args=(self.status, act_pos, position, self.getSpeed())) p.start() p.start() if self.getMinLimit() < position < self.getMaxLimit(): if self.getMinLimit() < position < self.getMaxLimit(): self.history.insert(position) self.history.insert(position) Loading Loading @@ -94,9 +95,10 @@ class DerotatorSimulatorImpl(SRTKBandDerotator, cc, services, lcycle): self.status = Status() self.status = Status() @staticmethod @staticmethod def _set_position_process(status, position, speed): def _set_position_process(status, act_pos, position, speed): status.is_slewing.value = True status.is_slewing.value = True time.sleep(position/speed*1.0) # Speed degrees per second distance = float(abs(act_pos - position)) time.sleep(distance/speed) # Speed degrees per second status.is_slewing.value = False status.is_slewing.value = False Loading
Common/Servers/DewarPositioner/test/functional/test_startUpdating.py 0 → 100644 +84 −0 Original line number Original line Diff line number Diff line from __future__ import with_statement import unittest2 import time import math from DewarPositioner.posgenerator import PosGenerator from Antenna import ANT_HORIZONTAL, ANT_NORTH from Management import MNG_TRACK from Acspy.Clients.SimpleClient import PySimpleClient from ComponentErrors import ComponentErrorsEx class StartUpdatingTest(unittest2.TestCase): """Test the DewarPositioner.rewind() method""" def setUp(self): self.client = PySimpleClient() self.device = self.client.getComponent('RECEIVERS/SRTKBandDerotator') self.antenna = self.client.getComponent('ANTENNA/BossSimulator') self.positioner = self.client.getComponent('RECEIVERS/DewarPositioner') self.positioner.setup('KKG') self.positioner.setConfiguration('custom') def tearDown(self): if self.positioner.isReady(): self.positioner.park() time.sleep(0.5) self.client.releaseComponent('RECEIVERS/DewarPositioner') self.client.releaseComponent('ANTENNA/BossSimulator') self.device = self.client.releaseComponent('RECEIVERS/SRTKBandDerotator') def test_rewind_offset_properly_cleared(self): """Verify the startUpdating() clears previous rewinding offsets. For instance, in the following case: - startUpdating() out of range -> rewind - new startUpdating() with (Pis + parallactic) in range In the first startUpdating() we want the position to be:: Pis + Pip + Pid + rewinding_offset In the second startUpdating() the position must be:: Pis + Pip + Pid """ latitude = 0.689 # 39.5 degrees # First step: we choose (az, el) in order to have a parallactic angle # out of range. That means the derotator has to rewind az, el = 1.2217, 0.6109 # 70 degrees, 35 degrees parallactic = PosGenerator.getParallacticAngle(latitude, az, el) # -63 min_limit = self.device.getMinLimit() # -85.77 degrees for the K Band Pis = -30 # Final angle -93, lower than the min limit (-85.77) self.positioner.setPosition(Pis) self.antenna.setOffsets(az, el, ANT_HORIZONTAL) target = Pis + parallactic self.assertLess(target, min_limit) # We expect a rewind of 180 degrees: -93 + 180 -> 87 expected = target + 180 self.positioner.startUpdating(MNG_TRACK, ANT_NORTH, az, el, 0, 0) time.sleep(0.11) self.assertAlmostEqual(expected, self.device.getActPosition(), delta=0.1) # Second step: we do not call stopUpdating(), and we choose (az, el) # in order to have a parallactic angle in range az, el = 5, 0.5 # In radians parallactic = PosGenerator.getParallacticAngle(latitude, az, el) # 58.5 self.antenna.setOffsets(az, el, ANT_HORIZONTAL) target = Pis + parallactic self.assertGreater(target, min_limit) # We do not expect a rewind expected = target self.positioner.startUpdating(MNG_TRACK, ANT_NORTH, az, el, 0, 0) time.sleep(0.11) self.assertAlmostEqual(expected, self.device.getActPosition(), delta=0.1) self.positioner.stopUpdating() if __name__ == '__main__': unittest2.main()
SRT/CDB/MACI/Components/ANTENNA/BossSimulator/BossSimulator.xml +1 −1 Original line number Original line Diff line number Diff line Loading @@ -7,7 +7,7 @@ Name="Boss" Name="Boss" Code="AntennaSimulator.AntennaSimulatorImpl" Code="AntennaSimulator.AntennaSimulatorImpl" Type="IDL:alma/Antenna/AntennaBoss:1.0" Type="IDL:alma/Antenna/AntennaBoss:1.0" Container="AntennaSimContainer" Container="AntennaBossSimulatorContainer" Default="true" Default="true" KeepAliveTime="-1" KeepAliveTime="-1" ImplLang="py" ImplLang="py" Loading