import sys
import time
sys.path.append("../src/")
from python_runtime.statecharts_core import Event

import sccd
from services.DEVS.pypdevs.examples.model import TrafficSystem
controller = sccd.Controller(TrafficSystem(name="MyTrafficSystem"))
controller.start()
reply_port = controller.addOutputListener('reply')
"""
params = [{"termination_time": 10, "realtime_scale": 3.0}]
controller.addInput(Event("realtime", "request", params))
print(reply_port.fetch(-1))
params = [{"termination_time": 20, "realtime_scale": 0.333}]
controller.addInput(Event("realtime", "request", params))
print(reply_port.fetch(-1))
params = [{"termination_time": 50, "realtime_scale": 1.0}]
controller.addInput(Event("simulate", "request", params))
print(reply_port.fetch(-1))
"""
params = [{"termination_time": 50}]
controller.addInput(Event("big_step", "request", params))
print(reply_port.fetch(-1))
for _ in range(10):
    controller.addInput(Event("small_step", "request", params))
    #print(reply_port.fetch(-1))
controller.addInput(Event("big_step", "request", params))
print(reply_port.fetch(-1))
params = [{"model": "MyTrafficSystem.trafficLight", "attribute": "colour", "value": "green"}]
controller.addInput(Event("god_event", "request", params))
print(reply_port.fetch(-1))
params = [{"termination_time": 5000}]
controller.addInput(Event("simulate", "request", params))
print(reply_port.fetch(-1))
controller.stop()