Commit a2f51fa8 authored by Giacomo Strangolino's avatar Giacomo Strangolino
Browse files

added acmd.h,cpp

parent cfe3c66a
#include "acmd.h"
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QMultiMap>
#include <AlarmTreeWidget.h>
#include <quwriter.h>
Acmd::Acmd() {
}
void Acmd::ack(const QTreeWidget *tw, bool all, CumbiaPool *cup, const CuControlsFactoryPool& fpoo) {
QMultiMap<QString, QString> map = m_getDevAlarmMap(tw, all);
foreach(const QString& dev, map.uniqueKeys()) {
QuWriter *w = new QuWriter(nullptr, cup, fpoo);
const QStringList &alarms = map.values(dev);
w->setAutoDestroy(true);
w->setTarget(dev + "->Ack");
printf("AckCmd.ack: executing %s (%s)\n", qstoc(w->target()), qstoc(alarms.join(",")));
w->execute(alarms);
/* stop new */
QuWriter *stopNewWriter = new QuWriter(nullptr, cup, fpoo);
stopNewWriter->setAutoDestroy(true);
stopNewWriter->setTarget(dev + "->StopNew");
stopNewWriter->execute();
}
}
void Acmd::silence(const QTreeWidget *tw, bool all, CumbiaPool *cup, const CuControlsFactoryPool &fpoo) {
QMultiMap<QString, QString> map = m_getDevAlarmMap(tw, all);
foreach(const QString& dev, map.uniqueKeys()) {
QuWriter *w = new QuWriter(nullptr, cup, fpoo);
const QStringList &alarms = map.values(dev);
w->setAutoDestroy(true);
w->setTarget(dev + "->Silence");
printf("AckCmd.ack: executing %s (%s)\n", qstoc(w->target()), qstoc(alarms.join(",")));
w->execute(alarms);
}
}
QMultiMap<QString, QString> Acmd::m_getDevAlarmMap(const QTreeWidget *tw, bool all) const {
QMultiMap<QString, QString> map;
QList<QTreeWidgetItem *> selected;
for(int i = 0; all && i < tw->topLevelItemCount(); i++)
selected << tw->topLevelItem(i);
if(!all)
selected = tw->selectedItems();
foreach(QTreeWidgetItem *si, selected)
map.insert(si->text(AlarmTreeWidget::DEVICE), si->text(AlarmTreeWidget::ALARM));
return map;
}
#ifndef A_CMD_H
#define A_CMD_H
class QTreeWidget;
class CumbiaPool;
class CuControlsFactoryPool;
#include <QMultiMap>
class Acmd
{
public:
Acmd();
void ack(const QTreeWidget *tw, bool all, CumbiaPool *cup, const CuControlsFactoryPool &fpoo);
void silence(const QTreeWidget *tw, bool all, CumbiaPool *cup, const CuControlsFactoryPool &fpoo);
private:
QMultiMap<QString, QString> m_getDevAlarmMap(const QTreeWidget *tw, bool all) const;
};
#endif // ACKCMD_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment