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

Method cmdSetLevel

src/core/RigctlProtocol.cpp:1398–1562  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1396}
1397
1398QString RigctlProtocol::cmdSetLevel(const QString& args)
1399{
1400 QStringList parts = args.split(' ', Qt::SkipEmptyParts);
1401 // Strip + resolve any VFO prefix once. Slice-specific levels use targetSlice
1402 // (#5); radio-wide levels ignore it. nullptr only fails the slice branches.
1403 SliceModel* targetSlice = takeVfoPrefix(parts);
1404 if (parts.isEmpty())
1405 return rprt(-1);
1406
1407 const QString level = parts[0].trimmed().toUpper();
1408 if (level == "?") {
1409 const QString supported = rigSetLevelTokens().join(' ');
1410 if (m_extended)
1411 return QStringLiteral("set_level:\nLevels: %1\n").arg(supported) + rprt(0);
1412 return supported + "\n";
1413 }
1414 if (level == "AGC") {
1415 if (parts.size() < 2) return rprt(-1);
1416 bool ok = false;
1417 const int agcVal = parts[1].toInt(&ok);
1418 if (!ok) return rprt(-1);
1419 // Hamlib RIG_AGC_* → Flex agcMode (4 states). Inverse of cmdGetLevel for
1420 // the canonical values 0/2/3/5; Hamlib's superfast(1)/user(4)/auto(6)
1421 // collapse to the nearest Flex state (#8).
1422 // 0=off, 1-2=fast, 3=slow, 4-6=med
1423 const QString mode = (agcVal == 0) ? QStringLiteral("off")
1424 : (agcVal <= 2) ? QStringLiteral("fast")
1425 : (agcVal == 3) ? QStringLiteral("slow")
1426 : QStringLiteral("med");
1427 if (!targetSlice) return rprt(-8);
1428 SliceModel* s = targetSlice;
1429 QMetaObject::invokeMethod(s, [s, mode]() {
1430 s->setAgcMode(mode);
1431 }, Qt::QueuedConnection);
1432 return rprt(0);
1433 }
1434
1435 if (level == "KEYSPD")
1436 return cmdSetKeySpeed(parts.mid(1).join(' '));
1437
1438 if (level == "RFPOWER") {
1439 if (parts.size() < 2) return rprt(-1);
1440 bool ok = false;
1441 double ratio = parts[1].toDouble(&ok);
1442 if (!ok) return rprt(-1);
1443 // Hamlib delivers RFPOWER as 0.0–1.0; convert to the radio's 0–100
1444 // scale and let TransmitModel::setRfPower clamp.
1445 const int percent = qRound(qBound(0.0, ratio, 1.0) * 100.0);
1446 if (!m_model) return rprt(-8);
1447 QMetaObject::invokeMethod(m_model, [model = m_model, percent]() {
1448 model->transmitModel().setRfPower(percent);
1449 }, Qt::QueuedConnection);
1450 return rprt(0);
1451 }
1452
1453 // All remaining set-levels need a value argument and a connected model
1454 if (parts.size() < 2) return rprt(-1);
1455 if (!m_model) return rprt(-8);

Callers

nothing calls this directly

Calls 15

rigSetLevelTokensFunction · 0.85
setAgcModeMethod · 0.80
setRfPowerMethod · 0.80
setCwPitchMethod · 0.80
setVoxLevelMethod · 0.80
setVoxDelayMethod · 0.80
setMonGainSbMethod · 0.80
setCwDelayMethod · 0.80
setAudioGainMethod · 0.80
squelchOnMethod · 0.80
setSquelchMethod · 0.80

Tested by

no test coverage detected