Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
RTT::scripting::ScriptingService Class Reference

#include <ScriptingService.hpp>

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

Public Types

typedef std::vector< ProgramInterfacePtrFunctions
 
typedef ProgramInterface::Status ProgramStatus
 
typedef boost::shared_ptr< ScriptingServiceshared_ptr
 
typedef scripting::StateMachine::Status StateMachineStatus
 
- Public Types inherited from RTT::Service
typedef OperationInterface Factory
 
typedef std::vector< std::string > ProviderNames
 
typedef boost::shared_ptr< const Serviceshared_constptr
 
typedef boost::shared_ptr< Serviceshared_ptr
 
- Public Types inherited from RTT::OperationInterface
typedef std::vector< base::DataSourceBase::shared_ptrArguments
 
typedef std::vector< ArgumentDescriptionDescriptions
 
- Public Types inherited from RTT::ConfigurationInterface
typedef std::vector< std::string > AttributeNames
 
typedef std::vector< base::AttributeBase * > AttributeObjects
 
- Public Types inherited from RTT::DataFlowInterface
typedef std::vector< std::string > PortNames
 
typedef std::vector< base::PortInterface * > Ports
 
typedef boost::function< void(base::PortInterface *)> SlotFunction
 

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)
 
const ProgramInterfacePtr getProgram (const std::string &name) const
 
ProgramInterfacePtr getProgram (const std::string &name)
 
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
 
const StateMachinePtr getStateMachine (const std::string &name) const
 
StateMachinePtr getStateMachine (const std::string &name)
 
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 &filename, bool do_throw)
 
virtual Functions loadFunctions (const std::string &code, const std::string &filename, bool do_throw)
 
bool loadProgram (ProgramInterfacePtr pi)
 
virtual bool loadPrograms (const std::string &filename, bool do_throw)
 
virtual bool loadPrograms (const std::string &code, const std::string &filename, bool do_throw)
 
bool loadStateMachine (StateMachinePtr sc)
 
virtual bool loadStateMachines (const std::string &filename, bool do_throw)
 
virtual bool loadStateMachines (const std::string &code, const std::string &filename, bool do_throw)
 
bool runScript (const std::string &filename)
 
 ScriptingService (TaskContext *parent)
 
bool unloadProgram (const std::string &name)
 
virtual bool unloadProgram (const std::string &name, bool do_throw)
 
bool unloadStateMachine (const std::string &name)
 
virtual bool unloadStateMachine (const std::string &name, bool do_throw)
 
virtual ~ScriptingService ()
 
Script Program Commands
bool startProgram (const std::string &name)
 
bool stopProgram (const std::string &name)
 
bool pauseProgram (const std::string &name)
 
bool stepProgram (const std::string &name)
 
Script Program OperationCallers
virtual bool hasProgram (const std::string &name) const
 
bool isProgramRunning (const std::string &name) const
 
bool isProgramPaused (const std::string &name) const
 
bool inProgramError (const std::string &name) const
 
Script State Machine Commands
bool activateStateMachine (const std::string &name)
 
bool deactivateStateMachine (const std::string &name)
 
bool startStateMachine (const std::string &name)
 
bool pauseStateMachine (const std::string &name)
 
bool stopStateMachine (const std::string &name)
 
bool resetStateMachine (const std::string &name)
 
bool requestStateMachineState (const std::string &name, const std::string &state)
 
Script State Machine OperationCallers
virtual bool hasStateMachine (const std::string &name) const
 
bool isStateMachineActive (const std::string &name) const
 
bool isStateMachineRunning (const std::string &name) const
 
bool inStateMachineError (const std::string &name) const
 
bool isStateMachinePaused (const std::string &name) const
 
std::string getStateMachineState (const std::string &name) const
 
bool inStateMachineState (const std::string &name, const std::string &state) const
 
- Public Member Functions inherited from RTT::Service
bool addLocalOperation (base::OperationBase &op)
 
template<class Signature >
Operation< Signature > & addOperation (Operation< Signature > &op)
 
template<class Func , class Class >
Operation< typename internal::GetSignature< Func >::Signature > & addOperation (const std::string name, Func func, Class *obj, ExecutionThread et=ClientThread)
 
template<class Func >
Operation< Func > & addOperation (const std::string name, Func *func, ExecutionThread et=ClientThread)
 
template<class Func , class ObjT >
Operation< typename internal::GetSignatureDS< Func >::Signature > & addOperationDS (const std::string &name, Func func, internal::DataSource< boost::shared_ptr< ObjT > > *sp, ExecutionThread et=ClientThread)
 
template<class Signature , class ObjT >
Operation< Signature > & addOperationDS (internal::DataSource< boost::shared_ptr< ObjT > > *sp, Operation< Signature > &op)
 
virtual bool addService (shared_ptr obj)
 
template<class Signature >
Operation< Signature > & addSynchronousOperation (Operation< Signature > &op)
 
template<class Func , class Class >
Operation< typename internal::GetSignature< Func >::Signature > & addSynchronousOperation (const std::string name, Func func, Class *obj, ExecutionThread et=ClientThread)
 
void clear ()
 
internal::OperationCallerC create (std::string name, ExecutionEngine *caller)
 
const std::string & doc () const
 
void doc (const std::string &description)
 
boost::shared_ptr< base::DisposableInterfacegetLocalOperation (std::string name)
 
const std::string & getName () const
 
OperationInterfacePartgetOperation (std::string name)
 
base::DataSourceBase::shared_ptr getOperation (std::string name, const std::vector< base::DataSourceBase::shared_ptr > &args, ExecutionEngine *caller) const
 
std::vector< std::string > getOperationNames () const
 
TaskContextgetOwner () const
 
ExecutionEnginegetOwnerExecutionEngine () const
 
shared_ptr getParent () const
 
virtual ProviderNames getProviderNames () const
 
shared_ptr getService (const std::string &service_name)
 
bool hasOperation (const std::string &name) const
 
bool hasService (const std::string &service_name)
 
Service::shared_ptr provides ()
 
Service::shared_ptr provides (const std::string &service_name)
 
void removeOperation (const std::string &name)
 
virtual void removeService (std::string const &service_name)
 
bool resetOperation (std::string name, base::OperationBase *impl)
 
 Service (const std::string &name, TaskContext *owner=0)
 
void setName (const std::string &name)
 
bool setOperationThread (std::string const &name, ExecutionThread et)
 
void setOwner (TaskContext *new_owner)
 
void setParent (shared_ptr new_parent)
 
virtual ~Service ()
 
- Public Member Functions inherited from RTT::OperationInterface
void add (const std::string &name, OperationInterfacePart *part)
 
void clear ()
 
Descriptions getArgumentList (const std::string &name) const
 
int getArity (const std::string &name) const
 
int getCollectArity (const std::string &name) const
 
std::string getDescription (const std::string &name) const
 
std::vector< std::string > getNames () const
 
OperationInterfacePartgetPart (const std::string &name)
 
std::string getResultType (const std::string &name) const
 
bool hasMember (const std::string &name) const
 
bool isSynchronous (const std::string &name) const
 
base::DataSourceBase::shared_ptr produce (const std::string &name, const Arguments &args, ExecutionEngine *caller) const
 
base::DataSourceBase::shared_ptr produceCollect (const std::string &name, const Arguments &args, internal::DataSource< bool >::shared_ptr blocking) const
 
base::DataSourceBase::shared_ptr produceHandle (const std::string &name) const
 
base::DataSourceBase::shared_ptr produceSend (const std::string &name, const Arguments &args, ExecutionEngine *caller) const
 
void remove (const std::string &name)
 
- Public Member Functions inherited from RTT::ConfigurationInterface
template<class T >
bool addAttribute (const std::string &name, T &attr)
 
template<class T >
Attribute< T > & addAttribute (const std::string &name, Attribute< T > &attr)
 
bool addAttribute (base::AttributeBase &a)
 
template<class T >
bool addConstant (const std::string &name, const T &cnst)
 
template<class T >
Constant< T > & addConstant (const std::string &name, Constant< T > &cnst)
 
bool addConstant (base::AttributeBase &c)
 
template<class T >
Property< T > & addProperty (const std::string &name, T &prop)
 
template<class T >
Property< T > & addProperty (const std::string &name, Property< T > &prop)
 
bool addProperty (base::PropertyBase &pb)
 
void clear ()
 
 ConfigurationInterface ()
 
ConfigurationInterfacecopy (std::map< const base::DataSourceBase *, base::DataSourceBase * > &repl, bool instantiate) const
 
base::AttributeBasegetAttribute (const std::string &name) const
 
AttributeNames getAttributeNames () const
 
base::AttributeBasegetConstant (const std::string &name) const
 
base::PropertyBasegetProperty (const std::string &name) const
 
base::AttributeBasegetValue (const std::string &name) const
 
AttributeObjects const & getValues () const
 
bool hasAttribute (const std::string &name) const
 
bool hasProperty (const std::string &name) const
 
void loadValues (AttributeObjects const &new_values)
 
PropertyBagproperties ()
 
void removeAttribute (const std::string &name)
 
bool removeProperty (base::PropertyBase &p)
 
bool removeValue (const std::string &name)
 
bool setValue (base::AttributeBase *ab)
 
 ~ConfigurationInterface ()
 
- Public Member Functions inherited from RTT::DataFlowInterface
base::InputPortInterfaceaddEventPort (const std::string &name, base::InputPortInterface &port, SlotFunction callback=SlotFunction())
 
base::InputPortInterfaceaddEventPort (base::InputPortInterface &port, SlotFunction callback=SlotFunction())
 
base::InputPortInterfaceaddLocalEventPort (base::InputPortInterface &port, SlotFunction callback=SlotFunction())
 
base::PortInterfaceaddLocalPort (base::PortInterface &port)
 
base::PortInterfaceaddPort (const std::string &name, base::PortInterface &port)
 
base::PortInterfaceaddPort (base::PortInterface &port)
 
void clear ()
 
 DataFlowInterface (Service *parent=0)
 
void dataOnPort (base::PortInterface *port)
 
TaskContextgetOwner () const
 
base::PortInterfacegetPort (const std::string &name) const
 
std::string getPortDescription (const std::string &name) const
 
PortNames getPortNames () const
 
Ports getPorts () const
 
template<class Type >
Type * getPortType (const std::string &name)
 
ServicegetService () const
 
void removeLocalPort (const std::string &name)
 
void removePort (const std::string &name)
 
bool setPortDescription (const std::string &name, const std::string description)
 
 ~DataFlowInterface ()
 

Static Public Member Functions

static shared_ptr Create (TaskContext *parent)
 
- Static Public Member Functions inherited from RTT::Service
static Service::shared_ptr Create (const std::string &name, TaskContext *owner=0)
 

Protected Types

typedef std::map< std::string, ProgramInterfacePtrProgMap
 
typedef ProgMap::const_iterator ProgMapIt
 
typedef std::map< std::string, StateMachinePtrStateMap
 
typedef StateMap::const_iterator StateMapIt
 
- Protected Types inherited from RTT::Service
typedef std::vector< base::OperationBase * > OperationList
 
typedef std::map< std::string, shared_ptrServices
 
typedef std::map< std::string, base::OperationBase * > SimpleOperations
 
- Protected Types inherited from RTT::OperationInterface
typedef std::map< std::string, OperationInterfacePart * > map_t
 
- Protected Types inherited from RTT::ConfigurationInterface
typedef std::vector< base::AttributeBase * > map_t
 

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 Member Functions inherited from RTT::Service
bool testOperation (base::OperationBase &op)
 
- Protected Member Functions inherited from RTT::ConfigurationInterface
bool chkPtr (const std::string &where, const std::string &name, const void *ptr)
 
- Protected Member Functions inherited from RTT::DataFlowInterface
bool chkPtr (const std::string &where, const std::string &name, const void *ptr)
 
ServicecreatePortObject (const std::string &name)
 

Protected Attributes

ProgMap programs
 
StatementProcessorsproc
 
StateMap states
 
bool ZeroPeriodWarning
 
- Protected Attributes inherited from RTT::Service
std::string mdescription
 
std::string mname
 
TaskContextmowner
 
OperationList ownedoperations
 
shared_ptr parent
 
Services services
 the services we implement. More...
 
SimpleOperations simpleoperations
 
- Protected Attributes inherited from RTT::OperationInterface
map_t data
 
- Protected Attributes inherited from RTT::ConfigurationInterface
PropertyBag bag
 
map_t values
 
- Protected Attributes inherited from RTT::DataFlowInterface
Ports mports
 
Servicemservice
 

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.

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 71 of file ScriptingService.cpp.

RTT::ScriptingService::~ScriptingService ( )
virtual

Definition at line 84 of file ScriptingService.cpp.

Member Function Documentation

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

Activate a previously loaded StateMachine.

Parameters
nameThe name of the StateMachine.

Definition at line 869 of file ScriptingService.cpp.

void RTT::ScriptingService::clear ( )

Stop and unload all program scripts.

Definition at line 92 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 65 of file ScriptingService.cpp.

void RTT::ScriptingService::createInterface ( void  )
protected

Definition at line 448 of file ScriptingService.cpp.

bool RTT::ScriptingService::deactivateStateMachine ( const std::string &  name)

Deactivate a stopped StateMachine.

Parameters
nameThe name of the StateMachine.

Definition at line 877 of file ScriptingService.cpp.

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

Completely discard a loaded Program.

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

Delete a deactivated State Machine and all its children.

Exceptions
program_unload_exceptionif the state machine or one of its children is still active.
Deprecated:
by unloadStateMachine

Definition at line 306 of file ScriptingService.cpp.

bool RTT::ScriptingService::doExecute ( const std::string &  code)
protected

Definition at line 416 of file ScriptingService.cpp.

bool RTT::ScriptingService::doLoadPrograms ( const std::string &  filename)
protected

Definition at line 421 of file ScriptingService.cpp.

bool RTT::ScriptingService::doLoadProgramText ( const std::string &  code)
protected

Definition at line 426 of file ScriptingService.cpp.

bool RTT::ScriptingService::doLoadStateMachines ( const std::string &  filename)
protected

Definition at line 435 of file ScriptingService.cpp.

bool RTT::ScriptingService::doLoadStateMachineText ( const std::string &  code)
protected

Definition at line 439 of file ScriptingService.cpp.

bool RTT::ScriptingService::doUnloadProgram ( const std::string &  name)
protected

Definition at line 430 of file ScriptingService.cpp.

bool RTT::ScriptingService::doUnloadStateMachine ( const std::string &  name)
protected

Definition at line 443 of file ScriptingService.cpp.

bool RTT::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
codeA 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_exceptionand its derivatives for parse errors in code.

Definition at line 596 of file ScriptingService.cpp.

bool RTT::ScriptingService::evalInternal ( const std::string &  filename,
const std::string &  code 
)
protected

Definition at line 600 of file ScriptingService.cpp.

int RTT::ScriptingService::execute ( const std::string &  code)

Parse and execute a statement.

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

Definition at line 516 of file ScriptingService.cpp.

const ProgramInterfacePtr RTT::scripting::ScriptingService::getProgram ( const std::string &  name) const

Get a pointer to a loaded Program.

ProgramInterfacePtr RTT::scripting::ScriptingService::getProgram ( const std::string &  name)
int RTT::ScriptingService::getProgramLine ( const std::string &  name) const
virtual

Get the current line of execution of a loaded program script.

Parameters
nameThe name of the program.
Returns
The line number.
Return values
-1if the program does not exist.
0if the program is not running.
nthe line number if the program is executing.

Definition at line 789 of file ScriptingService.cpp.

vector< string > RTT::ScriptingService::getProgramList ( ) const

Get a list of all loaded Programs.

Definition at line 398 of file ScriptingService.cpp.

ProgramInterface::Status::ProgramStatus RTT::ScriptingService::getProgramStatus ( const std::string &  name) const

Return the status of a Program.

Definition at line 328 of file ScriptingService.cpp.

string RTT::ScriptingService::getProgramStatusStr ( const std::string &  name) const

Return the status of a Program as a human readable string.

Definition at line 337 of file ScriptingService.cpp.

string RTT::ScriptingService::getProgramText ( const std::string &  name) const
virtual

Get the original script description of a loaded program.

Parameters
nameThe name of the program.
Returns
A string containing only that program.

Definition at line 794 of file ScriptingService.cpp.

const StateMachinePtr RTT::scripting::ScriptingService::getStateMachine ( const std::string &  name) const

Get a pointer to a loaded StateMachine.

StateMachinePtr RTT::scripting::ScriptingService::getStateMachine ( const std::string &  name)

