# $Header: https://oberon.oapd.inaf.it/shins/trunk/shins/src/scripts/templates/tpl/testOB_tiptilt_open_loop.py 3790 2022-01-17 19:18:52Z depa $

import sys
import Ice
from util.shinsLogger import logger
from util import variables as uvars
from util import functions as ufun
from util import exception
from shinsapp import SHINSApp

class SHARKNIR_gen_tec_OpenLoop(SHINSApp):

    @exception.handler_for_run
    def run(self, ins_s=None, det_s=None, tel_s=None, rtc_s=None, **kwargs):
        '''Open tiptilt loop
        '''

        logger.info(__name__)
        self.status = uvars.EXIT_SUCCESS
        obsController = self.obsController

        ##########################
        # OPEN REAL-TIME TT LOOP #
        ##########################
        if self.paragraph("OPEN REAL-TIME TT LOOP"):

            logger.info("TT open loop")
            self.status = obsController.RTCTTOpenLoop()
            ufun.error_handler(self.status, "RTCTTOpenLoop")
            logger.debug(self.status)
            
            logger.info("Tip tilt loop open on TECCAM")
