MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / Base

Method Base

app/src/UI/Widgets/Output/Base.cpp:26–50  ·  view source on GitHub ↗

* @brief Constructs an output widget base from a config struct. */

Source from the content-addressed store, hash-verified

24 * @brief Constructs an output widget base from a config struct.
25 */
26Widgets::Output::Base::Base(const DataModel::OutputWidget& config, QQuickItem* parent)
27 : QQuickItem(parent)
28 , m_sourceId(config.sourceId)
29 , m_minValue(config.minValue)
30 , m_maxValue(config.maxValue)
31 , m_stepSize(config.stepSize)
32 , m_title(config.title)
33 , m_txEncoding(static_cast<SerialStudio::TextEncoding>(config.txEncoding))
34 , m_hasFn(false)
35 , m_watchdog(&m_jsEngine, kTransmitWatchdogMs, QStringLiteral("transmit"))
36{
37 m_rateLimiter.start();
38 DataModel::ScriptApiCall::installAll(&m_jsEngine, m_sourceId);
39
40 if (!config.transmitFunction.isEmpty()) {
41 const auto wrapped =
42 QStringLiteral("(function() { %1; return transmit; })()").arg(config.transmitFunction);
43 m_transmitFn = m_jsEngine.evaluate(wrapped);
44 m_hasFn = m_transmitFn.isCallable();
45
46 if (!m_hasFn)
47 qWarning() << "Output widget" << m_title
48 << "- transmit function is not callable:" << m_transmitFn.toString();
49 }
50}
51
52/**
53 * @brief Destructor.

Callers

nothing calls this directly

Calls 3

isEmptyMethod · 0.80
startMethod · 0.45
evaluateMethod · 0.45

Tested by

no test coverage detected