#!/usr/bin/python3
# This file was automatically generated from drawio2cbd with the command:
#   /home/red/git/DrawioConvert/__main__.py -F CBD -e LotkeVolterra -fvaSrg -E delta=0.1 -t 100 diagram.io

from diagram import *
from CBD.simulator import Simulator
from CBD.realtime.plotting import plot, LinePlot
from CBD.converters.latexify import CBD2Latex
from CBD.converters.CBDDraw import gvDraw

DELTA_T = 0.01
END = 10.0

cbd = LotkeVolterra("LotkeVolterra")

cbd.addFixedRateClock("clock", DELTA_T)
cbd.addConnection("clock-clock", "x", output_port_name="delta", input_port_name='delta_t')
cbd.addConnection("clock-clock", "y", output_port_name="delta", input_port_name='delta_t')

cbd.flatten()
gvDraw(cbd, "lv.gv")


cbd.flatten()
c2l = CBD2Latex(cbd, show_steps=False, render_latex=False, time_variable="t")
c2l.simplify()
print(c2l.render())

# # cbd = SinGen("SinGen")
#
# # Run the Simulation
# sim = Simulator(cbd)
# sim.setDeltaT(DELTA_T)
# sim.run(END)
#
# # TODO: Process Your Simulation Results
# import matplotlib.pyplot as plt
# fig = plt.figure()
# ax = fig.add_subplot(111)
# plot(cbd.find("rabbits")[0], (fig, ax), LinePlot(color='red', label='rabbits'))
# plot(cbd.find("foxes")[0], (fig, ax), LinePlot(color='blue', label='foxes'))
# # plot(cbd.find("mySin")[0], (fig, ax), LinePlot(color='red'))
# ax.legend()
# plt.show()
