|
@@ -0,0 +1,155 @@
|
|
|
+«REM»
|
|
|
+
|
|
|
+Templates for the main statechart cpp file.
|
|
|
+
|
|
|
+@auther joern seger
|
|
|
+
|
|
|
+«ENDREM»
|
|
|
+
|
|
|
+«IMPORT sexec»
|
|
|
+«IMPORT stext»
|
|
|
+«IMPORT sgraph»
|
|
|
+
|
|
|
+«EXTENSION org::yakindu::sct::generator::cpp::templates::Expression»
|
|
|
+«EXTENSION org::yakindu::sct::generator::cpp::templates::Naming»
|
|
|
+
|
|
|
+
|
|
|
+«DEFINE file FOR ExecutionFlow»
|
|
|
+«FOREACH this.scopes.typeSelect(InterfaceScope) AS interface»
|
|
|
+«FILE StName()+interface.interfaceClassName()+".h"»
|
|
|
+
|
|
|
+#ifndef «interface.interfaceClassName().toUpperCase()»_H_
|
|
|
+#define «interface.interfaceClassName().toUpperCase()»_H_
|
|
|
+
|
|
|
+#include "definition.h"
|
|
|
+#include "Event.h"
|
|
|
+#include "EventSet.h"
|
|
|
+#include "EventPool.h"
|
|
|
+#include "Statemachine.h"
|
|
|
+#include "«EvName()».h"
|
|
|
+#include <vector>
|
|
|
+
|
|
|
+namespace «StName()» {
|
|
|
+
|
|
|
+class AbstractInterface {
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
+class «interfaceClassName(interface)» : public AbstractInterface {
|
|
|
+
|
|
|
+protected:
|
|
|
+ Statemachine& statemachine;
|
|
|
+ std::vector<_Event*> outEventList;
|
|
|
+
|
|
|
+«FOREACH interface.declarations.typeSelect(VariableDefinition) AS variable -»
|
|
|
+ «variable.type» «variable.name»;
|
|
|
+«ENDFOREACH»
|
|
|
+
|
|
|
+ bool isMyEvent(Event& event);
|
|
|
+
|
|
|
+public:
|
|
|
+
|
|
|
+ «interfaceClassName(interface)»(Statemachine& statemachine);
|
|
|
+
|
|
|
+«FOREACH interface.declarations.typeSelect(VariableDefinition) AS variable -»
|
|
|
+ «variable.type»& get_«variable.name»() const;
|
|
|
+ «IF variable.readonly == false -»
|
|
|
+ void set_«variable.name»(«variable.type»& value);
|
|
|
+ «ENDIF»
|
|
|
+«ENDFOREACH»
|
|
|
+
|
|
|
+ void resetEvent();
|
|
|
+
|
|
|
+ «FOREACH interface.getOutEvents() AS event -»
|
|
|
+ boolean is_«event.name»_raised(«
|
|
|
+ IF event.type != Type::void -» «event.type.eventTypeToString()»* value«ENDIF» );
|
|
|
+ «ENDFOREACH»
|
|
|
+
|
|
|
+ «FOREACH interface.getInEvents() AS event -»
|
|
|
+ void raise_«event.name»(«
|
|
|
+ IF event.type != Type::void -» «event.type.eventTypeToString()» value «ENDIF»);
|
|
|
+ «ENDFOREACH»
|
|
|
+
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+#endif /* INTERFACEBASE_H_ */
|
|
|
+
|
|
|
+
|
|
|
+«ENDFILE»
|
|
|
+
|
|
|
+«FILE StName()+interface.interfaceClassName()+".cpp"»
|
|
|
+#include "«StName()»«interface.interfaceClassName()».h"
|
|
|
+
|
|
|
+using namespace «StName()»;
|
|
|
+
|
|
|
+bool «interfaceClassName(interface)»::isMyEvent(Event& event)
|
|
|
+{
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+«interfaceClassName(interface)»::«interfaceClassName(interface)»(Statemachine& _statemachine)
|
|
|
+ : statemachine(_statemachine)
|
|
|
+{}
|
|
|
+
|
|
|
+«FOREACH interface.declarations.typeSelect(VariableDefinition) AS variable -»
|
|
|
+«variable.type»& «interfaceClassName(interface)»::get_«variable.name»() const
|
|
|
+{ return «variable.name»; }
|
|
|
+
|
|
|
+«IF variable.readonly == false -»
|
|
|
+void «interfaceClassName(interface)»::set_«variable.name»(«variable.type»& value)
|
|
|
+{ «variable.name» = value; }
|
|
|
+«ENDIF-»
|
|
|
+«ENDFOREACH»
|
|
|
+
|
|
|
+void «interfaceClassName(interface)»::resetEvent()
|
|
|
+{ outEventList.clear(); }
|
|
|
+
|
|
|
+«FOREACH interface.getOutEvents() AS event -»
|
|
|
+boolean «interfaceClassName(interface)»::is_«event.name»_raised(«
|
|
|
+ IF event.type != Type::void -» «event.type.eventTypeToString()»* value«ENDIF» )
|
|
|
+{
|
|
|
+ std::vector<Event>::const_iterator cit(outEventList.begin());
|
|
|
+ for(; cit != outEventList.end(); ++cit)
|
|
|
+ if (cit->getID() == (uint32_t)«event.getEventEnumName()») {
|
|
|
+ «IF event.type != Type::void -»
|
|
|
+ *value = static_cast<«event.name»*>(cit)->value;
|
|
|
+ «ENDIF»
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
+«ENDFOREACH»
|
|
|
+
|
|
|
+
|
|
|
+«FOREACH interface.getInEvents() AS event -»
|
|
|
+void «interfaceClassName(interface)»::raise_«event.name»(«
|
|
|
+ IF event.type != Type::void -» «event.type.eventTypeToString()» value «ENDIF»)
|
|
|
+{
|
|
|
+ Event ev = new «event.name»;
|
|
|
+ statemachine.setEvent(ev);
|
|
|
+}
|
|
|
+«ENDFOREACH»
|
|
|
+
|
|
|
+bool «interface.interfaceName()»::is_my_event(uint32_t evid)
|
|
|
+{
|
|
|
+ bool ret = false;
|
|
|
+ switch (evid) {
|
|
|
+«FOREACH interface.getInEvents() AS event -»
|
|
|
+ case «event.getEventEnumName()»:
|
|
|
+«ENDFOREACH»
|
|
|
+ ret = true;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+«ENDFILE»
|
|
|
+«ENDFOREACH»
|
|
|
+«ENDDEFINE»
|