Commit aa343ee0 authored by SRT Operator's avatar SRT Operator
Browse files

Fixed a bug in checkScan()

There was an uncatched exception in case of empty axis code.
parent ae2988ba
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -70,12 +70,14 @@ class ScanTest(ScanBaseTest):
            if self.boss.isParking():
                self.fail('The system can not exit form a parking state')

        if self.boss.getActualSetup() != setupCode:
        if self.boss.getActualSetup() != setupCode or not self.boss.isReady():
            self.boss.setup(setupCode)

        # Wait (maximum 5 minutes) in case the boss is starting
        t0 = datetime.now()
        while not self.boss.isReady() and (datetime.now() - t0).seconds < 60*5:
            time.sleep(2)

        if not self.boss.isReady():
            self.fail('The system is not ready for executing the tests')

+6 −0
Original line number Diff line number Diff line
@@ -201,6 +201,12 @@ InfoAxisCode MSBossConfiguration::getInfoFromAxisCode(string axis_code) throw (M
    short id = 0;
    string comp_name;
    strip(axis_code);
    if(axis_code.size() == 0) {
        result.comp_name = "";
        result.numberOfAxes = 0;
        result.axis_id = -1;
    }

    try {
        vector<string> items = split(axis_code, string("_"));
        comp_name = items[0];
+47 −19
Original line number Diff line number Diff line
@@ -678,10 +678,11 @@ void MinorServoBossImpl::closeScan(ACS::Time& timeToStop) throw (
        }
    }
    else {
        string msg("closeScan(): no scan active");
        _EXCPT(MinorServoErrors::StatusErrorExImpl, impl, msg.c_str());
        impl.log(LM_DEBUG);
        throw impl.getMinorServoErrorsEx();
        // string msg("closeScan(): no scan active");
        // _EXCPT(MinorServoErrors::StatusErrorExImpl, impl, msg.c_str());
        // impl.log(LM_DEBUG);
        // throw impl.getMinorServoErrorsEx();
        ; // Do nothing
    }
}

@@ -734,7 +735,7 @@ bool MinorServoBossImpl::checkScanImpl(
    ) throw (MinorServoErrors::MinorServoErrorsEx, ComponentErrors::ComponentErrorsEx)
{
    MinorServo::TRunTimeParameters_var msParamVar = new MinorServo::TRunTimeParameters;
    msParamVar->onTheFly = false;
    msParamVar->onTheFly = (msScanInfo.is_empty_scan == false) ? true : false;
    msParamVar->startEpoch = 0;
    msParamVar->centerScan = 0;
    msParamVar->scanAxis = CORBA::string_dup("");
@@ -751,11 +752,17 @@ bool MinorServoBossImpl::checkScanImpl(
    catch(ManagementErrors::ConfigurationErrorExImpl& ex) {
        ex.log(LM_ERROR);
        msParameters = msParamVar._retn(); 
        if(msScanInfo.is_empty_scan == true)
            return true;
        else
            return false;
    }
    catch (...) {
        ACS_SHORT_LOG((LM_ERROR, "checkScanImpl(): cannot get the axis info"));
        msParameters = msParamVar._retn(); 
        if(msScanInfo.is_empty_scan == true)
            return true;
        else
            return false;
    }

@@ -770,11 +777,17 @@ bool MinorServoBossImpl::checkScanImpl(
    catch(ManagementErrors::ConfigurationErrorExImpl& ex) {
        ex.log(LM_ERROR);
        msParameters = msParamVar._retn(); 
        if(msScanInfo.is_empty_scan == true)
            return true;
        else
            return false;
    }
    catch (...) {
        ACS_SHORT_LOG((LM_ERROR, "checkScanImpl(): cannot get the central scan position"));
        msParameters = msParamVar._retn(); 
        if(msScanInfo.is_empty_scan == true)
            return true;
        else
            return false;
    }

@@ -803,15 +816,15 @@ bool MinorServoBossImpl::checkScanImpl(
        string msg("startScanImpl(): cannot get the " + comp_name + " component");
        ACS_SHORT_LOG((LM_ERROR, msg.c_str()));
        msParameters = msParamVar._retn(); 
        if(msScanInfo.is_empty_scan == true)
            return true;
        else
            return false;
    }

    ACS::Time min_starting_time = 0;
    msParamVar->onTheFly = (msScanInfo.is_empty_scan == false) ? true : false;
    msParamVar->startEpoch = 0;
    msParamVar->centerScan = centralPos[axis];
    msParamVar->scanAxis = CORBA::string_dup(msScanInfo.axis_code);
    msParamVar->timeToStop = 0;

    double acceleration = 0.0;
    double max_speed = 0.0;
@@ -829,16 +842,25 @@ bool MinorServoBossImpl::checkScanImpl(
    catch(ManagementErrors::ConfigurationErrorExImpl& ex) {
        ex.log(LM_ERROR);
        msParameters = msParamVar._retn(); 
        if(msScanInfo.is_empty_scan == true)
            return true;
        else
            return false;
    }
    catch(ManagementErrors::SubscanErrorExImpl& ex) {
        ex.log(LM_ERROR);
        msParameters = msParamVar._retn(); 
        if(msScanInfo.is_empty_scan == true)
            return true;
        else
            return false;
    }
    catch(...) {
        ACS_SHORT_LOG((LM_WARNING, "MinorServoBoss::checkScan(): unexpected exception getting the min starting time"));
        msParameters = msParamVar._retn(); 
        if(msScanInfo.is_empty_scan == true)
            return true;
        else
            return false;
    }
    
@@ -849,6 +871,9 @@ bool MinorServoBossImpl::checkScanImpl(
    if(startingTime != 0 && min_starting_time > startingTime) {
        ACS_SHORT_LOG((LM_WARNING, "MinorServoBoss::checkScan(): not enought time to start the scan"));
        msParameters = msParamVar._retn(); 
        if(msScanInfo.is_empty_scan == true)
            return true;
        else
            return false;
    }

@@ -859,6 +884,9 @@ bool MinorServoBossImpl::checkScanImpl(
    TIMEVALUE gmst(guard_min_scan_time);
    if(CIRATools::timeSubtract(ttime, gmst) <= 0) {
        ACS_SHORT_LOG((LM_WARNING, "MinorServoBoss::checkScan(): total time too short for performing the scan."));
        if(msScanInfo.is_empty_scan == true)
            return true;
        else
            return false;
    }
    else {
+8 −0
Original line number Diff line number Diff line
@@ -129,6 +129,10 @@ vector<string> split(const string &s, const string &match, bool removeEmpty, boo
    vector<string> result; // return container for tokens
    string::size_type start = 0, skip = 1; // starting position for searches and positions to skip after a match
    find_t pfind = &string::find_first_of; // search algorithm for matches
    if(s.size() == 0) {
        result.push_back(string(s));
        return result;
    }

    if (fullMatch)
    {
@@ -169,6 +173,10 @@ vector<string> split(const string &s, const string &match, bool removeEmpty, boo

void strip(string &s, const string &token) {
    // ridx (lidx) is the index of first occurence starting from right (left)

    if(s.size() == 0)
        return;

    string::size_type ridx, lidx;
    string base_token("\n");
    while(true) {