Ejemplo n.º 1
0
    def test_expose_abort (self):

        cam = self.manager.getProxy(self.CAMERA)

        print
        
        def doExpose():
            # need to get another Proxy as Proxies cannot be shared among threads
            cam = self.manager.getProxy(self.CAMERA)
            cam.expose(exptime=10, filename="autogen-expose-abort.fits")

        #
        # abort exposure while exposing
        #

        pool = ThreadPool()
        pool.queueTask(doExpose)

        # thread scheduling
        time.sleep(2)

        assert cam.isExposing() == True
        cam.abortExposure()
        assert cam.isExposing() == False

        pool.joinAll()

        self.assertEvents(CameraStatus.ABORTED, False)
Ejemplo n.º 2
0
    def test_slew_abort (self):

        site = self.manager.getProxy("/Site/0")

        # go to know position
        self.tel.slewToRaDec(Position.fromRaDec(site.LST(), site["latitude"]))
        last = self.tel.getPositionRaDec()

        # clear event checkings
        FiredEvents = {}

        # drift it
        dest = Position.fromRaDec(last.ra+Coord.fromH(1), last.dec+Coord.fromD(10))
        real_dest = None

        @callback(self.manager)
        def slewBeginClbk(target):
            global real_dest
            real_dest = target

        @callback(self.manager)
        def slewCompleteClbk(position, status):
            assert last.ra  < position.ra  < real_dest.ra
            assert last.dec < position.dec < real_dest.dec

        self.tel.slewBegin += slewBeginClbk
        self.tel.slewComplete += slewCompleteClbk

        # async slew
        def slew():
            tel = self.manager.getProxy(self.TELESCOPE)
            tel.slewToRaDec(dest)

        pool = ThreadPool()
        pool.queueTask(slew)

        # wait thread to be scheduled
        time.sleep(2)

        # abort and test
        self.tel.abortSlew()

        pool.joinAll()

        # event checkings
        self.assertEvents(TelescopeStatus.ABORTED)
Ejemplo n.º 3
0
    def test_expose_lock (self):

        cam = self.manager.getProxy(self.CAMERA)

        begin_times = []
        end_times = []

        @callback(self.manager)
        def exposeBeginClbk(request):
            begin_times.append(time.time())

        @callback(self.manager)
        def readoutCompleteClbk(request, status):
            end_times.append(time.time())

        cam.exposeBegin     += exposeBeginClbk
        cam.readoutComplete += readoutCompleteClbk        

        def doExpose():
            # need to get another Proxy as Proxies cannot be shared among threads
            cam = self.manager.getProxy(self.CAMERA)
            cam.expose(exptime=2, filename="autogen-expose-lock.fits")

        pool = ThreadPool()
        pool.queueTask(doExpose)
        pool.queueTask(doExpose)

        # wait doExpose to be scheduled
        time.sleep(1)        

        while len(end_times) < 2: time.sleep(1)

        # rationale: first exposure will start and the next will wait,
        # so we can never get the second exposure beginning before exposure one readout finishes.
        assert len(begin_times) == 2
        assert len(end_times) == 2
        assert (end_times[1] > begin_times[0])

        pool.joinAll()

        self.assertEvents(CameraStatus.OK, CameraStatus.OK)        
Ejemplo n.º 4
0
    def test_expose_abort(self):

        cam = self.manager.getProxy(Camera)

        print

        def doExpose():
            # need to get another Proxy as Proxies cannot be shared among threads
            cam = self.manager.getProxy(Camera)
            cam.expose(exptime=10, filename="autogen-expose-abort.fits")

        #
        # abort exposure while exposing
        #

        pool = ThreadPool()
        pool.queueTask(doExpose)

        # thread scheduling
        time.sleep(2)

        assert cam.isExposing() == True
        cam.abortExposure()
        assert cam.isExposing() == False

        pool.joinAll()
Ejemplo n.º 5
0
    def test_readout_abort (self):

        cam = self.manager.getProxy(self.CAMERA)
        exposeComplete = threading.Event()

        print
        
        def doExpose():
            # need to get another Proxy as Proxies cannot be shared among threads
            cam = self.manager.getProxy(self.CAMERA)
            cam.expose(exptime=5, filename="autogen-readout-abort.fits")

        @callback(self.manager)
        def exposeCompleteCallback(request, status):
            exposeComplete.set()

        cam.exposeComplete += exposeCompleteCallback

        #
        # abort exposure while reading out
        #

        pool = ThreadPool()
        pool.queueTask(doExpose)

        # thread scheduling
        time.sleep(2)

        assert cam.isExposing() == True

        while not exposeComplete.isSet():
            time.sleep(0.1)

        assert cam.isExposing() == True
        cam.abortExposure()
        assert cam.isExposing() == False

        pool.joinAll()

        self.assertEvents(CameraStatus.OK, CameraStatus.ABORTED)
