Commit a448f253 authored by Marco Buttu's avatar Marco Buttu
Browse files

Changed and widely applyed clearScanInfo()


* clearScanInfo() clears all the iXXXPos and scan flags
* stopUpdating(), startUpdating() and clearScanInfo() call clearScanInfo()
parent 9a46c6e7
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -565,8 +565,9 @@ class DewarPositionerImpl(POA, cc, services, lcycle):
        # The unit of time is `seconds`
        max_wait_time = 2 
        counter = 0
        step = 0.1
        step = 0.2
        while self.positioner.isUpdating():
            self.positioner.stopUpdating()
            time.sleep(step)
            counter += step
            if counter > max_wait_time:
@@ -576,13 +577,8 @@ class DewarPositionerImpl(POA, cc, services, lcycle):
                exc.setReason(reason)
                raise exc.getComponentErrorsEx()
        try:
            self.positioner.control.clearScanInfo()
            self.cdbconf.setConfiguration(confCode.upper())
            if self.cdbconf.getAttribute('SetCustomPositionAllowed') == 'true':
                position = float(self.cdbconf.getAttribute('SetupPosition'))
                # Set the initialPosition, in order to add it to the dynamic one
                self.cdbconf.updateInitialPositions(position)
                self.positioner.control.updateScanInfo({'iStaticPos': position})
                logger.logNotice('initial position set to %.4f' %position)
        except Exception, ex:
            reason = ex.getReason() if hasattr(ex, 'getReason') else ex.message
            logger.logError(reason)
@@ -590,6 +586,7 @@ class DewarPositionerImpl(POA, cc, services, lcycle):
            exc.setData('Reason', reason)
            raise exc.getComponentErrorsEx()


    def getManagementStatus(self):
        return self.control.mngStatus

+12 −12
Original line number Diff line number Diff line
@@ -160,6 +160,7 @@ class Positioner(object):
            elif str(sector) not in sectors:
                raise NotAllowedError('sector %s not in %s' %(sector, sectors))
            else:
                self.control.clearScanInfo()
                if self.isUpdating():
                    self.stopUpdating()
                try:
@@ -371,10 +372,9 @@ class Positioner(object):
            if self.t.isAlive():
                logger.logWarning('thread %s is alive' %self.t.getName())
        except AttributeError:
            return # self.t is None because the system is not yet configured
            pass # self.t is None because the system is not yet configured
        finally:
            self.control.stop = False
            self.control.mustUpdate = False
            self.control.clearScanInfo()
            time.sleep(0.1)


@@ -648,17 +648,9 @@ class Positioner(object):

class Control(object):
    def __init__(self):
        self.isUpdating = False
        self.mustUpdate = False
        self.stop = False
        self.offset = 0.0
        self.target = 0,0
        self.rewindingOffset = 0.0
        self.isRewindingRequired = False
        self.isRewinding = False
        self.clearScanInfo()
        self.autoRewindingSteps = None
        self.modes = {'rewinding': 'none', 'updating': 'none'}
        self.clearScanInfo()

    def setScanInfo(self, axis, sector, iStaticPos, iParallacticPos, dParallacticPos):
        self.scanInfo = {
@@ -671,6 +663,14 @@ class Control(object):
        }

    def clearScanInfo(self):
        self.isUpdating = False
        self.mustUpdate = False
        self.stop = False
        self.offset = 0.0
        self.target = 0.0
        self.rewindingOffset = 0.0
        self.isRewindingRequired = False
        self.isRewinding = False
        self.setScanInfo(
            axis=Management.MNG_NO_AXIS, 
            sector=Antenna.ANT_NORTH,
+6 −2
Original line number Diff line number Diff line
@@ -12,14 +12,18 @@ from DewarPositioner.cdbconf import CDBConf

class GetPositionFromHistoryTest(unittest2.TestCase):

    def setUp(self):
    @classmethod
    def setUpClass(self):
        client = PySimpleClient()
        self.positioner = client.getComponent('RECEIVERS/DewarPositioner')
        self.positioner.setup('KKG')
        self.cmdPos = 0.8
        time.sleep(0.2)

    def tearDown(self):
    @classmethod
    def tearDownClass(self):
        self.positioner.park()
        time.sleep(0.2)

    def test_notReady(self):
        self.positioner.park()
+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ class PositionerOffsetTest(unittest2.TestCase):
        self.p.setup(siteInfo={}, source=None, device=self.device)
        self.p.setOffset(2)
        self.assertEqual(self.p.getOffset(), 2)
        self.assertEqual(self.p.getPosition(), 2)
        self.p.clearOffset()
        self.assertEqual(self.p.getOffset(), 0)