Get a pointer to a loaded StateMachine.

int RTT::ScriptingService::getStateMachineLine ( const std::string &  name) const
virtual

Get the current line of execution of a loaded state machine script.

Parameters
nameThe name of the state machine.
Returns
The line number.
Return values
-1if the state machine does not exist.
0if the state machine is not running.
nthe line number if the state machine is executing.

Definition at line 808 of file ScriptingService.cpp.

vector< string > RTT::ScriptingService::getStateMachineList ( ) const

Get a list of all loaded StateMachines and their children.

Definition at line 323 of file ScriptingService.cpp.

string RTT::ScriptingService::getStateMachineState ( const std::string &  name) const

Get the current state of a state machine.

Parameters
nameThe name of the StateMachine.

Definition at line 941 of file ScriptingService.cpp.

StateMachine::Status::StateMachineStatus RTT::ScriptingService::getStateMachineStatus ( const std::string &  name) const

Return the status of a StateMachine.

Definition at line 132 of file ScriptingService.cpp.

string RTT::ScriptingService::getStateMachineStatusStr ( const std::string &  name) const

Return the status of a StateMachine as a human readable string

Definition at line 141 of file ScriptingService.cpp.

string RTT::ScriptingService::getStateMachineText ( const std::string &  name) const
virtual

Get the original script description of a loaded state machine.

Parameters
nameThe name of the state machine.
Returns
A string containing only that state machine.

Definition at line 803 of file ScriptingService.cpp.

bool RTT::ScriptingService::hasProgram ( const std::string &  name) const
virtual

Check if a program is loaded

Parameters
nameThe name of the program.
Returns
True if so.

Definition at line 785 of file ScriptingService.cpp.

bool RTT::ScriptingService::hasStateMachine ( const std::string &  name) const
virtual

Check if a state machine is loaded.

Parameters
nameThe name of the state machine.
Returns
True if so.

Definition at line 799 of file ScriptingService.cpp.

bool RTT::ScriptingService::inProgramError ( const std::string &  name) const

Inspect if a loaded program is in the error state

Parameters
nameThe name of the Program.
Returns
true if so.

Definition at line 837 of file ScriptingService.cpp.

bool RTT::ScriptingService::inStateMachineError ( const std::string &  name) const

Returns true if the state machine is in error.

Parameters
nameThe name of the StateMachine.

Definition at line 933 of file ScriptingService.cpp.

bool RTT::ScriptingService::inStateMachineState ( const std::string &  name,
const std::string &  state 
) const

Check if a state machine is in a given state

Parameters
nameThe name of the StateMachine.
stateThe state to enter.
Returns
true if so.

Definition at line 957 of file ScriptingService.cpp.

bool RTT::ScriptingService::isProgramPaused ( const std::string &  name) const

Inspect if a loaded program is in the paused state

Parameters
nameThe name of the Program.
Returns
true if so.

Definition at line 829 of file ScriptingService.cpp.

bool RTT::ScriptingService::isProgramRunning ( const std::string &  name) const

Inspect if a loaded program is in the running state

Parameters
nameThe name of the Program.
Returns
true if so.

Definition at line 821 of file ScriptingService.cpp.

bool RTT::ScriptingService::isStateMachineActive ( const std::string &  name) const

Returns true if the state machine has been activated.

Parameters
nameThe name of the StateMachine.

Definition at line 917 of file ScriptingService.cpp.

bool RTT::ScriptingService::isStateMachinePaused ( const std::string &  name) const

Returns true if the state machine is paused.

Parameters
nameThe name of the StateMachine.

Definition at line 909 of file ScriptingService.cpp.

bool RTT::ScriptingService::isStateMachineRunning ( const std::string &  name) const

Returns true if the state machine was successfully started.

Parameters
nameThe name of the StateMachine.

Definition at line 925 of file ScriptingService.cpp.

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
filenameThe file to load
do_throwSet 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 &  code,
const std::string &  filename,
bool  do_throw 
)
virtual

Load and execute a set of functions into the Program Processor for execution

Parameters
codeA string containing the function definitions.
filenameThe file name to use in the error messages.
do_throwSet 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_exceptionif a program with the same name already exists.

