Skip to content
Snippets Groups Projects
Commit c321d514 authored by Claudio Scafuri's avatar Claudio Scafuri :speech_balloon:
Browse files

imported from CVS repo fermi/panels/interlock/general release_11

parent 3400329b
No related branches found
No related tags found
No related merge requests found
.pydevproject
.project
.cproject
.settings
Makefile
moc
obj
bin
objects
core*
*~
*.pyc
*.so
*.so*
.pylintrc
.metadata
.idea
.cvsignore
.nse_depinfo
software
oldsrc
ui_*
qrc*.cpp
.qmake.stash
CVS
release_10: porting to QT5 (from phonon to Qt Multimedia)
release_09: Fixed sorting problem on the tree widgets. Added missing modulators to the combo box.
release_08: Fixed scroll issue on updates in TTreeWidget
Ported to QTango5
release_07: added Test Sound button
release_06: Ticket 975: General Interlock: sounds and important/blocking alarm
Added sound support.
Tabs with recent alarms are evidentiated by an alarm bell icon.
Recent alarms are bold.
release_04: Ticket 774 ferminterlock: manca history per "PS and Vacuum"
Added search box on each tab. Text based search.
Queries have been modified.
See http://acswww.elettra.trieste.it/bugzilla/show_bug.cgi?id=774
release_05: ticket 983:
srv-tango-srf/interlock/plc_mod_ll --> f/interlock/plc_mod_ll
srv-tango-srf/interlock/plc_int_ll.01 --> f/interlock/plc_int_ll.01
srv-tango-srf/interlock/plc_int_ll.02 --> f/interlock/plc_int_l
database: su srv-log-srf --> srv-db-srf
README 0 → 100644
ferminterlock
USAGE:
ferminterlock f/interlock/plc_mod_ll f/interlock/plc_int_ll.01 f/interlock/plc_int_ll.02 srv-padres-srf:20000/srv-padres-srf/interlock/plc_int_ll.03 --sound-file-name /runtime/share/sounds/generalintlkpanel_beep.ogg
Contacts:
giacomo.strangolino@elettra....
graziano.scalamera@elettra...
# ferminterlock
pannello fermi interlock
# usage
ferminterlock f/interlock/plc_mod_ll f/interlock/plc_int_ll.01 f/interlock/plc_int_ll.02 srv-padres-srf:20000/srv-padres-srf/interlock/plc_int_ll.03 --sound-file-name /runtime/share/sounds/generalintlkpanel_beep.ogg
# contatcts
giacomo.strangolino@elettra....
graziano.scalamera@elettra...
include(/usr/local/qtango/include/qtango6/qtango.pri)
CONFIG += debug
QT += sql
QT += multimedia
DEFINES -= QT_NO_DEBUG_OUTPUT
RESOURCES += general.qrc
# DEFINES -= QT_NO_DEBUG_OUTPUT
SOURCES += src/tlabelitem.cpp \
src/ttreewidget.cpp \
src/ttablewidget.cpp \
src/interlock.cpp \
src/main.cpp \
src/queryconfiguration.cpp \
src/mysqlmodel.cpp \
src/ttreeview.cpp \
src/Sound.cpp \
src/tabwidget.cpp \
src/treeitem.cpp
HEADERS += src/tlabelitem.h \
src/ttreewidget.h \
src/ttablewidget.h \
src/interlock.h \
src/queryconfiguration.h \
src/mysqlmodel.h \
src/ttreeview.h \
src/Sound.h \
src/tabwidget.h \
src/treeitem.h
FORMS = src/interlock.ui src/queryconfiguration.ui
TARGET = bin/ferminterlock-gui
sounds.files = sounds/generalintlkpanel_beep.ogg
sounds.path = $${INSTALL_ROOT}/share/sounds
INSTALLS += sounds
OTHER_FILES += \
properties.txt
QMAKE_POST_LINK = $(STRIP) $(TARGET)
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>icons/alarm.png</file>
</qresource>
</RCC>
icons/alarm.png

1.84 KiB

