Further integration tests
This commit is contained in:
parent
6e5f2635d1
commit
46b41a4a04
@ -1,9 +1,9 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
testmodules = [
|
testmodules = [
|
||||||
# 'tests.TestConnect',
|
'tests.TestConnect',
|
||||||
# 'tests.TestMode',
|
'tests.TestMode',
|
||||||
# 'tests.TestVNASweep',
|
'tests.TestVNASweep',
|
||||||
'tests.TestCalibration',
|
'tests.TestCalibration',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ from signal import SIGINT
|
|||||||
|
|
||||||
class TestBase(unittest.TestCase):
|
class TestBase(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.gui = subprocess.Popen([defs.GUI_PATH, '-p', '19543'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
self.gui = subprocess.Popen([defs.GUI_PATH, '-p', '19544'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
# wait for the SCPI server to become available
|
# wait for the SCPI server to become available
|
||||||
timeout = time.time() + 3;
|
timeout = time.time() + 3;
|
||||||
@ -18,13 +18,17 @@ class TestBase(unittest.TestCase):
|
|||||||
poll_result = poll_obj.poll(0)
|
poll_result = poll_obj.poll(0)
|
||||||
if poll_result:
|
if poll_result:
|
||||||
line = self.gui.stdout.readline().decode().strip()
|
line = self.gui.stdout.readline().decode().strip()
|
||||||
if "Listening on port 19543" in line:
|
if "Listening on port 19544" in line:
|
||||||
break
|
break
|
||||||
|
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
|
|
||||||
self.vna = libreVNA('localhost', 19543)
|
self.vna = libreVNA('localhost', 19544)
|
||||||
|
try:
|
||||||
self.vna.cmd(":DEV:CONN")
|
self.vna.cmd(":DEV:CONN")
|
||||||
|
except Exception as e:
|
||||||
|
self.tearDown()
|
||||||
|
raise e
|
||||||
if self.vna.query(":DEV:CONN?") == "Not connected":
|
if self.vna.query(":DEV:CONN?") == "Not connected":
|
||||||
self.tearDown()
|
self.tearDown()
|
||||||
raise AssertionError("Not connected")
|
raise AssertionError("Not connected")
|
||||||
|
@ -2,6 +2,13 @@ from tests.TestBase import TestBase
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
class TestVNASweep(TestBase):
|
class TestVNASweep(TestBase):
|
||||||
|
def waitSweepTimeout(self, timeout = 1):
|
||||||
|
self.assertEqual(self.vna.query(":VNA:ACQ:FIN?"), "FALSE")
|
||||||
|
stoptime = time.time() + timeout
|
||||||
|
while self.vna.query(":VNA:ACQ:FIN?") == "FALSE":
|
||||||
|
if time.time() > stoptime:
|
||||||
|
raise AssertionError("Sweep timed out")
|
||||||
|
|
||||||
def test_sweep_frequency(self):
|
def test_sweep_frequency(self):
|
||||||
self.vna.cmd(":DEV:MODE VNA")
|
self.vna.cmd(":DEV:MODE VNA")
|
||||||
self.vna.cmd(":VNA:SWEEP FREQUENCY")
|
self.vna.cmd(":VNA:SWEEP FREQUENCY")
|
||||||
@ -11,8 +18,7 @@ class TestVNASweep(TestBase):
|
|||||||
self.vna.cmd(":VNA:ACQ:POINTS 501")
|
self.vna.cmd(":VNA:ACQ:POINTS 501")
|
||||||
self.vna.cmd(":VNA:FREQuency:START 1000000")
|
self.vna.cmd(":VNA:FREQuency:START 1000000")
|
||||||
self.vna.cmd(":VNA:FREQuency:STOP 6000000000")
|
self.vna.cmd(":VNA:FREQuency:STOP 6000000000")
|
||||||
while self.vna.query(":VNA:ACQ:FIN?") == "FALSE":
|
self.waitSweepTimeout(2)
|
||||||
time.sleep(0.1)
|
|
||||||
|
|
||||||
S11 = self.vna.parse_trace_data(self.vna.query(":VNA:TRACE:DATA? S11"))
|
S11 = self.vna.parse_trace_data(self.vna.query(":VNA:TRACE:DATA? S11"))
|
||||||
self.assertEqual(S11[0][0], 1000000)
|
self.assertEqual(S11[0][0], 1000000)
|
||||||
@ -28,8 +34,7 @@ class TestVNASweep(TestBase):
|
|||||||
self.vna.cmd(":VNA:FREQuency:START 500000000")
|
self.vna.cmd(":VNA:FREQuency:START 500000000")
|
||||||
self.vna.cmd(":VNA:FREQuency:STOP 1500000000")
|
self.vna.cmd(":VNA:FREQuency:STOP 1500000000")
|
||||||
self.vna.cmd(":VNA:FREQuency:ZERO 1500000000")
|
self.vna.cmd(":VNA:FREQuency:ZERO 1500000000")
|
||||||
while self.vna.query(":VNA:ACQ:FIN?") == "FALSE":
|
self.waitSweepTimeout(2)
|
||||||
time.sleep(0.1)
|
|
||||||
|
|
||||||
S11 = self.vna.parse_trace_data(self.vna.query(":VNA:TRACE:DATA? S11"))
|
S11 = self.vna.parse_trace_data(self.vna.query(":VNA:TRACE:DATA? S11"))
|
||||||
self.assertEqual(S11[0][0], 0.0)
|
self.assertEqual(S11[0][0], 0.0)
|
||||||
@ -46,9 +51,23 @@ class TestVNASweep(TestBase):
|
|||||||
self.vna.cmd(":VNA:ACQ:POINTS 501")
|
self.vna.cmd(":VNA:ACQ:POINTS 501")
|
||||||
self.vna.cmd(":VNA:POWER:START -30")
|
self.vna.cmd(":VNA:POWER:START -30")
|
||||||
self.vna.cmd(":VNA:POWER:STOP -10")
|
self.vna.cmd(":VNA:POWER:STOP -10")
|
||||||
while self.vna.query(":VNA:ACQ:FIN?") == "FALSE":
|
self.waitSweepTimeout(2)
|
||||||
time.sleep(0.1)
|
|
||||||
|
|
||||||
S11 = self.vna.parse_trace_data(self.vna.query(":VNA:TRACE:DATA? S11"))
|
S11 = self.vna.parse_trace_data(self.vna.query(":VNA:TRACE:DATA? S11"))
|
||||||
self.assertEqual(S11[0][0], -30)
|
self.assertEqual(S11[0][0], -30)
|
||||||
self.assertEqual(S11[-1][0], -10)
|
self.assertEqual(S11[-1][0], -10)
|
||||||
|
|
||||||
|
def test_fast_single_sweeps(self):
|
||||||
|
self.vna.cmd(":DEV:MODE VNA")
|
||||||
|
self.vna.cmd(":VNA:SWEEP FREQUENCY")
|
||||||
|
self.vna.cmd(":VNA:STIM:LVL -10")
|
||||||
|
self.vna.cmd(":VNA:ACQ:IFBW 50000")
|
||||||
|
self.vna.cmd(":VNA:ACQ:AVG 1")
|
||||||
|
self.vna.cmd(":VNA:ACQ:POINTS 501")
|
||||||
|
self.vna.cmd(":VNA:FREQuency:START 1000000")
|
||||||
|
self.vna.cmd(":VNA:FREQuency:STOP 6000000000")
|
||||||
|
|
||||||
|
for i in range(10):
|
||||||
|
# Change something irrelevant (to force reconfiguration of device)
|
||||||
|
self.vna.cmd(":VNA:FREQuency:START "+str(1000000+i))
|
||||||
|
self.waitSweepTimeout(2)
|
@ -208,6 +208,7 @@ void TraceWidget::SetupSCPI()
|
|||||||
return "ERROR";
|
return "ERROR";
|
||||||
}
|
}
|
||||||
QString ret;
|
QString ret;
|
||||||
|
if(t->size() > 0) {
|
||||||
for(unsigned int i=0;i<t->size();i++) {
|
for(unsigned int i=0;i<t->size();i++) {
|
||||||
auto d = t->sample(i);
|
auto d = t->sample(i);
|
||||||
int precision = 0;
|
int precision = 0;
|
||||||
@ -221,6 +222,9 @@ void TraceWidget::SetupSCPI()
|
|||||||
ret += "[" + QString::number(d.x, 'f', precision) + ","+createStringFromData(t, d)+"],";
|
ret += "[" + QString::number(d.x, 'f', precision) + ","+createStringFromData(t, d)+"],";
|
||||||
}
|
}
|
||||||
ret.chop(1);
|
ret.chop(1);
|
||||||
|
} else {
|
||||||
|
ret = "EMPTY";
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}));
|
}));
|
||||||
add(new SCPICommand("AT", nullptr, [=](QStringList params) -> QString {
|
add(new SCPICommand("AT", nullptr, [=](QStringList params) -> QString {
|
||||||
|
@ -909,6 +909,8 @@ void VNA::UpdateAverageCount()
|
|||||||
void VNA::SettingsChanged()
|
void VNA::SettingsChanged()
|
||||||
{
|
{
|
||||||
configurationTimer.start(100);
|
configurationTimer.start(100);
|
||||||
|
changingSettings = true;
|
||||||
|
ResetLiveTraces();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VNA::StartImpedanceMatching()
|
void VNA::StartImpedanceMatching()
|
||||||
@ -938,6 +940,7 @@ void VNA::SetSweepType(SweepType sw)
|
|||||||
if(settings.sweepType != sw) {
|
if(settings.sweepType != sw) {
|
||||||
settings.sweepType = sw;
|
settings.sweepType = sw;
|
||||||
emit sweepTypeChanged(sw);
|
emit sweepTypeChanged(sw);
|
||||||
|
ConstrainAndUpdateFrequencies();
|
||||||
SettingsChanged();
|
SettingsChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1085,6 +1088,7 @@ void VNA::SetPowerSweepFrequency(double freq)
|
|||||||
{
|
{
|
||||||
settings.Power.frequency = freq;
|
settings.Power.frequency = freq;
|
||||||
emit powerSweepFrequencyChanged(freq);
|
emit powerSweepFrequencyChanged(freq);
|
||||||
|
ConstrainAndUpdateFrequencies();
|
||||||
SettingsChanged();
|
SettingsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1220,7 +1224,8 @@ void VNA::SetupSCPI()
|
|||||||
if(params.size() >= 1) {
|
if(params.size() >= 1) {
|
||||||
if(params[0] == "FREQUENCY") {
|
if(params[0] == "FREQUENCY") {
|
||||||
SetSweepType(SweepType::Frequency);
|
SetSweepType(SweepType::Frequency);
|
||||||
return "";
|
ResetLiveTraces();
|
||||||
|
return SCPI::getResultName(SCPI::Result::Empty);
|
||||||
} else if(params[0] == "POWER") {
|
} else if(params[0] == "POWER") {
|
||||||
SetSweepType(SweepType::Power);
|
SetSweepType(SweepType::Power);
|
||||||
return SCPI::getResultName(SCPI::Result::Empty);
|
return SCPI::getResultName(SCPI::Result::Empty);
|
||||||
@ -1280,6 +1285,7 @@ void VNA::SetupSCPI()
|
|||||||
scpi_freq->add(new SCPICommand("FULL", [=](QStringList params) -> QString {
|
scpi_freq->add(new SCPICommand("FULL", [=](QStringList params) -> QString {
|
||||||
Q_UNUSED(params)
|
Q_UNUSED(params)
|
||||||
SetFullSpan();
|
SetFullSpan();
|
||||||
|
ResetLiveTraces();
|
||||||
return SCPI::getResultName(SCPI::Result::Empty);
|
return SCPI::getResultName(SCPI::Result::Empty);
|
||||||
}, nullptr));
|
}, nullptr));
|
||||||
scpi_freq->add(new SCPICommand("ZERO", [=](QStringList params) -> QString {
|
scpi_freq->add(new SCPICommand("ZERO", [=](QStringList params) -> QString {
|
||||||
@ -1653,11 +1659,7 @@ void VNA::ConfigureDevice(bool resetTraces, std::function<void(bool)> cb)
|
|||||||
{
|
{
|
||||||
if(running) {
|
if(running) {
|
||||||
if (resetTraces) {
|
if (resetTraces) {
|
||||||
settings.activeSegment = 0;
|
ResetLiveTraces();
|
||||||
average.reset(settings.npoints);
|
|
||||||
traceModel.clearLiveData();
|
|
||||||
UpdateAverageCount();
|
|
||||||
UpdateCalWidget();
|
|
||||||
}
|
}
|
||||||
changingSettings = true;
|
changingSettings = true;
|
||||||
// assemble VNA protocol settings
|
// assemble VNA protocol settings
|
||||||
@ -1713,10 +1715,7 @@ void VNA::ConfigureDevice(bool resetTraces, std::function<void(bool)> cb)
|
|||||||
window->getDevice()->setVNA(s, [=](bool res){
|
window->getDevice()->setVNA(s, [=](bool res){
|
||||||
// device received command, reset traces now
|
// device received command, reset traces now
|
||||||
if (resetTraces) {
|
if (resetTraces) {
|
||||||
average.reset(settings.npoints);
|
ResetLiveTraces();
|
||||||
traceModel.clearLiveData();
|
|
||||||
UpdateAverageCount();
|
|
||||||
UpdateCalWidget();
|
|
||||||
}
|
}
|
||||||
if(cb) {
|
if(cb) {
|
||||||
cb(res);
|
cb(res);
|
||||||
@ -1743,6 +1742,15 @@ void VNA::ConfigureDevice(bool resetTraces, std::function<void(bool)> cb)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VNA::ResetLiveTraces()
|
||||||
|
{
|
||||||
|
settings.activeSegment = 0;
|
||||||
|
average.reset(settings.npoints);
|
||||||
|
traceModel.clearLiveData();
|
||||||
|
UpdateAverageCount();
|
||||||
|
UpdateCalWidget();
|
||||||
|
}
|
||||||
|
|
||||||
bool VNA::LoadCalibration(QString filename)
|
bool VNA::LoadCalibration(QString filename)
|
||||||
{
|
{
|
||||||
return cal.fromFile(filename);
|
return cal.fromFile(filename);
|
||||||
|
@ -132,6 +132,7 @@ private slots:
|
|||||||
void Run();
|
void Run();
|
||||||
void Stop();
|
void Stop();
|
||||||
void ConfigureDevice(bool resetTraces = true, std::function<void(bool)> cb = nullptr);
|
void ConfigureDevice(bool resetTraces = true, std::function<void(bool)> cb = nullptr);
|
||||||
|
void ResetLiveTraces();
|
||||||
private:
|
private:
|
||||||
Settings settings;
|
Settings settings;
|
||||||
unsigned int averages;
|
unsigned int averages;
|
||||||
|
Loading…
Reference in New Issue
Block a user