Commit 8e4d52a4 authored by Marco Buttu's avatar Marco Buttu
Browse files

The MinorServo setup enables both AS configuration and elevation tracking

parent 6c870b34
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ def run(test_case):
    FNULL = open(os.devnull, 'w')
    try:
        subprocess.Popen(['%s-start' %server_name], stdout=FNULL, stderr=FNULL)
        time.sleep(0.5) # Give the server the time to start
        time.sleep(1) # Give the server the time to start
        suite = unittest2.TestSuite()
        tests = unittest2.TestLoader().loadTestsFromTestCase(test_case)
        suite.addTests(tests)
@@ -21,4 +21,4 @@ def run(test_case):
        unittest2.TextTestRunner(verbosity=2).run(suite)
    finally:
        subprocess.Popen(['%s-stop' %server_name], stdout=FNULL, stderr=FNULL)
        time.sleep(1) # Give the server the time to stop
        time.sleep(2) # Give the server the time to stop
+4 −3
Original line number Diff line number Diff line
@@ -341,11 +341,11 @@ void MinorServoBossImpl::setupImpl(const char *config) throw (ManagementErrors::
{

    try {
        if(m_configuration->isElevationTrackingEn())
            setElevationTrackingImpl(IRA::CString("OFF"));
        if(!m_configuration->isElevationTrackingEn())
            setElevationTrackingImpl(IRA::CString("ON"));
    }
    catch(...) {
        THROW_EX(ManagementErrors, ConfigurationErrorEx, "cannot turn the tracking off", false);
        THROW_EX(ManagementErrors, ConfigurationErrorEx, "cannot turn the tracking on", false);
    }

    if(m_configuration->isStarting())
@@ -354,6 +354,7 @@ void MinorServoBossImpl::setupImpl(const char *config) throw (ManagementErrors::
    if(m_configuration->isParking())
        THROW_EX(ManagementErrors, ConfigurationErrorEx, "The system is executing a park", false);

    m_configuration->setASConfiguration(IRA::CString("ON"));
    m_configuration->init(string(config));  // Throw (ComponentErrors::CDBAccessExImpl);

    try {
+59 −0
Original line number Diff line number Diff line
from __future__ import with_statement
import random 
import math
import time
import os
from datetime import datetime

import unittest2 # https://pypi.python.org/pypi/unittest2
import Management
import MinorServo
import Antenna

from MinorServoErrors import MinorServoErrorsEx
from Acspy.Common.TimeHelper import getTimeStamp
from Acspy.Clients.SimpleClient import PySimpleClient
from Acspy.Util import ACSCorba


__author__ = "Marco Buttu <mbuttu@oa-cagliari.inaf.it>"

class SetupTest(unittest2.TestCase):

    telescope = os.getenv('TARGETSYS')
    
    def setUp(self):
        self.client = PySimpleClient()
        self.boss = self.client.getComponent('MINORSERVO/Boss')
        
    def tearDown(self):
        self.client.releaseComponent('MINORSERVO/Boss')
        self.client.disconnect()

    def test_elevation_tracking_ON(self):
        """The setup turns the elevation tracking on"""
        self.boss.setup('KKG')
        self.wait_until_ready()
        self.assertTrue(self.boss.isElevationTrackingEn())

    def test_as_configuration_ON(self):
        """The setup turns the AS configuration on"""
        self.boss.setup('KKG')
        self.wait_until_ready()
        self.assertEqual(self.boss.getActualSetup(), 'KKG_ASACTIVE')

    def wait_until_ready(self, timeout=20):
        t0 = datetime.now()
        while not self.boss.isReady():
            if (datetime.now() - t0).seconds > timeout:
                assert False, 'The minor servo boss is not ready'
            else:
                time.sleep(1)


if __name__ == '__main__':
    if 'Configuration' in os.getenv('ACS_CDB'):
        unittest2.main(verbosity=2, failfast=True) # Real test using the antenna CDB
    else:
        from PyMinorServoTest import simunittest
        simunittest.run(SetupTest)