19 #include <QtCore/QString> 20 #include <QtCore/QThread> 21 #include <QtScript/QScriptEngine> 85 void completed(
const QString &error,
int scriptId);
107 void run(
const QString &
script,
int scriptId);
114 void runDirect(
const QString &command,
int scriptId);
122 void onScriptRequestingToQuit();
125 void doRun(
const QString &script);
128 void doRunDirect(
const QString &command,
int scriptId);
144 void startScriptEvaluation(
int scriptId);
147 void evalSystemJs(QScriptEngine * engine)
const;
153 QScriptEngine *mDirectScriptsEngine =
nullptr;
155 State mState = State::ready;
156 QHash<QString, QScriptEngine::FunctionSignature> mRegisteredUserFunctions;
157 QVector<std::function<void (QScriptEngine *)>> mCustomInitSteps;
161 QMutex mScriptStateMutex;
Definition: trikCommunicator.h:23
void brickBeep()
Plays "beep" sound.
Definition: scriptEngineWorker.cpp:183
Designed to support OS threads from a Qt Script.
Definition: threading.h:34
void getVariables(const QString &propertyName)
Emitted when there is a request for variables values.
void resetBrick()
Clears execution state and stops robot.
Definition: scriptEngineWorker.cpp:242
QScriptEngine * copyScriptEngine(const QScriptEngine *original)
Copies given script engine creating a new one with the same context as existing one.
Definition: scriptEngineWorker.cpp:382
void addCustomEngineInitStep(const std::function< void(QScriptEngine *)> &step)
Helper for adding custom initialization steps when creating script engine from outside of the TrikRun...
Definition: scriptEngineWorker.cpp:402
void completed(const QString &error, int scriptId)
Emitted when current script execution is completed or is aborted by reset() call. ...
Worker object to be run in a separate thread for Qt Script execution.
Definition: scriptEngineWorker.h:35
void runDirect(const QString &command, int scriptId)
Runs a command in a current context.
Definition: scriptEngineWorker.cpp:274
void variablesReady(const QJsonObject &data)
Emitted when variables values are ready.
void startedScript(int scriptId)
Emitted when new script is started.
ScriptEngineWorker(trikControl::BrickInterface &brick, trikNetwork::MailboxInterface *mailbox, ScriptExecutionControl &scriptControl)
Constructor.
Definition: scriptEngineWorker.cpp:162
Script execution controller, provides related functions to scripts.
Definition: scriptExecutionControl.h:24
void stopScript()
Stops script execution and resets script engine.
Definition: scriptEngineWorker.cpp:188
QStringList knownMethodNames() const
Gets all method names from executive objects (brick, script, etc.) from ScriptEngineWorker (useful wh...
Definition: scriptEngineWorker.cpp:427
void run(const QString &script, int scriptId)
Starts script evaluation, emits startedScript() signal and returns.
Definition: scriptEngineWorker.cpp:254
Allows communication between robots.
Definition: mailboxInterface.h:31
QScriptEngine * createScriptEngine(bool supportThreads=true)
Create and initialize a new script engine.
Definition: scriptEngineWorker.cpp:341
script
Definition: system.py:83
void registerUserFunction(const QString &name, QScriptEngine::FunctionSignature function)
Registers given C++ function as callable from script, with given name.
Definition: scriptEngineWorker.cpp:397
Interface representing TRIK controller board and devices installed on it, also provides access to per...
Definition: brickInterface.h:46