Commit 075cebb2 authored by Giacomo Strangolino's avatar Giacomo Strangolino
Browse files

Project xps imported from last version in CVS

parents
release_05: porting to qtango6 (installed in /usr/local/qtango) and qt5
release_04: porting to qtango6 (installed in /usr/local/qtango) and qt5
release_03: porting qtango5 tango8
release_02:
Workaround for Backwards and forward push buttons due to QTango ticket 568.
To remove when 4.2.1 is available.
release_01:
First release. Discussed with Paolo Sigalotti and Graziano Scalamera
$Id: README,v 1.1 2010/12/14 14:44:48 giacomo Exp $
Xps Single Axis / Group2
========================================================================
Introduction
------------
Xps positioner control panel
Requirements
------------
tango >= 7.1.1
qtango 4.x
Notes for the developer:
Pisition, Acceleration, Speed are spectrum attributes with just one element.
So Spectrum push buttons and spectrum readers have been configured.
Tango devices used
------------------
sl/motor/trls_sl.04
Building
--------
qmake
make
Installed release
-----------------
release_01
Main customers
--------------
Errors & Troubleshooting
------------------------
If you experience problems, please contact:
giacomo.strangolino@elettra.trieste.it
graziano.scalamera@elettra.trieste.it
Thank you.
Sincrotrone Trieste s.c.p.a - ELETTRA Laboratory - Controls Group
/***************************************************************************
* Copyright (C) 2010 by Giacomo Strangolino,T2 PT 025,, *
* giacomo@runners *
* *
* 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 "xps.h"
#include <tutil.h> /* for setLoggingTarget() */
/* the following two are used to register the application to the window manager */
#include <X11/Xlib.h>
#include <QX11Info>
#include <elettracolors.h> /* to set elettra/booster/fermi palette */
#include <TApplication>
#include <TSplashScreen>
// #include <EStyleLoader> /* see comment below */
#define CVSVERSION "$Name: $"
int main( int argc, char ** argv ) {
/* introduced in version 3.1. To retrieve the version:
* 1. on the executable, execute `strings' and grep with "\$Name"
* 2. call qApp->applicationVersion
* 3. TApplication exports "version" on the DBus system.
*/
const char *cvs_version = CVSVERSION;
/* Create TApplication */
TApplication a( argc, argv );
/* make the version available through QApplication::instance()->applicationVersion()
* and through the DBus message bus.
*/
a.setApplicationVersion(cvs_version);
/* change "fermi" into "booster" or "elettra" to set booster/elettra palettes */
a.setPalette(EPalette("fermi"));
a.setApplicationName("xps");
/* comment the following properties if you are not interested in them.
* They are exported through QApplication and are available from any
* QTango widget by right clicking and executing the "Info" action
* of the menu.
*/
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"); /* name of the referent that provides the device server */
TUtil::instance()->setLoggingTarget(argv[0]);
/* load the style sheet for QTango application.
* The file is read from the "${INSTALL_ROOT}/share/qtango/stylesheets/qtango.css"
* file. You can load a custom stylesheet by exporting the environment variable
* "QTANGO_STYLESHEET" and setting it to a different path.
* Moreover, you can construct EStyleLoader with a file name as argument, to ignore
* the installed "${INSTALL_ROOT}/share/qtango/stylesheets/qtango.css" and the value
* of the environment variable.
*
* This does not work as expected in Qt version 4.4. Uncomment the following two lines
* when solved.
*/
// EStyleLoader sLoader;
// a.setStyleSheet(sLoader.styleSheet());
/* splash screen */
TSplashScreen splash;
xps mw;
if (argc > 1)
mw.setWindowTitle(QApplication::arguments()[1].split('/').last());
else
mw.setWindowTitle("xps");
mw.show();
/* hide splash screen */
splash.finish(&mw);
/* register to window manager */
Display *disp = QX11Info::display();
Window root_win = (Window) mw.winId();
XSetCommand(disp, root_win, argv, argc);
return a.exec();
}
#include "multiplier_pushbutton.h"
#include <QtDebug>
#include <simple_dataproxy.h>
#include <QMessageBox>
#include <QDateTime>
SpectrumMultiplierPushButton::SpectrumMultiplierPushButton(QWidget *parent) : TPushButton(parent)
{
d_factor = 1.0;
}
QList<TVariant> SpectrumMultiplierPushButton::execute(QVariant v)
{
QList<TVariant > tvret;
std::vector<double> input;
bool ok;
double val = d_proxy->getData().toDouble(&ok) * d_factor;
if(ok)
{
input.push_back(val);
QString tp = realTargets();
QString cmd = tp.split("->").last();
std::string dev = tp.split("->").first().toStdString();
try
{
Tango::DeviceProxy *devp = new Tango::DeviceProxy(dev);
DeviceData din;
din << input;
devp->command_inout(qstoc(cmd), din);
setToolTip(QString("Correctly imparted command \"%1(x%2)\" on "
"%3.\nPlease update this implementation when QTango 4.2.1 is available").
arg(cmd).arg(d_factor).arg(QDateTime::currentDateTime().toString()));
}
catch(Tango::DevFailed &e)
{
TLog log(e);
QMessageBox::critical(this, "Error executing command_inout",
QString("Error executing the command \"%1\" on the device \"%2\"\n%3").
arg(cmd).arg(QString::fromStdString(dev)).arg(log.formatMessage()));
setToolTip(QString("Failed to impart command \"%1(x%2)\" on "
"%3.\nPlease update this implementation when QTango 4.2.1 is available").
arg(cmd).arg(d_factor).arg(QDateTime::currentDateTime().toString()));
}
}
else
{
QMessageBox::information(this, "Error", "You must specify a value in the line edit");
if(dynamic_cast<QWidget *>(d_proxy))
dynamic_cast<QWidget *>(d_proxy)->setFocus();
}
return tvret;
}
QString SpectrumMultiplierPushButton::htmlHandleRepresentation()
{
QString ret;
ret += QString("<h3>Note</h3><p>This implementation directly uses Tango DeviceProxy::command_inout() "
"due to ticket 568 related to QVariantConverter in_type wrong detection.<br/>"
"Please ask the developer to migrate to QTango as soon as <em>4.2.1</em> version is "
"installed.</p>");
ret += ProxyInterface::htmlHandleRepresentation();
return ret;
}
#ifndef MULTIPLIER_PUSHBUTTON_H
#define MULTIPLIER_PUSHBUTTON_H
#include <TPushButton>
class SimpleDataProxy;
class SpectrumMultiplierPushButton : public TPushButton
{
Q_OBJECT
public:
SpectrumMultiplierPushButton(QWidget *parent);
void setFactor(double f) { d_factor = f; }
void setDataProxy(SimpleDataProxy *dp) { d_proxy = dp; }
virtual QString htmlHandleRepresentation();
protected:
QList<TVariant> execute(QVariant v);
double d_factor;
SimpleDataProxy *d_proxy;
};
#endif
/***************************************************************************
* Copyright (C) 2010 by Giacomo Strangolino,T2 PT 025,, *
* giacomo@runners *
* *
* 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 "xps.h"
#include <qtango.h>
xps::xps(QWidget *parent) : QWidget(parent)
{
ui.setupUi(this);
/* hide go home and init push buttons */
ui.tpbGoHome->setHidden(true);
ui.init_tPushButton->setHidden(true);
ui.fast_backward_pushButton->setFactor(5);
ui.fast_forward_pushButton->setFactor(5);
QList<SpectrumMultiplierPushButton *>multiB = findChildren<SpectrumMultiplierPushButton *>();
foreach(SpectrumMultiplierPushButton * b, multiB)
{
b->setDataProxy(ui.tleStep);
if(b->objectName().contains("backward"))
b->setTargets("$1->Backward");
else if(b->objectName().contains("forward"))
b->setTargets("$1->Forward");
}
/* need to setup readers group because the attributes are spectra
*/
/* 1. Position */
ReadersGroup *positionRG = new ReadersGroup(this);
positionRG->addReader(ui.tlPosition, 0);
positionRG->setSource("$1/position");
/* 2. Acceleration */
ReadersGroup *accelerationRG = new ReadersGroup(this);
accelerationRG->addReader(ui.tlAcceleration, 0);
accelerationRG->setSource("$1/acceleration");
/* 3. Speed */
ReadersGroup *speedRG = new ReadersGroup(this);
speedRG->addReader(ui.tlSpeed, 0);
speedRG->setSource("$1/speed");
/* Expert */
ReadersGroup *speedRGExpert = new ReadersGroup(this);
speedRGExpert->addReader(ui.tlSpeedExpert, 0);
speedRGExpert->setSource("$1/speed");
/* There are 2 spectrum buttons to configure: one in the Normal tab and
* one in the expert tab.
* setObjectNameList has been configured inside the designer.
*/
ui.tSpectrumButtonPosition->setTargets("$1/position");
ui.tSpectrumButtonSpeed->setTargets("$1/speed");
}
xps::~xps()
{
}
/***************************************************************************
* Copyright (C) 2010 by Giacomo Strangolino,T2 PT 025,, *
* giacomo@runners *
* *
* 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 xps_H
#define xps_H
#include "ui_xps.h"
class xps: public QWidget
{
Q_OBJECT
public:
xps(QWidget * =NULL);
~xps();
private:
Ui::xps ui;
};
#endif
<ui version="4.0" >
<class>xps</class>
<widget class="QWidget" name="xps" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>481</width>
<height>423</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_6" >
<item row="0" column="0" >
<widget class="QTabWidget" name="tabWidget" >
<property name="tabPosition" >
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex" >
<number>0</number>
</property>
<widget class="QWidget" name="main_tab" >
<attribute name="title" >
<string>Main</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5" >
<item rowspan="4" row="0" column="0" >
<widget class="QGroupBox" name="groupBox_3" >
<property name="title" >
<string>Position</string>
</property>
<layout class="QGridLayout" name="gridLayout_3" >
<item row="0" column="0" colspan="3" >
<widget class="TLabel" name="tlPosition" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="3" >
<widget class="TNumeric" name="tNumericPosition" >
<property name="targets" >
<string>;;</string>
</property>
</widget>
</item>
<item row="0" column="4" colspan="2" >
<widget class="TSpectrumButton" name="tSpectrumButtonPosition" >
<property name="text" >
<string>Ok</string>
</property>
<property name="objectNameList" >
<stringlist>
<string>tNumericPosition</string>
</stringlist>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="SpectrumMultiplierPushButton" name="fast_backward_pushButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="../../standa8smc1/standa8smc1.qrc" >
<normaloff>:/images/fast_left.png</normaloff>:/images/fast_left.png</iconset>
</property>
<property name="iconSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="SpectrumMultiplierPushButton" name="backward_pushButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="../../standa8smc1/standa8smc1.qrc" >
<normaloff>:/images/left.png</normaloff>:/images/left.png</iconset>
</property>
<property name="iconSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item row="1" column="4" >
<widget class="SpectrumMultiplierPushButton" name="forward_pushButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="../../standa8smc1/standa8smc1.qrc" >
<normaloff>:/images/right.png</normaloff>:/images/right.png</iconset>
</property>
<property name="iconSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item row="1" column="5" >
<widget class="SpectrumMultiplierPushButton" name="fast_forward_pushButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="../../standa8smc1/standa8smc1.qrc" >
<normaloff>:/images/fast_right.png</normaloff>:/images/fast_right.png</iconset>
</property>
<property name="iconSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item row="2" column="4" colspan="2" >
<widget class="QLabel" name="label_7" >
<property name="font" >
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text" >
<string>x1 x5</string>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="2" colspan="2" >
<widget class="TLineEdit" name="tleStep" >
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1" >
<widget class="TPushButton" name="stop_tPushButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>STOP</string>
</property>
<property name="targets" >
<string>$1->Stop;</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="TPushButton" name="init_tPushButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>INIT</string>
</property>
<property name="targets" >
<string>$1->Initialize;;;</string>
</property>
</widget>
</item>
<item row="3" column="1" >
<spacer name="verticalSpacer_2" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>34</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0" colspan="2" >
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string>movement</string>
</property>
<layout class="QGridLayout" name="gridLayout_2" >
<item row="0" column="0" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>acceleration</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_9" >
<property name="text" >
<string>speed</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="TLabel" name="tlSpeed" >