12 #ifndef FAUDES_IEC61131stCode_H
13 #define FAUDES_IEC61131stCode_H
15 #include "libfaudes.h"
18 using namespace faudes;
126 enum IECVariableType { LOCAL, TEMP, INPUT, OUTPUT, INOUT, EXTERNAL, GLOBAL, ACCESS, NONE };
147 virtual void Clear(
void);
164 void DoCompile(
void);
167 void DoGenerate(
void);
170 virtual void DoGenerateFunction(
void);
173 virtual void DoGenerateLookups(
void);
176 virtual void DecrementTimers(
void);
185 virtual std::string TargetAddress(
const AA& address);
188 virtual AX TargetExpression(
const AA& address);
197 virtual void Comment(
const std::string& text);
200 virtual void VariableDeclare(
const std::string& laddr,
const std::string& ltype);
201 virtual void VariableDeclare(
const std::string& laddr,
const std::string& ltype,
const std::string& lval);
204 virtual void IntegerDeclare(
const AA& address);
205 virtual void IntegerDeclare(
const AA& address,
int val);
206 virtual void IntegerAssign(
const AA& address,
int val);
207 virtual void IntegerAssign(
const AA& address,
const AX& expression);
208 virtual void IntegerIncrement(
const AA& address,
int val);
209 virtual AX IntegerQuotient(
const AX& expression,
int val);
210 virtual AX IntegerRemainder(
const AX& expression,
int val);
211 virtual AX IntegerBitmask(
const AX& expression);
212 virtual AX IntegerIsEq(
const AA& address,
int val);
213 virtual AX IntegerIsEq(
const AA& address,
const AX& expression);
214 virtual AX IntegerIsNotEq(
const AA& address,
int val);
215 virtual AX IntegerIsNotEq(
const AA& address,
const AX& expression);
216 virtual AX IntegerIsGreater(
const AA& address,
int val);
217 virtual AX IntegerIsLess(
const AA& address,
int val);
218 virtual AX IntegerConstant(
int val);
221 virtual bool HasIntmaths(
void);
222 virtual void WordDeclare(
const AA& address);
223 virtual void WordDeclare(
const AA& address,
word_t val);
224 virtual void WordAssign(
const AA& address,
word_t val);
225 virtual void WordAssign(
const AA& address,
const AX& expression);
226 virtual void WordOr(
const AA& address,
word_t val);
227 virtual void WordOr(
const AA& address,
const AX& expression);
228 virtual void WordOr(
const AA& address,
const AA& op1,
const AA& op2);
229 virtual void WordOr(
const AA& address,
const AA& op1,
word_t op2);
230 virtual void WordAnd(
const AA& address,
word_t val);
231 virtual void WordAnd(
const AA& address,
const AX& expression);
232 virtual void WordAnd(
const AA& address,
const AA& op1,
const AA& op2);
233 virtual void WordAnd(
const AA& address,
const AA& op1,
word_t op2);
234 virtual void WordNand(
const AA& address,
const AX& expression);
235 virtual AX WordIsBitSet(
const AA& address,
int idx);
236 virtual AX WordIsBitClr(
const AA& address,
int idx);
237 virtual AX WordIsMaskSet(
const AA& address,
word_t mask);
238 virtual AX WordIsEq(
const AA& address,
word_t val);
239 virtual AX WordIsNotEq(
const AA& address,
word_t val);
240 virtual AX WordConstant(
word_t val);
243 virtual void BooleanDeclare(
const AA& address);
244 virtual void BooleanDeclare(
const AA& address,
int val);
245 virtual void BooleanAssign(
const AA& address,
int val);
246 virtual void BooleanAssign(
const AA& address,
const AX& expression);
247 virtual AX BooleanIsEq(
const AA& op1,
const AA& op2);
248 virtual AX BooleanIsNotEq(
const AA& op1,
const AA& op2);
251 virtual void CintarrayDeclare(
const AA& address,
int offset,
const std::vector<int>& val);
252 virtual AA CintarrayAccess(
const AA& address,
int index);
253 virtual AA CintarrayAccess(
const AA& address,
const AA& indexaddr);
254 virtual bool HasCintarray(
void);
255 virtual void CwordarrayDeclare(
const AA& address,
int offset,
const std::vector<word_t>& val);
256 virtual AA CwordarrayAccess(
const AA& address,
int index);
257 virtual AA CwordarrayAccess(
const AA& address,
const AA& indexaddr);
258 virtual bool HasCwordarray(
void);
259 virtual void CstrarrayDeclare(
const AA& address,
int offset,
const std::vector<std::string>& val);
260 virtual AA CstrarrayAccess(
const AA& address,
int index);
261 virtual AA CstrarrayAccess(
const AA& address,
const AA& indexaddr);
262 virtual bool HasCstrarray(
void);
263 virtual void IntarrayDeclare(
const AA& address,
int offset,
int len);
264 virtual void IntarrayDeclare(
const AA& address,
int offset,
const std::vector<int>& val);
265 virtual AA IntarrayAccess(
const AA& address,
int index);
266 virtual AA IntarrayAccess(
const AA& address,
const AA& indexaddr);
267 virtual bool HasIntarray(
void);
268 virtual void WordarrayDeclare(
const AA& address,
int offset,
int len);
269 virtual void WordarrayDeclare(
const AA& address,
int offset,
const std::vector<word_t>& val);
270 virtual AA WordarrayAccess(
const AA& address,
int index);
271 virtual AA WordarrayAccess(
const AA& address,
const AA& indexaddr);
272 virtual bool HasWordarray(
void);
276 virtual void IfTrue(
const AX& expression);
277 virtual void IfFalse(
const AX& expression);
278 virtual void IfWord(
const AX& expression);
279 virtual void IfElse(
void);
280 virtual void IfElseIfTrue(
const AX& expression);
281 virtual void IfEnd(
void);
284 virtual void SwitchBegin(
const AA& address);
285 virtual void SwitchCase(
const AA& address,
int val);
286 virtual void SwitchCases(
const AA& address,
int from,
int to);
287 virtual void SwitchCases(
const AA& address,
const std::set< int >& vals);
288 virtual void SwitchBreak(
void);
289 virtual void SwitchEnd(
void);
290 virtual bool HasMultiCase(
void);
293 virtual void LoopBegin(
void);
294 virtual void LoopBreak(
const AX& expression);
295 virtual void LoopEnd(
void);
296 virtual void FunctionReturn(
void);
300 virtual void RunActionSet(
const std::string& address);
301 virtual void RunActionClr(
const std::string& address);
302 virtual void RunActionExe(
const AX& expression);
305 virtual void TimerDeclare(
const AA& address,
const std::string& val);
306 virtual void TimerStart(
const AA& address);
307 virtual void TimerStop(
const AA& address);
308 virtual void TimerReset(
const AA& address,
const std::string& val);
309 virtual AX TimerIsElapsed(
const AA& address);
312 virtual void DeclareTimers(
void);
313 virtual void ResetState(
void);
317 virtual AX TimeConstant(
int val);
318 virtual AX IntarrayConstant(
const std::vector<int>& val);
319 virtual AX WordarrayConstant(
const std::vector<word_t>& val);
320 virtual AX StringConstant(
const std::string& val);
321 virtual AX StrarrayConstant(
const std::vector<std::string>& val);
323 virtual void DeclareImportPhysicalIo(
void);
324 virtual void DeclareImportSymbolicIo(
void);
325 virtual int CountImportPhysicalIo(
void);
326 virtual int CountImportSymbolicIo(
void);
327 virtual void LiteralCyclic(
void);
328 virtual void DeclareSystime(
void);
329 virtual void UpdateSystime(
void);
330 virtual void InsertExecHooks(
void);
349 virtual void DoReadTargetConfiguration(TokenReader& rTr);
362 virtual void DoWriteTargetConfiguration(TokenWriter& rTw)
const;
364 void CurrentVariableType(
const IECVariableType& type);
365 IECVariableType CurrentVariableType(
void);
368 IECVariableType mCurrentVariableType;
Code-generator with abstract types and operations.
unsigned long word_t
Code-generator internal data type of target words.
Abstract address; see also Absstract_Addresses.
Abstract expression; see also Absstract_Addresses.
Execution semantics in terms of code primitives.
Implementation of primitives by IEC 61131 ST.
void EndCyclicCode(void)
reimplemented code snippets
void BeginCyclicCode(void)
reimplemented code snippets
std::string mLiteralCyclic
option: extra cyclic code
bool mHasIecTimeOperators
option: overloaded operators for time maths
std::string mIecDeclarePhysical
option: formal declaration of io lines