Commit 9765f7c0 authored by Giacomo Strangolino's avatar Giacomo Strangolino
Browse files

added ack support

parent cc21c1ca
......@@ -26,6 +26,7 @@ RESOURCES += alarm.qrc
INCLUDEPATH += src
SOURCES += src/alarm.cpp \
src/ackcmd.cpp \
src/alarminfow.cpp \
src/main.cpp \
src/AlarmTreeWidget.cpp \
......@@ -37,6 +38,7 @@ SOURCES += src/alarm.cpp \
HEADERS += src/alarm.h \
src/AlarmTreeWidget.h \
src/AlarmTreeWidgetItem.h \
src/ackcmd.h \
src/alarminfow.h \
src/filter.h \
src/Sound.h \
......
......@@ -21,6 +21,7 @@
#include "alarm.h"
#include "filter.h"
#include "ackcmd.h"
#include "AlarmTreeWidget.h"
#include "AlarmTreeWidgetItem.h"
#include <QMessageBox>
......@@ -62,6 +63,7 @@ Alarm::Alarm(CumbiaPool *cu_p, QWidget *parent) : QWidget(parent)
// connect(qtangoComHandle(), SIGNAL(newData(const TVariant&)), this, SLOT(refresh(const TVariant&))); //qui e' dove il nuovo allarme scatena il maeccanismo
connect(ui->pBAckAll, SIGNAL(clicked()), this, SLOT(ackAll()));
connect(ui->pBStopSound, SIGNAL(clicked()), this, SLOT(stopSound()));
/* silence alarm */
connect(ui->treeWidgetAlarms, SIGNAL(silence()), this, SLOT(silence()));
......@@ -94,23 +96,20 @@ Alarm::Alarm(CumbiaPool *cu_p, QWidget *parent) : QWidget(parent)
db_dlist_w->setSource("tango://#AlarmHandler#DeviceList");
//---------------------------------------------------------------------------------------
if(args.contains("--alarm-test-devname") && args.size() > args.indexOf("--alarm-test-devname") + 1)
{
if(args.contains("--alarm-test-devname") && args.size() > args.indexOf("--alarm-test-devname") + 1) {
alarmSysTestServerName = args.at(args.indexOf("--alarm-test-devname") + 1);
// printf("\e[1;32m --alarm-test-devname specified: \"%s\"\e[0m\n", qstoc(alarmSysTestServerName));
ui->tPBTestAlarm->setTarget(alarmSysTestServerName + "/alarm_test(true)");
ui->tPBTestAlarmStop->setTarget(alarmSysTestServerName + "/alarm_test(false)");
}
else
{
else if(args.contains("--alarm-test-default-dev")) {
printf("no --alarm-test-devname specified: using ecrfpsa/alarmtest/0/alarm_test\n");
ui->tPBTestAlarm->setTarget("ecrfpsa/alarmtest/0/alarm_test(true)");
ui->tPBTestAlarmStop->setTarget("ecrfpsa/alarmtest/0/alarm_test(false)");
}
//---------------------------------------------------------------------------------------
if(args.contains("--sound-file-name") && args.size() > args.indexOf("--sound-file-name"))
{
if(args.contains("--sound-file-name") && args.size() > args.indexOf("--sound-file-name")) {
soundFileName = args.at(args.indexOf("--sound-file-name") + 1);
qDebug() <<"Sound file name: "<< soundFileName;
}
......@@ -211,45 +210,16 @@ void Alarm::stopSound() {
}
void Alarm::ack() {
QList<QTreeWidgetItem *> selItems = mGetSelectedItems();
QStringList ackedAlarms;
for(int i = 0; i < selItems.size(); i++) {
QString dev;
QTreeWidgetItem *it = selItems[i];
if(it->columnCount() > AlarmTreeWidgetItem::Alarm)
ackedAlarms.push_back(it->text(AlarmTreeWidgetItem::Alarm));
tangoStringListCommand(dev, ackedAlarms, "ack");
}
/* stop new command, just like it was in the previous version by means of TPushButton */
QuWriter *stopNewWriter = findChild<QuWriter *>("stopNewWriter");
if(!stopNewWriter) {
stopNewWriter = new QuWriter(this, cu_pool, m_ctrl_factory_pool);
stopNewWriter->setObjectName("stopNewWriter");
stopNewWriter->setTarget("$1->StopNew");
}
stopNewWriter->execute();
AckCmd acmd;
acmd.ack(ui->treeWidgetAlarms, false, cu_pool, m_ctrl_factory_pool);
}
void Alarm::ackAll()
{
QList<QTreeWidgetItem *>items;
QStringList ackedAlarms;
/* a method to gather all items is search on wildcard */
if(ui->treeWidgetAlarms->isVisible())
items = ui->treeWidgetAlarms->findItems("*", Qt::MatchWildcard);
for(int i = 0; i < items.size(); i++) {
QString dev;
QTreeWidgetItem *it = items[i];
if(it->columnCount() > AlarmTreeWidgetItem::Alarm)
ackedAlarms.push_back(it->text(AlarmTreeWidgetItem::Alarm));
tangoStringListCommand(dev, ackedAlarms, "ack");
}
void Alarm::ackAll() {
AckCmd acmd;
acmd.ack(ui->treeWidgetAlarms, true, cu_pool, m_ctrl_factory_pool);
}
void Alarm::tangoStringListCommand(const QString& device_name, const QStringList &names, const char *cmdname)
{
void Alarm::tangoStringListCommand(const QString& device_name, const QStringList &names, const char *cmdname) {
QuWriter *w = new QuWriter(this, cu_pool, m_ctrl_factory_pool);
w->setAutoDestroy(true);
w->setTarget(QString("%s->%s").arg(device_name).arg(cmdname));
......
......@@ -445,23 +445,17 @@
</spacer>
</item>
<item>
<widget class="QuButton" name="pBStopSound">
<widget class="QPushButton" name="pBStopSound">
<property name="text">
<string>Stop Beep</string>
</property>
<property name="target">
<string>$1-&gt;stopnew</string>
</property>
</widget>
</item>
<item>
<widget class="QuButton" name="pBAckAll">
<widget class="QPushButton" name="pBAckAll">
<property name="text">
<string>Acknowledge All</string>
</property>
<property name="target">
<string>$1-&gt;stopnew</string>
</property>
</widget>
</item>
<item>
......
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