void MessageBoxInstance::buttonClicked() { bool ok = true; QString line; if(mMessageBox->clickedButton() == mMessageBox->button(QMessageBox::Yes)) { line = evaluateSubParameter(ok, mIfYes.actionParameter()); if(!ok) { closeAndDelete(); return; } if(mIfYes.action() == ActionTools::IfActionValue::GOTO) setNextLine(line); else if(mIfYes.action() == ActionTools::IfActionValue::CALLPROCEDURE) { if(!callProcedure(line)) { closeAndDelete(); return; } } } else if(mMessageBox->clickedButton() == mMessageBox->button(QMessageBox::No)) { line = evaluateSubParameter(ok, mIfNo.actionParameter()); if(!ok) { closeAndDelete(); return; } if(mIfNo.action() == ActionTools::IfActionValue::GOTO) setNextLine(line); else if(mIfNo.action() == ActionTools::IfActionValue::CALLPROCEDURE) { if(!callProcedure(line)) { closeAndDelete(); return; } } } closeAndDelete(); emit executionEnded(); }
int movie(char *command, const char *frameFile) { int failed = TRUE; double step; LINEBUF frameData[1]; register int j; static const char noDataMsg[] = "/** Data file does not define any fields **/"; if (*command == 'R' || *command == 'D' || *command == 'I') { loadData(infile); if (npnts < 1) return TRUE; step = (qmax - qmin) / (double) (npnts - 1); for (j = 0; j < npnts; j++) xtemp[j] = (double) j * step + qmin; if (extend(xtemp, npnts, lambda, lamdel, thedel) == NULL) return TRUE; } if (openBuf(frameFile, "r", frameData, FBUFFLEN) == NULL) noFile(frameFile); else { int frames; long headerOffset; frames = countData(frameData); headerOffset = locateHeader(frameData); if (headerOffset == -1) puts(noDataMsg); else { int numFields; setNextLine(frameData, headerOffset); getNextLine(frameData); numFields = loadFields(frameData, frameData->buffer+1); if (numFields == 0) puts(noDataMsg); else if (numFields > 0) { FILE *gnuPipe; genva(fields, 1, fitlist); gnuPipe = popen("gnuplot", "w"); if (gnuPipe != NULL) { failed = runMovie(npnts, frames, numFields, frameData, gnuPipe, command); pclose(gnuPipe); } } } closeBuf(frameData, 0); } return failed; }
int movie(char *command, int xspin[4], const char *frameFile) { int failed = TRUE; LINEBUF frameData[1]; static const char noDataMsg[] = "/** Data file does not define any fields **/"; /* Determine reflectivities to print */ setPspin(pspin, xspin, command + 1); if ((*command == 'R' || *command == 'D' || *command == 'I') && ( loadData(infile, xspin) || extend(q4x, n4x, lambda, lamdel, thedel) == NULL ) ) return TRUE; if (openBuf(frameFile, "r", frameData, FBUFFLEN) == NULL) noFile(frameFile); else { int frames; long headerOffset; frames = countData(frameData); headerOffset = locateHeader(frameData); if (headerOffset == -1) puts(noDataMsg); else { int numFields; setNextLine(frameData, headerOffset); getNextLine(frameData); numFields = loadFields(frameData, frameData->buffer + 1); if (numFields == 0) puts(noDataMsg); else if (numFields > 0) { FILE *gnuPipe; genva(fields, 1, fitlist); gnuPipe = popen("gnuplot", "w"); if (gnuPipe != NULL) { failed = runMovie(frames, numFields, frameData, gnuPipe, command); pclose(gnuPipe); } } } closeBuf(frameData, 0); } return failed; }
void WindowConditionInstance::checkWindow() { ActionTools::WindowHandle foundWindow = findWindow(); if((foundWindow.isValid() && mCondition == Exists) || (!foundWindow.isValid() && mCondition == DontExists)) { bool ok = true; QString line = evaluateSubParameter(ok, mIfTrue.actionParameter()); if(!ok) return; if(mIfTrue.action() == ActionTools::IfActionValue::GOTO) setNextLine(line); else if(mIfTrue.action() == ActionTools::IfActionValue::CALLPROCEDURE) { if(!callProcedure(line)) return; } mTimer.stop(); executionEnded(); } }
void FindImageInstance::searchFinished(const ActionTools::MatchingPointList &matchingPointList) { bool ok = true; if(matchingPointList.empty()) { setCurrentParameter(QStringLiteral("ifNotFound"), QStringLiteral("line")); QString line = evaluateSubParameter(ok, mIfNotFound.actionParameter()); if(!ok) return; if(mIfNotFound.action() == ActionTools::IfActionValue::GOTO) { setNextLine(line); executionEnded(); } else if(mIfNotFound.action() == ActionTools::IfActionValue::CALLPROCEDURE) { if(!callProcedure(line)) return; executionEnded(); } else if(mIfNotFound.action() == ActionTools::IfActionValue::WAIT) { mWaitTimer.start(mSearchDelay); } else executionEnded(); return; } if(mMaximumMatches == 1) { const ActionTools::MatchingPoint &bestMatchingPoint = matchingPointList.first(); QPoint position = bestMatchingPoint.position; if(mSource != WindowSource || !mWindowRelativePosition) position += mImagesToSearchIn.at(bestMatchingPoint.imageIndex).second.topLeft(); setVariable(mPositionVariableName, Code::Point::constructor(position, scriptEngine())); setVariable(mConfidenceVariableName, bestMatchingPoint.confidence); } else { QScriptValue arrayResult = scriptEngine()->newArray(matchingPointList.size()); QScriptValue arrayConfidenceResult = scriptEngine()->newArray(matchingPointList.size()); for(int i = 0; i < matchingPointList.size(); ++i) { const ActionTools::MatchingPoint &matchingPoint = matchingPointList.at(i); QPoint position = matchingPoint.position; if(mSource != WindowSource || !mWindowRelativePosition) position += mImagesToSearchIn.at(matchingPoint.imageIndex).second.topLeft(); arrayResult.setProperty(i, Code::Point::constructor(position, scriptEngine())); arrayConfidenceResult.setProperty(i, matchingPoint.confidence); } setVariable(mPositionVariableName, arrayResult); setVariable(mConfidenceVariableName, arrayConfidenceResult); } setCurrentParameter(QStringLiteral("ifFound"), QStringLiteral("line")); QString line = evaluateSubParameter(ok, mIfFound.actionParameter()); if(!ok) return; if(mIfFound.action() == ActionTools::IfActionValue::GOTO) { setNextLine(line); executionEnded(); } else if(mIfFound.action() == ActionTools::IfActionValue::CALLPROCEDURE) { if(!callProcedure(line)) return; executionEnded(); } else if(mIfFound.action() == ActionTools::IfActionValue::WAIT) { mWaitTimer.start(mSearchDelay); } else executionEnded(); }
void ActionInstance::setNextLine(int nextLine, bool doNotResetPreviousActions) { setNextLine(QString::number(nextLine), doNotResetPreviousActions); }
void WindowConditionInstance::startExecution() { bool ok = true; QString title = evaluateString(ok, QStringLiteral("title")); mCondition = evaluateListElement<Condition>(ok, conditions, QStringLiteral("condition")); mIfTrue = evaluateIfAction(ok, QStringLiteral("ifTrue")); ActionTools::IfActionValue ifFalse = evaluateIfAction(ok, QStringLiteral("ifFalse")); mPosition = evaluateVariable(ok, QStringLiteral("position")); mSize = evaluateVariable(ok, QStringLiteral("size")); mXCoordinate = evaluateVariable(ok, QStringLiteral("xCoordinate")); mYCoordinate = evaluateVariable(ok, QStringLiteral("yCoordinate")); mWidth = evaluateVariable(ok, QStringLiteral("width")); mHeight = evaluateVariable(ok, QStringLiteral("height")); mProcessId = evaluateVariable(ok, QStringLiteral("processId")); if(!ok) return; mTitleRegExp = QRegExp(title, Qt::CaseSensitive, QRegExp::WildcardUnix); ActionTools::WindowHandle foundWindow = findWindow(); if((foundWindow.isValid() && mCondition == Exists) || (!foundWindow.isValid() && mCondition == DontExists)) { QString line = evaluateSubParameter(ok, mIfTrue.actionParameter()); if(!ok) return; if(mIfTrue.action() == ActionTools::IfActionValue::GOTO) setNextLine(line); else if(mIfTrue.action() == ActionTools::IfActionValue::CALLPROCEDURE) { if(!callProcedure(line)) return; } executionEnded(); } else { QString line = evaluateSubParameter(ok, ifFalse.actionParameter()); if(!ok) return; if(ifFalse.action() == ActionTools::IfActionValue::GOTO) { setNextLine(line); executionEnded(); } else if(ifFalse.action() == ActionTools::IfActionValue::CALLPROCEDURE) { if(!callProcedure(line)) return; executionEnded(); } else if(ifFalse.action() == ActionTools::IfActionValue::WAIT) { connect(&mTimer, &QTimer::timeout, this, &WindowConditionInstance::checkWindow); mTimer.setInterval(100); mTimer.start(); } else executionEnded(); } }
void ActionInstance::setNextLine(int nextLine) { setNextLine(QString::number(nextLine)); }