// qappctrl.h : // #if !defined(AGD_QAPPCTRL_H__ADD46467_F628_4A07_8844_613598E359DE__INCLUDED_) #define AGD_QAPPCTRL_H__ADD46467_F628_4A07_8844_613598E359DE__INCLUDED_ #include #include #include #include #ifdef __cplusplus ///////////////////////////////////////////////////////////////////////////// // qappctrl.h - Declarations: class QGfaAppInfo : public QObject { Q_OBJECT Q_PROPERTY(int state READ state NOTIFY stateChanged) Q_PROPERTY(QString stateText READ stateText NOTIFY stateTextChanged) Q_PROPERTY(QString name READ name NOTIFY nameChanged) Q_PROPERTY(quint64 cycCur READ cycCur NOTIFY cycCurChanged) Q_PROPERTY(quint64 cycMin READ cycMin NOTIFY cycMinChanged) Q_PROPERTY(quint64 cycMax READ cycMax NOTIFY cycMaxChanged) Q_PROPERTY(quint64 upTime READ upTime NOTIFY upTimeChanged) Q_PROPERTY(double cpuTime READ cpuTime NOTIFY cpuTimeChanged) Q_PROPERTY(double cpuCur READ cpuCur NOTIFY cpuCurChanged) Q_PROPERTY(double cpuAvg READ cpuAvg NOTIFY cpuAvgChanged) public: Q_INVOKABLE bool pause(void); Q_INVOKABLE bool resume(void); Q_INVOKABLE bool stop(void); signals: void stateChanged(int val); void stateTextChanged(const QString &val); void nameChanged(const QString &val); void sendControlMessage(appid_t nAppID, ctrlmsg_t msg); void cycCurChanged(quint64 val); void cycMinChanged(quint64 val); void cycMaxChanged(quint64 val); void upTimeChanged(quint64 val); void cpuTimeChanged(double val); void cpuCurChanged(double val); void cpuAvgChanged(double val); public: explicit QGfaAppInfo(int nIndex, QObject *pParent = NULL); virtual ~QGfaAppInfo(void); int state(void) const; bool setState(int val); QString stateText(void) const; void setStateText(int val); QString name(void) const; void setName(const QString &val); quint64 cycCur(void) const; quint64 cycMin(void) const; quint64 cycMax(void) const; quint64 upTime(void) const; double cpuTime(void) const; double cpuCur(void) const; double cpuAvg(void) const; void setAppTimes(LPCGFA_APPCTRL_APPTIMES pat, GfaIpcAppStates state, bool bDoHeavyLoadUpdate = false); private: private: int m_state; QString m_stateText; QString m_name; int m_nIndex; appid_t m_nAppID; quint64 m_cycCur; quint64 m_cycMin; quint64 m_cycMax; quint64 m_upTime; double m_cpuTime; double m_cpuPercCur; double m_cpuPercAvg; }; ///////////////////////////////////////////////////////////////////////////// class QGfaAppCtrl : public QObject { Q_OBJECT Q_PROPERTY(QQmlListProperty appInfo READ appInfo CONSTANT) Q_PROPERTY(quint64 minPass READ minPass NOTIFY minPassChanged) Q_PROPERTY(quint64 maxPass READ maxPass NOTIFY maxPassChanged) Q_PROPERTY(quint64 avgPass READ avgPass NOTIFY avgPassChanged) public: enum AppStates { STATE_NOT_RUNNING = GIAS_StateNotRunning, STATE_INITIALIZING, STATE_RUNNING, STATE_PAUSED, STATE_HANGING, STATE_TERMINATING, STATE_INVALID }; Q_ENUM(AppStates) enum AppIndex { APP_INDEX_REMANENT = GAI_Remanent, APP_INDEX_DATALOGGER = GAI_Datalogger, APP_INDEX_SUMMARIST = GAI_Summarist, APP_INDEX_REST = GAI_Rest, APP_INDEX_MQTTCL = GAI_Mqttcl }; Q_ENUM(AppIndex) signals: void minPassChanged(quint64 val); void maxPassChanged(quint64 val); void avgPassChanged(quint64 val); public: explicit QGfaAppCtrl(QObject *pParent = NULL); virtual ~QGfaAppCtrl(void); bool Create(appid_t nAppID, const char *pszDisplayName, int nTimerIntMs, clock64_t nHeavyLoadUpdateIntervalMs); void Release(void); void RegisterQmlTypes(QQmlEngine &rEng, int nVerMajor = 1, int nVerMinor = 0); bool PresetDisplayName(appid_t nAppID, const char *pszName); bool SubscribeStateEvents(appid_t nAppMask); int SetState(int nState); public: Q_INVOKABLE int appIndexFromAppID(quint64 nAppID); public: QQmlListProperty appInfo(void); quint64 minPass(void) const; quint64 maxPass(void) const; quint64 avgPass(void) const; private slots: void onSendControlMessage(appid_t nAppID, ctrlmsg_t msg); void timerEvent(QTimerEvent *event) override; private: HAPPCTRL m_hAC; appid_t m_nAppID; int m_nTimerID; QList m_appInfo; clock64_t m_curPass; clock64_t m_minPass; clock64_t m_maxPass; clock64_t m_avgPass; appid_t m_nEvtSrcs; clock64_t m_nHeavyLoadUpdateIntervalUs; struct timespec m_tsLastHeavyLoadUpdate; }; ///////////////////////////////////////////////////////////////////////////// #endif // __cplusplus #endif // !defined(AGD_QAPPCTRL_H__ADD46467_F628_4A07_8844_613598E359DE__INCLUDED_)