$search
#include <ScriptingService.hpp>
Public Types | |
typedef std::vector < ProgramInterfacePtr > | Functions |
typedef ProgramInterface::Status | ProgramStatus |
typedef boost::shared_ptr < ScriptingService > | shared_ptr |
typedef scripting::StateMachine::Status | StateMachineStatus |
Public Member Functions | |
void | clear () |
bool | deleteProgram (const std::string &name) |
bool | deleteStateMachine (const std::string &name) |
bool | eval (const std::string &code) |
int | execute (const std::string &code) |
ProgramInterfacePtr | getProgram (const std::string &name) |
const ProgramInterfacePtr | getProgram (const std::string &name) const |
virtual int | getProgramLine (const std::string &name) const |
std::vector< std::string > | getProgramList () const |
ProgramStatus::ProgramStatus | getProgramStatus (const std::string &name) const |
std::string | getProgramStatusStr (const std::string &name) const |
virtual std::string | getProgramText (const std::string &name) const |
StateMachinePtr | getStateMachine (const std::string &name) |
const StateMachinePtr | getStateMachine (const std::string &name) const |
virtual int | getStateMachineLine (const std::string &name) const |
std::vector< std::string > | getStateMachineList () const |
StateMachineStatus::StateMachineStatus | getStateMachineStatus (const std::string &name) const |
std::string | getStateMachineStatusStr (const std::string &name) const |
virtual std::string | getStateMachineText (const std::string &name) const |
virtual Functions | loadFunctions (const std::string &code, const std::string &filename, bool do_throw) |
virtual Functions | loadFunctions (const std::string &filename, bool do_throw) |
bool | loadProgram (ProgramInterfacePtr pi) |
virtual bool | loadPrograms (const std::string &code, const std::string &filename, bool do_throw) |
virtual bool | loadPrograms (const std::string &filename, bool do_throw) |
bool | loadStateMachine (StateMachinePtr sc) |
virtual bool | loadStateMachines (const std::string &code, const std::string &filename, bool do_throw) |
virtual bool | loadStateMachines (const std::string &filename, bool do_throw) |
bool | runScript (const std::string &filename) |
ScriptingService (TaskContext *parent) | |
virtual bool | unloadProgram (const std::string &name, bool do_throw) |
bool | unloadProgram (const std::string &name) |
virtual bool | unloadStateMachine (const std::string &name, bool do_throw) |
bool | unloadStateMachine (const std::string &name) |
virtual | ~ScriptingService () |
Script State Machine Commands | |
bool | activateStateMachine (const std::string &name) |
bool | deactivateStateMachine (const std::string &name) |
bool | pauseStateMachine (const std::string &name) |
bool | requestStateMachineState (const std::string &name, const std::string &state) |
bool | resetStateMachine (const std::string &name) |
bool | startStateMachine (const std::string &name) |
bool | stopStateMachine (const std::string &name) |
Script State Machine OperationCallers | |
std::string | getStateMachineState (const std::string &name) const |
virtual bool | hasStateMachine (const std::string &name) const |
bool | inStateMachineError (const std::string &name) const |
bool | inStateMachineState (const std::string &name, const std::string &state) const |
bool | isStateMachineActive (const std::string &name) const |
bool | isStateMachinePaused (const std::string &name) const |
bool | isStateMachineRunning (const std::string &name) const |
Script Program OperationCallers | |
virtual bool | hasProgram (const std::string &name) const |
bool | inProgramError (const std::string &name) const |
bool | isProgramPaused (const std::string &name) const |
bool | isProgramRunning (const std::string &name) const |
Script Program Commands | |
bool | pauseProgram (const std::string &name) |
bool | startProgram (const std::string &name) |
bool | stepProgram (const std::string &name) |
bool | stopProgram (const std::string &name) |
Static Public Member Functions | |
static shared_ptr | Create (TaskContext *parent) |
Protected Types | |
typedef std::map< std::string, ProgramInterfacePtr > | ProgMap |
typedef ProgMap::const_iterator | ProgMapIt |
typedef std::map< std::string, StateMachinePtr > | StateMap |
typedef StateMap::const_iterator | StateMapIt |
Protected Member Functions | |
void | createInterface (void) |
bool | doExecute (const std::string &code) |
bool | doLoadPrograms (const std::string &filename) |
bool | doLoadProgramText (const std::string &code) |
bool | doLoadStateMachines (const std::string &filename) |
bool | doLoadStateMachineText (const std::string &code) |
bool | doUnloadProgram (const std::string &name) |
bool | doUnloadStateMachine (const std::string &name) |
bool | evalInternal (const std::string &filename, const std::string &code) |
bool | recursiveCheckLoadStateMachine (StateMachinePtr sc) |
bool | recursiveCheckUnloadStateMachine (StateMachinePtr si) |
void | recursiveLoadStateMachine (StateMachinePtr sc) |
void | recursiveUnloadStateMachine (StateMachinePtr sc) |
Protected Attributes | |
ProgMap | programs |
StatementProcessor * | sproc |
StateMap | states |
bool | ZeroPeriodWarning |
This interface allows to load program scripts and state machines and allows execution of code. It keeps track of all loaded scripts of the parent component. It can be found as the scripting object of a TaskContext.
Definition at line 60 of file ScriptingService.hpp.
typedef std::vector< ProgramInterfacePtr > RTT::scripting::ScriptingService::Functions |
List of executed functions.
Definition at line 224 of file ScriptingService.hpp.
typedef std::map<std::string,ProgramInterfacePtr> RTT::scripting::ScriptingService::ProgMap [protected] |
Definition at line 571 of file ScriptingService.hpp.
typedef ProgMap::const_iterator RTT::scripting::ScriptingService::ProgMapIt [protected] |
Definition at line 573 of file ScriptingService.hpp.
Definition at line 80 of file ScriptingService.hpp.
typedef boost::shared_ptr<ScriptingService> RTT::scripting::ScriptingService::shared_ptr |
Reimplemented from RTT::Service.
Definition at line 64 of file ScriptingService.hpp.
Definition at line 81 of file ScriptingService.hpp.
typedef std::map<std::string,StateMachinePtr> RTT::scripting::ScriptingService::StateMap [protected] |
Definition at line 567 of file ScriptingService.hpp.
typedef StateMap::const_iterator RTT::scripting::ScriptingService::StateMapIt [protected] |
Definition at line 569 of file ScriptingService.hpp.
RTT::ScriptingService::ScriptingService | ( | TaskContext * | parent | ) |
Creates a ScriptingService object. You need to add the service to parent yourself, or use Create().
Definition at line 60 of file ScriptingService.cpp.
RTT::ScriptingService::~ScriptingService | ( | ) | [virtual] |
Definition at line 73 of file ScriptingService.cpp.
bool RTT::scripting::ScriptingService::activateStateMachine | ( | const std::string & | name | ) |
Activate a previously loaded StateMachine.
name | The name of the StateMachine. |
void RTT::ScriptingService::clear | ( | ) |
Stop and unload all program scripts.
Reimplemented from RTT::Service.
Definition at line 81 of file ScriptingService.cpp.
ScriptingService::shared_ptr RTT::ScriptingService::Create | ( | TaskContext * | parent | ) | [static] |
Creates a ScriptingService object and registers the service to parent.
Definition at line 54 of file ScriptingService.cpp.
void RTT::ScriptingService::createInterface | ( | void | ) | [protected] |
Definition at line 437 of file ScriptingService.cpp.
bool RTT::scripting::ScriptingService::deactivateStateMachine | ( | const std::string & | name | ) |
Deactivate a stopped StateMachine.
name | The name of the StateMachine. |
bool RTT::scripting::ScriptingService::deleteProgram | ( | const std::string & | name | ) |
Completely discard a loaded Program.
program_unload_exception | if the program is not stopped or does not exist. |
bool RTT::scripting::ScriptingService::deleteStateMachine | ( | const std::string & | name | ) |
Delete a deactivated State Machine and all its children.
program_unload_exception | if the state machine or one of its children is still active. |
bool RTT::scripting::ScriptingService::doExecute | ( | const std::string & | code | ) | [protected] |
bool RTT::scripting::ScriptingService::doLoadPrograms | ( | const std::string & | filename | ) | [protected] |
bool RTT::scripting::ScriptingService::doLoadProgramText | ( | const std::string & | code | ) | [protected] |
bool RTT::scripting::ScriptingService::doLoadStateMachines | ( | const std::string & | filename | ) | [protected] |
bool RTT::scripting::ScriptingService::doLoadStateMachineText | ( | const std::string & | code | ) | [protected] |
bool RTT::scripting::ScriptingService::doUnloadProgram | ( | const std::string & | name | ) | [protected] |
bool RTT::scripting::ScriptingService::doUnloadStateMachine | ( | const std::string & | name | ) | [protected] |
bool RTT::scripting::ScriptingService::eval | ( | const std::string & | code | ) |
Evaluate and run all statements in code. This function is in functionality equivalent to runScript, except that runScript takes a filename as an argument, while this function takes the contents of the script itself as an argument. All possible syntax may be used.
code | A list of statements, program/function definitions etc. which get evaluated in the context of this component |
parse_exception | and its derivatives for parse errors in code. |
bool RTT::scripting::ScriptingService::evalInternal | ( | const std::string & | filename, | |
const std::string & | code | |||
) | [protected] |
int RTT::scripting::ScriptingService::execute | ( | const std::string & | code | ) |
ProgramInterfacePtr RTT::scripting::ScriptingService::getProgram | ( | const std::string & | name | ) |
const ProgramInterfacePtr RTT::scripting::ScriptingService::getProgram | ( | const std::string & | name | ) | const |
Get a pointer to a loaded Program.
virtual int RTT::scripting::ScriptingService::getProgramLine | ( | const std::string & | name | ) | const [virtual] |
Get the current line of execution of a loaded program script.
name | The name of the program. |
-1 | if the program does not exist. | |
0 | if the program is not running. | |
n | the line number if the program is executing. |
vector< string > RTT::ScriptingService::getProgramList | ( | ) | const |
Get a list of all loaded Programs.
Definition at line 387 of file ScriptingService.cpp.
ProgramStatus::ProgramStatus RTT::scripting::ScriptingService::getProgramStatus | ( | const std::string & | name | ) | const |
Return the status of a Program.
std::string RTT::scripting::ScriptingService::getProgramStatusStr | ( | const std::string & | name | ) | const |
Return the status of a Program as a human readable string.
virtual std::string RTT::scripting::ScriptingService::getProgramText | ( | const std::string & | name | ) | const [virtual] |
Get the original script description of a loaded program.
name | The name of the program. |
StateMachinePtr RTT::scripting::ScriptingService::getStateMachine | ( | const std::string & | name | ) |
Get a pointer to a loaded StateMachine.
const StateMachinePtr RTT::scripting::ScriptingService::getStateMachine | ( | const std::string & | name | ) | const |
Get a pointer to a loaded StateMachine.
virtual int RTT::scripting::ScriptingService::getStateMachineLine | ( | const std::string & | name | ) | const [virtual] |
Get the current line of execution of a loaded state machine script.
name | The name of the state machine. |
-1 | if the state machine does not exist. | |
0 | if the state machine is not running. | |
n | the line number if the state machine is executing. |
vector< string > RTT::ScriptingService::getStateMachineList | ( | ) | const |
Get a list of all loaded StateMachines and their children.
Definition at line 312 of file ScriptingService.cpp.
std::string RTT::scripting::ScriptingService::getStateMachineState | ( | const std::string & | name | ) | const |
Get the current state of a state machine.
name | The name of the StateMachine. |
StateMachineStatus::StateMachineStatus RTT::scripting::ScriptingService::getStateMachineStatus | ( | const std::string & | name | ) | const |
Return the status of a StateMachine.
std::string RTT::scripting::ScriptingService::getStateMachineStatusStr | ( | const std::string & | name | ) | const |
Return the status of a StateMachine as a human readable string
virtual std::string RTT::scripting::ScriptingService::getStateMachineText | ( | const std::string & | name | ) | const [virtual] |
Get the original script description of a loaded state machine.
name | The name of the state machine. |
virtual bool RTT::scripting::ScriptingService::hasProgram | ( | const std::string & | name | ) | const [virtual] |
Check if a program is loaded
name | The name of the program. |
virtual bool RTT::scripting::ScriptingService::hasStateMachine | ( | const std::string & | name | ) | const [virtual] |
Check if a state machine is loaded.
name | The name of the state machine. |
bool RTT::scripting::ScriptingService::inProgramError | ( | const std::string & | name | ) | const |
Inspect if a loaded program is in the error state
name | The name of the Program. |
bool RTT::scripting::ScriptingService::inStateMachineError | ( | const std::string & | name | ) | const |
Returns true if the state machine is in error.
name | The name of the StateMachine. |
bool RTT::scripting::ScriptingService::inStateMachineState | ( | const std::string & | name, | |
const std::string & | state | |||
) | const |
Check if a state machine is in a given state
name | The name of the StateMachine. | |
state | The state to enter. |
bool RTT::scripting::ScriptingService::isProgramPaused | ( | const std::string & | name | ) | const |
Inspect if a loaded program is in the paused state
name | The name of the Program. |
bool RTT::scripting::ScriptingService::isProgramRunning | ( | const std::string & | name | ) | const |
Inspect if a loaded program is in the running state
name | The name of the Program. |
bool RTT::scripting::ScriptingService::isStateMachineActive | ( | const std::string & | name | ) | const |
Returns true if the state machine has been activated.
name | The name of the StateMachine. |
bool RTT::scripting::ScriptingService::isStateMachinePaused | ( | const std::string & | name | ) | const |
Returns true if the state machine is paused.
name | The name of the StateMachine. |
bool RTT::scripting::ScriptingService::isStateMachineRunning | ( | const std::string & | name | ) | const |
Returns true if the state machine was successfully started.
name | The name of the StateMachine. |
virtual Functions RTT::scripting::ScriptingService::loadFunctions | ( | const std::string & | code, | |
const std::string & | filename, | |||
bool | do_throw | |||
) | [virtual] |
Load and execute a set of functions into the Program Processor for execution
code | A string containing the function definitions. | |
filename | The file name to use in the error messages. | |
do_throw | Set to yes to cause the parse errors to be thrown instead of being printed to the Logger interface. |
virtual Functions RTT::scripting::ScriptingService::loadFunctions | ( | const std::string & | filename, | |
bool | do_throw | |||
) | [virtual] |
Load and execute a set of functions into the Program Processor for execution
filename | The file to load | |
do_throw | Set to yes to cause the parse errors to be thrown instead of being printed to the Logger interface. |
bool RTT::ScriptingService::loadProgram | ( | ProgramInterfacePtr | pi | ) |
Load a new Program. The Processor takes full ownership and will delete it upon destruction.
program_load_exception | if a program with the same name already exists. |
Definition at line 349 of file ScriptingService.cpp.
virtual bool RTT::scripting::ScriptingService::loadPrograms | ( | const std::string & | code, | |
const std::string & | filename, | |||
bool | do_throw | |||
) | [virtual] |
Load a set of programs into the Program Processor for execution. The programs are just loaded, not started yet.
code | A string containing the function definitions. | |
filename | The file name to use in the error messages. | |
do_throw | Set to yes to cause the parse errors to be thrown instead of being printed to the Logger interface. |
virtual bool RTT::scripting::ScriptingService::loadPrograms | ( | const std::string & | filename, | |
bool | do_throw | |||
) | [virtual] |
Load a set of programs into the Program Processor for execution. The programs are just loaded, not started yet.
filename | The file to load | |
do_throw | Set to yes to cause the parse errors to be thrown instead of being printed to the Logger interface. |
bool RTT::ScriptingService::loadStateMachine | ( | StateMachinePtr | sc | ) |
Load a new State Machine and all its children.
program_load_exception | if a state machine with the same name already exists. |
Definition at line 174 of file ScriptingService.cpp.
virtual bool RTT::scripting::ScriptingService::loadStateMachines | ( | const std::string & | code, | |
const std::string & | filename, | |||
bool | do_throw | |||
) | [virtual] |
Load a set of state machines into the StateMachineProcessor for execution. The state machines are just loaded, not started yet.
code | A string containing the function definitions. | |
filename | The file name to use in the error messages. | |
do_throw | Set to yes to cause the parse errors to be thrown instead of being printed to the Logger interface. |
virtual bool RTT::scripting::ScriptingService::loadStateMachines | ( | const std::string & | filename, | |
bool | do_throw | |||
) | [virtual] |
Load a set of state machines into the StateMachineProcessor for execution. The state machines are just loaded, not started yet.
filename | The file to load | |
do_throw | Set to yes to cause the parse errors to be thrown instead of being printed to the Logger interface. |
bool RTT::scripting::ScriptingService::pauseProgram | ( | const std::string & | name | ) |
Pauses the execution of a running program.
name | The name of the Program. |
bool RTT::scripting::ScriptingService::pauseStateMachine | ( | const std::string & | name | ) |
Pause a previously activated StateMachine.
name | The name of the StateMachine. |
bool RTT::ScriptingService::recursiveCheckLoadStateMachine | ( | StateMachinePtr | sc | ) | [protected] |
Definition at line 199 of file ScriptingService.cpp.
bool RTT::ScriptingService::recursiveCheckUnloadStateMachine | ( | StateMachinePtr | si | ) | [protected] |
Definition at line 255 of file ScriptingService.cpp.
void RTT::ScriptingService::recursiveLoadStateMachine | ( | StateMachinePtr | sc | ) | [protected] |
Definition at line 219 of file ScriptingService.cpp.
void RTT::ScriptingService::recursiveUnloadStateMachine | ( | StateMachinePtr | sc | ) | [protected] |
Definition at line 277 of file ScriptingService.cpp.
bool RTT::scripting::ScriptingService::requestStateMachineState | ( | const std::string & | name, | |
const std::string & | state | |||
) |
Request a state change in a state machine.
name | The name of the StateMachine. | |
state | The state to enter. |
bool RTT::scripting::ScriptingService::resetStateMachine | ( | const std::string & | name | ) |
Resets the execution of a scripting::StateMachine and enters the Initial_State.
name | The name of the StateMachine. |
bool RTT::scripting::ScriptingService::runScript | ( | const std::string & | filename | ) |
Run a script which is stored in a file.
filename | The local file to load and execute |
parse_exception | and its derivatives for parse errors in code. |
bool RTT::scripting::ScriptingService::startProgram | ( | const std::string & | name | ) |
Start a Program.
name | The name of the Program. |
bool RTT::scripting::ScriptingService::startStateMachine | ( | const std::string & | name | ) |
Start a previously activated StateMachine.
name | The name of the StateMachine. |
bool RTT::scripting::ScriptingService::stepProgram | ( | const std::string & | name | ) |
Steps a single instruction of a paused program.
name | The name of the Program. |
bool RTT::scripting::ScriptingService::stopProgram | ( | const std::string & | name | ) |
Stops the execution of a program.
name | The name of the Program. |
bool RTT::scripting::ScriptingService::stopStateMachine | ( | const std::string & | name | ) |
Stops the execution of a scripting::StateMachine and enters the Final_State.
name | The name of the StateMachine. |
virtual bool RTT::scripting::ScriptingService::unloadProgram | ( | const std::string & | name, | |
bool | do_throw | |||
) | [virtual] |
Unload a program from the Program Processor.
name | The name of the loaded program. | |
do_throw | Set to yes to cause the unloading errors to be thrown instead of being printed to the Logger interface. |
bool RTT::scripting::ScriptingService::unloadProgram | ( | const std::string & | name | ) |
Unload a program from this processor.
program_unload_exception | if the program is not stopped or does not exist. |
virtual bool RTT::scripting::ScriptingService::unloadStateMachine | ( | const std::string & | name, | |
bool | do_throw | |||
) | [virtual] |
Unload a state machine from the StateMachineProcessor.
name | The name of the loaded program. | |
do_throw | Set to yes to cause the unloading errors to be thrown instead of being printed to the Logger interface. |
bool RTT::scripting::ScriptingService::unloadStateMachine | ( | const std::string & | name | ) |
Unload a deactivated State Machine and all its children.
program_unload_exception | if the state machine or one of its children is still active. |
ProgMap RTT::scripting::ScriptingService::programs [protected] |
Definition at line 572 of file ScriptingService.hpp.
Definition at line 548 of file ScriptingService.hpp.
StateMap RTT::scripting::ScriptingService::states [protected] |
Definition at line 568 of file ScriptingService.hpp.
bool RTT::scripting::ScriptingService::ZeroPeriodWarning [protected] |
This is a property of the Scripting service It is true by default If this is set to false, the warning log when loading a program or a state machine into a Component with a null period will not be printed.
Be sure you have something else triggering periodically your Component activity unless your script may not work.
Definition at line 583 of file ScriptingService.hpp.