Implementation of primitives by IEC 61131 ST. More...
#include <cgp_iec61131st.h>

Public Types | |
| enum | IECVariableType { LOCAL , TEMP , INPUT , OUTPUT , INOUT , EXTERNAL , GLOBAL , ACCESS , NONE } |
Public Types inherited from CodeGenerator | |
| enum | OutSink { CONSOLE , FILE , STRING } |
| typedef std::vector< TimedGenerator >::const_iterator | Iterator |
| Iterator for read-only access of generators. | |
| typedef unsigned long | word_t |
| Code-generator internal data type of target words. | |
| typedef std::map< std::string, LineAddress >::iterator | LineIterator |
| Access to line records by iterator. | |
| typedef std::map< std::string, FlagExpression >::iterator | FlagIterator |
| Access to flag records by iterator. | |
| typedef std::map< std::string, TimerConfiguration >::iterator | TimerIterator |
| Access to timer records by iterator. | |
| typedef std::map< std::string, ActionAddress >::iterator | ActionAddressIterator |
| Access to action record by iterator. | |
| typedef std::map< std::string, TimerAction >::iterator | TimerActionIterator |
| Access to timer records by iterator. | |
Protected Member Functions | |
| void | DoCompile (void) |
| add my preferences to DoCompile | |
| void | DoGenerate (void) |
| code generation hook (overall) | |
| virtual void | DoGenerateFunction (void) |
| code generation hook (function block) | |
| virtual void | DoGenerateLookups (void) |
| code generation hook (lookup functions) | |
| virtual void | DecrementTimers (void) |
| code snippet | |
| void | BeginCyclicCode (void) |
| reimplemented code snippets | |
| void | EndCyclicCode (void) |
| reimplemented code snippets | |
| virtual std::string | TargetAddress (const AA &address) |
| abstract address conversion | |
| virtual AX | TargetExpression (const AA &address) |
| abstract address conversion | |
| virtual void | DoReadTargetConfiguration (TokenReader &rTr) |
| File i/o. | |
| virtual void | DoWriteTargetConfiguration (TokenWriter &rTw) const |
| File i/o. | |
| void | CurrentVariableType (const IECVariableType &type) |
| IECVariableType | CurrentVariableType (void) |
Protected Member Functions inherited from CodePrimitives | |
| virtual void | DoGenerateDeclarations (void) |
| cut-and-paste template for code snippet assembly | |
| virtual void | DoGenerateResetCode (void) |
| cut-and-paste template for code snippet assembly | |
| virtual void | DoGenerateCyclicCode (void) |
| cut-and-paste template for code snippet assembly | |
| virtual void | LiteralPrepend (void) |
| Cosmetic: prepend literally from configuration data. | |
| virtual void | DeclareStatus (void) |
| Declare "status". | |
| virtual void | DeclareReset (void) |
| Declare "reset". | |
| virtual void | DeclareRecentEvent (void) |
| Declare "recent_event". | |
| virtual void | DeclareParallelState (void) |
| Declare "parallel_state". | |
| virtual void | DeclarePendingEvents (void) |
| Declare "pending_events" and "enabled_events". | |
| virtual void | DeclareLoopState (void) |
| Declare loop state, i.e. line levels, loop flag. | |
| virtual void | DeclareAux (void) |
| Declare variables local to the provided snippets, e.g. helpers for bit-mask computation. | |
| virtual void | DeclareLargeCarray (void) |
| Declare compiled transition relations. | |
| virtual void | DeclareSmallCarray (void) |
| Declare bit-mask loop-ups. | |
| virtual void | DeclareEventNameLookup (void) |
| Declare symbolic name lookup tables. | |
| virtual void | DeclareStateNameLookup (void) |
| Declare symbolic name lookup tables. | |
| virtual void | ResetReturn (void) |
| Reset bail out. | |
| virtual void | SenseInputs (void) |
| Sense input events and add to "pending_events". | |
| virtual void | SenseTimerElapse (void) |
| Sense timer elapse vents and add to "pending_events". | |
| virtual void | BeginExecutionLoop (void) |
| Execution Loop, begin. | |
| virtual void | UpdateEnabled (void) |
| Update "enabled_events" from "parallel_state" if "exec_event" was set. | |
| virtual void | ScheduleEvent (void) |
| Select event to execute from "pending_and_enabled_events" or "enabled_events". | |
| virtual void | BreakExecutionLoop (void) |
| Execution Loop, break. | |
| virtual void | ExecuteEvent (void) |
| Take transition and figure new state. | |
| virtual void | OperateTimers (void) |
| Start/stop/reset timers w.r.t. "exec_event". | |
| virtual void | OperateOutputs (void) |
| Operate output lines w.r.t. "exec_event". | |
| virtual void | EndExecutionLoop (void) |
| Loop end. | |
| virtual void | LiteralAppend (void) |
| Cosmetic: append literally from configuration. | |
| virtual void | ExecuteEventBySwitching (void) |
| Alternative implementation of ExecuteEvent() | |
| virtual void | ExecuteEventByInterpreter (void) |
| Alternative implementation of ExecuteEventBy() | |
| virtual void | UpdateEnabledBySwitching (void) |
| Alternative implementations UpdateEnabled() | |
| virtual void | UpdateEnabledByInterpreter (void) |
| Alternative implementations UpdateEnabled() | |
| virtual std::string | TargetSymbol (const std::string &str) |
| Mangle string to valid target symbol. | |
| virtual void | IntegerDecrement (const AA &address, int val=1) |
| virtual void | BitarrayDeclare (const AA &address, int blen) |
| virtual void | BitarrayDeclare (const AA &address, const std::vector< bool > &val) |
| virtual void | BitarrayAssign (const AA &address, const std::vector< bool > &val) |
| virtual void | BitarrayAssign (const AA &address, const AA &otherarray) |
| virtual void | BitarrayClear (const AA &address) |
| virtual void | BitarrayFull (const AA &address) |
| virtual void | BitarraySetBit (const AA &address, int bitaddr) |
| virtual void | BitarraySetBit (const AA &address, const AA &indexaddr, int offset=0, const std::vector< bool > &hint=std::vector< bool >()) |
| virtual void | BitarrayClrBit (const AA &address, int bitaddr) |
| virtual void | BitarrayClrBit (const AA &address, const AA &indexaddr, int offset=0, const std::vector< bool > &hint=std::vector< bool >()) |
| virtual void | BitarrayIsBitSet (const AA &address, const AA &indexaddr, const AA &result, int offset=0, const std::vector< bool > &hint=std::vector< bool >()) |
| virtual void | BitarrayOr (const AA &address, const std::vector< bool > &val) |
| virtual void | BitarrayOr (const AA &address, const AA &op1, const std::vector< bool > &op2) |
| virtual void | BitarrayOrAllWords (const AA &address, const AA &result) |
| virtual void | BitarrayAnd (const AA &address, const std::vector< bool > &val) |
| virtual void | BitarrayAnd (const AA &address, const AA &otherarray) |
| virtual void | BitarrayAnd (const AA &address, const AA &op1, const AA &op2) |
| virtual void | BitarrayAnd (const AA &address, const AA &op1, const std::vector< bool > &op2) |
| virtual void | BitarrayFindFirst (const AA &address, const AA &result, int offset=0) |
| virtual void | EventSetDeclare (const AA &address) |
| virtual void | EventSetDeclare (const AA &address, const EventSet &evset) |
| virtual void | EventSetAssign (const AA &address, const EventSet &evset) |
| virtual void | EventSetInsert (const AA &address, const EventSet &evset) |
| virtual void | EventSetInsert (const AA &address, Idx ev) |
| virtual void | EventSetInsert (const AA &address, const AA &evaddr) |
| virtual void | EventSetInsert (const AA &address, const AA &evaddr, const EventSet &hint) |
| virtual void | EventSetErase (const AA &address, const EventSet &evset) |
| virtual void | EventSetErase (const AA &address, Idx ev) |
| virtual void | EventSetErase (const AA &address, const AA &evaddr) |
| virtual void | EventSetErase (const AA &address, const AA &evaddr, const EventSet &hint) |
| virtual void | EventSetExists (const AA &address, const AA &evaddr, const AA &result, const EventSet &hint) |
| virtual void | EventSetRestrict (const AA &address, const AA &otherset) |
| virtual void | EventSetUnion (const AA &address, const AA &op1, const EventSet &op2) |
| virtual void | EventSetIntersection (const AA &address, const AA &op1, const EventSet &op2) |
| virtual void | EventSetClear (const AA &address) |
| virtual void | EventSetFull (const AA &address) |
| virtual void | EventSetIsNotEmpty (const AA &address, const AA &result) |
| virtual void | EventSetFindHighestPriority (const AA &address, const AA &result) |
| virtual AX | ReadInputLine (const std::string &address) |
| virtual AX | InputExpression (const std::string &expression) |
| virtual int | StateTargetIdx (size_t git, Idx idx) |
| Overload base class to use the vector address only if the respective code option is active) | |
| virtual Idx | StateFaudesIdx (size_t git, int idx) |
| Overload base class to use the vector address only if the respective code option is active) | |
Protected Member Functions inherited from CodeGenerator | |
| virtual void | DoRead (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0) |
| Read the configuration from TokenReader, see faudes Type for public wrappers. | |
| virtual void | DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const |
| Writes the configuration to TokenWriter, see faudes Type for public wrappers. | |
Protected Attributes | |
| std::string | mIecDeclarePhysical |
| option: formal declaration of io lines | |
| std::string | mIecDeclareSymbolic |
| option: formal declaration of io variables | |
| bool | mHasIecTimeOperators |
| option: overloaded operators for time maths | |
| std::string | mLiteralCyclic |
| option: extra cyclic code | |
Protected Attributes inherited from CodePrimitives | |
| std::string | mWordType |
| target data type for word | |
| std::string | mIntegerType |
| target data type for integer | |
| std::string | mPrefix |
| universal prefix (pseudo name space) | |
| bool | mArrayForTransitions |
| code option: use const array to represent transitions | |
| bool | mMaintainStateIndices |
| code option: use state indices as provided | |
| bool | mBitAddressArithmetic |
| code option: compute bit and word address on target | |
| bool | mArrayForBitmasks |
| code option: use const array to represent bit-masks | |
| bool | mArrayForBitarray |
| code option: use const array to represent bit-masks | |
| bool | mBisectionForBitfind |
| code option: use bisection to fing lowest set bit | |
| bool | mArrayForState |
| code option: use int arrays to represent that overall state | |
| bool | mEventsetsForPerformance |
| code option: eventsets for performance | |
| bool | mLoopPendingInputs |
| code option: loop until all inputs are resolved | |
| bool | mLoopEnabledOutputs |
| code option: loop until all enabled outputs are executed | |
| bool | mStrictEventSynchronisation |
| code option: strict event synchronisation | |
| bool | mEventNameLookup |
| code option: event name lookup | |
| bool | mStateNameLookup |
| code option: state name lookup | |
| std::vector< bool > | mHasStateNames |
| record per generator whether there is a lookup table | |
| bool | mExistStateNames |
| record whether there exist statenames at all | |
| std::string | mEventExecutionHook |
| code option: event exec hook | |
| std::string | mStateUpdateHook |
| code option: state change hook | |
| std::string | mLiteralPrepend |
| extra code to prepend | |
| std::string | mLiteralAppend |
| extra code to prepend | |
| std::map< std::string, bitarray_rec > | mBitarrays |
| Record of all declared bit-arrays. | |
Protected Attributes inherited from CodeGenerator | |
| std::string | mName |
| faudes object name (aka project name) | |
| std::vector< TimedGenerator > | mGenerators |
| list of executors | |
| std::vector< std::string > | mGeneratorNames |
| list of filenames when generator are read from file | |
| cgEventSet | mAlphabet |
| event configuration by attributes | |
| int | mWordSize |
| compressed boolean capacity of target type word | |
| int | mIntegerSize |
| compressed boolean capacity of target type integer | |
| std::map< Idx, int > | mEventBitAddress |
| mapping from faudes event idx to bit address (descending priority, range 0 . | |
| std::map< int, Idx > | mEventFaudesIdx |
| mapping from bit address to faudes event idx | |
| int | mLastInputEvent |
| highest bit-address with input (or timer) event (-1 for none) | |
| int | mLastOutputEvent |
| highest bit-address with output event (-1 for none) | |
| std::vector< std::map< Idx, int > > | mStateVectorAddress |
| mapping from faudes state idx to vector index | |
| std::vector< std::map< int, Idx > > | mStateFaudesIndex |
| mapping from vector state idx to faudes index | |
| std::vector< bool > | mUsingVectorAddressStates |
| configuration of state indexing per generator | |
| std::vector< std::vector< int > > | mTransitionVector |
| compiled transition-sets, represented as vectors of integers with 0 as separator | |
| EventSet | mUsedEvents |
| configured events that are referred to by some generator | |
| EventSet | mOutputEvents |
| used events that are configured as outputs | |
| EventSet | mInputEvents |
| used events that are configured as inputs (incl timer) | |
| EventSet | mInternalEvents |
| used events that are configured as internal events (excl. | |
| std::map< std::string, LineAddress > | mLines |
| input event generation | |
| std::map< std::string, FlagExpression > | mFlags |
| input event generation | |
| std::map< std::string, TimerConfiguration > | mTimers |
| timer definitions | |
| std::map< std::string, ActionAddress > | mActionAddresses |
| action addresses | |
| std::map< std::string, TimerAction > | mTimerActions |
| timer actions by event name | |
| int | mVerbLevel |
| diagnpstic-output level | |
| std::string | mOutMode |
| output file name (base) | |
| char | mMuteMode |
| current output mode | |
| bool | mMuteComments |
| mute comments | |
| std::string | mRecentMutedComment |
| recent muted comment | |
| std::ostream * | pOutStream |
| output stream | |
| std::ostream * | pErrStream |
| error stream | |
Basic Class Maintenance | |
| Iec61131stCodeGenerator (void) | |
| Constructor. | |
| virtual | ~Iec61131stCodeGenerator (void) |
| Explicit destructor. | |
| virtual void | Clear (void) |
| Clear all data. | |
Implement Primitives | |
| virtual void | Comment (const std::string &text) |
| generate code: conditionals | |
| virtual void | VariableDeclare (const std::string &laddr, const std::string <ype) |
| generate code: conditionals | |
| virtual void | VariableDeclare (const std::string &laddr, const std::string <ype, const std::string &lval) |
| generate code: conditionals | |
| virtual void | IntegerDeclare (const AA &address) |
| generate code: conditionals | |
| virtual void | IntegerDeclare (const AA &address, int val) |
| generate code: conditionals | |
| virtual void | IntegerAssign (const AA &address, int val) |
| generate code: conditionals | |
| virtual void | IntegerAssign (const AA &address, const AX &expression) |
| generate code: conditionals | |
| virtual void | IntegerIncrement (const AA &address, int val) |
| generate code: conditionals | |
| virtual AX | IntegerQuotient (const AX &expression, int val) |
| generate code: conditionals | |
| virtual AX | IntegerRemainder (const AX &expression, int val) |
| generate code: conditionals | |
| virtual AX | IntegerBitmask (const AX &expression) |
| generate code: conditionals | |
| virtual AX | IntegerIsEq (const AA &address, int val) |
| generate code: conditionals | |
| virtual AX | IntegerIsEq (const AA &address, const AX &expression) |
| generate code: conditionals | |
| virtual AX | IntegerIsNotEq (const AA &address, int val) |
| generate code: conditionals | |
| virtual AX | IntegerIsNotEq (const AA &address, const AX &expression) |
| generate code: conditionals | |
| virtual AX | IntegerIsGreater (const AA &address, int val) |
| generate code: conditionals | |
| virtual AX | IntegerIsLess (const AA &address, int val) |
| generate code: conditionals | |
| virtual AX | IntegerConstant (int val) |
| generate code: conditionals | |
| virtual bool | HasIntmaths (void) |
| generate code: conditionals | |
| virtual void | WordDeclare (const AA &address) |
| generate code: conditionals | |
| virtual void | WordDeclare (const AA &address, word_t val) |
| generate code: conditionals | |
| virtual void | WordAssign (const AA &address, word_t val) |
| generate code: conditionals | |
| virtual void | WordAssign (const AA &address, const AX &expression) |
| generate code: conditionals | |
| virtual void | WordOr (const AA &address, word_t val) |
| generate code: conditionals | |
| virtual void | WordOr (const AA &address, const AX &expression) |
| generate code: conditionals | |
| virtual void | WordOr (const AA &address, const AA &op1, const AA &op2) |
| generate code: conditionals | |
| virtual void | WordOr (const AA &address, const AA &op1, word_t op2) |
| generate code: conditionals | |
| virtual void | WordAnd (const AA &address, word_t val) |
| generate code: conditionals | |
| virtual void | WordAnd (const AA &address, const AX &expression) |
| generate code: conditionals | |
| virtual void | WordAnd (const AA &address, const AA &op1, const AA &op2) |
| generate code: conditionals | |
| virtual void | WordAnd (const AA &address, const AA &op1, word_t op2) |
| generate code: conditionals | |
| virtual void | WordNand (const AA &address, const AX &expression) |
| generate code: conditionals | |
| virtual AX | WordIsBitSet (const AA &address, int idx) |
| generate code: conditionals | |
| virtual AX | WordIsBitClr (const AA &address, int idx) |
| generate code: conditionals | |
| virtual AX | WordIsMaskSet (const AA &address, word_t mask) |
| generate code: conditionals | |
| virtual AX | WordIsEq (const AA &address, word_t val) |
| generate code: conditionals | |
| virtual AX | WordIsNotEq (const AA &address, word_t val) |
| generate code: conditionals | |
| virtual AX | WordConstant (word_t val) |
| generate code: conditionals | |
| virtual void | BooleanDeclare (const AA &address) |
| generate code: conditionals | |
| virtual void | BooleanDeclare (const AA &address, int val) |
| generate code: conditionals | |
| virtual void | BooleanAssign (const AA &address, int val) |
| generate code: conditionals | |
| virtual void | BooleanAssign (const AA &address, const AX &expression) |
| generate code: conditionals | |
| virtual AX | BooleanIsEq (const AA &op1, const AA &op2) |
| generate code: conditionals | |
| virtual AX | BooleanIsNotEq (const AA &op1, const AA &op2) |
| generate code: conditionals | |
| virtual void | CintarrayDeclare (const AA &address, int offset, const std::vector< int > &val) |
| generate code: conditionals | |
| virtual AA | CintarrayAccess (const AA &address, int index) |
| generate code: conditionals | |
| virtual AA | CintarrayAccess (const AA &address, const AA &indexaddr) |
| generate code: conditionals | |
| virtual bool | HasCintarray (void) |
| generate code: conditionals | |
| virtual void | CwordarrayDeclare (const AA &address, int offset, const std::vector< word_t > &val) |
| generate code: conditionals | |
| virtual AA | CwordarrayAccess (const AA &address, int index) |
| generate code: conditionals | |
| virtual AA | CwordarrayAccess (const AA &address, const AA &indexaddr) |
| generate code: conditionals | |
| virtual bool | HasCwordarray (void) |
| generate code: conditionals | |
| virtual void | CstrarrayDeclare (const AA &address, int offset, const std::vector< std::string > &val) |
| generate code: conditionals | |
| virtual AA | CstrarrayAccess (const AA &address, int index) |
| generate code: conditionals | |
| virtual AA | CstrarrayAccess (const AA &address, const AA &indexaddr) |
| generate code: conditionals | |
| virtual bool | HasCstrarray (void) |
| generate code: conditionals | |
| virtual void | IntarrayDeclare (const AA &address, int offset, int len) |
| generate code: conditionals | |
| virtual void | IntarrayDeclare (const AA &address, int offset, const std::vector< int > &val) |
| generate code: conditionals | |
| virtual AA | IntarrayAccess (const AA &address, int index) |
| generate code: conditionals | |
| virtual AA | IntarrayAccess (const AA &address, const AA &indexaddr) |
| generate code: conditionals | |
| virtual bool | HasIntarray (void) |
| generate code: conditionals | |
| virtual void | WordarrayDeclare (const AA &address, int offset, int len) |
| generate code: conditionals | |
| virtual void | WordarrayDeclare (const AA &address, int offset, const std::vector< word_t > &val) |
| generate code: conditionals | |
| virtual AA | WordarrayAccess (const AA &address, int index) |
| generate code: conditionals | |
| virtual AA | WordarrayAccess (const AA &address, const AA &indexaddr) |
| generate code: conditionals | |
| virtual bool | HasWordarray (void) |
| generate code: conditionals | |
| virtual void | IfTrue (const AX &expression) |
| generate code: conditionals | |
| virtual void | IfFalse (const AX &expression) |
| generate code: conditionals | |
| virtual void | IfWord (const AX &expression) |
| generate code: conditionals | |
| virtual void | IfElse (void) |
| generate code: conditionals | |
| virtual void | IfElseIfTrue (const AX &expression) |
| generate code: conditionals | |
| virtual void | IfEnd (void) |
| generate code: conditionals | |
| virtual void | SwitchBegin (const AA &address) |
| generate code: conditionals | |
| virtual void | SwitchCase (const AA &address, int val) |
| generate code: conditionals | |
| virtual void | SwitchCases (const AA &address, int from, int to) |
| generate code: conditionals | |
| virtual void | SwitchCases (const AA &address, const std::set< int > &vals) |
| generate code: conditionals | |
| virtual void | SwitchBreak (void) |
| generate code: conditionals | |
| virtual void | SwitchEnd (void) |
| generate code: conditionals | |
| virtual bool | HasMultiCase (void) |
| generate code: conditionals | |
| virtual void | LoopBegin (void) |
| generate code: conditionals | |
| virtual void | LoopBreak (const AX &expression) |
| generate code: conditionals | |
| virtual void | LoopEnd (void) |
| generate code: conditionals | |
| virtual void | FunctionReturn (void) |
| generate code: conditionals | |
| virtual void | RunActionSet (const std::string &address) |
| generate code: conditionals | |
| virtual void | RunActionClr (const std::string &address) |
| generate code: conditionals | |
| virtual void | RunActionExe (const AX &expression) |
| generate code: conditionals | |
| virtual void | TimerDeclare (const AA &address, const std::string &val) |
| generate code: conditionals | |
| virtual void | TimerStart (const AA &address) |
| generate code: conditionals | |
| virtual void | TimerStop (const AA &address) |
| generate code: conditionals | |
| virtual void | TimerReset (const AA &address, const std::string &val) |
| generate code: conditionals | |
| virtual AX | TimerIsElapsed (const AA &address) |
| generate code: conditionals | |
| virtual void | DeclareTimers (void) |
| generate code: conditionals | |
| virtual void | ResetState (void) |
| generate code: conditionals | |
| virtual AX | TimeConstant (int val) |
| generate code: conditionals | |
| virtual AX | IntarrayConstant (const std::vector< int > &val) |
| generate code: conditionals | |
| virtual AX | WordarrayConstant (const std::vector< word_t > &val) |
| generate code: conditionals | |
| virtual AX | StringConstant (const std::string &val) |
| generate code: conditionals | |
| virtual AX | StrarrayConstant (const std::vector< std::string > &val) |
| generate code: conditionals | |
| virtual void | DeclareImportPhysicalIo (void) |
| generate code: conditionals | |
| virtual void | DeclareImportSymbolicIo (void) |
| generate code: conditionals | |
| virtual int | CountImportPhysicalIo (void) |
| generate code: conditionals | |
| virtual int | CountImportSymbolicIo (void) |
| generate code: conditionals | |
| virtual void | LiteralCyclic (void) |
| generate code: conditionals | |
| virtual void | DeclareSystime (void) |
| generate code: conditionals | |
| virtual void | UpdateSystime (void) |
| generate code: conditionals | |
| virtual void | InsertExecHooks (void) |
| generate code: conditionals | |
Additional Inherited Members | |
Public Member Functions inherited from CodePrimitives | |
| CodePrimitives (void) | |
| Constructor. | |
| virtual | ~CodePrimitives (void) |
| Explicit destructor. | |
Public Member Functions inherited from CodeGenerator | |
| Idx | Size (void) const |
| Number of generators. | |
| void | Insert (const std::string &file) |
| Add a Generator from file. | |
| void | Insert (const TimedGenerator &rGen) |
| Add a generator by reference. | |
| const TimedGenerator & | At (int i) const |
| Direct access for read-only access of generators. | |
| Iterator | Begin (void) const |
| Begin-iterator for read-only access of generators. | |
| Iterator | End (void) const |
| End-iterator for read-only access of generators. | |
| virtual int | EventTargetIdx (Idx idx) |
| Get target event Idx from faudes Idx (use bit-address + 1) | |
| virtual int | EventTargetIdx (const std::string &ev) |
| Get target event Idx from faudes name (use bit-address + 1) | |
| int | EventBitAddress (Idx idx) |
| Get event bit-address from faudes Idx (consecutive, starts at 0) | |
| Idx | EventFaudesIdx (int idx) |
| Get faudes Idx from target Idx (aka from bit-address + 1) | |
| std::vector< bool > | EventBitMask (Idx idx) |
| Get vector representation for a single faudes event Idx. | |
| std::vector< bool > | EventBitMask (const EventSet &eset) |
| Get vector representation for faudes event set. | |
| int | EventBitMaskSize (void) |
| Get overall number of events. | |
| word_t | WordFromBitVector (const std::vector< bool > &vect, int wordindex) |
| Extract individual word from boolean vector. | |
| std::vector< word_t > | WordVectorFromBitVector (const std::vector< bool > &vect) |
| Convert boolean vector to word array. | |
| LineIterator | LinesBegin () |
| Access to line records by iterator. | |
| LineIterator | LinesEnd () |
| Access to line records by iterator. | |
| FlagIterator | FlagsBegin () |
| Access to flag records by iterator. | |
| FlagIterator | FlagsEnd () |
| Access to flag records by iterator. | |
| TimerIterator | TimersBegin () |
| Access to timer records by iterator. | |
| TimerIterator | TimersEnd () |
| Access to timer records by iterator. | |
| ActionAddressIterator | ActionAddressesBegin () |
| Access to action addresses by iterator. | |
| ActionAddressIterator | ActionAddressesEnd () |
| Access to action addresses by iterator. | |
| TimerActionIterator | TimerActionsBegin () |
| Access to timer records by iterator. | |
| TimerActionIterator | TimerActionsEnd () |
| Access to timer records by iterator. | |
| CodeGenerator (void) | |
| Constructor. | |
| virtual | ~CodeGenerator (void) |
| Destructor. | |
| virtual void | Name (const std::string &rName) |
| Set objects's name (reimplementing base faudes::Type) | |
| virtual const std::string & | Name (void) const |
| Get objects's name (reimplementing base faudes::Type) | |
| virtual void | Compile (void) |
| Compile input data for alternative representation. | |
| Idx | EventIndex (const std::string &rName) const |
| Faudes-event index lookup. | |
| std::string | EventName (Idx index) const |
| Faudes-event name lookup. | |
| const AttributeCodeGeneratorEvent & | EventAttribute (Idx ev) const |
| Event configuration attribute lookup. | |
| void | EventAttribute (Idx ev, const AttributeCodeGeneratorEvent &attr) |
| Set event attribute. | |
| void | Alphabet (const cgEventSet &rAlphabet) |
| Set all event attributes. | |
| const cgEventSet & | Alphabet (void) const |
| Access alphabet (incl event attributes) | |
| const std::vector< int > & | TransitionVector (size_t git) |
| Get target state index (refer to vector representation as default, overload in CodePrimitives) | |
| virtual void | Generate (void) |
| Generate code. | |
| void | Verbose (int level, std::ostream *altout=0) |
| Set verbosity level. | |
| virtual void | OutputMode (const std::string &mode) |
| Set code output mode. | |
| std::string | OutputMode (void) |
| Report code output mode. | |
| virtual std::ostream & | Output (void) |
| Output stream. | |
| const std::string & | OutputString (void) |
| Get accumulated output as string. | |
| void | OutputString (const std::string &strbuf) |
| Set output to string. | |
| virtual void | MuteMode (char mode) |
| Set current mute mode. | |
| virtual void | MuteCond (char mode) |
| Set mode condition. | |
| virtual void | LineFeed (int lines=1) |
| LineFeed (convenience support for derived classes) | |
| virtual std::string | LineCount (void) |
| LineFeed (convenience support for derived classes) | |
| virtual void | IndentInc () |
| Indentation (convenience support for derived classes) | |
| virtual void | IndentDec () |
| Indentation (convenience support for derived classes) | |
| std::string | RecentComment (void) |
| Recent muted comment (convenience support for derived classes) | |
| virtual void | XmlTextEscape (bool on) |
| XmlTextEscape (escape "<", ">", "&", "\"" and "'") | |
| virtual void | XmlCdataEscape (bool on) |
| XmlCdataEscape (escape "]]>") | |
| virtual void | MuteComments (bool on) |
| Mute comments (convenience support for derived classes) | |
| virtual void | MuteVspace (bool on) |
| Mute empty lines (convenience support for derived classes) | |
Static Public Member Functions inherited from CodeGenerator | |
| static std::string | VersionString (void) |
| Version (refers to macro COMPILEDES_VERSION, defined in cgp_codegenerator.h) | |
| static void | Register (const std::string &type, CodeGenerator *(*newcg)(void)) |
| Insert derived class in the registry. | |
| static std::vector< std::string > | Registry (void) |
| Access registry contents. | |
| static CodeGenerator * | New (const std::string &type) |
| Instantiate by identifier (returns 0 on unknown class) | |
Public Attributes inherited from CodeGenerator | |
| std::vector< int > | mWordAddressVector |
| Look-up table to map a bit-address to the word-index. | |
| std::vector< word_t > | mBitMaskVector |
| Look-up table to map a bit-address to the word-bitmask. | |
This class generates code for generic IEC 61131-3 Structured Text targets. Since ST is a high-level language and offers all relevant constructs natively, implementation of individual code primitives is straight forward.
The generated output consists of a single ASCII-encoded file, intended for cut-and-paste insertion into an IEC IDE. The derived class PlcoxmlCodeGenerator provides an alternative XML-encoded output.
Regarding top-level code organisation, Iec61131stCodeGenerator produces one IEC FUNCTION_BLOCK for cyclic invocation by the host application. It accepts the optional input RESET for manual reset and it provides the output variable STATUS with bit 0 for busy and bit 1 for event synchronisation error, respectively. Optionally, there are the additional output variables RECENT_EVENT and PARALLEL_STATE for diagnosis purposes.
The following additional code-options are supported.
IecIncludeCyclic. This option specifies additional code to be inserted just after the variable declarations of the cyclic function block. The intended use case is to instantiate function blocks used in execute actions. Note also the inherited options IncludeBefore and IecIncludeAfter if you want to add additional program organisation units, e.g., an IEC PROGRAM that invokes the cyclic function block.
<IecIncludeCyclic>
<![CDATA[
[... insert code here ...]
]]>
</IecIncludeCyclic>IecDeclarePhysical. This option specifies the declaration keyword for the import of physical i/o addresses. The default is VAR_EXTERNAL, however, some compilers insist in a plain VAR. To disable explicit declaration of physical i/o alltogether, set this option to the empty string.
<IecDeclarePhysical val="VAR_EXTERNAL"/>
IecDeclareSymbolic. This option specifies the declaration keyword for the import of symbolic i/o addresses. The default is VAR_EXTERNAL, however, some compilers insist in a plain VAR. To disable explicit declaration of symbolic i/o alltogether, set this option to the empty string.
<IecDeclareSymbolic val="VAR_EXTERNAL"/>
IecTimeOperators. The default is to use explicit functions for artithmetic with time date, i.e., SUB_TIME and ADD_TIME. This is IEC compliant. However, some target platforms do not provide these functions but insist in appropriatly overloaded binary operators + and -. Corresponding code will be generated by setting this option true.
<IecTimeOperators val="true"/>
Example of generated code
See blink_geb.cgc for an self-contained example.
Definition at line 129 of file cgp_iec61131st.h.
| enum Iec61131stCodeGenerator::IECVariableType |
Definition at line 137 of file cgp_iec61131st.h.
| Iec61131stCodeGenerator::Iec61131stCodeGenerator | ( | void | ) |
Definition at line 32 of file cgp_iec61131st.cpp.
|
virtual |
Definition at line 38 of file cgp_iec61131st.cpp.
|
virtual |
Reimplemented from CodePrimitives.
Reimplemented in GebtoolsCodeGenerator, and PlcoxmlCodeGenerator.
Definition at line 44 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 124 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Reimplemented in PlcoxmlCodeGenerator.
Definition at line 141 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented in GebtoolsCodeGenerator, and PlcoxmlCodeGenerator.
Definition at line 168 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented in GebtoolsCodeGenerator, and PlcoxmlCodeGenerator.
Definition at line 230 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Definition at line 450 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Implements CodePrimitives.
Definition at line 571 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Implements CodePrimitives.
Definition at line 596 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 545 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Reimplemented in PlcoxmlCodeGenerator.
Definition at line 556 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Reimplemented in PlcoxmlCodeGenerator.
Definition at line 563 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Implements CodePrimitives.
Definition at line 601 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Implements CodePrimitives.
Definition at line 606 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Implements CodePrimitives.
Definition at line 611 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Implements CodePrimitives.
Definition at line 617 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Implements CodePrimitives.
Definition at line 623 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 633 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 638 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 643 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 663 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 668 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 673 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 678 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 683 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 688 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Implements CodePrimitives.
Definition at line 653 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 648 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 695 of file cgp_iec61131st.cpp.
Reimplemented from CodePrimitives.
Definition at line 700 of file cgp_iec61131st.cpp.
Reimplemented from CodePrimitives.
Definition at line 705 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 711 of file cgp_iec61131st.cpp.
Reimplemented from CodePrimitives.
Definition at line 718 of file cgp_iec61131st.cpp.
Reimplemented from CodePrimitives.
Definition at line 724 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 730 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 736 of file cgp_iec61131st.cpp.
Reimplemented from CodePrimitives.
Definition at line 742 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 748 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 754 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 760 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 766 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 772 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 777 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 782 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 787 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 792 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 797 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 814 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 819 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 826 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 834 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 845 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 840 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Reimplemented in GebtoolsCodeGenerator, and PlcoxmlCodeGenerator.
Definition at line 874 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 894 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 899 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 904 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Reimplemented in GebtoolsCodeGenerator, and PlcoxmlCodeGenerator.
Definition at line 933 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 953 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 958 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 963 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Reimplemented in GebtoolsCodeGenerator, and PlcoxmlCodeGenerator.
Definition at line 1018 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1042 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1047 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1052 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Reimplemented in GebtoolsCodeGenerator, and PlcoxmlCodeGenerator.
Definition at line 1077 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Reimplemented in GebtoolsCodeGenerator, and PlcoxmlCodeGenerator.
Definition at line 1057 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1091 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1096 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1101 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Reimplemented in GebtoolsCodeGenerator, and PlcoxmlCodeGenerator.
Definition at line 1127 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Reimplemented in GebtoolsCodeGenerator, and PlcoxmlCodeGenerator.
Definition at line 1107 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1141 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1146 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1151 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1166 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1173 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1180 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1187 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1195 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1203 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1210 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1216 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1224 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1243 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1269 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1274 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1280 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1285 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1292 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1298 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1305 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1342 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1346 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1350 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1311 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1317 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1321 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1325 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 1330 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 312 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 301 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Definition at line 1335 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Definition at line 851 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Definition at line 910 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 968 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Definition at line 989 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented in PlcoxmlCodeGenerator.
Definition at line 347 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Definition at line 393 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Definition at line 325 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Definition at line 372 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Definition at line 419 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Definition at line 496 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Definition at line 506 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reimplemented from CodePrimitives.
Definition at line 432 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Reads global configuration from TokenReader, excl. label
| rTr | TokenReader to read from |
| Exception |
|
Reimplemented from CodePrimitives.
Reimplemented in GebtoolsCodeGenerator, and PlcoxmlCodeGenerator.
Definition at line 60 of file cgp_iec61131st.cpp.
|
protectedvirtual |
Write global configuration to TokenWriter, excl. label
| rTw | Reference to TokenWriter |
| Exception |
|
Reimplemented from CodePrimitives.
Reimplemented in GebtoolsCodeGenerator, and PlcoxmlCodeGenerator.
Definition at line 88 of file cgp_iec61131st.cpp.
|
protected |
Definition at line 1359 of file cgp_iec61131st.cpp.
|
protected |
Definition at line 1355 of file cgp_iec61131st.cpp.
|
protected |
Definition at line 166 of file cgp_iec61131st.h.
|
protected |
Definition at line 169 of file cgp_iec61131st.h.
|
protected |
Definition at line 172 of file cgp_iec61131st.h.
|
protected |
Definition at line 175 of file cgp_iec61131st.h.