Commit a7d6256c authored by Lucio Zambon's avatar Lucio Zambon
Browse files

add status label conf

parent ac08f85b
This diff is collapsed.
...@@ -56,7 +56,7 @@ void laserpssokintck::refresh() { ...@@ -56,7 +56,7 @@ void laserpssokintck::refresh() {
for (unsigned j=0; j < states.size(); j++) { for (unsigned j=0; j < states.size(); j++) {
if (states[j].attr == attributes[i]) { if (states[j].attr == attributes[i]) {
states[j].value = (int) (states[j].bit>=0? stat[states[j].bit]: !stat[-1 - states[j].bit]); states[j].value = (int) (states[j].bit>=0? stat[states[j].bit]: !stat[-1 - states[j].bit]);
mySetTextColor(states[j].label, (states[j].value? "OK": "NOK"), "#000000", (states[j].value? "#00C800": "#DC0000")); mySetTextColor(states[j].label, (states[j].value? statLabel[1]: statLabel[0]), "#000000", (states[j].value? "#00C800": "#DC0000"));
} }
} }
} }
...@@ -69,7 +69,7 @@ void laserpssokintck::refresh() { ...@@ -69,7 +69,7 @@ void laserpssokintck::refresh() {
for (unsigned c=0; c < derivedCond[k].cond.size(); c++) { for (unsigned c=0; c < derivedCond[k].cond.size(); c++) {
derivedCond[k].value = derivedCond[k].isAnd? derivedCond[k].value && derivedCond[derivedCond[k].cond[c]].value: derivedCond[k].value || derivedCond[derivedCond[k].cond[c]].value; derivedCond[k].value = derivedCond[k].isAnd? derivedCond[k].value && derivedCond[derivedCond[k].cond[c]].value: derivedCond[k].value || derivedCond[derivedCond[k].cond[c]].value;
} }
mySetTextColor(derivedCond[k].label, (derivedCond[k].value? "OK": "NOK"), "#000000", (derivedCond[k].value? "#00C800": "#DC0000")); mySetTextColor(derivedCond[k].label, (derivedCond[k].value? statLabel[1]: statLabel[0]), "#000000", (derivedCond[k].value? "#00C800": "#DC0000"));
} }
} }
...@@ -110,6 +110,14 @@ int laserpssokintck::mySetTextColor(QLabel *widget, const char *text, const char ...@@ -110,6 +110,14 @@ int laserpssokintck::mySetTextColor(QLabel *widget, const char *text, const char
widget->setPalette(button); widget->setPalette(button);
return 0; return 0;
} }
int laserpssokintck::mySetTextColor(QLabel *widget, QString text, const char *color, const char *bgcolor) {
QPalette button;
widget->setText(text);
button.setColor(QPalette::Window, QColor(bgcolor));
button.setColor(QPalette::WindowText, QColor(color));
widget->setPalette(button);
return 0;
}
void laserpssokintck::handleButton(int n) { void laserpssokintck::handleButton(int n) {
cout << "button: " << n << ", cmd: " << infoButton[n].toStdString() << endl; cout << "button: " << n << ", cmd: " << infoButton[n].toStdString() << endl;
if (myprocess->state() == QProcess::Running) { if (myprocess->state() == QProcess::Running) {
...@@ -228,17 +236,27 @@ void laserpssokintck::preParseBlock(QMap<QString, QVariant> map, int x) { ...@@ -228,17 +236,27 @@ void laserpssokintck::preParseBlock(QMap<QString, QVariant> map, int x) {
} }
} }
void laserpssokintck::parseLabel(QString labels) {
statLabel = labels.split(",");
}
laserpssokintck::laserpssokintck(QWidget *parent) : QWidget(parent) { laserpssokintck::laserpssokintck(QWidget *parent) : QWidget(parent) {
if (qApp->arguments().count() < 2 || qApp->arguments()[1]=="-h" || qApp->arguments()[1]=="--help") { if (qApp->arguments().count() < 2 || qApp->arguments()[1]=="-h" || qApp->arguments()[1]=="--help") {
cout << "Usage: " << qApp->arguments()[0].toStdString() << " configuration file (JSON)" << endl; cout << "Usage: " << qApp->arguments()[0].toStdString() << " configuration file (JSON) [description] [statLabel]" << endl;
cout << " statLabel default = NOK,OK || false,true" << endl;
exit(0); exit(0);
} }
QString labels = "NOK,OK";
statLabel = labels.split(",");
description = false; description = false;
descriptionWidth = 0; descriptionWidth = 0;
if (qApp->arguments().count() > 2 && qApp->arguments()[2]=="description") { if (qApp->arguments().count() > 2 && qApp->arguments()[2]=="description") {
description = true; description = true;
descriptionWidth = 500; descriptionWidth = 500;
if (qApp->arguments().count() > 3) parseLabel(qApp->arguments()[3]);
} }
else if (qApp->arguments().count() > 2) parseLabel(qApp->arguments()[2]);
// cout << statLabel[0].toStdString() << endl; cout << statLabel[1].toStdString() << endl; exit(0);
x=620; y=30; xStep=-70; yStep=30, by=30, xOffset = 10000; x=620; y=30; xStep=-70; yStep=30, by=30, xOffset = 10000;
QSettings settings("fermi", "acs"); QSettings settings("fermi", "acs");
// load (or set) path for images // load (or set) path for images
...@@ -310,4 +328,3 @@ laserpssokintck::laserpssokintck(QWidget *parent) : QWidget(parent) { ...@@ -310,4 +328,3 @@ laserpssokintck::laserpssokintck(QWidget *parent) : QWidget(parent) {
laserpssokintck::~laserpssokintck() { laserpssokintck::~laserpssokintck() {
exit(0); exit(0);
} }
...@@ -74,7 +74,10 @@ private: ...@@ -74,7 +74,10 @@ private:
QSignalMapper mapper; QSignalMapper mapper;
void appendAttr(QString attr); void appendAttr(QString attr);
void parseLabel(QString labels);
QStringList statLabel;
int mySetTextColor(QLabel *widget, const char *text, const char *color, const char *bgcolor); int mySetTextColor(QLabel *widget, const char *text, const char *color, const char *bgcolor);
int mySetTextColor(QLabel *widget, QString text, const char *color, const char *bgcolor);
int myReadBoolArray(QString, vector<bool> &); int myReadBoolArray(QString, vector<bool> &);
Tango::DeviceProxy *plc_server; Tango::DeviceProxy *plc_server;
QTimer *timer; QTimer *timer;
......
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