MCPcopy Create free account
hub / github.com/aethersdr/AetherSDR / section7

Function section7

tests/rigctld_test.cpp:1199–1323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1197// ═════════════════════════════════════════════════════════════════════════════
1198
1199void section7(RigctlClient& c, Runner& r)
1200{
1201 r.section(QStringLiteral("Section 7 — Levels"));
1202
1203 // 7.5 STRENGTH is read-only
1204 QStringList lines = c.send(QStringLiteral("\\get_level STRENGTH"));
1205 const QString strength = c.field(lines, QStringLiteral("STRENGTH"));
1206 r.check(QStringLiteral("7.5 get_level STRENGTH returns numeric dB value"),
1207 c.ok(lines) && isFloat(strength), strength);
1208
1209 struct LevelCase { const char* name; const char* getId; const char* setId; double testVal; };
1210 static constexpr LevelCase kLevels[] = {
1211 {"AF", "7.1", "7.2", 0.75},
1212 {"RF", "7.3", "7.4", 1.0},
1213 {"SQL", "7.6", "7.7", 0.3},
1214 };
1215 for (const auto& lv : kLevels) {
1216 const QString lvName = QLatin1String(lv.name);
1217 lines = c.send(QStringLiteral("\\get_level ") + lvName);
1218 const QString val = c.field(lines, lvName);
1219 r.check(QStringLiteral("%1 get_level %2 returns numeric value")
1220 .arg(QLatin1String(lv.getId), lvName),
1221 c.ok(lines) && isFloat(val), val);
1222
1223 const QString orig = val;
1224 lines = c.send(QStringLiteral("\\set_level %1 %2").arg(lvName).arg(lv.testVal));
1225 r.check(QStringLiteral("%1 set_level %2 %3 returns RPRT 0")
1226 .arg(QLatin1String(lv.setId), lvName).arg(lv.testVal),
1227 c.ok(lines));
1228 if (isFloat(orig))
1229 c.send(QStringLiteral("\\set_level %1 %2").arg(lvName, orig));
1230 }
1231
1232 // 7.8 / 7.9 / 7.9b / 7.9c / 7.9d RFPOWER — set to 50 W, confirm, restore, confirm
1233 lines = c.send(QStringLiteral("\\get_level RFPOWER"));
1234 const QString origRfpower = c.field(lines, QStringLiteral("RFPOWER"));
1235 r.check(QStringLiteral("7.8 get_level RFPOWER returns numeric value"),
1236 c.ok(lines) && isFloat(origRfpower), origRfpower);
1237
1238 lines = c.send(QStringLiteral("\\set_level RFPOWER 0.5"));
1239 r.check(QStringLiteral("7.9 set_level RFPOWER 0.5 (50 W) returns RPRT 0"), c.ok(lines));
1240 QString pwrSet;
1241 {
1242 QElapsedTimer t; t.start();
1243 do {
1244 lines = c.send(QStringLiteral("\\get_level RFPOWER"));
1245 pwrSet = c.field(lines, QStringLiteral("RFPOWER"));
1246 if ((isFloat(pwrSet) && qAbs(pwrSet.toDouble() - 0.5) < 0.02) || t.elapsed() >= 1000) break;
1247 QThread::msleep(100);
1248 } while (true);
1249 }
1250 r.check(QStringLiteral("7.9b confirm RFPOWER ≈ 0.5 (50 W)"),
1251 c.ok(lines) && isFloat(pwrSet) && qAbs(pwrSet.toDouble() - 0.5) < 0.02, pwrSet);
1252
1253 if (isFloat(origRfpower)) {
1254 lines = c.send(QStringLiteral("\\set_level RFPOWER ") + origRfpower);
1255 r.check(QStringLiteral("7.9c restore RFPOWER returns RPRT 0"), c.ok(lines));
1256 QString pwrRestored;

Callers 1

mainFunction · 0.70

Calls 8

isFloatFunction · 0.85
sectionMethod · 0.45
sendMethod · 0.45
fieldMethod · 0.45
checkMethod · 0.45
okMethod · 0.45
startMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected