$search

RTT::scripting::ScriptingService Class Reference

#include <ScriptingService.hpp>

Inheritance diagram for RTT::scripting::ScriptingService:
Inheritance graph
[legend]

List of all members.

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
StatementProcessorsproc
StateMap states
bool ZeroPeriodWarning

Detailed Description

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.


Member Typedef Documentation

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.

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.


Constructor & Destructor Documentation

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.


Member Function Documentation

bool RTT::scripting::ScriptingService::activateStateMachine ( const std::string &  name  ) 

Activate a previously loaded StateMachine.

Parameters:
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.

Parameters:
name The name of the StateMachine.
bool RTT::scripting::ScriptingService::deleteProgram ( const std::string &  name  ) 

Completely discard a loaded Program.

Exceptions:
program_unload_exception if the program is not stopped or does not exist.
Deprecated:
by unloadProgram
bool RTT::scripting::ScriptingService::deleteStateMachine ( const std::string &  name  ) 

Delete a deactivated State Machine and all its children.

Exceptions:
program_unload_exception if the state machine or one of its children is still active.
Deprecated:
by unloadStateMachine
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.

Parameters:
code A list of statements, program/function definitions etc. which get evaluated in the context of this component
Returns:
true if the parsing and execution succeeded (= no syntax errors and no exceptions thrown when executing code ), false otherwise.
Exceptions:
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  ) 

Parse and execute a statement.

Parameters:
code A single statement to execute.
Returns:
A ticket number.
Return values:
-1 if the code could not be parsed.
0 if the code was an expression and could be executed.
>0 if the code was a command and is being executed.
See also:
getCommand
Deprecated:
by eval()
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.

Parameters:
name The name of the program.
Returns:
The line number.
Return values:
-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.

Parameters:
name The name of the program.
Returns:
A string containing only that 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.

Parameters:
name The name of the state machine.
Returns:
The line number.
Return values:
-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.

Parameters:
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.

Parameters:
name The name of the state machine.
Returns:
A string containing only that state machine.
virtual bool RTT::scripting::ScriptingService::hasProgram ( const std::string &  name  )  const [virtual]

Check if a program is loaded

Parameters:
name The name of the program.
Returns:
True if so.
virtual bool RTT::scripting::ScriptingService::hasStateMachine ( const std::string &  name  )  const [virtual]

Check if a state machine is loaded.

Parameters:
name The name of the state machine.
Returns:
True if so.
bool RTT::scripting::ScriptingService::inProgramError ( const std::string &  name  )  const

Inspect if a loaded program is in the error state

Parameters:
name The name of the Program.
Returns:
true if so.
bool RTT::scripting::ScriptingService::inStateMachineError ( const std::string &  name  )  const

Returns true if the state machine is in error.

Parameters:
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

Parameters:
name The name of the StateMachine.
state The state to enter.
Returns:
true if so.
bool RTT::scripting::ScriptingService::isProgramPaused ( const std::string &  name  )  const

Inspect if a loaded program is in the paused state

Parameters:
name The name of the Program.
Returns:
true if so.
bool RTT::scripting::ScriptingService::isProgramRunning ( const std::string &  name  )  const

Inspect if a loaded program is in the running state

Parameters:
name The name of the Program.
Returns:
true if so.
bool RTT::scripting::ScriptingService::isStateMachineActive ( const std::string &  name  )  const

Returns true if the state machine has been activated.

Parameters:
name The name of the StateMachine.
bool RTT::scripting::ScriptingService::isStateMachinePaused ( const std::string &  name  )  const

Returns true if the state machine is paused.

Parameters:
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.

Parameters:
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

Parameters:
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.
Returns:
A list of functions loaded in the ProgramProcessor.
Deprecated:
by runScript
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

Parameters:
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.
Returns:
A list of functions loaded in the ProgramProcessor.
Deprecated:
by runScript
bool RTT::ScriptingService::loadProgram ( ProgramInterfacePtr  pi  ) 

Load a new Program. The Processor takes full ownership and will delete it upon destruction.

Exceptions:
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.

Parameters:
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.
Returns:
true if all state machines could be loaded in the ProgramProcessor.
Deprecated:
by runScript
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.

Parameters:
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.
Returns:
true if all state machines could be loaded in the ProgramProcessor.
Deprecated:
by runScript
bool RTT::ScriptingService::loadStateMachine ( StateMachinePtr  sc  ) 

Load a new State Machine and all its children.

Exceptions:
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.

Parameters:
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.
Returns:
true if all state machines could be loaded in the StateMachineProcessor.
Deprecated:
by runScript
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.

Parameters:
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.
Returns:
true if all state machines could be loaded in the StateMachineProcessor.
Deprecated:
by runScript
bool RTT::scripting::ScriptingService::pauseProgram ( const std::string &  name  ) 

Pauses the execution of a running program.

Parameters:
name The name of the Program.
bool RTT::scripting::ScriptingService::pauseStateMachine ( const std::string &  name  ) 

Pause a previously activated StateMachine.

Parameters:
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.

Parameters:
name The name of the StateMachine.
state The state to enter.
Returns:
true if the state change request was accepted.
bool RTT::scripting::ScriptingService::resetStateMachine ( const std::string &  name  ) 

Resets the execution of a scripting::StateMachine and enters the Initial_State.

Parameters:
name The name of the StateMachine.
bool RTT::scripting::ScriptingService::runScript ( const std::string &  filename  ) 

Run a script which is stored in a file.

Parameters:
filename The local file to load and execute
Returns:
true if the parsing and execution succeeded (= no syntax errors and no exceptions thrown when executing code ), false otherwise.
Exceptions:
parse_exception and its derivatives for parse errors in code.
bool RTT::scripting::ScriptingService::startProgram ( const std::string &  name  ) 

Start a Program.

Parameters:
name The name of the Program.
bool RTT::scripting::ScriptingService::startStateMachine ( const std::string &  name  ) 

Start a previously activated StateMachine.

Parameters:
name The name of the StateMachine.
bool RTT::scripting::ScriptingService::stepProgram ( const std::string &  name  ) 

Steps a single instruction of a paused program.

Parameters:
name The name of the Program.
bool RTT::scripting::ScriptingService::stopProgram ( const std::string &  name  ) 

Stops the execution of a program.

Parameters:
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.

Parameters:
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.

Parameters:
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.
Returns:
true if it could be unloaded
bool RTT::scripting::ScriptingService::unloadProgram ( const std::string &  name  ) 

Unload a program from this processor.

Exceptions:
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.

Parameters:
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.
Returns:
true if it could be unloaded
bool RTT::scripting::ScriptingService::unloadStateMachine ( const std::string &  name  ) 

Unload a deactivated State Machine and all its children.

Exceptions:
program_unload_exception if the state machine or one of its children is still active.

Member Data Documentation

Definition at line 572 of file ScriptingService.hpp.

Definition at line 548 of file ScriptingService.hpp.

Definition at line 568 of file ScriptingService.hpp.

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.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


rtt
Author(s): RTT Developers
autogenerated on Fri Mar 1 16:27:54 2013