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

Add new file

parent 1c7c49c5
Branches master
No related tags found
No related merge requests found
/***************************************************************************
* Copyright (C) 2006 by LZ *
* *
* *
* 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 "hv.h"
#include <X11/Xlib.h>
#include <QX11Info>
#include <tutil.h>
#include <QMessageBox>
int main( int argc, char ** argv ) {
TApplication a( argc, argv );
TUtil::instance()->setLoggingTarget(argv[0]);
if (argc < 2) {
QMessageBox::information(0, "Error in startup parameters",
QString("Error starting the program \"%1\"\nUsage:\n"
"%1 modulator_number\n"
"modulator_number: [1|2]\n").arg(
argv[0]).arg(argv[0]));
exit(EXIT_FAILURE);
}
/*
Rewrite parameters passed from command line. This is due to an unfair
constraint which limit the command line parameters to any Tango device
i.e. you can use parameters to connect a panel to whichever device
regardless of any assumption done by widgets in panel, but you cannot
pass any other type of parameter for whichever pursue it can be usefull.
The trick used here is to parse the appropriate command line parameters
and rewrite them in order to satisfy the completely misconceived
assumptions done by the method replaceWildcards()
*/
QString paramString;
if (!strcmp(argv[1], "1")) {
paramString = "p/mod/ross_p1 p/mod/hv_p1 p/mod/general_p1 booster/interlock/mod1";
}
else if (!strcmp(argv[1], "2")) {
paramString = "p/mod/ross_p2 p/mod/hv_p2 p/mod/general_p2 booster/interlock/mod2";
}
else if (!strcmp(argv[1], "10")) {
paramString = "f/mod/ross_f10 f/mod/hv_f10 f/mod/general_f10 f/mod/intlk_f10";
}
else {
QMessageBox::information(0, "Error in startup parameters",
QString("Error starting the program \"%1 %2\"\nUsage:\n"
"%1 modulator_number\n"
"modulator_number: [1|2]\n").arg(
argv[0]).arg(argv[1]));
exit(EXIT_FAILURE);
}
QStringList paramArray = paramString.split(" ");
hv mw;
// TUtil::replaceWildcards(mw.children(), a.arguments());
TUtil::replaceWildcards(mw.children(), paramArray);
mw.setWindowTitle(QString("Mod %1 HV").arg(qApp->arguments().at(1)));
mw.show();
/* register to window manager */
Display *disp = QX11Info::display();
Window root_win = (Window) mw.winId();
XSetCommand(disp, root_win, QApplication::argv(), QApplication::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