AuboCaps  0.6.0
arcs::aubo_scope::ScriptWriter Class Reference

This interface provides support for generating Script code. More...

#include <script_writer.h>

Public Member Functions

 ScriptWriter (ScriptWriter &f)
 
 ScriptWriter (ScriptWriter &&f)
 
virtual ~ScriptWriter ()
 
void setLabel (int lineno, const std::string &comment)
 
void appendLine (const std::string &script_line)
 Adds a single line of script code using auto-indentation. More...
 
void appendVectorDouble (const std::vector< double > &value)
 
void appendRaw (const std::string &script)
 Adds script code appending the script code as is without using auto-indentation. More...
 
std::string generateScript ()
 Generate a string with the full script code. More...
 
void writeChildren ()
 
void assign (VariablePtr variable, const std::string &expression, bool sync=false)
 
void assign (const std::string &variableName, const ExpressionPtr &expression, bool sync=false)
 
void assign (VariablePtr variable, const ExpressionPtr &expression, bool sync=false)
 
void incrementVariable (const std::string &variable_name)
 Add 1 to the variable value. More...
 
void note (const std::string &expression)
 Add a note. More...
 
void sleep (double seconds)
 Sleep for a number of seconds. More...
 
void sync ()
 Uses up the remaining "physical" time a thread has in the current frame. More...
 
void defineFunction (const std::string &func_name)
 
void anonyFunction (const std::string &func_name)
 
void setRobotIndex (int robot_index)
 
void returnMethod ()
 Return from method. More...
 
void end ()
 Insert an end. More...
 
void lineFeed ()
 Insert an empty line. More...
 
void setPayload (double mass, double x, double y, double z)
 
void setTcp (const std::vector< double > &pose)
 
void ifCondition (const ExpressionPtr &expression)
 Start an if-conditional. More...
 
void ifNotCondition (const ExpressionPtr &expression)
 Start a negated if-conditional. More...
 
void elseIfCondition (const ExpressionPtr &expression)
 Adds an else-if branch. More...
 
void elseCondition ()
 Adds an else branch. More...
 
void forCondition (int count, int step)
 Starts a for-loop with tow loop invariants. More...
 
void whileTrue ()
 Starts a while true loop. More...
 
void whileCondition (const ExpressionPtr &expression)
 Starts a while-loop with a loop invariant. More...
 
void whileNot (const ExpressionPtr &expression)
 Starts a while-loop with a negated loop invariant. More...
 
void defineThread (const std::string &thread_name, bool loop_or_not)
 Start a thread definition with a given thread name. More...
 
void runThread (const std::string &thread_name)
 Start a previously defined thread. More...
 
void killThread (const std::string &thread_name)
 killThread More...
 
std::string getResolvedVariable (const std::string &variable_name)
 
void increaseIndent ()
 
void decreaseIndent ()
 

Private Member Functions

 ScriptWriter ()
 

Private Attributes

void * d_ { nullptr }
 

Friends

class DataSwitch
 

Detailed Description

This interface provides support for generating Script code.

Definition at line 16 of file script_writer.h.

Constructor & Destructor Documentation

arcs::aubo_scope::ScriptWriter::ScriptWriter ( ScriptWriter f)
arcs::aubo_scope::ScriptWriter::ScriptWriter ( ScriptWriter &&  f)
virtual arcs::aubo_scope::ScriptWriter::~ScriptWriter ( )
virtual
arcs::aubo_scope::ScriptWriter::ScriptWriter ( )
private

Member Function Documentation

void arcs::aubo_scope::ScriptWriter::anonyFunction ( const std::string &  func_name)
void arcs::aubo_scope::ScriptWriter::appendLine ( const std::string &  script_line)

Adds a single line of script code using auto-indentation.

Parameters
script_linesingle line of script code to append.
void arcs::aubo_scope::ScriptWriter::appendRaw ( const std::string &  script)

Adds script code appending the script code as is without using auto-indentation.

Parameters
scriptscript code to append.
void arcs::aubo_scope::ScriptWriter::appendVectorDouble ( const std::vector< double > &  value)
void arcs::aubo_scope::ScriptWriter::assign ( VariablePtr  variable,
const std::string &  expression,
bool  sync = false 
)
void arcs::aubo_scope::ScriptWriter::assign ( const std::string &  variableName,
const ExpressionPtr &  expression,
bool  sync = false 
)

Variable assignment. Assigns the variable without a local or global qualifier. See the Script Manual for the scoping rules.

Parameters
variableNamename of the variable, not null.
expressionexpression that is assigned to the variable, not null.
void arcs::aubo_scope::ScriptWriter::assign ( VariablePtr  variable,
const ExpressionPtr &  expression,
bool  sync = false 
)

Variable assignment.

Parameters
variablethe variable to assign an expression to, not null.
expressionexpression that is assigned to the variable, not null.
void arcs::aubo_scope::ScriptWriter::decreaseIndent ( )
void arcs::aubo_scope::ScriptWriter::defineFunction ( const std::string &  func_name)
Parameters
nameDefine a function of name name.
void arcs::aubo_scope::ScriptWriter::defineThread ( const std::string &  thread_name,
bool  loop_or_not 
)

Start a thread definition with a given thread name.

