Skip to content
Snippets Groups Projects
Commit d8f0b7e3 authored by Lucio Zambon's avatar Lucio Zambon
Browse files

Initial import

parent f0f7152c
No related branches found
No related tags found
No related merge requests found
include(/usr/local/qtango/include/qtango6/qtango.pri)
# include(/runtime/elettra/include/qtango4/qtango.pri)
# include(../../../../utils/qmake.custom.3)
SOURCES += src/acsboard104.cpp \
src/main.cpp
HEADERS += src/acsboard104.h
FORMS = src/acsboard104.ui
TARGET = ../acs/bin/acsboard104
/***************************************************************************
* Copyright (C) 2007 by *
* *
* *
* 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 "acsboard104.h"
#include <qtango.h>
char tmBuffer[80];
/*
timestamp()
send a timestamp to standard output
*/
void timestamp()
{
struct tm *mytime;
time_t myTime_t;
myTime_t = time(NULL);
mytime = localtime(&myTime_t);
strftime(tmBuffer, 79, "%Y-%m-%d %H:%M:%S ", mytime);
return;
}
acsboard104::acsboard104(QWidget *parent) : QWidget(parent)
{
// setup User Interface
try {
ui.setupUi(this);
}
catch (const Tango::DevFailed &e) {
timestamp();
cout << tmBuffer << "cannot setup UI" << endl;
}
catch (...) {
timestamp();
cout << tmBuffer << "default exception, cannot setup UI" << endl;
}
// connect to control access server
try {
// plc_server = new Tango::DeviceProxy("ken/plcaccess/0");
plc_server = new Tango::DeviceProxy("sr/accessi/pss");
}
catch (const Tango::DevFailed &e) {
timestamp();
cout << tmBuffer << "Fatal Error: Access Control Device Server not responding, the application will be terminated immediately" << endl;
exit(1);
}
catch (...) {
timestamp();
cout << tmBuffer << "Fatal Error: Access Control Device Server not responding, the application will be terminated immediately" << endl;
exit(1);
}
refresh();
// init timer
try {
timer = new QTimer(this);
timer->setInterval(1000);
timer->setSingleShot(false);
connect(timer, SIGNAL(timeout()), this, SLOT(refresh()));
timer->start();
}
catch (const Tango::DevFailed &e) {
timestamp();
cout << tmBuffer << "cannot connect UI" << endl;
}
catch (...) {
timestamp();
cout << tmBuffer << "default exception, cannot setup UI" << endl;
}
}
acsboard104::~acsboard104()
{
}
int acsboard104::myReadAttribute(const char *attrName)
{
try {
myAttribute = plc_server->read_attribute(attrName);
return 1;
}
catch (const Tango::DevFailed &e) {
timestamp();
cout << "error reading attribute: " << attrName << endl;
}
catch (...) {
timestamp();
cout << tmBuffer << "default exception reading attribute: " << attrName << endl;
}
return 0;
}
void acsboard104::refresh()
{
vector<bool> stat;
if (myReadAttribute("Disabled_board_104")) {
try {
myAttribute >> stat;
}
catch (const Tango::DevFailed &e) {
}
ui.checkBox_0->setCheckState(stat[0]? Qt::Checked: Qt::Unchecked);
ui.checkBox_1->setCheckState(stat[1]? Qt::Checked: Qt::Unchecked);
}
}
/***************************************************************************
* Copyright (C) 2007 by *
* *
* *
* 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 acsboard104_H
#define acsboard104_H
#include "ui_acsboard104.h"
#include <tango.h>
#include <QProcess>
class acsboard104: public QWidget
{
Q_OBJECT
public:
acsboard104(QWidget * =NULL);
~acsboard104();
public slots:
void refresh();
private:
Ui::acsboard104 ui;
QTimer *timer;
Tango::DeviceAttribute myAttribute;
Tango::DeviceProxy *plc_server;
int myReadAttribute(const char *);
};
#endif
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>acsboard104</class>
<widget class="QWidget" name="acsboard104">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>460</width>
<height>30</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>460</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>460</width>
<height>30</height>
</size>
</property>
<property name="windowTitle">
<string>BOARD 104 - ingressi</string>
</property>
<widget class="QLabel" name="label_1">
<property name="geometry">
<rect>
<x>5</x>
<y>63</y>
<width>420</width>
<height>18</height>
</rect>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>key_RFs_fail: chiave RF service failure</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>5</x>
<y>6</y>
<width>420</width>
<height>18</height>
</rect>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>key_1a_ABI_fail: chiave 1a abilitazione failure</string>
</property>
</widget>
<widget class="Line" name="line_4">
<property name="geometry">
<rect>
<x>430</x>
<y>0</y>
<width>2</width>
<height>361</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<widget class="Line" name="line_14">
<property name="geometry">
<rect>
<x>0</x>
<y>83</y>
<width>780</width>
<height>2</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QCheckBox" name="checkBox_0">
<property name="geometry">
<rect>
<x>440</x>
<y>60</y>
<width>16</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QCheckBox" name="checkBox_1">
<property name="geometry">
<rect>
<x>440</x>
<y>3</y>
<width>16</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<resources/>
<connections/>
</ui>
/***************************************************************************
* Copyright (C) 2007 by *
* *
* *
* 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 <QApplication>
#include "acsboard104.h"
#include <X11/Xlib.h>
#include <QX11Info>
#define CVSVERSION "$Name: $"
int main( int argc, char ** argv ) {
QApplication a( argc, argv );
a.setApplicationVersion(CVSVERSION);
acsboard104 mw;
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();
}
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