33 #include "systemalarms.h"
35 #include <QMainWindow>
39 SysAlarmsMessagingPlugin::SysAlarmsMessagingPlugin()
43 SysAlarmsMessagingPlugin::~SysAlarmsMessagingPlugin()
47 void SysAlarmsMessagingPlugin::extensionsInitialized()
52 dynamic_cast<SystemAlarms *
>(objManager->
getObject(QString(
"SystemAlarms")));
61 bool SysAlarmsMessagingPlugin::initialize(
const QStringList &arguments, QString *errorString)
64 Q_UNUSED(errorString);
67 SystemAlarms *obj = SystemAlarms::GetInstance(objManager);
69 for (
const auto field : obj->getFields()) {
70 for (
int i = 0;
i < field->getNumElements(); ++
i) {
71 QString element = field->getElementNames()[
i];
75 errorMessages.insert(element, msg);
78 warningMessages.insert(element, msg);
83 &SysAlarmsMessagingPlugin::onAutopilotDisconnect);
92 void SysAlarmsMessagingPlugin::updateAlarms(
UAVObject *systemAlarm)
98 const QString value = field->
getValue(
i).toString();
99 if (value == field->
getOptions().at(SystemAlarms::ALARM_ERROR)) {
100 errorMessages.value(element)->setActive(
true);
101 errorMessages.value(element)->setDescription(element +
" module is in error state");
102 warningMessages.value(element)->setActive(
false);
103 }
else if (value == field->
getOptions().at(SystemAlarms::ALARM_CRITICAL)) {
104 errorMessages.value(element)->setActive(
true);
105 errorMessages.value(element)->setDescription(element +
" module is in CRITICAL state");
106 warningMessages.value(element)->setActive(
false);
107 }
else if (value == field->
getOptions().at(SystemAlarms::ALARM_WARNING)) {
108 warningMessages.value(element)->setActive(
true);
109 warningMessages.value(element)->setDescription(element +
" module is in warning state");
110 errorMessages.value(element)->setActive(
false);
111 }
else if (value == field->
getOptions().at(SystemAlarms::ALARM_UNINITIALISED)) {
112 warningMessages.value(element)->setActive(
false);
113 errorMessages.value(element)->setActive(
false);
114 }
else if (value == field->
getOptions().at(SystemAlarms::ALARM_OK)) {
115 warningMessages.value(element)->setActive(
false);
116 errorMessages.value(element)->setActive(
false);
121 void SysAlarmsMessagingPlugin::onAutopilotDisconnect()
123 foreach (GlobalMessage *msg, errorMessages.values())
124 msg->setActive(
false);
125 foreach (GlobalMessage *msg, warningMessages.values())
126 msg->setActive(
false);
GlobalMessage * addErrorMessage(QString brief, QString description)
Core plugin system that manages the plugins, their life cycle and their registered objects...
QVariant getValue(int index=0) const
void setActive(bool value)
int getNumElements() const
virtual GlobalMessaging * globalMessaging() const =0
void objectUpdated(UAVObject *obj)
Signal sent whenever any field of the object is updated.
QStringList getOptions() const
static ICore * instance()
UAVObjectField * getField(const QString &name)
QStringList getElementNames() const
GlobalMessage * addWarningMessage(QString brief, QString description)
UAVObject * getObject(const QString &name, quint32 instId=0)