trikRuntime
trikScriptRunner::TrikJavaScriptRunner Class Reference

Executes scripts in Qt Scripting Engine. More...

#include <trikJavaScriptRunner.h>

Inheritance diagram for trikScriptRunner::TrikJavaScriptRunner:
Collaboration diagram for trikScriptRunner::TrikJavaScriptRunner:

Public Slots

void run (const QString &script, const QString &fileName="") override
 
void runDirectCommand (const QString &command) override
 
void abort () override
 
void brickBeep () override
 
- Public Slots inherited from trikScriptRunner::TrikScriptRunnerInterface
virtual void run (const QString &script, const QString &fileName="")=0
 Executes given script asynchronously. More...
 
virtual void runDirectCommand (const QString &command)=0
 Executes given script as direct command, so it will use existing script execution environment (or create one if needed) and will not reset execution state before or after execution. More...
 
virtual void abort ()=0
 Aborts script execution. More...
 
virtual void brickBeep ()=0
 Plays "beep" sound. More...
 

Public Member Functions

 TrikJavaScriptRunner (trikControl::BrickInterface &brick, trikNetwork::MailboxInterface *mailbox)
 Constructor. More...
 
 ~TrikJavaScriptRunner ()
 
void registerUserFunction (const QString &name, QScriptEngine::FunctionSignature function) override
 Registers given C++ function as callable from script, with given name. More...
 
void addCustomEngineInitStep (const std::function< void(QScriptEngine *)> &step) override
 Adds custom initialization steps when creating script engine (useful when used from outside of the TrikRuntime). More...
 
QStringList knownMethodNames () const override
 Gets all method names from executive objects (brick, script, etc.) from ScriptEngineWorker (useful when used from outside of the TrikRuntime). More...
 
bool wasError () override
 Get status of last direct command/script. More...
 

Additional Inherited Members

- Signals inherited from trikScriptRunner::TrikScriptRunnerInterface
void completed (const QString &error, int scriptId)
 Emitted when current script completes execution (for event-driven mode it means that script requested to quit or was aborted). More...
 
void startedScript (const QString &fileName, int scriptId)
 Emitted when new script from file started. More...
 
void startedDirectScript (int scriptId)
 Emitted when new direct script started. More...
 
void sendMessage (const QString &text)
 Emitted when a message must be sent to a desktop. More...
 

Detailed Description

Executes scripts in Qt Scripting Engine.

Constructor & Destructor Documentation

TrikJavaScriptRunner::TrikJavaScriptRunner ( trikControl::BrickInterface brick,
trikNetwork::MailboxInterface mailbox 
)

Constructor.

Parameters
brick- reference to trikControl::Brick instance.
mailbox- mailbox object used to communicate with other robots.
TrikJavaScriptRunner::~TrikJavaScriptRunner ( )

Member Function Documentation

void TrikJavaScriptRunner::abort ( )
overrideslot
void TrikJavaScriptRunner::addCustomEngineInitStep ( const std::function< void(QScriptEngine *)> &  step)
overridevirtual

Adds custom initialization steps when creating script engine (useful when used from outside of the TrikRuntime).

Implements trikScriptRunner::TrikScriptRunnerInterface.

void TrikJavaScriptRunner::brickBeep ( )
overrideslot
QStringList TrikJavaScriptRunner::knownMethodNames ( ) const
overridevirtual

Gets all method names from executive objects (brick, script, etc.) from ScriptEngineWorker (useful when used from outside of the TrikRuntime).

Implements trikScriptRunner::TrikScriptRunnerInterface.

void TrikJavaScriptRunner::registerUserFunction ( const QString &  name,
QScriptEngine::FunctionSignature  function 
)
overridevirtual

Registers given C++ function as callable from script, with given name.

Implements trikScriptRunner::TrikScriptRunnerInterface.

void TrikJavaScriptRunner::run ( const QString &  script,
const QString &  fileName = "" 
)
overrideslot
void TrikJavaScriptRunner::runDirectCommand ( const QString &  command)
overrideslot
bool trikScriptRunner::TrikJavaScriptRunner::wasError ( )
inlineoverridevirtual

Get status of last direct command/script.

Implements trikScriptRunner::TrikScriptRunnerInterface.


The documentation for this class was generated from the following files: