Loading Common/Interfaces/MinorServoInterface/test/PyMinorServoTest/simunittest.py +1 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ def run(test_case): tests = unittest2.TestLoader().loadTestsFromTestCase(test_case) suite.addTests(tests) print 'Running the tests using the antenna simulators...' unittest2.TextTestRunner().run(suite) 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 Common/Interfaces/MinorServoInterface/test/functional/test_scan.py +7 −7 Original line number Diff line number Diff line Loading @@ -51,6 +51,10 @@ class ScanBaseTest(unittest2.TestCase): axis_code='SRP_TZ' if self.telescope == 'SRT' else 'Z', is_empty_scan=False) def tearDown(self): if self.boss.isScanActive(): self.boss.closeScan() class ScanTest(ScanBaseTest): """Test checkScan(), startScan() and closeScan()""" Loading Loading @@ -88,10 +92,6 @@ class ScanTest(ScanBaseTest): math.degrees(self.antennaInfo.elevation)) self.centerScan = centerScanPosition[self.idx] def tearDown(self): if self.boss.isScanActive(): self.boss.closeScan() def test_startScan_empty_scan(self): """Do nothing in case of empty scan""" self.scan.is_empty_scan = True Loading Loading @@ -137,10 +137,10 @@ class ScanTest(ScanBaseTest): """Return the time_to_stop""" startTime = 0 t = self.boss.startScan(startTime, self.scan, self.antennaInfo) self.waitUntil(startTime) time_to_stop = self.boss.closeScan() # The time_to_stop should be greater than the starting time self.assertGreater(time_to_stop, t) # The time_to_stop should be greater than now self.assertGreater(time_to_stop, getTimeStamp().value) def test_checkScan_empty_scan_start_ASAP(self): """Starting time unknown: the scan must start ASAP""" Loading SRT/Servers/SRTMinorServo/src/MinorServoBossImpl.cpp +34 −9 Original line number Diff line number Diff line Loading @@ -598,9 +598,7 @@ void MinorServoBossImpl::closeScan(ACS::Time& timeToStop) throw ( MinorServoErrors::MinorServoErrorsEx, ComponentErrors::ComponentErrorsEx) { // ********* to be computed ******************** timeToStop=0; // ********************************************* if(m_configuration->m_isScanActive) { string comp_name((m_configuration->m_scan).comp_name); if(m_component_refs.count(comp_name)) { Loading Loading @@ -630,6 +628,32 @@ void MinorServoBossImpl::closeScan(ACS::Time& timeToStop) throw ( } m_configuration->m_isScanActive = false; ACSErr::Completion_var completion; ACS::doubleSeq actPos = *((component_ref->actPos())->get_sync(completion.out())); ACS::doubleSeq centralPos = (m_configuration->m_scan).centralPos; size_t axis = (m_configuration->m_scan).axis_index; ACS::doubleSeq *acc = component_ref->getData("ACCELERATION"); ACS::doubleSeq *mspeed = component_ref->getData("MAX_SPEED"); CDB::DAL_ptr dal_p = getContainerServices()->getCDB(); CDB::DAO_ptr dao_p = dal_p->get_DAO_Servant( ("alma/MINORSERVO/" + (m_configuration->m_scan).comp_name).c_str()); size_t number_of_axis = dao_p->get_long("number_of_axis"); size_t idx = (*acc).length() - number_of_axis + axis; if((*acc).length() - 1 < idx || (*mspeed).length() - 1 < idx) { string msg("closeScan(): acceleration index out of range"); _EXCPT(MinorServoErrors::StatusErrorExImpl, impl, msg.c_str()); impl.log(LM_DEBUG); throw impl.getMinorServoErrorsEx(); } double acceleration = (*acc)[idx]; double max_speed= (*mspeed)[idx]; double distance = fabs(actPos[axis] - centralPos[axis]); ACS::Time min_scan_time = get_min_time(distance, acceleration, max_speed); ACS::Time guard_min_scan_time = static_cast<ACS::Time>(min_scan_time * (1 + SCAN_GUARD_COEFF)); timeToStop = getTimeStamp() + guard_min_scan_time; } else { string msg("closeScan(): nil component reference"); Loading Loading @@ -1152,15 +1176,16 @@ void MinorServoBossImpl::startScanImpl( throw impl.getMinorServoErrorsEx(); } min_starting_time = (startingTime==0) ? min_starting_time : startingTime; if(startingTime != 0 && min_starting_time > startingTime) { if(startingTime != 0) { if(min_starting_time > startingTime) { m_configuration->m_isScanning = false; string msg("startScanImpl(): the scan is supposed to start to early"); _EXCPT(MinorServoErrors::StatusErrorExImpl, impl, msg.c_str()); impl.log(LM_DEBUG); throw impl.getMinorServoErrorsEx(); } } else { startingTime = min_starting_time; } Loading Loading
Common/Interfaces/MinorServoInterface/test/PyMinorServoTest/simunittest.py +1 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ def run(test_case): tests = unittest2.TestLoader().loadTestsFromTestCase(test_case) suite.addTests(tests) print 'Running the tests using the antenna simulators...' unittest2.TextTestRunner().run(suite) 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
Common/Interfaces/MinorServoInterface/test/functional/test_scan.py +7 −7 Original line number Diff line number Diff line Loading @@ -51,6 +51,10 @@ class ScanBaseTest(unittest2.TestCase): axis_code='SRP_TZ' if self.telescope == 'SRT' else 'Z', is_empty_scan=False) def tearDown(self): if self.boss.isScanActive(): self.boss.closeScan() class ScanTest(ScanBaseTest): """Test checkScan(), startScan() and closeScan()""" Loading Loading @@ -88,10 +92,6 @@ class ScanTest(ScanBaseTest): math.degrees(self.antennaInfo.elevation)) self.centerScan = centerScanPosition[self.idx] def tearDown(self): if self.boss.isScanActive(): self.boss.closeScan() def test_startScan_empty_scan(self): """Do nothing in case of empty scan""" self.scan.is_empty_scan = True Loading Loading @@ -137,10 +137,10 @@ class ScanTest(ScanBaseTest): """Return the time_to_stop""" startTime = 0 t = self.boss.startScan(startTime, self.scan, self.antennaInfo) self.waitUntil(startTime) time_to_stop = self.boss.closeScan() # The time_to_stop should be greater than the starting time self.assertGreater(time_to_stop, t) # The time_to_stop should be greater than now self.assertGreater(time_to_stop, getTimeStamp().value) def test_checkScan_empty_scan_start_ASAP(self): """Starting time unknown: the scan must start ASAP""" Loading
SRT/Servers/SRTMinorServo/src/MinorServoBossImpl.cpp +34 −9 Original line number Diff line number Diff line Loading @@ -598,9 +598,7 @@ void MinorServoBossImpl::closeScan(ACS::Time& timeToStop) throw ( MinorServoErrors::MinorServoErrorsEx, ComponentErrors::ComponentErrorsEx) { // ********* to be computed ******************** timeToStop=0; // ********************************************* if(m_configuration->m_isScanActive) { string comp_name((m_configuration->m_scan).comp_name); if(m_component_refs.count(comp_name)) { Loading Loading @@ -630,6 +628,32 @@ void MinorServoBossImpl::closeScan(ACS::Time& timeToStop) throw ( } m_configuration->m_isScanActive = false; ACSErr::Completion_var completion; ACS::doubleSeq actPos = *((component_ref->actPos())->get_sync(completion.out())); ACS::doubleSeq centralPos = (m_configuration->m_scan).centralPos; size_t axis = (m_configuration->m_scan).axis_index; ACS::doubleSeq *acc = component_ref->getData("ACCELERATION"); ACS::doubleSeq *mspeed = component_ref->getData("MAX_SPEED"); CDB::DAL_ptr dal_p = getContainerServices()->getCDB(); CDB::DAO_ptr dao_p = dal_p->get_DAO_Servant( ("alma/MINORSERVO/" + (m_configuration->m_scan).comp_name).c_str()); size_t number_of_axis = dao_p->get_long("number_of_axis"); size_t idx = (*acc).length() - number_of_axis + axis; if((*acc).length() - 1 < idx || (*mspeed).length() - 1 < idx) { string msg("closeScan(): acceleration index out of range"); _EXCPT(MinorServoErrors::StatusErrorExImpl, impl, msg.c_str()); impl.log(LM_DEBUG); throw impl.getMinorServoErrorsEx(); } double acceleration = (*acc)[idx]; double max_speed= (*mspeed)[idx]; double distance = fabs(actPos[axis] - centralPos[axis]); ACS::Time min_scan_time = get_min_time(distance, acceleration, max_speed); ACS::Time guard_min_scan_time = static_cast<ACS::Time>(min_scan_time * (1 + SCAN_GUARD_COEFF)); timeToStop = getTimeStamp() + guard_min_scan_time; } else { string msg("closeScan(): nil component reference"); Loading Loading @@ -1152,15 +1176,16 @@ void MinorServoBossImpl::startScanImpl( throw impl.getMinorServoErrorsEx(); } min_starting_time = (startingTime==0) ? min_starting_time : startingTime; if(startingTime != 0 && min_starting_time > startingTime) { if(startingTime != 0) { if(min_starting_time > startingTime) { m_configuration->m_isScanning = false; string msg("startScanImpl(): the scan is supposed to start to early"); _EXCPT(MinorServoErrors::StatusErrorExImpl, impl, msg.c_str()); impl.log(LM_DEBUG); throw impl.getMinorServoErrorsEx(); } } else { startingTime = min_starting_time; } Loading