Commit 0480892d authored by Giacomo Strangolino's avatar Giacomo Strangolino
Browse files

- implemented getalarminfo -- after cumbia http reader factory fix

parent 9bcec5d1
......@@ -27,7 +27,7 @@ AlarmTreeWidget::AlarmTreeWidget(QWidget *parent) : QTreeWidget(parent)
setRootIsDecorated(false);
setAutoScroll(true);
setSelectionMode(QAbstractItemView::ExtendedSelection);
setHeaderLabels(QStringList() << "Date/time" << "microsecs" << "Alarm" << "Status" << "Ack" << "Count" << "Level" << "Silenced min." << "Group" << "Message");
setHeaderLabels(QStringList() << "Date/time" << "microsecs" << "Alarm" << "Status" << "Ack" << "Count" << "Level" << "Silenced min." << "Device" << "Message");
// setSortingEnabled(true);
#if QT_VERSION > 0x050000
header()->setSectionResizeMode( QHeaderView::ResizeToContents);
......@@ -111,7 +111,7 @@ void AlarmTreeWidget::applyFilter(AlarmFilter f)
{
for(int j = 0; j < f.groups.size(); j++)
{
if(!items[i]->text(GROUP).contains(f.groups[j]))
if(!items[i]->text(DEVICE).contains(f.groups[j]))
{
items[i]->setHidden(true);
break;
......@@ -119,10 +119,10 @@ void AlarmTreeWidget::applyFilter(AlarmFilter f)
}
}
}
headerItem()->setIcon(GROUP, QIcon(ICON_PATH + "filter.png"));
headerItem()->setIcon(DEVICE, QIcon(ICON_PATH + "filter.png"));
}
else
headerItem()->setIcon(GROUP, QIcon(ICON_PATH + ""));
headerItem()->setIcon(DEVICE, QIcon(ICON_PATH + ""));
_filter_enabled = true;
......@@ -140,22 +140,20 @@ void AlarmTreeWidget::removeFilter()
headerItem()->setIcon(ACK, QIcon(ICON_PATH + ""));
headerItem()->setIcon(LEVEL, QIcon(ICON_PATH + ""));
headerItem()->setIcon(STATUS, QIcon(ICON_PATH + ""));
headerItem()->setIcon(GROUP, QIcon(ICON_PATH + ""));
headerItem()->setIcon(DEVICE, QIcon(ICON_PATH + ""));
}
void AlarmTreeWidget::refresh(const CuData &v)
{
printf("Alarm.refresh: from \e[1;34m%s\e[0m\n", vtoc2(v, "src"));
void AlarmTreeWidget::refresh(const CuData &v) {
double d = static_cast<int>(v["timestamp_us"].toDouble());
QString ts = QDateTime::fromSecsSinceEpoch(d).toString("HH:mm:ss");
ts += QString("+%1").arg(d - static_cast<int>(d));
const QuString src(v, "src");
bool err = v["err"].toBool();
//QAbstractItemModel *model = ui->treeWidgetAlarms->model();
/* remove the filter */
if (err)
{
if (err) {
setDisabled(true);
}
else
{
else {
setDisabled(false);
int scrollBarPos;
QStringList fields;
......@@ -178,11 +176,8 @@ void AlarmTreeWidget::refresh(const CuData &v)
else
unknown_level << row;
}
data = unknown_level + lowest + low + medium + high;
int index = 0;
const QSet<QString> oldset = mSrcAlarmHash.value(src);
QSet<QString>& alsrcset = mSrcAlarmHash[src];
......@@ -193,12 +188,16 @@ void AlarmTreeWidget::refresh(const CuData &v)
alrnames << fields.at(AlarmTreeWidgetItem::Alarm);
/* save current scroll bar value */
scrollBarPos = verticalScrollBar()->value();
/* instead of GROUP information, show DEVICE */
fields[DEVICE] = src;
item = mItemHash.value(fields.at(AlarmTreeWidgetItem::Alarm));
if(!item) /* create a new item */ {
index = findPos(fields[0].toUInt(), fields[AlarmTreeWidgetItem::Level]);
m_insert_item(fields, index);
printf("\e[1;34m%s - number of tabs %d -- index %d\e[0m\n", qstoc(data[i]), data[i].count("\t"), index);
index = findPos(fields[0].toUInt(), fields[AlarmTreeWidgetItem::Level], fields[AlarmTreeWidgetItem::Status]);
m_insert_item(src, fields, index);
// printf("\e[1;33m%s \e[1;34m%s - number of tabs %d -- index %d\e[0m\n",
// qstoc(QDateTime::fromTime_t(fields.first().toUInt()).toString()),
// qstoc(data[i]), data[i].count("\t"), index);
}
else /* update fields of existing items */
item->update(fields);
......@@ -221,17 +220,28 @@ void AlarmTreeWidget::refresh(const CuData &v)
}
int AlarmTreeWidget::findPos(time_t ts, const QString &pri) {
int i = 0, prio = m_pri_to_int(pri);
while(i < topLevelItemCount() && topLevelItem(i)->data(AlarmTreeWidgetItem::Level, Qt::UserRole).toInt() > prio)
int AlarmTreeWidget::findPos(time_t ts, const QString &pri, const QString& status) {
int i = 0, prio = m_pri_to_int(pri), stat = m_status_to_int(status);
// printf("findPos called with ts %ld, pri %d\n", ts, prio);
while(i < topLevelItemCount() && topLevelItem(i)->data(AlarmTreeWidgetItem::Status, Qt::UserRole).toInt() > stat) {
// printf("1st pri %d pri %d --> i %d\n", prio, topLevelItem(i)->data(AlarmTreeWidgetItem::Level, Qt::UserRole).toInt(), i);
i++;
}
while(i < topLevelItemCount() && topLevelItem(i)->data(AlarmTreeWidgetItem::Level, Qt::UserRole).toInt() > prio
&& topLevelItem(i)->data(AlarmTreeWidgetItem::Status, Qt::UserRole).toInt() == stat) {
// printf("1st pri %d pri %d --> i %d\n", prio, topLevelItem(i)->data(AlarmTreeWidgetItem::Level, Qt::UserRole).toInt(), i);
i++;
}
// i points to the first item with same pri or to the very last item in the view
while(i < topLevelItemCount() && topLevelItem(i)->data(AlarmTreeWidgetItem::DateTime, Qt::UserRole).toUInt() > ts
&& topLevelItem(i)->data(AlarmTreeWidgetItem::Level, Qt::UserRole).toInt() == prio) {
&& topLevelItem(i)->data(AlarmTreeWidgetItem::Level, Qt::UserRole).toInt() == prio
&& topLevelItem(i)->data(AlarmTreeWidgetItem::Status, Qt::UserRole).toInt() == stat) {
// printf("1st ts %u item ts %u --> i %d\n", ts, topLevelItem(i)->data(AlarmTreeWidgetItem::DateTime, Qt::UserRole).toUInt(), i);
i++;
}
return i ;
return i;
}
void AlarmTreeWidget::contextMenuEvent(QContextMenuEvent *e)
......@@ -264,7 +274,7 @@ void AlarmTreeWidget::contextMenuEvent(QContextMenuEvent *e)
}
}
void AlarmTreeWidget::m_insert_item(const QStringList &list, int index)
void AlarmTreeWidget::m_insert_item(const QString& src, const QStringList &list, int index)
{
qDebug() << __PRETTY_FUNCTION__ << "inserting " << list << index;
AlarmTreeWidgetItem *item;
......@@ -280,11 +290,13 @@ void AlarmTreeWidget::m_insert_item(const QStringList &list, int index)
if(fields.last().toUpper() == "NEW"){
isNew = true;
}
fields.removeLast(); /* the last element contains info about "NEW", than must not be displayed */
// printf("\e[1;32m ADDING NEW AlarmTreeWidgetitem to index %d\e[0m\n", index);
fields.removeLast(); /* the last element contains "NEW" flag, need not be displayed */
item = new AlarmTreeWidgetItem(fields);
item->setData(AlarmTreeWidgetItem::Level, m_pri_to_int(fields[AlarmTreeWidgetItem::Level]), Qt::UserRole);
item->setData(AlarmTreeWidgetItem::DateTime, list.at(AlarmTreeWidgetItem::DateTime).toUInt(), Qt::UserRole);
item->setData(AlarmTreeWidgetItem::Level, Qt::UserRole, m_pri_to_int(list[AlarmTreeWidgetItem::Level]));
item->setData(AlarmTreeWidgetItem::DateTime, Qt::UserRole, list.at(AlarmTreeWidgetItem::DateTime).toUInt());
item->setData(AlarmTreeWidgetItem::Status, Qt::UserRole, m_status_to_int(list.at(AlarmTreeWidgetItem::Status)));
QString s = src.section('/', 0, src.count('/') - 1);
item->setData(AlarmTreeWidgetItem::Device, Qt::UserRole, src.section('/', 0, src.count('/') - 1));
insertTopLevelItem(index, item);
item->setNew(isNew);
}
......@@ -310,6 +322,12 @@ int AlarmTreeWidget::m_pri_to_int(const QString &pri) const {
else return 10;
}
int AlarmTreeWidget::m_status_to_int(const QString &stat) {
if(stat == "ALARM")
return 100;
return 50;
}
void AlarmTreeWidget::mouseMoveEvent(QMouseEvent *event)
{
QTreeWidget::mouseMoveEvent(event);
......
......@@ -15,51 +15,46 @@ class AlarmTreeWidget : public QTreeWidget
{
Q_OBJECT
public:
enum Type {AlarmType, InternalErrorTyp };
enum columns { DATET, MICROSEC, ALARM, STATUS, ACK, COUNT, LEVEL, SILENCED, DEVICE, MESSAGE };
AlarmTreeWidget(QWidget *parent);
void applyFilter(AlarmFilter f);
//void cloneTreeWidget(QTreeWidget* other);
void setType(Type t);
void removeFilter();
enum columns { DATET, MICROSEC, ALARM, STATUS, ACK, COUNT, LEVEL, SILENCED, GROUP, MESSAGE };
int findPos(time_t ts, const QString& pri);
int findPos(time_t ts, const QString& pri, const QString &status);
public slots:
void refresh(const CuData &v);
protected slots:
void slotItemEntered(QTreeWidgetItem*,int);
void openUrl();
signals:
void newAlarmDetected();
void message(const QString& msg);
void mouseOverItem(bool);
void silence();
void ack();
protected:
void showEvent(QShowEvent *e);
void mouseMoveEvent(QMouseEvent *event);
void contextMenuEvent(QContextMenuEvent *);
private:
int m_pri_to_int(const QString& pri) const;
int m_status_to_int(const QString& stat);
void m_remove_stale_items(const QSet<QString> stale_names);
void m_insert_item(const QStringList &list, int index);
void m_insert_item(const QString &src, const QStringList &list, int index);
bool _filter_enabled;
QHash<QString, AlarmTreeWidgetItem*> mItemHash;
QHash<QString, QSet<QString> >mSrcAlarmHash;
Type m_type;
};
......
......@@ -11,7 +11,7 @@ class AlarmTreeWidgetItem : public QTreeWidgetItem
public:
enum Columns { DateTime, muSecs, Alarm, Status, Ack, Count, Level,
SilencedMin, Group, Message };
SilencedMin, Device, Message };
AlarmTreeWidgetItem(QTreeWidget *parent, QStringList &strings);
AlarmTreeWidgetItem(QStringList &strings);
......
......@@ -15,4 +15,6 @@
/Sound.h/1.9/Wed Mar 20 09:34:55 2019//
/Sound.cpp/1.13/Mon Mar 25 09:53:10 2019//
/AlarmTreeWidget.cpp/1.16/Thu Sep 19 06:58:54 2019//
/alarminfow.h/0/dummy timestamp//
/alarminfow.cpp/0/dummy timestamp//
D
......@@ -42,6 +42,7 @@
#include <quwatcher.h>
#include <qustring.h>
#include <qustringlist.h>
#include <QTimer>
// cumbia
Alarm::Alarm(CumbiaPool *cu_p, QWidget *parent) : QWidget(parent)
......@@ -57,22 +58,6 @@ Alarm::Alarm(CumbiaPool *cu_p, QWidget *parent) : QWidget(parent)
QString soundFileName, alarmSysTestServerName;
QStringList args = qApp->arguments();
std::string s_instanceName;
if(args.size() <= 1)
{
QString s;
s += "error: tango device name requested as first argument\n";
s += "example: " + args[0] + "alarms/test/1\n";
s += "Correct TANGO_HOST environment variable has to be set too.\n";
s += "If you want to enable sounds specify the tango sound device server like this:\n";
s += "--sound-server-name $HOSTNAME/audio/card0\n";
s += "To set style: style=fermi or style=booster\n";
s += "To test alarms: --alarm-test-devname test/alarmtest/0 (or whatever device)\n";
s += "Log database host: --log-database-host srv-log-srf (or whatever db host)\n";
QMessageBox::information(this, "Usage", s);
exit(EXIT_FAILURE);
}
device_name = args[1];
// connect(qtangoComHandle(), SIGNAL(newData(const TVariant&)), this, SLOT(refresh(const TVariant&))); //qui e' dove il nuovo allarme scatena il maeccanismo
......@@ -107,25 +92,14 @@ Alarm::Alarm(CumbiaPool *cu_p, QWidget *parent) : QWidget(parent)
ui->tWGroup->header()->setHidden(true);
ui->pBConfHistory->setHidden(true);
// data from Tango DB
// ////////////////////////////////////////////////////////////
QuWatcher *db_gn_w = new QuWatcher(this, cu_pool, m_ctrl_factory_pool); // device prop watcher
db_gn_w->setSingleShot(true);
db_gn_w->setAutoDestroy(true);
connect(db_gn_w, SIGNAL(newData(CuData)), this, SLOT(onDevProps(CuData)));
db_gn_w->setSource(QString("%1(GroupNames,InstanceName)").arg(qApp->arguments().at(1)));
// // device list from Tango DB free prop
QuWatcher *db_dlist_w = new QuWatcher(this, cu_pool, m_ctrl_factory_pool); // device prop watcher
db_dlist_w->setObjectName("free_prop_w");
db_dlist_w->setSingleShot(true);
db_dlist_w->setAutoDestroy(true);
connect(db_dlist_w, SIGNAL(newData(CuData)), this, SLOT(onDevList(CuData)));
db_dlist_w->setSource("tango://#AlarmHandler#DeviceList");
// ////////////////////////////////////////////////////////////
//
//---------------------------------------------------------------------------------------
if(args.contains("--alarm-test-devname") && args.size() > args.indexOf("--alarm-test-devname") + 1)
{
......@@ -152,14 +126,7 @@ Alarm::Alarm(CumbiaPool *cu_p, QWidget *parent) : QWidget(parent)
sound = new Sound(soundFileName);
connect( ui->pBTestSoundOn,SIGNAL(clicked()), sound, SLOT(play()));
connect( ui->pBTestSoundOff,SIGNAL(clicked()), sound, SLOT(stop()));
/* connections for History */
connect(ui->pBApplyHistory, SIGNAL(clicked()), this, SLOT(queryDB()));
ui->dateStart->setDate(QDate::currentDate());
ui->dateStop->setDate(QDate::currentDate());
ui->timeStart->setTime(QTime::currentTime());
ui->timeStop->setTime(QTime::currentTime());
ui->groupBoxFilter->setHidden(true);
connect(ui->comboPeriod, SIGNAL(currentIndexChanged(int)), this, SLOT(enableFrameHistoryInterval(int)));
connect(ui->pBFilter, SIGNAL(toggled(bool)), ui->groupBoxFilter, SLOT(setVisible(bool)));
/* connections for filter group box */
......@@ -168,6 +135,10 @@ Alarm::Alarm(CumbiaPool *cu_p, QWidget *parent) : QWidget(parent)
connect(ui->cBLevel, SIGNAL(toggled(bool)), ui->comboLog, SLOT(setEnabled(bool)));
connect(ui->cBStatus, SIGNAL(toggled(bool)), ui->comboStatus, SLOT(setEnabled(bool)));
connect(ui->cBGroup, SIGNAL(toggled(bool)), ui->tWGroup, SLOT(setEnabled(bool)));
ui->pbInfo->setEnabled(false);
ui->liViewInfo->setVisible(false);
connect(ui->pbInfo, SIGNAL(toggled(bool)), this, SLOT(onInfoListViewVisibilityChange(bool)));
connect(ui->treeWidgetAlarms, SIGNAL(itemSelectionChanged()), this, SLOT(onItemSelectionChange()));
/* connections for test section */
//connect(ui->pBTestSoundOn, SIGNAL(clicked()), this, SLOT(testSound()));
//connect(ui->pBTestSoundOff, SIGNAL(clicked()), this, SLOT(stopSound()));
......@@ -189,24 +160,6 @@ void Alarm::refresh(const CuData &da) {
applyFilter();
}
void Alarm::onDevProps(const CuData &da)
{
if(da["err"].toBool()) {
perr("Alarm.onDevProps: error fetching database properties specified in src %s", vtoc2(da, "src"));
}
else {
if(da.containsKey("GroupNames")) {
const std::vector<std::string> &gnames = da["GroupNames"].toStringVector();
QStringList statesList;
for(unsigned long i = 0; i < gnames.size(); i++)
statesList << QString::fromStdString(gnames[i]).remove("gr_");
statesList << "all";
}
if(da.containsKey("InstanceName"))
instance_name = QuString(da, "InstanceName");
}
}
void Alarm::onDevList(const CuData &da) {
if(da["err"].toBool()) {
perr("Alarm.onDevList: error fetching device list from database: src: \"%s\" msg: \"%s\"", vtoc2(da, "src"), vtoc2(da, "msg"));
......@@ -217,8 +170,7 @@ void Alarm::onDevList(const CuData &da) {
}
}
void Alarm::m_connect_devs(const QStringList &devs)
{
void Alarm::m_connect_devs(const QStringList &devs) {
foreach(const QString dev, devs) {
QuWatcher *alrw = new QuWatcher(this, cu_pool, m_ctrl_factory_pool);
alrw->setObjectName(dev + "/alarm" + "+watcher");
......@@ -241,20 +193,12 @@ QList<QTreeWidgetItem *> Alarm::mGetSelectedItems()
void Alarm::silence()
{
QList<QTreeWidgetItem *> selItems = mGetSelectedItems();
QStringList toSilenceAlarms;
if(selItems.size() == 0)
QMessageBox::information(this, "Information", "Select one or more items with the\n"
"mouse and then click again.\nMultiple selections are possible: just\n"
"hold the control key while selecting the items with the mouse.");
else
{
for(int i = 0; i < selItems.size(); i++)
{
QTreeWidgetItem *it = selItems[i];
if(it->columnCount() > AlarmTreeWidgetItem::Alarm)
toSilenceAlarms.push_back(it->text(AlarmTreeWidgetItem::Alarm));
}
tangoStringListCommand(toSilenceAlarms, "Silence");
QStringList toSilenceAlarms;for(int i = 0; i < selItems.size(); i++) {
QString dev;
QTreeWidgetItem *it = selItems[i];
if(it->columnCount() > AlarmTreeWidgetItem::Alarm)
toSilenceAlarms.push_back(it->text(AlarmTreeWidgetItem::Alarm));
tangoStringListCommand(dev, toSilenceAlarms, "Silence");
}
}
......@@ -267,6 +211,11 @@ void Alarm::beep() {
sound->play();
}
void Alarm::onTestW(const CuData &d)
{
printf("Alarm.onTestW: data %s %s\n", vtoc2(d, "src"), vtoc2(d, "value"));
}
void Alarm::stopSound() {
sound->stop();
}
......@@ -274,24 +223,18 @@ void Alarm::stopSound() {
void Alarm::ack() {
QList<QTreeWidgetItem *> selItems = mGetSelectedItems();
QStringList ackedAlarms;
if(selItems.size() == 0)
QMessageBox::information(this, "Information", "Select one or more items with the\n"
"mouse and then click again.\nMultiple selections are possible: just\n"
"hold the control key while selecting the items with the mouse.");
else
{
for(int i = 0; i < selItems.size(); i++)
{
QTreeWidgetItem *it = selItems[i];
if(it->columnCount() > AlarmTreeWidgetItem::Alarm)
ackedAlarms.push_back(it->text(AlarmTreeWidgetItem::Alarm));
}
tangoStringListCommand(ackedAlarms, "ack");
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)
{
if(!stopNewWriter) {
stopNewWriter = new QuWriter(this, cu_pool, m_ctrl_factory_pool);
stopNewWriter->setObjectName("stopNewWriter");
stopNewWriter->setTarget("$1->StopNew");
......@@ -308,23 +251,16 @@ void Alarm::ackAll()
items = ui->treeWidgetAlarms->findItems("*", Qt::MatchWildcard);
else
items = ui->treeWidgetInternalErrors->findItems("*", Qt::MatchWildcard);
if(items.size() > 0)
{
for(int i = 0; i < items.size(); i++)
{
QTreeWidgetItem *it = items[i];
if(it->columnCount() > AlarmTreeWidgetItem::Alarm)
ackedAlarms.push_back(it->text(AlarmTreeWidgetItem::Alarm));
}
tangoStringListCommand(ackedAlarms, "ack");
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");
}
else
QMessageBox::information(this, "Information", "No items are present on the list.\n"
"There must be at least one item in the window to be\n"
"able to remove it.");
}
void Alarm::tangoStringListCommand(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);
......@@ -357,98 +293,39 @@ void Alarm::applyFilter()
filter.groups << groups[i]->text(0);
}
ui->treeWidgetAlarms->applyFilter(filter);
ui->tWHistory->applyFilter(filter);
filtering = true;
ui->pBClearFilter->setDisabled(false);
}
void Alarm::clearFilter()
{
void Alarm::clearFilter() {
ui->treeWidgetAlarms->removeFilter();
ui->tWHistory->removeFilter();
ui->pBClearFilter->setDisabled(true);
ui->cBDynamic->setChecked(false);
filtering = false;
}
void Alarm::queryDB()
{
unsigned int startSearch;
QDateTime now = QDateTime::currentDateTime();
QString query;
QDateTime dts, dte;
switch(ui->comboPeriod->currentIndex())
{
case 0:
startSearch = now.addDays(-1).toTime_t();
query = QString("SELECT alarms.time_sec, alarms.time_usec, alarms.status, alarms.ack, description.name, description.level, "
"description.grp, description.msg FROM "
"alarms,description WHERE alarms.id_description=description.id_description AND description.instance='%1' AND alarms.time_sec > %2 "
"ORDER BY alarms.time_sec DESC").arg(instance_name).arg(startSearch);
break;
case 1:
startSearch = now.addDays(-7).toTime_t();
query = QString("SELECT alarms.time_sec, alarms.time_usec, alarms.status, alarms.ack, description.name, description.level, "
"description.grp, description.msg FROM "
"alarms,description WHERE alarms.id_description=description.id_description AND description.instance='%1' AND alarms.time_sec > %2 "
"ORDER BY alarms.time_sec DESC").arg(instance_name).arg(startSearch);
break;
case 2:
startSearch = now.addMonths(-1).toTime_t();
query = QString("SELECT alarms.time_sec, alarms.time_usec, alarms.status, alarms.ack, description.name, description.level, "
"description.grp, description.msg FROM "
"alarms,description WHERE alarms.id_description=description.id_description AND description.instance='%1' AND alarms.time_sec > %2 "
"ORDER BY alarms.time_sec DESC").arg(instance_name).arg(startSearch);
break;
case 3:
dts.setDate(ui->dateStart->date());
dts.setTime(ui->timeStart->time());
dte.setDate(ui->dateStop->date());
dte.setTime(ui->timeStop->time());
query = QString("SELECT alarms.time_sec, alarms.time_usec, alarms.status, alarms.ack, description.name, description.level, "
"description.grp, description.msg FROM "
"alarms,description WHERE alarms.id_description=description.id_description AND description.instance='%1' AND alarms.time_sec > %2 AND alarms.time_sec < %3 "
"ORDER BY alarms.time_sec DESC").arg(instance_name).arg(dts.toTime_t()).arg(dte.toTime_t());
break;
case 4:
query = QString("SELECT alarms.time_sec, alarms.time_usec, alarms.status, alarms.ack, description.name, description.level, "
"description.grp, description.msg FROM "
"alarms,description WHERE alarms.id_description=description.id_description AND description.instance='%1' "
"ORDER BY alarms.time_sec DESC").arg(instance_name);
break;
default:
break;
}
ui->tWHistory->executeQuery(query);
if(ui->cBDynamic->isChecked())
{
applyFilter();
}
}
void Alarm::enableFrameHistoryInterval(int i)
{
if(i == 3)
ui->widgetHystoryConf->setEnabled(true);
void Alarm::onInfoListViewVisibilityChange(bool vis) {
if(!vis)
ui->liViewInfo->activate("", "");
else
ui->widgetHystoryConf->setEnabled(false);
ui->treeWidgetAlarms->selectedItems().size() == 1 ?
ui->liViewInfo->activate(ui->treeWidgetAlarms->selectedItems().first()->data(AlarmTreeWidgetItem::Device, Qt::UserRole).toString(),
ui->treeWidgetAlarms->selectedItems().first()->text(AlarmTreeWidgetItem::Alarm))
: ui->liViewInfo->activate("", "");
}
void Alarm::raiseFromDbus()
{
hide();
raise();
show();
void Alarm::onItemSelectionChange() {
QList<QTreeWidgetItem *> sits = ui->treeWidgetAlarms->selectedItems();
QTreeWidgetItem *it = nullptr;
if(sits.size() == 1)
it = sits.first();
ui->pbInfo->setEnabled(it != nullptr);
if(ui->liViewInfo->isVisible() && it)
ui->liViewInfo->activate(it->data(AlarmTreeWidgetItem::Device, Qt::UserRole).toString(), it->text(AlarmTreeWidgetItem::Alarm));
}
void Alarm::tabChanged(int t)
{
if(t == 3)
{
void Alarm::tabChanged(int t) {
if(t == 2) {
ui->pBAckAll->setHidden(true);
ui->pBConfHistory->setHidden(false);
ui->pBConfHistory->setChecked(true);
......@@ -457,22 +334,13 @@ void Alarm::tabChanged(int t)
ui->pBConfHistory->setHidden(true);
ui->pBStopSound->setHidden(true);
}
else if(t == 0 || t == 1)
{
else if(t == 0 || t == 1) {
ui->pBStopSound->setHidden(false);
ui->pBAckAll->setHidden(false);
ui->pBConfHistory->setHidden(true);
ui->groupBoxFilter->setDisabled(false);
ui->pBFilter->setHidden(false);
}
else if(t == 2)
{
ui->pBFilter->setHidden(false);
ui->pBStopSound->setHidden(true);
ui->pBAckAll->setHidden(true);
ui->pBConfHistory->setHidden(true);
ui->groupBoxFilter->setDisabled(false);
}
}
void Alarm::closeEvent(QCloseEvent *e)
......
......@@ -55,7 +55,6 @@ public slots:
protected slots:
void refresh(const CuData &da);
void onDevProps(const CuData& da);
void onDevList(const CuData& da);