diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-03-16 16:19:49 +0100 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-03-16 16:19:49 +0100 |
| commit | fa095de6cc8ec5a5b5c14091f2b3179ad7071876 (patch) | |
| tree | aa094011263a83a4c91eb8722c2095344656c838 /src/Xpl2JcStatus.cpp | |
| parent | 7830f0ae98d742467b948ed93c85e122be38fb83 (diff) | |
| download | QtXpl2-fa095de6cc8ec5a5b5c14091f2b3179ad7071876.tar.gz QtXpl2-fa095de6cc8ec5a5b5c14091f2b3179ad7071876.zip | |
EV_ events with Q_GADGET status types, mock periodic emission, tabbed demo UI
Diffstat (limited to 'src/Xpl2JcStatus.cpp')
| -rw-r--r-- | src/Xpl2JcStatus.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/Xpl2JcStatus.cpp b/src/Xpl2JcStatus.cpp new file mode 100644 index 0000000..b800eb9 --- /dev/null +++ b/src/Xpl2JcStatus.cpp @@ -0,0 +1,70 @@ +/** + * @file Xpl2JcStatus.cpp + * @brief Structured JC status message (EV_STATUS_MSG_JC, Appendix A). + */ +#include "Xpl2JcStatus.h" + +#include <QVariant> + +Xpl2JcStatus +Xpl2JcStatus::fromParams (const QVariantList ¶ms) +{ + Xpl2JcStatus s; + int n = params.size (); + if (n < 2) + return s; + + s.controllerId = params[0].toInt (); + s.statusLevel = params[1].toInt (); + + /* Level 1: fields at indices 2-8 */ + if (n > 2) + s.cpuPercentageBusy = params[2].toFloat (); + if (n > 3) + s.rail5V = params[3].toFloat (); + if (n > 4) + s.railCanBus8V = params[4].toFloat (); + if (n > 5) + s.temperature = params[5].toFloat (); + if (n > 6) + s.humidity = params[6].toFloat (); + if (n > 7) + s.busCurrent = params[7].toFloat (); + if (n > 8) + s.onTimeSeconds = params[8].toInt (); + + /* Level 2: fields at indices 9-22 */ + if (s.statusLevel < 2 || n <= 9) + return s; + + if (n > 9) + s.ipAddress = params[9].toString (); + if (n > 10) + s.eFuseVoltage = params[10].toFloat (); + if (n > 11) + s.eFuseBusEnabled = params[11].toInt () != 0; + if (n > 12) + s.busPowerEnabled = params[12].toInt () != 0; + if (n > 13) + s.busPowerOk = params[13].toInt () != 0; + if (n > 14) + s.switchValue = params[14].toInt (); + if (n > 15) + s.firmwareVersion = params[15].toString (); + if (n > 16) + s.hardwareVersion = params[16].toString (); + if (n > 17) + s.indicator0 = params[17].toInt () != 0; + if (n > 18) + s.indicator1 = params[18].toInt () != 0; + if (n > 19) + s.indicator2 = params[19].toInt () != 0; + if (n > 20) + s.indicator3 = params[20].toInt () != 0; + if (n > 21) + s.indicator4 = params[21].toInt () != 0; + if (n > 22) + s.indicator5 = params[22].toInt () != 0; + + return s; +} |