Ejemplo n.º 6
0
    def test_slew_abort (self):

        last_ra  = self.tel.getRa()
        last_dec = self.tel.getDec()

        dest_ra  = last_ra  + "01 00 00"
        dest_dec = last_dec + "10 00 00"

        @callback(self.manager)
        def abortCompleteClbk(position):
            assert last_ra  < position.ra  < dest_ra
            assert last_dec < position.dec < dest_dec

        self.tel.abortComplete += abortCompleteClbk

        # async slew
        def slew():
            self.tel = self.manager.getProxy(Telescope)
            self.tel.slewToRaDec((dest_ra, dest_dec))

        pool = ThreadPool()
        pool.queueTask(slew)

        # wait thread to be scheduled
        time.sleep(2)

        # abort and test (on abortCompleteClbk).
        self.tel.abortSlew()

        pool.joinAll()
Ejemplo n.º 7
0
    def test_slew_abort(self):

        site = self.manager.getProxy("/Site/0")

        # go to know position
        self.tel.slewToRaDec(Position.fromRaDec(site.LST(), site["latitude"]))
        last = self.tel.getPositionRaDec()

        # clear event checkings
        FiredEvents = {}

        # drift it
        dest = Position.fromRaDec(last.ra + Coord.fromH(1),
                                  last.dec + Coord.fromD(10))
        real_dest = None

        @callback(self.manager)
        def slewBeginClbk(target):
            global real_dest
            real_dest = target

        @callback(self.manager)
        def slewCompleteClbk(position, status):
            assert last.ra < position.ra < real_dest.ra
            assert last.dec < position.dec < real_dest.dec

        self.tel.slewBegin += slewBeginClbk
        self.tel.slewComplete += slewCompleteClbk

        # async slew
        def slew():
            tel = self.manager.getProxy(self.TELESCOPE)
            tel.slewToRaDec(dest)

        pool = ThreadPool()
        pool.queueTask(slew)

        # wait thread to be scheduled
        time.sleep(2)

        # abort and test
        self.tel.abortSlew()

        pool.joinAll()

        # event checkings
        self.assertEvents(TelescopeStatus.ABORTED)
Ejemplo n.º 8
0
    def test_expose_lock(self):

        cam = self.manager.getProxy(self.CAMERA)

        begin_times = []
        end_times = []

        @callback(self.manager)
        def exposeBeginClbk(request):
            begin_times.append(time.time())

        @callback(self.manager)
        def readoutCompleteClbk(request, status):
            end_times.append(time.time())

        cam.exposeBegin += exposeBeginClbk
        cam.readoutComplete += readoutCompleteClbk

        def doExpose():
            # need to get another Proxy as Proxies cannot be shared among threads
            cam = self.manager.getProxy(self.CAMERA)
            cam.expose(exptime=2, filename="autogen-expose-lock.fits")

        pool = ThreadPool()
        pool.queueTask(doExpose)
        pool.queueTask(doExpose)

        # wait doExpose to be scheduled
        time.sleep(1)

        while len(end_times) < 2:
            time.sleep(1)

        # rationale: first exposure will start and the next will wait,
        # so we can never get the second exposure beginning before exposure one readout finishes.
        assert len(begin_times) == 2
        assert len(end_times) == 2
        assert (end_times[1] > begin_times[0])

        pool.joinAll()

        self.assertEvents(CameraStatus.OK, CameraStatus.OK)
Ejemplo n.º 9
0
    def test_readout_abort(self):

        cam = self.manager.getProxy(self.CAMERA)
        exposeComplete = threading.Event()

        print

        def doExpose():
            # need to get another Proxy as Proxies cannot be shared among threads
            cam = self.manager.getProxy(self.CAMERA)
            cam.expose(exptime=5, filename="autogen-readout-abort.fits")

        @callback(self.manager)
        def exposeCompleteCallback(request, status):
            exposeComplete.set()

        cam.exposeComplete += exposeCompleteCallback

        #
        # abort exposure while reading out
        #

        pool = ThreadPool()
        pool.queueTask(doExpose)

        # thread scheduling
        time.sleep(2)

        assert cam.isExposing() == True

        while not exposeComplete.isSet():
            time.sleep(0.1)

        assert cam.isExposing() == True
        cam.abortExposure()
        assert cam.isExposing() == False

        pool.joinAll()

        self.assertEvents(CameraStatus.OK, CameraStatus.ABORTED)