Definition at line 360 of file ScriptingService.cpp.

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
filenameThe file to load
do_throwSet 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 &  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
codeA string containing the function definitions.
filenameThe file name to use in the error messages.
do_throwSet 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_exceptionif a state machine with the same name already exists.

Definition at line 185 of file ScriptingService.cpp.

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
filenameThe file to load
do_throwSet 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 &  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
codeA string containing the function definitions.
filenameThe file name to use in the error messages.
do_throwSet 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::ScriptingService::pauseProgram ( const std::string &  name)

Pauses the execution of a running program.

Parameters
nameThe name of the Program.

Definition at line 853 of file ScriptingService.cpp.

bool RTT::ScriptingService::pauseStateMachine ( const std::string &  name)

Pause a previously activated StateMachine.

Parameters
nameThe name of the StateMachine.

Definition at line 893 of file ScriptingService.cpp.

bool RTT::ScriptingService::recursiveCheckLoadStateMachine ( StateMachinePtr  sc)
protected

Definition at line 210 of file ScriptingService.cpp.

bool RTT::ScriptingService::recursiveCheckUnloadStateMachine ( StateMachinePtr  si)
protected

Definition at line 266 of file ScriptingService.cpp.

void RTT::ScriptingService::recursiveLoadStateMachine ( StateMachinePtr  sc)
protected

Definition at line 230 of file ScriptingService.cpp.

void RTT::ScriptingService::recursiveUnloadStateMachine ( StateMachinePtr  sc)
protected

Definition at line 288 of file ScriptingService.cpp.

bool RTT::ScriptingService::requestStateMachineState ( const std::string &  name,
const std::string &  state 
)

Request a state change in a state machine.

Parameters
nameThe name of the StateMachine.
stateThe state to enter.
Returns
true if the state change request was accepted.

Definition at line 949 of file ScriptingService.cpp.

bool RTT::ScriptingService::resetStateMachine ( const std::string &  name)

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

Parameters
nameThe name of the StateMachine.

Definition at line 965 of file ScriptingService.cpp.

bool RTT::ScriptingService::runScript ( const std::string &  filename)

Run a script which is stored in a file.

Parameters
filenameThe 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_exceptionand its derivatives for parse errors in code.

Definition at line 578 of file ScriptingService.cpp.

bool RTT::ScriptingService::startProgram ( const std::string &  name)

Start a Program.

Parameters
nameThe name of the Program.

Definition at line 813 of file ScriptingService.cpp.

bool RTT::ScriptingService::startStateMachine ( const std::string &  name)

Start a previously activated StateMachine.

Parameters
nameThe name of the StateMachine.

Definition at line 885 of file ScriptingService.cpp.

bool RTT::ScriptingService::stepProgram ( const std::string &  name)

Steps a single instruction of a paused program.

Parameters
nameThe name of the Program.

Definition at line 861 of file ScriptingService.cpp.

bool RTT::ScriptingService::stopProgram ( const std::string &  name)

Stops the execution of a program.

Parameters
nameThe name of the Program.

Definition at line 845 of file ScriptingService.cpp.

bool RTT::ScriptingService::stopStateMachine ( const std::string &  name)

Stops the execution of a scripting::StateMachine and enters the Final_State.

Parameters
nameThe name of the StateMachine.

Definition at line 901 of file ScriptingService.cpp.

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

Unload a program from this processor.

Exceptions
program_unload_exceptionif the program is not stopped or does not exist.
virtual bool RTT::scripting::ScriptingService::unloadProgram ( const std::string &  name,
bool  do_throw 
)
virtual

Unload a program from the Program Processor.

Parameters
nameThe name of the loaded program.
do_throwSet 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_exceptionif the state machine or one of its children is still active.
virtual bool RTT::scripting::ScriptingService::unloadStateMachine ( const std::string &  name,
bool  do_throw 
)
virtual

Unload a state machine from the StateMachineProcessor.

Parameters
nameThe name of the loaded program.
do_throwSet 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

Member Data Documentation

ProgMap RTT::scripting::ScriptingService::programs
protected

Definition at line 572 of file ScriptingService.hpp.

StatementProcessor* RTT::scripting::ScriptingService::sproc
protected

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.


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


rtt
Author(s): RTT Developers
autogenerated on Fri Oct 25 2019 03:59:47