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

first import from CVS repo elettra/panels/feedback/gof/liberaethmon release_14

parent d57f3f7f
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
*.pro.user
# liberaethmon
control panel for monitoring elettra GOF system Libera ethernet messages
## example
liberaethmon-gui ecgofa2/mv64360mon/
include (/usr/local/qtango/include/qtango6/qtango.pri)
CONFIG += release
SOURCES = src/liberaethmon.cpp
HEADERS = src/liberaethmon.h
FORMS = src/liberaethmon.ui
TARGET = bin/liberaethmon-gui
QMAKE_CLEAN += src
QMAKE_POST_LINK = $(STRIP) $(TARGET)
#include "liberaethmon.h"
#include <tutil.h>
#include <device_factory.h>
#include <QApplication>
#include <QGridLayout>
#include <TLinearGauge>
LiberaEthMon::LiberaEthMon(QWidget *parent) : QDialog(parent)
{
device = qApp->arguments()[1];
ui.setupUi(this);
vg1 = new ReadersGroup(this);
vg2 = new ReadersGroup(this);
vg3 = new ReadersGroup(this);
// ((QGridLayout*)layout())->getItemPosition(layout()->indexOf(ui.groupErrorLog), &r1, &c1, &rs1, &cs1);
((QGridLayout*)layout())->getItemPosition(layout()->indexOf(ui.frameErr), &r2, &c2, &rs2, &cs2);
// ui.groupErrorLog->hide();
ui.frameErr->hide();
ui.tRate->setValueFormat("%1.1f");
QVBoxLayout *vbl = new QVBoxLayout(ui.fBPMLabels);
vbl->setSpacing(0);
vbl->setMargin(0);
for (int i = 0; i < 7; i++)
vbl->addWidget(new QLabel(QString("BPM %1").arg(i), ui.fBPMLabels));
QList<unsigned int> m;
m << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9;
ui.tFlag1->setDisplayMask(m);
ui.tFlag2->setDisplayMask(m);
ui.tFlag3->setDisplayMask(m);
ui.tFlag4->setDisplayMask(m);
for (int i = 0; i < 10; i++)
{
ui.tFlag1->setBooleanDisplay(i, "OFF", "ON", Qt::red, Qt::green);
ui.tFlag2->setBooleanDisplay(i, "OK", "Mis ERR", Qt::green, Qt::red);
ui.tFlag3->setBooleanDisplay(i, "OK", "Lost ERR", Qt::green, Qt::red);
ui.tFlag4->setBooleanDisplay(i, "OK", "Libera ERR", Qt::green, Qt::red);
}
vg3->addReader(ui.tFlag1,0);
vg3->addReader(ui.tFlag2,1);
vg3->addReader(ui.tFlag3,2);
vg3->addReader(ui.tFlag4,3);
// QVBoxLayout *vbl2 = new QVBoxLayout(ui.groupErrorLog);
//AttributeInfoEx info;
//info.format = "%x";
/* Removed until setSource() with DeviceData becomes available in QTango3 */
// for (int i = 0; i < 10; i++)
// {
// TTable *tsv = new TTable(ui.groupErrorLog);
// tsv->setNumRows(1);
// tsv->setNumColumns(6);
// tsv->setAttributeInfo(info);
// vbl2->addWidget(tsv);
// logViewers << tsv;
// }
try {
ui.tReset->setTargets(device + "->reset");
ui.tRate->setSource(device + "/irqbytes");
ui.tFreq->setSource(device + "/irqfreq");
ui.tRecTime->setSource(device + "/waittimecurrent");
ui.tTaskTime->setSource(device + "/tasktimecurrent");
ui.tMaxRecTime->setSource(device + "/worsttimemax");
ui.tMaxTaskTime->setSource(device + "/tasktimemax");
ui.tPacketCounter->setSource(device + "/packetcounter");
ui.tWaitTimeMax->setSource(device + "/waittimemax");
DeviceProxy *dev = DeviceFactory::instance()->getDeviceProxy(device);
if(dev) {
DeviceAttribute out = dev->read_attribute("waitslot");
vector<Tango::DevLong> intervals;
out >> intervals;
box1 = new QGridLayout(ui.groupWaitTime);
box1->setSpacing(2);
box1->setMargin(4);
for (Tango::DevLong i = 0; i < (out.dim_x+1); i++)
{
TLinearGauge *ptr = new TLinearGauge(ui.groupWaitTime, Qt::Vertical, false);
ptr->setFillMode(ELinearGauge::FROM_MIN);
ptr->setMinValue(0);
ptr->setLowError(0);
ptr->setLowWarning(0);
ptr->setHighWarning(100);
ptr->setHighError(100);
ptr->setMaxValue(100);
ptr->setReferenceEnabled(false);
vg1->addReader(ptr,i);
QLabel *l = new QLabel(ui.groupWaitTime);
l->setAlignment(Qt::AlignCenter);
if (i < out.dim_x)
l->setText(QString("<%1us").arg((int)(.001*intervals[i])));
else
l->setText(QString(">%1us").arg((int)(.001*intervals[i-1])));
box1->addWidget(ptr, 0, i, Qt::AlignCenter);
box1->addWidget(l, 1, i, Qt::AlignCenter);
}
box1->setRowStretch(0, 5);
box1->setRowStretch(1, 1);
vg1->setSource(QString(device + "/waittime"));
out = dev->read_attribute("taskslot");
out >> intervals;
box2 = new QGridLayout(ui.groupTaskTime);
box2->setSpacing(2);
box2->setMargin(4);
for (int i = 0; i < (out.dim_x+1); i++)
{
TLinearGauge *ptr = new TLinearGauge(ui.groupTaskTime, Qt::Vertical, false);
ptr->setFillMode(ELinearGauge::FROM_MIN);
ptr->setMinValue(0);
ptr->setLowError(0);
ptr->setLowWarning(0);
ptr->setHighWarning(100);
ptr->setHighError(100);
ptr->setMaxValue(100);
ptr->setReferenceEnabled(false);
vg2->addReader(ptr,i);
QLabel *l = new QLabel(ui.groupTaskTime);
l->setAlignment(Qt::AlignCenter);
if (i < out.dim_x)
l->setText(QString("<%1us").arg((int)(.001*intervals[i])));
else
l->setText(QString(">%1us").arg((int)(.001*intervals[i-1])));
box2->addWidget(ptr, 0, i, Qt::AlignCenter);
box2->addWidget(l, 1, i, Qt::AlignCenter);
}
box2->setRowStretch(0, 5);
box2->setRowStretch(1, 1);
vg2->setSource(QString(device + "/tasktime"));
vg3->setSource(QString(device + "/linkstat"));
/* Removed until setSource() with DeviceData for QTango3 becomes available. Unneeded? */
// long k = 0;
// foreach(TTable *v, logViewers)
// {
// DeviceData in;
// in << k;
// v->setSource(device + "->getlog", in);
// k++;
// }
ui.tLiberaCnt->setSource(device + "/liberacounter");
ui.tPacketCntErr->setSource(device + "/packetcountererr");
}
}
catch (DevFailed &e) {
Except::print_exception(e);
}
connect(ui.pushExpert, SIGNAL(toggled(bool)), this, SLOT(expertMode(bool)));
expertMode(true);
expertMode(false);
}
void LiberaEthMon::expertMode(bool visible)
{
int w = width() - ui.frameErr->width();
int w2 = width() + ui.frameErr->width();
// ui.groupErrorLog->setVisible(visible);
ui.frameErr->setVisible(visible);
if (!visible)
{
// layout()->removeWidget(ui.groupErrorLog);
layout()->removeWidget(ui.frameErr);
resize(w, height());
layout()->activate();
}
else if (layout()->indexOf(ui.frameErr) == -1)
{
// ((QGridLayout*)layout())->addWidget(ui.groupErrorLog, r1, c1, rs1, cs1);
((QGridLayout*)layout())->addWidget(ui.frameErr, r2, c2, rs2, cs2);
resize(w2, height());
}
}
int main(int argc, char **argv)
{
if (argc < 2)
{
qDebug("usage: %s device", argv[0]);
exit(-1);
}
QApplication a(argc, argv);
LiberaEthMon dialog;
dialog.show();
return a.exec();
}
#include "ui_liberaethmon.h"
#include <readersgroup.h>
#include <QVector>
#include <QPointer>
class TTable;
class QGridLayout;
class LiberaEthMon : public QDialog
{
Q_OBJECT
public:
LiberaEthMon(QWidget * = NULL);
~LiberaEthMon(){};
public slots:
void expertMode(bool);
private:
Ui::LiberaEthMon ui;
QGridLayout *box1, *box2;
int r1, c1, rs1, cs1, r2, c2, rs2, cs2;
ReadersGroup *vg1, *vg2, *vg3;
QString device;
QVector<QPointer<TTable> > logViewers;
};
This diff is collapsed.
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