73 lines
1.9 KiB
C++
Executable File
73 lines
1.9 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* Handler for ComponentStatus
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Norbert Thoden, SLSE, 2022-11-03
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "logger.h"
|
|
#include <InfrastructureManagement/ism_dtc.h>
|
|
#include <ComponentMonitor/cmo.hpp>
|
|
#include <QObject>
|
|
#include <memory>
|
|
|
|
namespace DDSConnector
|
|
{
|
|
class DdsConnector;
|
|
}
|
|
|
|
namespace ComponentMonitor
|
|
{
|
|
class DdsHandler;
|
|
|
|
// Class ComponentStatusHandler is created for publishing ComponentStatus.
|
|
|
|
class ComponentStatusHandler : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
using CONT_T = QMap<int, ComponentStatus>; // (instrumentationAsset)Id <-> ComponentStatus
|
|
using ITERATOR_T = QMap<int, ComponentStatus>::iterator;
|
|
using CONST_ITERATOR_T = QMap<int, ComponentStatus>::ConstIterator;
|
|
|
|
public:
|
|
ComponentStatusHandler();
|
|
~ComponentStatusHandler();
|
|
|
|
bool initialize(const std::shared_ptr<DdsHandler> &ddsHandler);
|
|
|
|
long statusMapSize() const { return m_statusMap.size(); }
|
|
std::vector<std::string> getHostnames() const;
|
|
|
|
public Q_SLOTS:
|
|
void onNewState(const QString &hostname, bool reachable, long long lastCheckSec);
|
|
|
|
// UpdateLastCheckTimeDirect:
|
|
void onUpdateLastCheckTimeDirect(const QStringList &hostnamesForUpdateLastCheckTime, qint64 lastCheckSec);
|
|
|
|
private Q_SLOTS:
|
|
void onInstrumentationAssetChanged(const InfrastructureManagement::InstrumentationAsset &iAsset, DataModification dataMod);
|
|
|
|
void dump();
|
|
|
|
protected:
|
|
bool addUpdateInstrumentationAsset(ITERATOR_T it, const ComponentStatus &cs);
|
|
bool removeInstrumentationAsset(ITERATOR_T it);
|
|
|
|
private:
|
|
std::shared_ptr<DdsHandler> m_ddsHandler;
|
|
|
|
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
|
|
|
CONT_T m_statusMap; // lookupTable for checkmk and publishing
|
|
|
|
NGL::INGLLogger &m_logger;
|
|
};
|
|
|
|
|
|
} // namespace ComponentMonitor
|