File added
File added
#include "Sound.h"
#include <QString>
#include <QSound>
#include <QtDebug>
#include <macros.h>
Sound::Sound(const QString& sound_file)
{
m_init(sound_file);
}
Sound::Sound(QObject *parent, const QString &sound_file) : QObject(parent)
{
m_init(sound_file);
}
void Sound::m_init(const QString& sound_file)
{
mSoundEffect.setSource(QUrl::fromLocalFile(sound_file));
set_loop_delay(500);
m_loop_timer.setSingleShot(true);
m_loop_enabled = false;
connect(&mSoundEffect, SIGNAL(playingChanged()), this, SLOT(playingChanged()));
connect(&m_loop_timer, SIGNAL(timeout()), &mSoundEffect, SLOT(play()));
}
void Sound::play()
{
if (m_loop_enabled) return;
mSoundEffect.play();
}
void Sound::loop()
{
if(!m_loop_enabled){
m_loop_enabled = true;
mSoundEffect.play();
}
}
void Sound::playingChanged()
{
if(m_loop_enabled && !mSoundEffect.isPlaying())
m_loop_timer.start();
}
void Sound::stop()
{
m_loop_enabled = false;
m_loop_timer.stop();
mSoundEffect.stop();
}
void Sound::set_loop_delay(int delay)
{
m_loop_timer.setInterval(delay);
}
int Sound::get_loop_delay()
{
return m_loop_timer.interval();
}
void Sound::timer_timeout() {
mSoundEffect.play();
}
#ifndef SOUND_H
#define SOUND_H
#include <QString>
#include <QObject>
#include <QTimer>
#include <QSoundEffect>
#include <QFile>
class Sound:public QObject
{
Q_OBJECT
public:
Sound(const QString& sound_file);
Sound(QObject *parent, const QString& sound_file);
void set_loop_delay(int);
int get_loop_delay();
public slots:
void play();
void stop();
void loop();
private slots:
void playingChanged();
void timer_timeout();
private:
bool m_loop_enabled;
QTimer m_loop_timer;
QSoundEffect mSoundEffect;
void m_init(const QString &sound_file);
};
#endif
/***************************************************************************
* Copyright (C) 2007 by Vincenzo Forchi`,,, *
* vincenzo.forchi@elettra.trieste.it *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "interlock.h"
#include "Sound.h"
#include <qtango.h>
#include <device_factory.h>
#include <QtSql>
#include <QScrollBar>
#include "mysqlmodel.h"
#include <TLog>
#include <QMessageBox>
#include <elettracolors.h>
Interlock::Interlock(QWidget *parent) : QWidget(parent)
{
QStringList args = qApp->arguments();
if(args.size() < 5)
{
QMessageBox::information(this, "Usage",
QString("%1 f/interlock/plc_mod_ll f/interlock/plc_int_ll.01"
"\nf/interlock/plc_int_ll.02 srv-padres-srf:20000/srv-tango-srf/interlock/plc_int_ll.03").
arg(args.first()));
exit(EXIT_FAILURE);
}
if(args.contains("--sound-file-name") && args.size() > args.indexOf("--sound-file-name"))
{
Sound *sound = new Sound(this, args.at(args.indexOf("--sound-file-name") + 1));
}
else
{
printf("\e[1;35m - if you want to enable sounds for alarms, provide as second argument the name of the sound file\e[0m\n");
ui.pbTestSound->setHidden(true);
ui.line->setHidden(true);
}
modDeviceName = QApplication::arguments()[1];
vacPsDeviceName = QApplication::arguments()[2];
Config::instance()->setOverrideValuesAttributePropertyName("labels");
ui.setupUi(this);
setupDb();
configureUi();
createConnections();
QTimer::singleShot(50, this, SLOT(connectTango()));
}
void Interlock::setupDb()
{
/* connect to db */
db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("srv-db-srf-02");
db.setDatabaseName("intlkfermi");
db.setUserName("ifermi");
db.setPassword("ferm");
if (!db.open())
QMessageBox::critical(0, "Error", "Can't establish connection with db intlkboost on host log");
queryType = QueryConfiguration::LastDay;
modulatorModel = new MySqlModel();
psvacModel = new MySqlModel();
ui.treeLogs->setModel(modulatorModel);
ui.treeLogsPSVAC->setModel(psvacModel);
dbTimer = new QTimer(this);
connect(dbTimer, SIGNAL(timeout()), this, SLOT(readFromDb()));
}
void Interlock::createConnections()
{
connect(ui.treeAlarms, SIGNAL(acknowledgeSelected()), this, SLOT(acknowledgeSelected()));
connect(ui.pushRefresh, SIGNAL(clicked()), this, SLOT(readFromDb()));
connect(ui.pushRefreshPSVacuum, SIGNAL(clicked()), this, SLOT(readFromDb()));
connect(ui.pushQueryConfiguration, SIGNAL(clicked()), this, SLOT(queryConfiguration()));
connect(ui.pushQueryConfigurationPSVAC, SIGNAL(clicked()), this, SLOT(queryConfiguration()));
connect(ui.comboAck, SIGNAL(currentIndexChanged(int)), this, SLOT(changeAckTarget(int)));
connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
/* 1 tab: mod filter */
connect(ui.pbClearModFilter, SIGNAL(clicked()), ui.leFilterMod, SLOT(clear()));
connect(ui.leFilterMod, SIGNAL(textChanged(QString)), ui.treeAlarms, SLOT(filter(QString)));
/* 2 tab: mod history */
connect(ui.pbClearModHist, SIGNAL(clicked()), ui.leFilterModHist, SLOT(clear()));
connect(ui.leFilterModHist, SIGNAL(textChanged(QString)), ui.treeLogs, SLOT(filter(QString)));
/* 3 tab: ps vac linac */
connect(ui.pbClearFilterVacLinac, SIGNAL(clicked()), ui.leFilterPsVacLinac, SLOT(clear()));
connect(ui.leFilterPsVacLinac, SIGNAL(textChanged(QString)), ui.treeAlarmsVPS, SLOT(filter(QString)));
/* 4 tab: ps vacuum uh */
connect(ui.pbClearFilterPSVacUH, SIGNAL(clicked()), ui.leFilterPsVacUH, SLOT(clear()));
connect(ui.leFilterPsVacUH, SIGNAL(textChanged(QString)), ui.treeAlarmsVUH, SLOT(filter(QString)));
/* 5 tab ps vacuum padres */
connect(ui.pbClearFilterPsVacPadres, SIGNAL(clicked()), ui.leFilterPsVacPadres, SLOT(clear()));
connect(ui.leFilterPsVacPadres, SIGNAL(textChanged(QString)), ui.treeAlarmsPadres, SLOT(filter(QString)));
/* 6. tab ps and vacuum history */
connect(ui.pbClearFilterPsVacHistory, SIGNAL(clicked()), ui.leFilterPsVacHistory, SLOT(clear()));
connect(ui.leFilterPsVacHistory, SIGNAL(textChanged(QString)), ui.treeLogsPSVAC, SLOT(filter(QString)));
/* sound */
Sound *sound = findChild<Sound *>();
if(sound)
{
connect(ui.treeAlarms, SIGNAL(newAlarmArrived()), sound, SLOT(play()));
connect(ui.treeAlarmsPadres, SIGNAL(newAlarmArrived()), sound, SLOT(play()));
connect(ui.treeAlarmsVPS, SIGNAL(newAlarmArrived()), sound, SLOT(play()));
connect(ui.treeAlarmsVUH, SIGNAL(newAlarmArrived()), sound, SLOT(play()));
connect(ui.pbTestSound, SIGNAL(clicked()), sound, SLOT(play()));
}
connect(ui.treeAlarms, SIGNAL(newAlarmArrived()), this, SLOT(newAlarmArrived()));
connect(ui.treeAlarmsPadres, SIGNAL(newAlarmArrived()), this, SLOT(newAlarmArrived()));
connect(ui.treeAlarmsVPS, SIGNAL(newAlarmArrived()), this, SLOT(newAlarmArrived()));
connect(ui.treeAlarmsVUH, SIGNAL(newAlarmArrived()), this, SLOT(newAlarmArrived()));
}
void Interlock::configureUi()
{
QStringList headers;
headers << "Date Time" << "Name" << "Description";
foreach(TTreeWidget *ttw, findChildren<TTreeWidget *>(QRegExp("treeAlarms.*")))
ttw->setHeaderLabels(headers);
QStringList mods;
for(int i = 0; i <= 15; i++)
mods << QString("mod%1").arg(i, 2, 10, QChar('0'));
mods.push_front("General");
ui.comboAck->insertItems(0, mods);
}
Interlock::~Interlock()
{
}
void Interlock::connectTango()
{
/* mod */
ui.treeAlarms->setPeriod(1000);
ui.treeAlarms->setSource(modDeviceName + "/Db_alarm");
ui.tAck->setTargets(modDeviceName + QString("->Acknowledge(%1)").arg(ui.comboAck->itemData(0).toInt()));
/* vacuum and power supply */
ui.treeAlarmsVPS->setPeriod(1000);
ui.treeAlarmsVPS->setSource(vacPsDeviceName + "/Db_alarm");
/* Ps and vacuum UH */
ui.treeAlarmsVUH->setSource("$3/Db_alarm");
/* padres */
ui.treeAlarmsPadres->setSource("$4/Db_alarm");
}
void Interlock::changeAckTarget(int idx)
{
/* item list (idx == 0) starts with "general".
* Then modulators follow, from mod00 (idx == 1) to mod12.
* So the correct argin is obtained subtracting 1 to the combo box index.
*/
int argin = idx - 1;
ui.tAck->setTargets(modDeviceName + QString("->Acknowledge(%1)").arg(argin));
}
void Interlock::newAlarmArrived()
{
/* get sender */
QString oName = sender()->objectName();
int tabIndex = -1;
if(oName == "treeAlarms")
tabIndex = 0;
else if(oName == "treeAlarmsVPS")
tabIndex = 2;
else if(oName == "treeAlarmsVUH")
tabIndex = 3;
else if(oName == "treeAlarmsPadres")
tabIndex = 4;
ui.tabWidget->setTabIcon(tabIndex, QIcon(":icons/alarm.png"));
}
/* icon removal is made inside custom TabBar.
* See tabwidget.h
*/
void Interlock::tabChanged(int idx)
{
if(idx == ModHistory || idx == PsVacHistory)
{
dbTimer->start(10000);
this->readFromDb();
}
else
{
dbTimer->stop();
}
}
void Interlock::acknowledgeSelected()
{
/// //////////////////
printf("\e[1;33m - da implementare - \e[0m\n");
return;
/// //////////////////
QVector<double> v_attr(ui.treeAlarms->dataSize(), 0);
// QVector<long> v_comm(ui.treeAlarms->dataSize(), 0);
foreach (QTreeWidgetItem *it, ui.treeAlarms->selectedItems())
{
//qDebug() << it->text(3);
v_attr[it->text(3).toInt()] = 1;
// v_comm << it->text(3).toLong();
}
try {
DeviceAttribute attr;
attr.set_name("Db_alarm");
vector<double> dati = v_attr.toStdVector();
attr << dati;
Tango::DeviceProxy *dpr = DeviceFactory::instance()->getDeviceProxy(modDeviceName);
if(dpr)
dpr->write_attribute(attr);
}
catch (DevFailed &e)
{
TLog log(e);
time_t now = time(NULL);
QPair<time_t, DevErrorList> err(now, e.errors);
TUtil::instance()->addLog(log.toTimeErrlistPair(), log.formatMessage());
QMessageBox::critical(0, "Error", log.formatMessage());
}
ui.treeAlarms->clearSelection();
}
void Interlock::queryConfiguration()
{
QueryConfiguration win;
win.setQueryType(queryType);
if (queryType == QueryConfiguration::Interval)
{
win.setStartDateTime(begin);
win.setStopDateTime(end);
}
if (win.exec() == QDialog::Accepted)
{
queryType = win.queryType();
begin = win.startDateTime();
end = win.stopDateTime();
readFromDb();
}
}
void Interlock::readFromDb()
{
MySqlModel *model = NULL;
QString dbnam;
bool modulator = true;
if(ui.tabWidget->currentIndex() == ModHistory)
{
model = modulatorModel;
dbnam = "real_time_";
}
else if(ui.tabWidget->currentIndex() == PsVacHistory)
{
modulator = false;
model = psvacModel;
dbnam = "vac_mag_";
}
else
return;
if (!db.isOpen())
{
if (!db.open())
{
QMessageBox::critical(0, "Error", "Can't establish connection with db FastInterlock on host log");
return;
}
}
QDateTime adesso = QDateTime::currentDateTime();
int year = adesso.date().year();
QString query, endquery;
if(modulator)
{
query = "SELECT FROM_UNIXTIME(" + dbnam + "%1.timestamp) AS 'Date Time', mod_description.name AS 'Name', "
+ dbnam + "%1.event AS 'Event', "
"mod_description.comment AS Description, mod_description.modulator AS 'Modulator' FROM "
+ dbnam + "%1 left join mod_description on (" + dbnam +
"%1.id_mod_description=mod_description.id_mod_description) WHERE timestamp>%2 "
;
endquery = " ORDER BY timestamp desc";
}
else
{
query = "SELECT FROM_UNIXTIME(" + dbnam + "%1.timestamp) AS 'Date Time', vac_mag_desc.name AS 'Name', "
+ dbnam + "%1.event AS 'Event', "
"vac_mag_desc.comment AS Description, vac_mag_desc.plc AS 'PLC' FROM "
+ dbnam + "%1 left join vac_mag_desc on (" + dbnam +
"%1.id_vac_mag_desc=vac_mag_desc.id_vac_mag_desc) WHERE timestamp>%2 "
;
endquery = " ORDER BY timestamp desc";
}
unsigned int inizioRicerca;
switch (queryType)
{
case QueryConfiguration::LastDay:
inizioRicerca = adesso.addDays(-1).toTime_t();
year = adesso.date().year();
query = QString(query).arg(year).arg(inizioRicerca) + endquery;
break;
case QueryConfiguration::LastWeek:
inizioRicerca = adesso.addDays(-7).toTime_t();
year = adesso.date().year();
query = QString(query).arg(year).arg(inizioRicerca) + endquery;
break;
case QueryConfiguration::LastMonth:
inizioRicerca = adesso.addMonths(-1).toTime_t();
year = adesso.date().year();
query = QString(query).arg(year).arg(inizioRicerca) + endquery;
break;
case QueryConfiguration::Interval:
year = end.date().year();
query = QString(query).arg(year).arg(begin.toTime_t());
query += QString(" AND timestamp<%1").arg(end.toTime_t()) + endquery;
break;
default:
break;
}
model->setQuery(query);
/* must apply filter if set */
if(modulator)
ui.treeLogs->updateFilter();
else
ui.treeLogsPSVAC->updateFilter();
QSqlError error = model->lastError();
if (error.type() != QSqlError::NoError)
{
QMessageBox::critical(0, "Database Error", QString("Error reading from Db:\n") + error.text() + "\nreconnecting");
db.close();
if (!db.open())
QMessageBox::critical(0, "Error", "Can't establish connection with db FastInterlock on host log");
}
}
void Interlock::on_tabWidget_currentChanged(int idx)
{
if (idx == 3)
{
readFromDb();
dbTimer->start();
}
else
dbTimer->stop();
}
void Interlock::modSelected(bool en)
{
// ui.cbStatSelection->setEnabled(en);
// changeStatView(ui.cbStatSelection->currentIndex()); /* will also update descriptions */
}
void Interlock::changeStatView(int index)
{
QString attname;
QString devName = modDeviceName;
/* if Select is checked, then set Stat_mod_NUMBER, otherwise Stat_system */
// if(ui.rbSelectMod->isChecked())
// attname = QString("Stat_mod_%1").arg(index);
// else
attname = "Stat_system";
// QString src = devName + "/" + attname;
// ui.tableStates->setSource(src);
}
/***************************************************************************
* Copyright (C) 2007 by Vincenzo Forchi`,,, *
* vincenzo.forchi@elettra.trieste.it *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef interlock_H
#define interlock_H
#include "ui_interlock.h"
#include "queryconfiguration.h"
#include <QString>
#include <QSqlDatabase>
//class QGraphicsScene;
class MySqlModel;
class Interlock: public QWidget
{
Q_OBJECT
public:
enum Tabs { Mod, ModHistory, PsVacLinac, PsVacUH, PsVacPadres, PsVacHistory };
Interlock(QWidget * =NULL);
~Interlock();
// QStringList getProperty(string, string);
protected slots:
void connectTango();
void acknowledgeSelected();
void queryConfiguration();
void readFromDb();
void on_tabWidget_currentChanged(int);
void changeStatView(int index);
void modSelected(bool en);
void changeAckTarget(int);
void tabChanged(int idx);
void newAlarmArrived();
private:
Ui::Interlock ui;
QString modDeviceName, vacPsDeviceName;
QSqlDatabase db;
MySqlModel *modulatorModel, *psvacModel;
QueryConfiguration::QueryType queryType;
QDateTime begin, end;
QTimer *dbTimer;
void setupDb();
void configureUi();
void createConnections();
// QGraphicsScene *boosterScene;
};
#endif
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Interlock</class>
<widget class="QWidget" name="Interlock">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>898</width>
<height>530</height>
</rect>
</property>
<property name="windowTitle">
<string>General Fermi Interlock</string>
</property>
<layout class="QVBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>9</number>
</property>
<item>
<widget class="TabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabAlarms">
<attribute name="title">
<string>Modulator</string>
</attribute>
<layout class="QGridLayout">
<property name="margin">
<number>9</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="1" column="8">
<widget class="QPushButton" name="pbTestSound">
<property name="text">
<string>Test Sound</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="leFilterMod">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Filter&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Start typing text to filter items on the second column of the view.&lt;/p&gt;&lt;p&gt;The search is &lt;span style=&quot; font-style:italic;&quot;&gt;case insensitive&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;Click on the &lt;span style=&quot; font-style:italic;&quot;&gt;Clear&lt;/span&gt; button to clear the text on the box.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="3">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="6">
<widget class="TPushButton" name="tAck">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Ack</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="9">
<widget class="TTreeWidget" name="treeAlarms">
<property name="enabled">
<bool>false</bool>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
<item row="1" column="5">
<widget class="TComboBox" name="comboAck">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pbClearModFilter">
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Filter by label:</string>
</property>
</widget>
</item>
<item row="1" column="7">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Modulator History</string>
</attribute>
<layout class="QVBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>9</number>
</property>
<item>
<widget class="TTreeView" name="treeLogs">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="itemsExpandable">
<bool>false</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="pushRefresh">
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Filter by name:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leFilterModHist">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Filter&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Start typing text to filter items on the second column of the view.&lt;/p&gt;&lt;p&gt;The search is &lt;span style=&quot; font-style:italic;&quot;&gt;case insensitive&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;Click on the &lt;span style=&quot; font-style:italic;&quot;&gt;Clear&lt;/span&gt; button to clear the text on the box.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbClearModHist">
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushQueryConfiguration">
<property name="text">
<string>Log Period</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>PS and Vacuum Linac</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="4">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="leFilterPsVacLinac">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Filter&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Start typing text to filter items on the second column of the view.&lt;/p&gt;&lt;p&gt;The search is &lt;span style=&quot; font-style:italic;&quot;&gt;case insensitive&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;Click on the &lt;span style=&quot; font-style:italic;&quot;&gt;Clear&lt;/span&gt; button to clear the text on the box.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Filter by label:</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="7">
<widget class="TTreeWidget" name="treeAlarmsVPS">
<property name="enabled">
<bool>false</bool>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
<item row="1" column="6">
<widget class="TPushButton" name="tAckPSV">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Ack</string>
</property>
<property name="targets">
<string>$2-&gt;Acknowledge(0);;</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="pbClearFilterVacLinac">
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>PS &amp;and Vacuum UH</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="6">
<widget class="TPushButton" name="tAckPSUH">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Ack</string>
</property>
<property name="targets">
<string>$3-&gt;Acknowledge(0);;;</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="7">
<widget class="TTreeWidget" name="treeAlarmsVUH">
<property name="enabled">
<bool>false</bool>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
<item row="1" column="5">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="pbClearFilterPSVacUH">
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Filter by label:</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="leFilterPsVacUH">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Filter&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Start typing text to filter items on the second column of the view.&lt;/p&gt;&lt;p&gt;The search is &lt;span style=&quot; font-style:italic;&quot;&gt;case insensitive&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;Click on the &lt;span style=&quot; font-style:italic;&quot;&gt;Clear&lt;/span&gt; button to clear the text on the box.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>PS and Vacuum Padres</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="4">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="5">
<widget class="TPushButton" name="tpbAckPSVPadres">
<property name="text">
<string>Ack</string>
</property>
<property name="targets">
<string>$4-&gt;Acknowledge(0);;</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="pbClearFilterPsVacPadres">
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="leFilterPsVacPadres">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Filter&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Start typing text to filter items on the second column of the view.&lt;/p&gt;&lt;p&gt;The search is &lt;span style=&quot; font-style:italic;&quot;&gt;case insensitive&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;Click on the &lt;span style=&quot; font-style:italic;&quot;&gt;Clear&lt;/span&gt; button to clear the text on the box.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Filter by label:</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="6">
<widget class="TTreeWidget" name="treeAlarmsPadres">
<property name="enabled">
<bool>false</bool>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>PS and Vacuum History</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0" colspan="6">
<widget class="TTreeView" name="treeLogsPSVAC">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="itemsExpandable">
<bool>false</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pushRefreshPSVacuum">
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Filter by name:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="leFilterPsVacHistory">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Filter&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Start typing text to filter items on the second column of the view.&lt;/p&gt;&lt;p&gt;The search is &lt;span style=&quot; font-style:italic;&quot;&gt;case insensitive&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;Click on the &lt;span style=&quot; font-style:italic;&quot;&gt;Clear&lt;/span&gt; button to clear the text on the box.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="pbClearFilterPsVacHistory">
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
<item row="1" column="4">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>245</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="5">
<widget class="QPushButton" name="pushQueryConfigurationPSVAC">
<property name="text">
<string>Log Period</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
<class>TComboBox</class>
<extends>QComboBox</extends>
<header>TComboBox</header>
</customwidget>
<customwidget>
<class>TPushButton</class>
<extends>QPushButton</extends>
<header>TPushButton</header>
</customwidget>
<customwidget>
<class>TTreeWidget</class>
<extends>QTreeWidget</extends>
<header>ttreewidget.h</header>
</customwidget>
<customwidget>
<class>TTreeView</class>
<extends>QTreeView</extends>
<header>ttreeview.h</header>
</customwidget>
<customwidget>
<class>TabWidget</class>
<extends>QTabWidget</extends>
<header>tabwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>treeAlarms</tabstop>
<tabstop>tAck</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
/***************************************************************************
* Copyright (C) 2007 by Vincenzo Forchi`,,, *
* vincenzo.forchi@elettra.trieste.it *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <TApplication>
#include "interlock.h"
#include <X11/Xlib.h>
#include <QX11Info>
#include <tutil.h>
#include <elettracolors.h>
#define CVSVERSION "$Name: $"
/* uncomment to set application color */
//#include <elettracolors.h>
int main( int argc, char ** argv ) {
TApplication a( argc, argv );
/* uncomment to set application color */
a.setPalette(EPalette("fermi"));
QString version(CVSVERSION);
a.setApplicationVersion(version);
a.setApplicationName("FermiInterlock");
a.setProperty("author", "Giacomo");
a.setProperty("mail", "giacomo.strangolino@elettra.trieste.it");
a.setProperty("phone", "375-8073");
a.setProperty("office", "T2PT025");
a.setProperty("hwReferent", "Graziano");
Interlock mw;
mw.setWindowTitle("Fermi Interlock");
mw.show();
/* register to window manager */
Display *disp = QX11Info::display();
Window root_win = (Window) mw.winId();
XSetCommand(disp, root_win, argv, argc);
return a.exec();
}
/****************************************************************************
**
** Copyright (C) 2004-2006 Trolltech ASA. All rights reserved.
**
** This file is part of the example classes of the Qt Toolkit.
**
** This file may be used under the terms of the GNU General Public
** License version 2.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of
** this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
** http://www.trolltech.com/products/qt/opensource.html
**
** If you are unsure which license is appropriate for your use, please
** review the following information:
** http://www.trolltech.com/products/qt/licensing.html or contact the
** sales department at sales@trolltech.com.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
#include <QtGui>
#include "mysqlmodel.h"
MySqlModel::MySqlModel(QObject *parent) : QSqlQueryModel(parent)
{
}
QVariant MySqlModel::data(const QModelIndex &index, int role) const
{
QVariant value = QSqlQueryModel::data(index, role);
if (value.isValid() && role == Qt::DisplayRole) {
if (index.column() == 0)
{
QString d = value.toString();
d.replace('T', ' ');
return d;
}
}
return value;
}
/****************************************************************************
**
** Copyright (C) 2004-2006 Trolltech ASA. All rights reserved.
**
** This file is part of the example classes of the Qt Toolkit.
**
** This file may be used under the terms of the GNU General Public
** License version 2.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of
** this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
** http://www.trolltech.com/products/qt/opensource.html
**
** If you are unsure which license is appropriate for your use, please
** review the following information:
** http://www.trolltech.com/products/qt/licensing.html or contact the
** sales department at sales@trolltech.com.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
#ifndef MYSQLMODEL_H
#define MYSQLMODEL_H
#include <QSqlQueryModel>
class MySqlModel : public QSqlQueryModel
{
Q_OBJECT
public:
MySqlModel(QObject *parent = 0);
QVariant data(const QModelIndex &item, int role) const;
};
#endif
/***************************************************************************
* Copyright (C) 2006 by Vincenzo Forchi`,,, *
* tus@ken *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "queryconfiguration.h"
#include <QDateTime>
#include <QMessageBox>
#include <QtDebug>
QueryConfiguration::QueryConfiguration(QDialog *parent) : QDialog(parent)
{
ui.setupUi(this);
ui.dateStart->setDate(QDate::currentDate());
ui.dateStop->setDate(QDate::currentDate());
ui.timeStart->setTime(QTime::currentTime());
ui.timeStop->setTime(QTime::currentTime());
connect(ui.comboPeriod, SIGNAL(currentIndexChanged(int)), this, SLOT(enableFrame(int)));
connect((QObject*) ui.buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(ok()));
}
QueryConfiguration::~QueryConfiguration()
{
}
void QueryConfiguration::enableFrame(int index)
{
if (index == 3)
ui.frame->setEnabled(true);
else
ui.frame->setEnabled(false);
}
void QueryConfiguration::ok()
{
if (ui.comboPeriod->currentIndex() == 3)
{
QDateTime begin, end;
begin.setDate(ui.dateStart->date());
begin.setTime(ui.timeStart->time());
end.setDate(ui.dateStop->date());
end.setTime(ui.timeStop->time());
if (begin >= end)
QMessageBox::warning(0, "Warning", "Invalid interval: check starting and ending dates");
else
accept();
}
else
accept();
}
void QueryConfiguration::setQueryType(QueryType qt)
{
ui.comboPeriod->setCurrentIndex((int) qt);
}
QueryConfiguration::QueryType QueryConfiguration::queryType()
{
return (QueryType) ui.comboPeriod->currentIndex();
}
void QueryConfiguration::setStartDateTime(QDateTime dt)
{
ui.dateStart->setDate(dt.date());
ui.timeStart->setTime(dt.time());
}
void QueryConfiguration::setStopDateTime(QDateTime dt)
{
ui.dateStop->setDate(dt.date());
ui.timeStop->setTime(dt.time());
}
QDateTime QueryConfiguration::startDateTime()
{
QDateTime dt;
dt.setDate(ui.dateStart->date());
dt.setTime(ui.timeStart->time());
return dt;
}
QDateTime QueryConfiguration::stopDateTime()
{
QDateTime dt;
dt.setDate(ui.dateStop->date());
dt.setTime(ui.timeStop->time());
return dt;
}
/***************************************************************************
* Copyright (C) 2006 by Vincenzo Forchi`,,, *
* tus@ken *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef QUERYCONFIGURATION_H
#define QUERYCONFIGURATION_H
#include "ui_queryconfiguration.h"
class QueryConfiguration : public QDialog
{
Q_OBJECT
public:
QueryConfiguration(QDialog * =NULL);
~QueryConfiguration();
enum QueryType
{
LastDay,
LastWeek,
LastMonth,
Interval,
All
};
void setQueryType(QueryType);
QueryType queryType();
void setStartDateTime(QDateTime);
void setStopDateTime(QDateTime);
QDateTime startDateTime();
QDateTime stopDateTime();
protected slots:
void enableFrame(int);
void ok();
private:
Ui::QueryConfiguration ui;
};
#endif
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