added timeout facility for musrfit, musrview, musrt0. Adopted musredit/musrgui accordingly.
This commit is contained in:
@@ -69,7 +69,9 @@ bool PAdminXMLParser::startElement( const QString&, const QString&,
|
||||
const QString& qName,
|
||||
const QXmlAttributes& )
|
||||
{
|
||||
if (qName == "font_name") {
|
||||
if (qName == "timeout") {
|
||||
fKeyWord = eTimeout;
|
||||
} else if (qName == "font_name") {
|
||||
fKeyWord = eFontName;
|
||||
} else if (qName == "font_size") {
|
||||
fKeyWord = eFontSize;
|
||||
@@ -196,6 +198,11 @@ bool PAdminXMLParser::characters(const QString& str)
|
||||
int ival;
|
||||
|
||||
switch (fKeyWord) {
|
||||
case eTimeout:
|
||||
ival = QString(str.toLatin1()).trimmed().toInt(&ok);
|
||||
if (ok)
|
||||
fAdmin->setTimeout(ival);
|
||||
break;
|
||||
case eFontName:
|
||||
fAdmin->setFontName(QString(str.toLatin1()).trimmed());
|
||||
break;
|
||||
@@ -529,6 +536,8 @@ QString PAdminXMLParser::expandPath(const QString &str)
|
||||
*/
|
||||
PAdmin::PAdmin()
|
||||
{
|
||||
fTimeout = 3600;
|
||||
|
||||
fFontName = QString("Courier"); // default font
|
||||
fFontSize = 11; // default font size
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ class PAdminXMLParser : public QXmlDefaultHandler
|
||||
virtual ~PAdminXMLParser() {}
|
||||
|
||||
private:
|
||||
enum EAdminKeyWords {eEmpty, eFontName, eFontSize, eExecPath, eDefaultSavePath, eTitleFromDataFile, eEnableMusrT0,
|
||||
enum EAdminKeyWords {eEmpty, eTimeout, eFontName, eFontSize, eExecPath, eDefaultSavePath, eTitleFromDataFile, eEnableMusrT0,
|
||||
eBeamline, eInstitute, eFileFormat, eLifetimeCorrection, eMsrDefaultFilePath,
|
||||
eTheoFuncPixmapPath, eFunc, eFuncName, eFuncComment, eFuncLabel,
|
||||
eFuncPixmap, eFuncParams, eHelpMain, eHelpTitle, eHelpParameters, eHelpTheory, eHelpFunctions,
|
||||
@@ -112,6 +112,7 @@ class PAdmin
|
||||
PAdmin();
|
||||
virtual ~PAdmin() {}
|
||||
|
||||
int getTimeout() { return fTimeout; }
|
||||
QString getFontName() { return fFontName; }
|
||||
int getFontSize() { return fFontSize; }
|
||||
QString getExecPath() { return fExecPath; }
|
||||
@@ -133,6 +134,7 @@ class PAdmin
|
||||
void setFontSize(const int ival) { fFontSize = ival; }
|
||||
|
||||
protected:
|
||||
void setTimeout(const int ival) { fTimeout = ival; }
|
||||
void setExecPath(const QString str) { fExecPath = str; }
|
||||
void setDefaultSavePath(const QString str) { fDefaultSavePath = str; }
|
||||
void setTitleFromDataFileFlag(const bool flag) { fTitleFromDataFile = flag; }
|
||||
@@ -149,6 +151,8 @@ class PAdmin
|
||||
private:
|
||||
friend class PAdminXMLParser;
|
||||
|
||||
int fTimeout; ///< timeout in seconds
|
||||
|
||||
QString fFontName; ///< default font name
|
||||
int fFontSize; ///< default font size
|
||||
|
||||
|
||||
@@ -667,7 +667,7 @@ bool PTextEdit::validRunList(const QString runList)
|
||||
int i = 0;
|
||||
QString subStr;
|
||||
bool done = false;
|
||||
int val;
|
||||
int val = 0;
|
||||
bool ok;
|
||||
while (!done) {
|
||||
subStr = runList.section(' ', i, i, QString::SectionSkipEmpty);
|
||||
@@ -1655,6 +1655,12 @@ void PTextEdit::musrFit()
|
||||
break;
|
||||
}
|
||||
|
||||
// add timeout
|
||||
cmd.append("--timeout");
|
||||
QString numStr;
|
||||
numStr.setNum(fAdmin->getTimeout());
|
||||
cmd.append(numStr);
|
||||
|
||||
PFitOutputHandler fitOutputHandler(QFileInfo(*fFilenames.find( currentEditor() )).absolutePath(), cmd);
|
||||
fitOutputHandler.setModal(true);
|
||||
fFileSystemWatcherActive = false;
|
||||
@@ -2058,9 +2064,11 @@ void PTextEdit::musrView()
|
||||
cmd = str + " \"";
|
||||
|
||||
str = *fFilenames.find( currentEditor() );
|
||||
cmd += str + "\" &";
|
||||
QString numStr;
|
||||
numStr.setNum(fAdmin->getTimeout());
|
||||
cmd += str + "\" --timeout " + numStr + " &";
|
||||
|
||||
system(cmd.toLatin1());
|
||||
int status=system(cmd.toLatin1());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@@ -2089,9 +2097,11 @@ void PTextEdit::musrT0()
|
||||
cmd = str + " \"";
|
||||
|
||||
str = *fFilenames.find( currentEditor() );
|
||||
cmd += str + "\" &";
|
||||
QString numStr;
|
||||
numStr.setNum(fAdmin->getTimeout());
|
||||
cmd += str + "\" --timeout " + numStr + " &";
|
||||
|
||||
system(cmd.toLatin1());
|
||||
int status=system(cmd.toLatin1());
|
||||
|
||||
QString fln = *fFilenames.find( currentEditor() );
|
||||
}
|
||||
@@ -2166,13 +2176,13 @@ void PTextEdit::musrSwapMsrMlog()
|
||||
// swap files
|
||||
QString cmd;
|
||||
cmd = QString("cp \"") + currentFileName + QString("\" \"") + tempFileName + QString("\"");
|
||||
system(cmd.toLatin1());
|
||||
int status=system(cmd.toLatin1());
|
||||
cmd = QString("cp \"") + swapFileName + QString("\" \"") + currentFileName + QString("\"");
|
||||
system(cmd.toLatin1());
|
||||
status=system(cmd.toLatin1());
|
||||
cmd = QString("cp \"") + tempFileName + QString("\" \"") + swapFileName + QString("\"");
|
||||
system(cmd.toLatin1());
|
||||
status=system(cmd.toLatin1());
|
||||
cmd = QString("rm \"") + tempFileName + QString("\"");
|
||||
system(cmd.toLatin1());
|
||||
status=system(cmd.toLatin1());
|
||||
|
||||
int currentIdx = fTabWidget->currentIndex();
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
<font_name>Courier</font_name>
|
||||
<font_size>12</font_size>
|
||||
</font_settings>
|
||||
<timeout>3600</timeout>
|
||||
<msr_file_defaults>
|
||||
<beamline>mue4</beamline>
|
||||
<institute>psi</institute>
|
||||
|
||||
Reference in New Issue
Block a user