trikRuntime
trikScriptRunner::ScriptExecutionControl Class Reference

Script execution controller, provides related functions to scripts. More...

#include <scriptExecutionControl.h>

Inheritance diagram for trikScriptRunner::ScriptExecutionControl:
Collaboration diagram for trikScriptRunner::ScriptExecutionControl:

Public Slots

void run ()
 Starts event loop for script. More...
 
void quit ()
 Aborts script execution. More...
 
void reset ()
 Resets script execution state, clearing all flags and stopping all timers. More...
 

Signals

void quitSignal ()
 Emitted when script requested system to abort execution. More...
 
void stopWaiting ()
 To be connected to quit() slot of local event loops that are used for waiting. More...
 
void sendMessage (const QString &text)
 Requests sending a message to a desktop. More...
 

Public Member Functions

 ~ScriptExecutionControl () override
 
bool isInEventDrivenMode () const
 Returns true if a script is in event-driven running mode, so it shall wait for events when script is executed. More...
 
Q_INVOKABLE QTimer * timer (int milliseconds)
 Starts a new timer with given interval and returns reference to it. More...
 
Q_INVOKABLE void wait (const int &milliseconds)
 Waits given amount of time in milliseconds and returns. More...
 
Q_INVOKABLE qint64 time () const
 Returns the number of milliseconds since 1970-01-01T00:00:00 UTC. More...
 
Q_INVOKABLE int random (int from, int to) const
 Returns random number from an interval [from, to]. More...
 
Q_INVOKABLE void system (const QString &command, bool synchronously=false)
 Execute given sh command. More...
 
Q_INVOKABLE void writeToFile (const QString &file, const QString &text)
 Appends given text to the end of a file. More...
 
Q_INVOKABLE QStringList readAll (const QString &file) const
 Reads all lines from a text file and returns it as a list of strings. More...
 
Q_INVOKABLE void removeFile (const QString &file)
 Removes a file. More...
 

Detailed Description

Script execution controller, provides related functions to scripts.

Constructor & Destructor Documentation

ScriptExecutionControl::~ScriptExecutionControl ( )
override

Member Function Documentation

bool ScriptExecutionControl::isInEventDrivenMode ( ) const

Returns true if a script is in event-driven running mode, so it shall wait for events when script is executed.

If it is false, script will exit immediately.

void ScriptExecutionControl::quit ( )
slot

Aborts script execution.

void trikScriptRunner::ScriptExecutionControl::quitSignal ( )
signal

Emitted when script requested system to abort execution.

int ScriptExecutionControl::random ( int  from,
int  to 
) const

Returns random number from an interval [from, to].

QStringList ScriptExecutionControl::readAll ( const QString &  file) const

Reads all lines from a text file and returns it as a list of strings.

void ScriptExecutionControl::removeFile ( const QString &  file)

Removes a file.

void ScriptExecutionControl::reset ( )
slot

Resets script execution state, clearing all flags and stopping all timers.

void ScriptExecutionControl::run ( )
slot

Starts event loop for script.

void trikScriptRunner::ScriptExecutionControl::sendMessage ( const QString &  text)
signal

Requests sending a message to a desktop.

void trikScriptRunner::ScriptExecutionControl::stopWaiting ( )
signal

To be connected to quit() slot of local event loops that are used for waiting.

void ScriptExecutionControl::system ( const QString &  command,
bool  synchronously = false 
)

Execute given sh command.

qint64 ScriptExecutionControl::time ( ) const

Returns the number of milliseconds since 1970-01-01T00:00:00 UTC.

QTimer * ScriptExecutionControl::timer ( int  milliseconds)

Starts a new timer with given interval and returns reference to it.

void ScriptExecutionControl::wait ( const int &  milliseconds)

Waits given amount of time in milliseconds and returns.

void ScriptExecutionControl::writeToFile ( const QString &  file,
const QString &  text 
)

Appends given text to the end of a file.


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