kbLogger 2.0.b1
The automotive ready test and logging program.
|
This class defines the API of the ScriptObject (so).
#include <script.h>
Public Slots | |
Message related functions. | |
void | sendCommand (QString strCommand) |
Sends a special, receiver specific command. | |
void | sendCommand (QString strTarget, QString strCommand) |
Sends a special, receiver specific command. | |
void | sendCommand (QString strTarget, QString strCommand, QString strMetadata) |
Sends a special, receiver specific command. | |
void | sendMessage (QString strPayload) |
Sends a message. | |
void | sendMessage (QString strTarget, QString strPayload) |
Sends a message. | |
void | sendMessage (QString strTarget, QString strPayload, QString strMetadata) |
Sends a message. | |
void | sendMessage (QString strTargetProject, QString strTarget, QString strPayload, QString strMetadata) |
Sends a message. | |
void | sendResponse (QString strPayload) |
Sends a response message. | |
void | sendResponse (QString strTarget, QString strPayload) |
Sends a response message. | |
void | sendResponse (QString strTarget, QString strPayload, QString strMetadata) |
Sends a response message. | |
Environment related functions. | |
void | useMSecsSinceEpochTimeStamp (bool bMsSinceEpoch) |
Causes kbLogger to call the processMessage method in the script with an integer representing the ms since epoch as a time stamp. | |
Timer related functions. | |
int | timerCreate (QString strCallback, QString strParam) |
Creates a timer. | |
void | timerRemove (int iTimer) |
Removes a timer. | |
void | timerRestart (int iTimer, int iMs) |
Restarts a timer. | |
void | timerStartCyclic (int iTimer, int iMs) |
Starts a cyclic timer. | |
void | timerStartSingle (int iTimer, int iMs) |
Starts a single shot timer. | |
void | timerStop (int iTimer) |
Stops a timer. | |
void | triggerWatchdog () |
Prevent the internal Watchdog from from throwing the timeout error. | |
ConfigItems related functions. | |
unsigned int | configItemCountReceiver (QString strTarget) |
Counts ConfigItems which are receivers from this one. | |
unsigned int | configItemCountSender (QString strSource) |
Counts ConfigItems which are senders to this one. | |
ConfigItem * | configItem (QString strConfigItem) |
Returns a config item which is a receiver or sender connected to this one. | |
Callback related functions. | |
int | callbackCreate (QString strPayload, QString strCallback) |
Creates a callback function. | |
int | callbackCreate (QString strPayload, QString strMetadata, QString strCallback) |
Creates a callback function. | |
void | callbackRemove (int iCallback) |
Removes a callback function. | |
Script execution related functions. | |
ScriptValue | extractVariable (QString strText, QString strDelimiter, QString strVariableName) |
Extracts a variable from the given text. | |
ScriptValue | getTimestamp () |
Returns the actual time stamp. | |
void | sleep (quint64 ms) |
Halts the execution of the script for a given time. | |
void | log (QString strText) |
Sends the given text to the log window. | |
void | trace (QString strText) |
Sends the given text to the trace window. | |
Project related functions. | |
QString | projectDir () |
Returns the full qualified name of the project path. | |
ProjectExplorer * | projectExplorer () |
Returns the ProjectExplorer object as void pointer (for usage in scripts). | |
kbLogger related functions related functions. | |
void | closeLogger (int exitCode) |
Closes the complete logger application. | |
Process related functions. | |
qint32 | processOpen (QString strEcecutable, QString strWorkingDir="") |
Opens an external processes. | |
void | processSetParameter (qint32 hProcess, QString strParameter) |
Appends a command line parameter to a process. | |
bool | processStart (qint32 hProcess, bool bStartDetached=true) |
Starts a process. | |
void | processClose (qint32 hProcess) |
Closes an external process. | |
void | processCloseAll () |
Close all external processes. | |
File related functions. | |
bool | fileExists (QString strFile) |
Checks if a file exists. | |
void * | fileOpen (QString strFile, QString strMode="rw") |
Opens a file. | |
quint64 | fileWrite (void *pFile, QString strText) |
Writes to a file. | |
QString | fileRead (void *pFile, quint64 length) |
Reads from a file. | |
QString | fileReadLine (void *pFile) |
Reads from a file a single line. | |
bool | fileSeek (void *pFile, quint64 pos) |
Sets the current position in a file. | |
bool | fileAtEnd (void *pFile) |
Retrieves true if the actual file position is at the end. | |
quint64 | fileSize (void *pFile) |
Retrieves the size of the file. | |
void | fileClose (void *pFile) |
Closes a file. | |
void | fileCloseAll () |
Closes all files. | |
bool | fileRemove (QString strFile) |
Removes the file. | |
Public Member Functions | |
void | startWatchdog () |
void | stopWatchdog () |
|
slot |
Creates a callback function and registers it in the java script interpreter. This function is called every time, a message arrives at the SciptObject and its payload causes a match in the regular expression in strPayload.
Example:
strPayload | A string containing a regular expression to test again the payload of every arrived message. |
strCallback | The name of the user defined callback function to call. |
|
slot |
Creates a callback function and registers it in the java script interpreter. This function is called every time, a message arrives at the SciptObject and its payload and its meta data causes a match in the regular expression in strPayload and in strMetadata.
Example:
strPayload | A string containing a regular expression to test the payload of every arrived message. |
strMetadata | A string containing a regular expression to test the meta data of every arrived message. |
strCallback | The name of the user defined callback function to call. |
|
slot |
Removes a callback function from the internal list. That means the callback function is not called anymore, even if the source code is contained in the java script file.
Example:
iCallback | The handle of the callback function to be removed. |
|
slot |
exitCode | Closes the complete logger application. |
|
slot |
Returns a config item which is a receiver or sender connected to this one. At first the receivers are searched, then the senders.
Example
strConfigItem | A string with a regular expression to match the AliasNames of the connected ConfigItems. |
|
slot |
Counts ConfigItems which are receivers from this one.
Example
strTarget | A string with a regular expression to match the AliasNames of the connected ConfigItems. |
|
slot |
Counts ConfigItems which are senders to this one.
Example
strSource | A string with a regular expression to match the AliasNames of the connected ConfigItems. |
|
slot |
Extracts a variable from the given text.
Example
strText | The text which contains the variables. |
strDelimiter | The regular expression which separates the variables. |
strVariableName | The name of the variable to search. |
|
slot |
Retrieves true if the actual file position is at the end.
Example
pFile | A handle to the file. |
|
slot |
|
slot |
|
slot |
Checks if a file exists.
Example
strFile | The file to check. |
|
slot |
Opens a file in read and/ or write mode. If the file does not exits and the file mode contains write access, the file will be created.
Example
strFile | The file to read and write. |
strMode | The access mode. Valid is "r", "w", "rw". |
|
slot |
Reads from the given file. The position to read can be set by fileSeek.
Example
pFile | The file handle. |
length | Amount of text to read in bytes. |
|
slot |
Reads from a file a single line.
Example
pFile | The file handle. |
|
slot |
Removes the file from the hard disk.
Example
strFile | The file to delete. |
|
slot |
Sets the current position to pos.
Example
pFile | A handle to the file. |
pos | The new read/write position. |
|
slot |
Retrieves the size of the file.
pFile | The file handle. |
|
slot |
Writes the given text to the given file. The position to write can be set by fileSeek.
Example
pFile | The file handle. |
strText | The text to write to the file. |
|
slot |
Returns the actual time stamp.
Example
|
slot |
Sends the given text to the log window.
Example
strLog | The text to log. |
|
slot |
Closes the given process. The external process is killed.
Example
hProcess | The process handle. |
|
slot |
Closes all processes. All external processes are killed.
Example
|
slot |
Opens an external process object, but does not start it.
Example:
strExecutable | The executable to start. |
strWorkingDir | Sets the working directory. If the is parameter is empty or not given, the project directory is used instead. |
|
slot |
Appends a start parameter to the parameter list of the given process.
Example
hProcess | The process handle. |
strParameter | The parameter. |
|
slot |
Starts the external process attached or detached. An attached process will be closed together with kbLogger. If the bStartDetached parameter is missing, the default value [true] is used.
Example
hProcess | The process handle. |
bStartDetached | True [default] if the process shall be started. |
|
slot |
Returns the full qualified project path.
Example This Example opens a excel sheet in the project directory.
|
slot |
Returns handle to the ProjectExplorer.
Example This Example shows how to open a new project from within a master project.
|
slot |
Sends a special, receiver specific command. This command is send as a broadcast to every receivers of this Script.
Example
strCommand | A string which contains the command which is interpreted by every receiver. |
|
slot |
Sends a special, receiver specific command. This command is not send as a broadcast to every receivers of this Script. Instead the receiver is searched in the list of connected ConfigItems and if found, called directly. Only the fist matching receiver is called.
Example
strTarget | The receiver of this command message. |
strCommand | A string which contains the command which is interpreted by the receiver. |
|
slot |
Sends a special, receiver specific command. This command is not send as a broadcast to every receivers of this Script. Instead the receiver is searched in the list of connected ConfigItems and if found, called directly. Only the fist matching receiver is called.
Example
strTarget | The receiver of this command message. |
strPayload | The user data for this command. |
strCommand | A string which contains the command which is interpreted by the receiver. |
|
slot |
Sends a message.
Example
This message is send as a broadcast to every receivers of this Script.
strPayload | The user data for this message. |
|
slot |
Sends a message. This message is not send as a broadcast to every receivers of this Script. Instead the receiver is searched in the list of connected ConfigItems and if found, called directly. Only the fist matching receiver is called.
Example
strTarget | The receiver of this message. |
strPayload | The user data for this message. |
|
slot |
Sends a message. This message is not send as a broadcast to every receivers of this Script. Instead the receiver is searched in the list of connected ConfigItems and if found, called directly. Only the fist matching receiver is called.
Example
strTarget | The receiver of this message. |
strPayload | The user data for this message. |
strMetadata | Additional data for this message. This can be the message type, communication channel or others. |
|
slot |
Sends a message. This message is not send as a broadcast to every receivers of this Script. Instead the receiver is searched by name in the target project and, if found, called directly. The names of the target project and the target item has to equal to the given parameters. If the target project is set to BROADCAST, all currently loaded projects will receive that message. Example
strTargetProject | The receiver project of this message. |
strTarget | The receiver ConfigItem of this message. |
strPayload | The user data for this message. |
strMetadata | Additional data for this message. This can be the message type, communication channel or others. |
|
slot |
Sends a response. A response is send in reverse arrow direction. This message is send as a broadcast to every sender of this Script.
Example
strPayload | The user data for this message. |
|
slot |
Sends a response. A response is send in reverse arrow direction. This message is not send as a broadcast to every sender of this Script. Instead the sender is searched in the list of connected ConfigItems and if found, called directly. Only the fist matching sender is called.
Example
strTarget | The receiver of this message. |
strPayload | The user data for this message. |
|
slot |
Sends a response. A response is send in reverse arrow direction. This message is not send as a broadcast to every sender of this Script. Instead the sender is searched in the list of connected ConfigItems and if found, called directly. Only the fist matching sender is called.
Example
strTarget | The receiver of this message. |
strPayload | The user data for this message. |
strMetadata | Additional data for this message. This can be the message type, communication channel or others. |
|
slot |
Halts the execution of the script for a given time.
Example
ms | The time in milliseconds to halt the execution. |
void startWatchdog | ( | ) |
void stopWatchdog | ( | ) |
|
slot |
Creates a timer. By using the parameter strParam it's possible to use a single callback function for different timers.
Example
strCallback | The name of the function to call when the timer elapsed. |
strParam | A (constant) parameter to handing over to the callback function. |
|
slot |
Removes a timer.
Example
iTimer | The handle of the timer to be removed. |
|
slot |
Restarts a timer but does not change its type (single or cyclic timer).
Example
iTimer | The handle to the timer. |
iMs | The timeout value in milliseconds. |
|
slot |
Starts a timer as cyclic timer.
Example
iTimer | The handle to the timer. |
iMs | The timeout value in milliseconds. |
|
slot |
Starts a timer as single shot timer.
Example
iTimer | The handle to the timer. |
iMs | The timeout value in milliseconds. |
|
slot |
Stops a timer.
Example
iTimer | The handle to the timer. |
|
slot |
Sends the given text to the trace window.
Example
strText | The text to trace. |
|
slot |
Triggers the Watchdog for this ScriptObject.
Each ScriptObject, TestObject, TranslatorObject and UserInterface has their own Watchdog. If the user script does not return after 1s, an JavaScript exception is thrown and the script is canceled. To avoid that and let the kbLogger internal events gets handled, the user needs to call this function periodically.
Example
|
slot |
Causes kbLogger to call the processMessage method in the script with an integer representing the ms since epoch as a time stamp. Without this call, the ScriptObject is using a string in this format: "YYYY.MM.DD HH:mm:ss:ms" .
Example
bMsSinceEpoch | Set this to true, if you want to use time stamps to be ms since epoch. |