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

Fixed auto-rewinding bug.

Test: functional/test_startUpdating/test_keep_updating_after_rewind
parent 825e54c3
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@ import Management
import Receivers 
import ComponentErrorsImpl
import ComponentErrors
import DerotatorErrorsImpl
import DerotatorErrors 


+17 −18
Original line number Diff line number Diff line
@@ -124,9 +124,11 @@ class Positioner(object):

    def _setPosition(self, position):
        self.control.target = position + self.control.offset
        if self.device.getMinLimit() < self.control.target < self.device.getMaxLimit():
        try:
            self.device.setPosition(self.control.target)
        except DerotatorErrors.OutOfRangeErrorEx:
            raise OutOfRangeError("position %.2f out of range {%.2f, %.2f}" 
                %(self.control.target, self.device.getMinLimit(), self.device.getMaxLimit()))
        except (DerotatorErrors.PositioningErrorEx, DerotatorErrors.CommunicationErrorEx), ex:
            raeson = "cannot set the %s position" %self.device._get_name()
            logger.logError('%s: %s' %(raeson, ex.message))
@@ -135,9 +137,6 @@ class Positioner(object):
            raeson = "unknown exception setting the %s position" %self.device._get_name()
            logger.logError('%s: %s' %(raeson, ex.message))
            raise PositionerError(raeson)
        else:
            raise OutOfRangeError("position %.2f out of range {%.2f, %.2f}" 
                    %(self.control.target, self.device.getMinLimit(), self.device.getMaxLimit()))


    def startUpdating(self, axis, sector, az, el, ra, dec):
@@ -214,6 +213,7 @@ class Positioner(object):
    def _updatePosition(self, posgen, vargs):
        try:
            self.control.isRewindingRequired = False
            self.control.isRewinding = False
            self.control.isUpdating = True
            self.control.scanInfo.update({'rewindingOffset': 0})

@@ -236,8 +236,8 @@ class Positioner(object):
                        Pip = self.control.scanInfo['iParallacticPos']
                        Pdp = 0 if posgen.__name__ == 'goto' else (position - Pip)
                        target = Pis + Pdp if isOptimized else Pis + Pip + Pdp
                        self._setPosition(target) # _setPosition() will add the offsets
                        self.control.scanInfo.update({'dParallacticPos': Pdp})
                        self._setPosition(target) # _setPosition() will add the offset
                        time.sleep(float(self.conf.getAttribute('UpdatingTime')))
                    except OutOfRangeError, ex:
                        logger.logWarning(ex.message)
@@ -270,6 +270,7 @@ class Positioner(object):
        except Exception, ex:
            logger.logError('unexcpected exception in Positioner._updatePosition(): %s' %ex)
        finally:
            self.control.scanInfo.update({'rewindingOffset': 0})
            self.control.stopUpdating()


@@ -289,9 +290,8 @@ class Positioner(object):
            # getAutoRewindingSteps() returns None in case the user did not specify it
            n = steps if steps != None else self.control.autoRewindingSteps
            targetPos, rewindingOffset = self.getRewindingParameters(n)
            newPos = targetPos + rewindingOffset
            self.control.updateScanInfo({'rewindingOffset': rewindingOffset})
            self._setPosition(newPos)
            self._setPosition(targetPos + rewindingOffset)
            logger.logInfo('rewinding in progress...')
            startingTime = now = datetime.datetime.now()
            while (now - startingTime).seconds < float(self.conf.getAttribute('RewindingTimeout')):
@@ -309,7 +309,6 @@ class Positioner(object):
            raise PositionerError(ex.message)
        finally:
            self.control.isRewinding = False
            self.control.updateScanInfo({'rewindingOffset': 0})
            Positioner.rewindingLock.release()


+6 −0
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@ from __future__ import with_statement

import operator
import time
import DerotatorErrorsImpl

from multiprocessing import Process, Value, Lock
from Receivers__POA import SRTKBandDerotator
from Acspy.Servants.CharacteristicComponent import CharacteristicComponent as cc
@@ -69,6 +71,10 @@ class DerotatorSimulatorImpl(SRTKBandDerotator, cc, services, lcycle):
        p.start()
        if self.getMinLimit() < position < self.getMaxLimit():
            self.history.insert(position)
        else:
            exc = DerotatorErrorsImpl.OutOfRangeErrorExImpl()
            exc.setData('reason', 'position %2.f out of range' %position)
            raise exc

    def getActPosition(self):
        return self.history.get()
+4 −0
Original line number Diff line number Diff line
from DerotatorErrors import OutOfRangeErrorEx

class MockDevice(object):
    def __init__(self):
        self._setDefault()
@@ -34,6 +36,8 @@ class MockDevice(object):
        self.cmd_position = position
        if self.getMinLimit() < position < self.getMaxLimit():
            self.position = position
        else:
            raise OutOfRangeErrorEx('%.2f out of range' %position)

    def getActPosition(self):
        return self.position
+3 −4
Original line number Diff line number Diff line
@@ -45,16 +45,15 @@ do_unit: all

do_pyunit:
	@echo "running python unit tests"
	python -m unittest pyunit
	unit2 pyunit

do_functional:
	@echo "running python functional tests"
	python -m unittest functional
	python -m unittest functional/commands
	unit2 discover functional

do_external:
	@echo "running python external tests"
	python -m unittest external
	unit2 discover external

clean_test:
	rm -f results/*.xml
Loading