Loading Common/Simulators/Hardware/ReceiverBoardSim/src/ReceiverBoardSimImpl/board_server.py +2 −2 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ To stop the server:: import socket, traceback, os, sys import binhex from random import randrange from multiprocessing import Value Loading Loading @@ -191,7 +190,8 @@ class BoardServer: data_list += [156, 157, 158, 159] * AD24_LEN # Add four bytes pass else: data_list += [item + 1 for item in range(randrange(1, 7))] # data_list += [item + 1 for item in range(randrange(1, 7))] data_list += [1] answer += chr(len(data_list)) for item in data_list: answer += chr(item) Loading SRT/Servers/SRTLPBandReceiver/include/Configuration.h +6 −0 Original line number Diff line number Diff line Loading @@ -311,6 +311,12 @@ public: inline double const * const getLOMax() const { return m_LOMax; } inline double const * const getLowpassFilterMin() const { return m_LowpassFilterMin; } inline double const * const getLowpassFilterMax() const { return m_LowpassFilterMax; } /** * This member function is used to configure component by reading the configuration parameter from the CDB. * This must be the first call before using any other function of this class. Loading SRT/Servers/SRTLPBandReceiver/src/ComponentCore.cpp +7 −2 Original line number Diff line number Diff line Loading @@ -107,8 +107,13 @@ void CComponentCore::getLBandBandwidth(ACS::doubleSeq& bw) { baci::ThreadSyncGuard guard(&m_mutex); bw.length(m_configuration.getIFs()); double ifmax, ifmin, filter; for (WORD i=0; i<m_configuration.getIFs(); i++) { bw[i] = m_configuration.getLBandRFMax()[i] - m_configuration.getLBandRFMin()[i]; ifmin = m_configuration.getLBandRFMin()[i] - m_localOscillatorValue; ifmax = m_configuration.getLBandRFMax()[i] - m_localOscillatorValue; filter = m_configuration.getLowpassFilterMin()[0]; ifmax = (ifmax < filter) ? ifmax : filter; bw[i] = (ifmax - ifmin) > 0 ? (ifmax - ifmin) : 0; } } Loading @@ -128,7 +133,7 @@ void CComponentCore::getLBandStartFrequency(ACS::doubleSeq& sf) baci::ThreadSyncGuard guard(&m_mutex); sf.length(m_configuration.getIFs()); for (WORD i=0; i<m_configuration.getIFs(); i++) { sf[i] = m_configuration.getLBandIFMin()[i]; sf[i] = m_configuration.getLBandIFMin()[i] - m_localOscillatorValue; } } Loading SRT/Servers/SRTLPBandReceiver/test/functional/docLO.rst +10 −10 Original line number Diff line number Diff line Loading @@ -55,13 +55,18 @@ Expected Message: "Mode not allowed. The LO value is within the band and might generate strong aliasing." Test 6: bandwidth and start freq (default) Test 6: default LO value after ============================== Expected: LO == DefaultLO Test 7: bandwidth and start freq (default) ========================================== Expected: bandwidth==500 Expected: start frequency==1300 (1300-0) Test 7: bandwidth and start freq (NO-default) Test 8: bandwidth and start freq (NO-default) ============================================= > receiversMode=L1L5 (1625:1715) > setLO=2300 Loading @@ -70,7 +75,7 @@ Expected: bandwidth==90 Expected: start frequency==-675 (1625-2300) Test 8: low pass IF filter (default) Test 9: low pass IF filter (default) ==================================== > setL0=600 (IF band: 700-1200) Loading @@ -78,7 +83,7 @@ Expected: Bandwidth==300 (700:1000) Expected: start frequency==700 Test 9: low pass IF filter (NO-default) Test 10: low pass IF filter (NO-default) ======================================= > receiversMode=L1L5 (1625-1715) > setL0=700 (IF band: 925-1015) Loading @@ -87,7 +92,7 @@ Expected: Bandwidth==75 (925:1000) Expected: start frequency==925 Test 10: low pass IF filter (NO-default) Test 11: low pass IF filter (NO-default) ======================================== > receiversMode=L1L5 (1625-1715) > setL0=500 (IF band: 1125-1215) # Target command Loading @@ -97,11 +102,6 @@ Expected Message: "LO frequency value not allowed. The IF bandwidth is outside the low pass filter (0-1000MHz)". Test 11: default LO value after setup ===================================== Expected: LO == DefaultLO .. note:: Maybe we should raise a more specific exception type. For instance, a ReceiverErrors::ValidationError. In that case, we have to change the implementation of every receiver, because this change Loading SRT/Servers/SRTLPBandReceiver/test/functional/test_lo.py +80 −21 Original line number Diff line number Diff line Loading @@ -36,17 +36,17 @@ class TestLO(unittest2.TestCase): def test_keep_the_current_value(self): """In case of setLO([-1, -1]), keep the current value""" min_values = get_cdb_values('LOMin') min_values = self.get_cdb_values('LOMin') target = [(min_value + 1) for min_value in min_values] self.lp.setLO(target) self.lp.setLO([-1, -1]) current_value = get_property(self.lp, 'LO') current_value = self.get_property('LO') self.assertEqual(current_value, target) def test_set_below_minimum_value(self): """LO below the minimum allowed value: not allowed""" min_values = get_cdb_values('LOMin') min_values = self.get_cdb_values('LOMin') values_not_allowed = [(value - 0.5) for value in min_values] with self.assertRaises(ComponentErrorsEx): self.lp.setLO(values_not_allowed) Loading @@ -54,18 +54,16 @@ class TestLO(unittest2.TestCase): def test_set_above_minimum_value(self): """LO above the minimum allowed value: not allowed""" max_values = get_cdb_values('LOMax') max_values = self.get_cdb_values('LOMax') values_not_allowed = [(value + 0.5) for value in max_values] with self.assertRaises(ComponentErrorsEx): self.lp.setLO(values_not_allowed) def test_lo_inside_default_sky_band(self): """LO inside the default (L3L4) observed sky band: not allowed""" # Check the bandwith is 1300:1800 MHz assert [1300.0] * 2 == get_cdb_values('LBandRFMin') assert [1800.0] * 2 == get_cdb_values('LBandRFMax') values_not_allowed = [1500.00, 1500.00] """LO inside the default observed sky band: not allowed""" rfmin = self.get_cdb_values('LBandRFMin') values_not_allowed = [(value + 0.5) for value in rfmin] with self.assertRaisesRegexp(ComponentErrorsEx, 'within the band'): self.lp.setLO(values_not_allowed) Loading @@ -87,16 +85,77 @@ class TestLO(unittest2.TestCase): self.lp.setMode('XXL4') # Bandwidth 1300:1800 def get_cdb_values(attr_name, type_=float): def test_default_LO(self): """The LO value after setup must be the default one""" default = self.get_cdb_values('DefaultLO') current_value = self.get_property('LO') self.assertEqual(default, current_value) def test_default_bandWidth(self): # I.e. LO=0; rf=1300:1800; filter=1000 -> expected=0 bandWidth = self.get_property('bandWidth') ifmin, ifmax = self.get_ifs() # expected = (ifmax - ifmin) if (ifmax - ifmin) > 0 else 0.0, so: expected = [max(((mx - mn), 0.0)) for mn, mx in zip(ifmin, ifmax)] self.assertEqual(bandWidth, expected) def test_NO_default_bandWidth(self): # I.e. LO=2300; rf=1625:1715; filter=1000 -> expected=90 self.lp.setMode('XXL5') # band 1625:1715 self.lp.setLO([2300.0, 2300.0]) bandWidth = self.get_property('bandWidth') ifmin, ifmax = self.get_ifs() expected = [max(((mx - mn), 0.0)) for mn, mx in zip(ifmin, ifmax)] self.assertEqual(bandWidth, expected) def test_default_initialFrequency(self): # I.e. LO=0; rfmin=1300 -> ifmin=1300 initialFrequency = self.get_property('initialFrequency') ifmin, ifmax = self.get_ifs() self.assertEqual(initialFrequency, ifmin) def test_NO_default_initialFrequency(self): # I.e. LO=2300; rfmin=1625 -> ifmin=-625 self.lp.setMode('XXL5') # band 1625:1715 self.lp.setLO([2300.0, 2300.0]) initialFrequency = self.get_property('initialFrequency') ifmin, ifmax = self.get_ifs() self.assertEqual(initialFrequency, ifmin) def get_ifs(self): """Return the current IFs, taking in account the low pass filter""" rfmin = self.get_cdb_values('LBandRFMin') rfmax = self.get_cdb_values('LBandRFMax') lo = self.get_property('LO') get_plain_ifs = lambda rf, lo: rf - lo # I.e. rfmin = [1300, 1300], rfmax = [1800, 1800], lo = [1000, 1000] ifmin = map(get_plain_ifs, rfmin, lo) # -> [300, 300] ifmax = map(get_plain_ifs, rfmax, lo) # -> [800, 800] filter = self.get_cdb_values('LowpassFilterMax') for i, value in enumerate(filter): if ifmax[i] < value: continue else: ifmax[i] = value return ifmin, ifmax # A tuple of tuples def get_cdb_values(self, attr_name, type_=float): mode = self.get_property('mode') dal = ACSCorba.cdb() dao = dal.get_DAO('alma/DataBlock/SRTLPBandReceiver/Modes/L3L4') dao = dal.get_DAO('alma/DataBlock/SRTLPBandReceiver/Modes/%s' % mode) body = ElementTree.fromstring(dao) str_values = body.attrib[attr_name].split() return [type_(item) for item in str_values] def get_property(component_ref, property_name): property_obj = getattr(component_ref, '_get_%s' % property_name) def get_property(self, property_name): property_obj = getattr(self.lp, '_get_%s' % property_name) value, comp = property_obj().get_sync() return value Loading Loading
Common/Simulators/Hardware/ReceiverBoardSim/src/ReceiverBoardSimImpl/board_server.py +2 −2 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ To stop the server:: import socket, traceback, os, sys import binhex from random import randrange from multiprocessing import Value Loading Loading @@ -191,7 +190,8 @@ class BoardServer: data_list += [156, 157, 158, 159] * AD24_LEN # Add four bytes pass else: data_list += [item + 1 for item in range(randrange(1, 7))] # data_list += [item + 1 for item in range(randrange(1, 7))] data_list += [1] answer += chr(len(data_list)) for item in data_list: answer += chr(item) Loading
SRT/Servers/SRTLPBandReceiver/include/Configuration.h +6 −0 Original line number Diff line number Diff line Loading @@ -311,6 +311,12 @@ public: inline double const * const getLOMax() const { return m_LOMax; } inline double const * const getLowpassFilterMin() const { return m_LowpassFilterMin; } inline double const * const getLowpassFilterMax() const { return m_LowpassFilterMax; } /** * This member function is used to configure component by reading the configuration parameter from the CDB. * This must be the first call before using any other function of this class. Loading
SRT/Servers/SRTLPBandReceiver/src/ComponentCore.cpp +7 −2 Original line number Diff line number Diff line Loading @@ -107,8 +107,13 @@ void CComponentCore::getLBandBandwidth(ACS::doubleSeq& bw) { baci::ThreadSyncGuard guard(&m_mutex); bw.length(m_configuration.getIFs()); double ifmax, ifmin, filter; for (WORD i=0; i<m_configuration.getIFs(); i++) { bw[i] = m_configuration.getLBandRFMax()[i] - m_configuration.getLBandRFMin()[i]; ifmin = m_configuration.getLBandRFMin()[i] - m_localOscillatorValue; ifmax = m_configuration.getLBandRFMax()[i] - m_localOscillatorValue; filter = m_configuration.getLowpassFilterMin()[0]; ifmax = (ifmax < filter) ? ifmax : filter; bw[i] = (ifmax - ifmin) > 0 ? (ifmax - ifmin) : 0; } } Loading @@ -128,7 +133,7 @@ void CComponentCore::getLBandStartFrequency(ACS::doubleSeq& sf) baci::ThreadSyncGuard guard(&m_mutex); sf.length(m_configuration.getIFs()); for (WORD i=0; i<m_configuration.getIFs(); i++) { sf[i] = m_configuration.getLBandIFMin()[i]; sf[i] = m_configuration.getLBandIFMin()[i] - m_localOscillatorValue; } } Loading
SRT/Servers/SRTLPBandReceiver/test/functional/docLO.rst +10 −10 Original line number Diff line number Diff line Loading @@ -55,13 +55,18 @@ Expected Message: "Mode not allowed. The LO value is within the band and might generate strong aliasing." Test 6: bandwidth and start freq (default) Test 6: default LO value after ============================== Expected: LO == DefaultLO Test 7: bandwidth and start freq (default) ========================================== Expected: bandwidth==500 Expected: start frequency==1300 (1300-0) Test 7: bandwidth and start freq (NO-default) Test 8: bandwidth and start freq (NO-default) ============================================= > receiversMode=L1L5 (1625:1715) > setLO=2300 Loading @@ -70,7 +75,7 @@ Expected: bandwidth==90 Expected: start frequency==-675 (1625-2300) Test 8: low pass IF filter (default) Test 9: low pass IF filter (default) ==================================== > setL0=600 (IF band: 700-1200) Loading @@ -78,7 +83,7 @@ Expected: Bandwidth==300 (700:1000) Expected: start frequency==700 Test 9: low pass IF filter (NO-default) Test 10: low pass IF filter (NO-default) ======================================= > receiversMode=L1L5 (1625-1715) > setL0=700 (IF band: 925-1015) Loading @@ -87,7 +92,7 @@ Expected: Bandwidth==75 (925:1000) Expected: start frequency==925 Test 10: low pass IF filter (NO-default) Test 11: low pass IF filter (NO-default) ======================================== > receiversMode=L1L5 (1625-1715) > setL0=500 (IF band: 1125-1215) # Target command Loading @@ -97,11 +102,6 @@ Expected Message: "LO frequency value not allowed. The IF bandwidth is outside the low pass filter (0-1000MHz)". Test 11: default LO value after setup ===================================== Expected: LO == DefaultLO .. note:: Maybe we should raise a more specific exception type. For instance, a ReceiverErrors::ValidationError. In that case, we have to change the implementation of every receiver, because this change Loading
SRT/Servers/SRTLPBandReceiver/test/functional/test_lo.py +80 −21 Original line number Diff line number Diff line Loading @@ -36,17 +36,17 @@ class TestLO(unittest2.TestCase): def test_keep_the_current_value(self): """In case of setLO([-1, -1]), keep the current value""" min_values = get_cdb_values('LOMin') min_values = self.get_cdb_values('LOMin') target = [(min_value + 1) for min_value in min_values] self.lp.setLO(target) self.lp.setLO([-1, -1]) current_value = get_property(self.lp, 'LO') current_value = self.get_property('LO') self.assertEqual(current_value, target) def test_set_below_minimum_value(self): """LO below the minimum allowed value: not allowed""" min_values = get_cdb_values('LOMin') min_values = self.get_cdb_values('LOMin') values_not_allowed = [(value - 0.5) for value in min_values] with self.assertRaises(ComponentErrorsEx): self.lp.setLO(values_not_allowed) Loading @@ -54,18 +54,16 @@ class TestLO(unittest2.TestCase): def test_set_above_minimum_value(self): """LO above the minimum allowed value: not allowed""" max_values = get_cdb_values('LOMax') max_values = self.get_cdb_values('LOMax') values_not_allowed = [(value + 0.5) for value in max_values] with self.assertRaises(ComponentErrorsEx): self.lp.setLO(values_not_allowed) def test_lo_inside_default_sky_band(self): """LO inside the default (L3L4) observed sky band: not allowed""" # Check the bandwith is 1300:1800 MHz assert [1300.0] * 2 == get_cdb_values('LBandRFMin') assert [1800.0] * 2 == get_cdb_values('LBandRFMax') values_not_allowed = [1500.00, 1500.00] """LO inside the default observed sky band: not allowed""" rfmin = self.get_cdb_values('LBandRFMin') values_not_allowed = [(value + 0.5) for value in rfmin] with self.assertRaisesRegexp(ComponentErrorsEx, 'within the band'): self.lp.setLO(values_not_allowed) Loading @@ -87,16 +85,77 @@ class TestLO(unittest2.TestCase): self.lp.setMode('XXL4') # Bandwidth 1300:1800 def get_cdb_values(attr_name, type_=float): def test_default_LO(self): """The LO value after setup must be the default one""" default = self.get_cdb_values('DefaultLO') current_value = self.get_property('LO') self.assertEqual(default, current_value) def test_default_bandWidth(self): # I.e. LO=0; rf=1300:1800; filter=1000 -> expected=0 bandWidth = self.get_property('bandWidth') ifmin, ifmax = self.get_ifs() # expected = (ifmax - ifmin) if (ifmax - ifmin) > 0 else 0.0, so: expected = [max(((mx - mn), 0.0)) for mn, mx in zip(ifmin, ifmax)] self.assertEqual(bandWidth, expected) def test_NO_default_bandWidth(self): # I.e. LO=2300; rf=1625:1715; filter=1000 -> expected=90 self.lp.setMode('XXL5') # band 1625:1715 self.lp.setLO([2300.0, 2300.0]) bandWidth = self.get_property('bandWidth') ifmin, ifmax = self.get_ifs() expected = [max(((mx - mn), 0.0)) for mn, mx in zip(ifmin, ifmax)] self.assertEqual(bandWidth, expected) def test_default_initialFrequency(self): # I.e. LO=0; rfmin=1300 -> ifmin=1300 initialFrequency = self.get_property('initialFrequency') ifmin, ifmax = self.get_ifs() self.assertEqual(initialFrequency, ifmin) def test_NO_default_initialFrequency(self): # I.e. LO=2300; rfmin=1625 -> ifmin=-625 self.lp.setMode('XXL5') # band 1625:1715 self.lp.setLO([2300.0, 2300.0]) initialFrequency = self.get_property('initialFrequency') ifmin, ifmax = self.get_ifs() self.assertEqual(initialFrequency, ifmin) def get_ifs(self): """Return the current IFs, taking in account the low pass filter""" rfmin = self.get_cdb_values('LBandRFMin') rfmax = self.get_cdb_values('LBandRFMax') lo = self.get_property('LO') get_plain_ifs = lambda rf, lo: rf - lo # I.e. rfmin = [1300, 1300], rfmax = [1800, 1800], lo = [1000, 1000] ifmin = map(get_plain_ifs, rfmin, lo) # -> [300, 300] ifmax = map(get_plain_ifs, rfmax, lo) # -> [800, 800] filter = self.get_cdb_values('LowpassFilterMax') for i, value in enumerate(filter): if ifmax[i] < value: continue else: ifmax[i] = value return ifmin, ifmax # A tuple of tuples def get_cdb_values(self, attr_name, type_=float): mode = self.get_property('mode') dal = ACSCorba.cdb() dao = dal.get_DAO('alma/DataBlock/SRTLPBandReceiver/Modes/L3L4') dao = dal.get_DAO('alma/DataBlock/SRTLPBandReceiver/Modes/%s' % mode) body = ElementTree.fromstring(dao) str_values = body.attrib[attr_name].split() return [type_(item) for item in str_values] def get_property(component_ref, property_name): property_obj = getattr(component_ref, '_get_%s' % property_name) def get_property(self, property_name): property_obj = getattr(self.lp, '_get_%s' % property_name) value, comp = property_obj().get_sync() return value Loading