#ifndef ISMASDATA_H #define ISMASDATA_H #include #include #include namespace ISMAS { static QString computeTimeStamp() { QDateTime const local(QDateTime::currentDateTime()); QDateTime utc(local); utc.setTimeSpec(Qt::UTC); int const diff = (int)local.secsTo(utc); // diff between UTC and local time QTime t(0, 0, 0); t = t.addSecs((uint)diff); QString const st(QString("%1%2").arg(diff < 0 ? "-" : "+").arg(t.toString("hh:mm"))); return QString (local.toString(Qt::ISODateWithMs) + st); } // // Note: // ! After U0002 immer ein CMD_SENDVERSION // ! Only U0002 and U0003 finish the Update process. // ! U0001: Update finished but not activated // ! U0002: Update finished and activated // ! U0003: Update finished but FAILed. // // #define _ISMAS_DONE "U0001" // 100%, Check: Resultcode: 0 // #define _ISMAS_SET_WAIT_OK "U0002" // empty WAIT-button (""), ResultCode: 0 // #define _ISMAS_NO_UPDATE_NECESSARY "M0100" // empty WAIT-button (""), ResultCode: 0 // #define _ISMAS_FAILURE "U0003" // FAIL // #define _ISMAS_CONTINUE "U0010" // %-values: update running, result codes according running step // #define _ISMAS_RESET_WAIT "ISMAS" // reset WAIT-button to "WAIT" // #define _ISMAS_TEST_TRIGGER "U0099" // check the WAIT-button static constexpr const char *DONE {"U0001"}; static constexpr const char *SET_WAIT_OK {"U0002"}; static constexpr const char *NO_UPDATE_NECESSARY{"M0100"}; static constexpr const char *FAILURE {"U0003"}; static constexpr const char *CONTINUE {"U0010"}; static constexpr const char *RESET_WAIT {"ISMAS"}; static constexpr const char *TEST_TRIGGER {"U0099"}; struct EventData : public QJsonObject { struct : public QJsonObject { QJsonValue reason; QJsonValue timestamp; QJsonValue eventID; QJsonValue event; QJsonValue eventState; struct : public QJsonObject { QJsonValue percent; QJsonValue resultCode; QJsonValue step; QJsonValue stepResult; QJsonValue version; } parameter; } newsToIsmas; explicit EventData(QString const &event, int percent, int resultCode, QString const &step, QString const &stepResult, QString const &version = "", QString const &reason = "SW_UP") { newsToIsmas.reason = reason; newsToIsmas.timestamp = computeTimeStamp(); newsToIsmas.eventID = QString{"0"}; newsToIsmas.event = event; newsToIsmas.eventState = 1; newsToIsmas.parameter.percent = percent; newsToIsmas.parameter.resultCode = resultCode; newsToIsmas.parameter.step = step; newsToIsmas.parameter.stepResult = stepResult; newsToIsmas.parameter.version = version; } }; struct StateData : public QJsonObject { QJsonValue Timestamp; QJsonArray HW_States; struct : public QJsonObject { QJsonValue name; QJsonValue value; QJsonValue unit; } machineState; // }; enum class REQUEST : quint8 { NO_REQUEST, PING, SELF, PARAMETER }; } #endif // ISMASDATA_H