<%def getClasses(){return u.classes.findAll{it.stereotypes.length==0}}%>\ <%def getAttr(name){u.classes.find{it.name=="Create2"}?.attributes?.find{it.name==name}}%>\ #!/usr/bin/python from create2.create2 import Create2 import time import paho.mqtt.client as mqtt <%def mqtt = getAttr("mqtt");\ if(mqtt!=null && mqtt.initialValue!=null){ %>\ host = "${mqtt.initialValue}" <%}else{%>\ host = "192.168.20.41" <%}%>\ <%def seed = getAttr("scoreSeed");\ if(seed!=null && seed.initialValue!=null){ %>\ seed = ${seed.initialValue} <%}else{%>\ seed = 12 <%}%>\ <%def initialScore = getAttr("initialScore");\ if(initialScore!=null && initialScore.initialValue!=null){ %>\ initialScore = [${initialScore.initialValue}] <%}else{%>\ initialScore = [1,1,2,2,3,3] <%}%>\ port = 1883 topic = "/course/corner" client = None <% for(c in getClasses()){ %>\ import ${c.name} <%}%>\ create2 = Create2(mqtthost=host, scoreSeed=seed, initialScore=initialScore) client = None <% for(c in getClasses()){ %>\ ${u.getInstanceName(c)} = None <%}%>\ def event_handler(events): for e in events: <% for(c in getClasses()){ %>\ ${u.getInstanceName(c)}.doTransition(e) <%}%>\ if __name__ == '__main__': <% for(c in getClasses()){ %>\ ${u.getInstanceName(c)} = ${c.name}.${c.name}() <%}%>\ create2.add_event_listener(event_handler) while True: time.sleep(1)