trikRuntime
trikScriptRunner::PythonEngineWorker Class Reference

Worker object to be run in a separate thread for Python execution. More...

#include <pythonEngineWorker.h>

Inheritance diagram for trikScriptRunner::PythonEngineWorker:
Collaboration diagram for trikScriptRunner::PythonEngineWorker:

Public Slots

void run (const QString &script)
 Starts script evaluation, emits startedScript() signal and returns. More...
 
void runDirect (const QString &command)
 Runs a command in a current context. More...
 
void init ()
 Initializes PythonQt and creates new main module, which will be used by user Must be invoked (called by the same thread as run or runDirect) Calls initTrik() More...
 
bool recreateContext ()
 Recreates Main Context made by init, returns true when were errors. More...
 
void brickBeep ()
 Plays "beep" sound. More...
 
void sendStdOutMessage (const QString &text)
 Sends message to listeners. More...
 

Signals

void completed (const QString &error, int scriptId)
 Emitted when current script execution is completed or is aborted by reset() call. More...
 
void startedScript (const QString &fileName, int scriptId)
 Emitted when new script is started. More...
 
void startedDirectScript (int scriptId)
 Emitted when new direct script is started. More...
 
void inited ()
 When engine was inited. More...
 
void sendMessage (const QString &)
 Some message to send, for example, from stdout. More...
 

Public Member Functions

 PythonEngineWorker (trikControl::BrickInterface &brick, trikNetwork::MailboxInterface *mailbox)
 Constructor. More...
 
 ~PythonEngineWorker ()
 
void resetBrick ()
 Clears execution state and stops robot. More...
 
void stopScript ()
 Stops script execution and resets script engine. More...
 
QStringList knownNames () const
 Report known objects and methods for autocompletion. More...
 

Detailed Description

Worker object to be run in a separate thread for Python execution.

Constructor & Destructor Documentation

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

Constructor.

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

Member Function Documentation

void PythonEngineWorker::brickBeep ( )
slot

Plays "beep" sound.

Can be safely called from other threads.

void trikScriptRunner::PythonEngineWorker::completed ( const QString &  error,
int  scriptId 
)
signal

Emitted when current script execution is completed or is aborted by reset() call.

Parameters
error- localized error message or empty string.
scriptId- unique identifier of a script completed
void PythonEngineWorker::init ( )
slot

Initializes PythonQt and creates new main module, which will be used by user Must be invoked (called by the same thread as run or runDirect) Calls initTrik()

TODO: Must point to local .zip file

void trikScriptRunner::PythonEngineWorker::inited ( )
signal

When engine was inited.

QStringList PythonEngineWorker::knownNames ( ) const

Report known objects and methods for autocompletion.

TODO: TrikScriptRunnerInterface::Helper::collectMethodNames(result, mScriptControl.metaObject());

TODO: TrikScriptRunnerInterface::Helper::collectMethodNames(result, mThreading.metaObject());

bool PythonEngineWorker::recreateContext ( )
slot

Recreates Main Context made by init, returns true when were errors.

void PythonEngineWorker::resetBrick ( )

Clears execution state and stops robot.

Can be safely called from other threads.

void PythonEngineWorker::run ( const QString &  script)
slot

Starts script evaluation, emits startedScript() signal and returns.

Script will be executed asynchronously. completed() signal is emitted upon script abortion or completion. It is a caller's responsibility to ensure that PythonEngineWorker is in ready state before a call to run() by calling reset() first.

Parameters
script- QtScript code to evaluate Can be safely called from other threads.
void PythonEngineWorker::runDirect ( const QString &  command)
slot

Runs a command in a current context.

Permits to run a script line by line. The command will be executed asynchronously. If called when an ordinary script is running, that script would be aborted before evaluation of a command. In this mode, threads and messages are unsupported. Can be safely called from other threads.

void trikScriptRunner::PythonEngineWorker::sendMessage ( const QString &  )
signal

Some message to send, for example, from stdout.

void PythonEngineWorker::sendStdOutMessage ( const QString &  text)
slot

Sends message to listeners.

void trikScriptRunner::PythonEngineWorker::startedDirectScript ( int  scriptId)
signal

Emitted when new direct script is started.

Parameters
scriptId- unique identifier assigned to a newly started script.
void trikScriptRunner::PythonEngineWorker::startedScript ( const QString &  fileName,
int  scriptId 
)
signal

Emitted when new script is started.

Parameters
scriptId- unique identifier assigned to a newly started script.
void PythonEngineWorker::stopScript ( )

Stops script execution and resets script engine.

Can be called from another thread. By the end of call the worker would be in a ready state. Can be safely called from other threads.

Todo:
: is it actually stopped?

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