import sys
sys.path.append("interface/HUTN")
sys.path.append("wrappers")
from hutn_compiler.compiler import main as do_compile
from modelverse import *

init()
login("admin", "admin")

model_add("CausalBlockDiagrams", "SimpleClassDiagrams", open("integration/code/cbd_design.mvc", 'r').read())
model_add("Trace", "SimpleClassDiagrams", open("models/trace.mvc", 'r').read())
model_add("MM_rendered_graphical", "SimpleClassDiagrams", open("models/MM_rendered_graphical.mvc", 'r').read())
model_add("MM_rendered_plot", "SimpleClassDiagrams", open("models/MM_rendered_plot.mvc", 'r').read())
model_add("my_CBD", "CausalBlockDiagrams", open("integration/code/my_cbd.mvc", 'r').read())
model_add("trace_example", "Trace", open("models/trace_example.mvc", 'r').read())

def callback_graphical():
    instantiate(None, "Association", ("abstract/Block", "rendered/Group"), ID="TracabilityLink")

def callback_plot():
    instantiate(None, "Association", ("abstract/Signal", "rendered/Dataset"), ID="TracabilityLink")

transformation_add_MT({"abstract": "CausalBlockDiagrams", "rendered": "MM_rendered_graphical"}, {"abstract": "CausalBlockDiagrams", "rendered": "MM_rendered_graphical"}, "render_graphical_CBD", open("models/CBD_mapper.mvc", 'r').read(), callback_graphical)
transformation_add_MT({"abstract": "Trace", "rendered": "MM_rendered_plot"}, {"abstract": "Trace", "rendered": "MM_rendered_plot"}, "render_plot_trace", open("models/trace_mapper.mvc", 'r').read(), callback_plot)