Parameters
threadNamethe name of the new thread.
loop_or_notthe new thread loops or not.
void arcs::aubo_scope::ScriptWriter::elseCondition ( )

Adds an else branch.

void arcs::aubo_scope::ScriptWriter::elseIfCondition ( const ExpressionPtr &  expression)

Adds an else-if branch.

Parameters
expressionthe expression of the "else-if"-sentence.
void arcs::aubo_scope::ScriptWriter::end ( )

Insert an end.

void arcs::aubo_scope::ScriptWriter::forCondition ( int  count,
int  step 
)

Starts a for-loop with tow loop invariants.

Parameters
countthe loop counts.
stepthe loop step.
std::string arcs::aubo_scope::ScriptWriter::generateScript ( )

Generate a string with the full script code.

Returns
the resulting script as a string.
std::string arcs::aubo_scope::ScriptWriter::getResolvedVariable ( const std::string &  variable_name)

Returns a registered variable name that can be used in a script.

A variable is registered if it has been stored in a DataModel instance or used for the configuration of a built-in AuboScope program node.

Please note: The name of a variable in the script can be different from the value of Variable#getDisplayName(). You should not use the value of Variable#getDisplayName() in a script.

Parameters
variablea registered Variable. Not null.
Returns
variable name that can be used in a script.
Exceptions
IllegalArgumentExceptionif the variable was not registered in the data model or used for the configuration of a built-in AuboScope program node.
ClassCastExceptionif the variable was not created by domain/variable/VariableFactory.
void arcs::aubo_scope::ScriptWriter::ifCondition ( const ExpressionPtr &  expression)

Start an if-conditional.

Parameters
expressionthe expression of the if-sentence. Not null.
void arcs::aubo_scope::ScriptWriter::ifNotCondition ( const ExpressionPtr &  expression)

Start a negated if-conditional.

Parameters
expressionthe expression of the negated if-sentence.
void arcs::aubo_scope::ScriptWriter::increaseIndent ( )
void arcs::aubo_scope::ScriptWriter::incrementVariable ( const std::string &  variable_name)

Add 1 to the variable value.

Parameters
variablethe variable to increment. Not null.
void arcs::aubo_scope::ScriptWriter::killThread ( const std::string &  thread_name)

killThread

Parameters
thread_name
void arcs::aubo_scope::ScriptWriter::lineFeed ( )

Insert an empty line.

void arcs::aubo_scope::ScriptWriter::note ( const std::string &  expression)

Add a note.

Parameters
expressionthe note expression.
void arcs::aubo_scope::ScriptWriter::returnMethod ( )

Return from method.

void arcs::aubo_scope::ScriptWriter::runThread ( const std::string &  thread_name)

Start a previously defined thread.

Parameters
threadNameThe name of the thread that will be started.
void arcs::aubo_scope::ScriptWriter::setLabel ( int  lineno,
const std::string &  comment 
)
void arcs::aubo_scope::ScriptWriter::setPayload ( double  mass,
double  x,
double  y,
double  z 
)

Sets the mass and Center of Gravity (CoG) of the payload.

This function must be called, when the payload weight or weigh distribution changes significantly, i.e when the robot arm picks up or puts down a heavy workpiece.

Parameters
payloadMassin kilograms
centerOfGravityXdisplacement from the tool-mount in meters.
centerOfGravityYdisplacement from the tool-mount in meters.
centerOfGravityZdisplacement from the tool-mount in meters.
void arcs::aubo_scope::ScriptWriter::setRobotIndex ( int  robot_index)
void arcs::aubo_scope::ScriptWriter::setTcp ( const std::vector< double > &  pose)

Set the Tool Center Point (TCP).

Sets the transformation from the tool output flange coordinate system to the TCP as a pose.

Parameters
xPosition part.
yPosition part.
zPosition part.
rxRotation part.
ryRotation part.
rzRotation part.
void arcs::aubo_scope::ScriptWriter::sleep ( double  seconds)

Sleep for a number of seconds.

Parameters
secondsamount of time to sleep in seconds.
void arcs::aubo_scope::ScriptWriter::sync ( )

Uses up the remaining "physical" time a thread has in the current frame.

void arcs::aubo_scope::ScriptWriter::whileCondition ( const ExpressionPtr &  expression)

Starts a while-loop with a loop invariant.

Parameters
expressionthe loop invariant.
void arcs::aubo_scope::ScriptWriter::whileNot ( const ExpressionPtr &  expression)

Starts a while-loop with a negated loop invariant.

Parameters
expressionthe loop invariant that will be negated.
void arcs::aubo_scope::ScriptWriter::whileTrue ( )

Starts a while true loop.

void arcs::aubo_scope::ScriptWriter::writeChildren ( )

Use this method when generating script code for a node that has children nodes.globalVariable

A simple example:

writer.ifCondition(expression)
writer.writeChildren() // let children nodes generate code.
writer.end()

In most cases you prglobalVariableobably only want to call ScriptWriter#writeChildren() once, but it is possible to call it multiple times and thus have children nodes generate their code multiple times.

Friends And Related Function Documentation

friend class DataSwitch
friend

Definition at line 282 of file script_writer.h.

Member Data Documentation

void* arcs::aubo_scope::ScriptWriter::d_ { nullptr }
private

Definition at line 284 of file script_writer.h.


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