AuboStudio SDK  0.6.3
script_writer.h
浏览该文件的文档.
1#ifndef AUBO_SCOPE_SCRIPT_WRITER_H
2#define AUBO_SCOPE_SCRIPT_WRITER_H
3
4#include <vector>
5#include <string>
8
9namespace arcs {
10namespace aubo_scope {
12
13/**
14 * \chinese
15 * 脚本写入器
16 * 此接口提供生成脚本代码的支持。
17 * \endchinese
18 * \english
19 * ScriptWriter
20 * This interface provides support for generating Script code.
21 * \endenglish
22 */
24{
25public:
28 virtual ~ScriptWriter();
29
30 void setLabel(int lineno, const std::string &comment);
31
32 /**
33 * \chinese
34 * 使用自动缩进添加一行脚本代码。
35 * @param script_line 要追加的脚本代码行。
36 * \endchinese
37 * \english
38 * Adds a single line of script code using auto-indentation.
39 *
40 * @param script_line single line of script code to append.
41 * \endenglish
42 */
43 void appendLine(const std::string &script_line);
44 void appendVectorDouble(const std::vector<double> &value);
45
46 /**
47 * \chinese
48 * 按原样追加脚本代码,不使用自动缩进。
49 * @param script 要追加的脚本代码。
50 * \endchinese
51 * \english
52 * Adds script code appending the script code as is without using
53 * auto-indentation.
54 *
55 * @param script script code to append.
56 * \endenglish
57 */
58 void appendRaw(const std::string &script);
59
60 /**
61 * \chinese
62 * 生成包含完整脚本代码的字符串。
63 * @return 生成的脚本字符串。
64 * \endchinese
65 * \english
66 * Generate a string with the full script code.
67 *
68 * @return the resulting script as a string.
69 * \endenglish
70 */
71 std::string generateScript();
72
73 /**
74 * \chinese
75 * 当为具有子节点的节点生成脚本代码时使用此方法。让子节点生成代码。
76 * \endchinese
77 * \english
78 * Use this method when generating script code for a node that has children
79 * nodes. Let children nodes generate code.
80 * \endenglish
81 */
83
84 void assign(VariablePtr variable, const std::string &expression,
85 bool sync = false);
86
87 /**
88 * \chinese
89 * <p>变量赋值。在无local或global限定符的情况下赋值。</p>
90 * @param variableName 变量名称。
91 * @param expression 赋给变量的表达式。
92 * \endchinese
93 * \english
94 * <p>Variable assignment.
95 * Assigns the variable without a local or global qualifier.</p>
96 * @param variableName name of the variable, not null.
97 * @param expression expression that is assigned to the variable, not null.
98 * \endenglish
99 */
100 void assign(const std::string &variableName,
101 const ExpressionPtr &expression, bool sync = false);
102
103 /**
104 * \chinese
105 * <p>变量赋值。</p>
106 * @param variable 变量。
107 * @param expression 表达式。
108 * \endchinese
109 * \english
110 * <p>Variable assignment.</p>
111 * @param variable the variable to assign an expression to, not null.
112 * @param expression expression that is assigned to the variable, not null.
113 * \endenglish
114 */
115 void assign(VariablePtr variable, const ExpressionPtr &expression,
116 bool sync = false);
117
118 /**
119 * \chinese
120 * 变量值加1。
121 * @param variable_name 要递增的变量名称。
122 * \endchinese
123 * \english
124 * Add 1 to the variable value.
125 * @param variable_name the variable to increment.
126 * \endenglish
127 */
128 void incrementVariable(const std::string &variable_name);
129
130 /**
131 * \chinese 添加注释。 \endchinese
132 * \english Add a note. @param expression the note expression. \endenglish
133 */
134 void note(const std::string &expression);
135
136 /**
137 * \chinese 休眠指定秒数。 \endchinese
138 * \english Sleep for a number of seconds. @param seconds amount of time to sleep in seconds. \endenglish
139 */
140 void sleep(double seconds);
141
142 /** \chinese 用完当前帧剩余时间。 \endchinese \english Sync. \endenglish */
143 void sync();
144
145 /** \chinese 定义函数。 \endchinese \english Define a function. @param func_name function name. \endenglish */
146 void defineFunction(const std::string &func_name);
147 void anonyFunction(const std::string &func_name);
148
149 void setRobotIndex(int robot_index);
150
151 /** \chinese 返回。 \endchinese \english Return from method. \endenglish */
153
154 /** \chinese 插入end。 \endchinese \english Insert an end. \endenglish */
155 void end();
156
157 /** \chinese 插入空行。 \endchinese \english Insert an empty line. \endenglish */
158 void lineFeed();
159
160 /**
161 * \chinese 设置负载质量和重心。 \endchinese
162 * \english Sets the mass and Center of Gravity of the payload. \endenglish
163 */
164 void setPayload(double mass, double x, double y, double z);
165
166 /** \chinese 设置TCP。 \endchinese \english Set the Tool Center Point. \endenglish */
167 void setTcp(const std::vector<double> &pose);
168
169 /** \chinese 开始if条件。 \endchinese \english Start an if-conditional. @param expression the expression. \endenglish */
170 void ifCondition(const ExpressionPtr &expression);
171
172 /** \chinese 开始取反的if条件。 \endchinese \english Start a negated if-conditional. @param expression the expression. \endenglish */
173 void ifNotCondition(const ExpressionPtr &expression);
174
175 /** \chinese 添加else-if分支。 \endchinese \english Adds an else-if branch. @param expression the expression. \endenglish */
176 void elseIfCondition(const ExpressionPtr &expression);
177
178 /** \chinese 添加else分支。 \endchinese \english Adds an else branch. \endenglish */
180
181 /** \chinese 开始for循环。 \endchinese \english Starts a for-loop. @param count loop count, @param step loop step. \endenglish */
182 void forCondition(int count, int step);
183
184 /** \chinese 开始while true循环。 \endchinese \english Starts a while true loop. \endenglish */
185 void whileTrue();
186
187 /** \chinese 开始while循环。 \endchinese \english Starts a while-loop. @param expression the loop invariant. \endenglish */
188 void whileCondition(const ExpressionPtr &expression);
189
190 /** \chinese 开始取反的while循环。 \endchinese \english Starts a negated while-loop. @param expression the loop invariant. \endenglish */
191 void whileNot(const ExpressionPtr &expression);
192
193 /**
194 * \chinese 定义线程。 \endchinese
195 * \english Start a thread definition. @param thread_name the thread name, @param loop_or_not whether loops. \endenglish
196 */
197 void defineThread(const std::string &thread_name, bool loop_or_not);
198
199 /** \chinese 启动线程。 \endchinese \english Start a thread. @param thread_name the thread name. \endenglish */
200 void runThread(const std::string &thread_name);
201
202 /** \chinese 终止线程。 \endchinese \english Kill a thread. @param thread_name the thread name. \endenglish */
203 void killThread(const std::string &thread_name);
204
205 /**
206 * \chinese
207 * 获取可在脚本中使用的已注册变量名。
208 * @param variable_name 变量名称。
209 * @return 可在脚本中使用的变量名。
210 * \endchinese
211 * \english
212 * Returns a registered variable name that can be used in a script.
213 * @param variable_name a variable name.
214 * @return variable name that can be used in a script.
215 * \endenglish
216 */
217 std::string getResolvedVariable(const std::string &variable_name);
218
221
222private:
223 friend class DataSwitch;
225 void *d_{ nullptr };
226};
227
228} // namespace aubo_scope
229} // namespace arcs
230
231#endif // AUBO_SCOPE_SCRIPT_WRITER_H
#define ARCS_ABI_EXPORT
#define ARCS_CLASS_FORWARD(C)
Macro that forward declares a class and defines the respective smartpointers through ARCS_DECLARE_PTR...
\chinese 脚本写入器 此接口提供生成脚本代码的支持。 \endchinese \english ScriptWriter This interface provides support for ...
void setLabel(int lineno, const std::string &comment)
ScriptWriter(ScriptWriter &&f)
std::string generateScript()
\chinese 生成包含完整脚本代码的字符串。
void writeChildren()
\chinese 当为具有子节点的节点生成脚本代码时使用此方法。让子节点生成代码。 \endchinese \english Use this method when generating script...
void anonyFunction(const std::string &func_name)
void sync()
\chinese 用完当前帧剩余时间。 \endchinese \english Sync.
void whileTrue()
\chinese 开始while true循环。 \endchinese \english Starts a while true loop.
void sleep(double seconds)
\chinese 休眠指定秒数。 \endchinese \english Sleep for a number of seconds.
void killThread(const std::string &thread_name)
\chinese 终止线程。 \endchinese \english Kill a thread.
void appendLine(const std::string &script_line)
\chinese 使用自动缩进添加一行脚本代码。
void ifNotCondition(const ExpressionPtr &expression)
\chinese 开始取反的if条件。 \endchinese \english Start a negated if-conditional.
void assign(VariablePtr variable, const ExpressionPtr &expression, bool sync=false)
\chinese
void incrementVariable(const std::string &variable_name)
\chinese 变量值加1。
void defineFunction(const std::string &func_name)
\chinese 定义函数。 \endchinese \english Define a function.
void setPayload(double mass, double x, double y, double z)
\chinese 设置负载质量和重心。 \endchinese \english Sets the mass and Center of Gravity of the payload.
void forCondition(int count, int step)
\chinese 开始for循环。 \endchinese \english Starts a for-loop.
void note(const std::string &expression)
\chinese 添加注释。 \endchinese \english Add a note.
void assign(const std::string &variableName, const ExpressionPtr &expression, bool sync=false)
\chinese
void end()
\chinese 插入end。 \endchinese \english Insert an end.
void runThread(const std::string &thread_name)
\chinese 启动线程。 \endchinese \english Start a thread.
void elseCondition()
\chinese 添加else分支。 \endchinese \english Adds an else branch.
void whileCondition(const ExpressionPtr &expression)
\chinese 开始while循环。 \endchinese \english Starts a while-loop.
void appendRaw(const std::string &script)
\chinese 按原样追加脚本代码,不使用自动缩进。
void setTcp(const std::vector< double > &pose)
\chinese 设置TCP。 \endchinese \english Set the Tool Center Point.
void appendVectorDouble(const std::vector< double > &value)
void assign(VariablePtr variable, const std::string &expression, bool sync=false)
void elseIfCondition(const ExpressionPtr &expression)
\chinese 添加else-if分支。 \endchinese \english Adds an else-if branch.
void lineFeed()
\chinese 插入空行。 \endchinese \english Insert an empty line.
void returnMethod()
\chinese 返回。 \endchinese \english Return from method.
std::string getResolvedVariable(const std::string &variable_name)
\chinese 获取可在脚本中使用的已注册变量名。
void ifCondition(const ExpressionPtr &expression)
\chinese 开始if条件。 \endchinese \english Start an if-conditional.
void defineThread(const std::string &thread_name, bool loop_or_not)
\chinese 定义线程。 \endchinese \english Start a thread definition.
void setRobotIndex(int robot_index)
void whileNot(const ExpressionPtr &expression)
\chinese 开始取反的while循环。 \endchinese \english Starts a negated while-loop.