import casp
import casp_targets
import casp_defs
from models import casp_plot_n_control

#Initialize CASP
casp.Init()

# Create and open default project.
casp.ProjectOpenDefault()

# Instantiate class object
obj = casp_plot_n_control.Model(6,6)

# Initiate serial port. Change serial port with actual port to which the board is connected
obj.InitSerialPort("COM34") #serial_port_name, master
#obj.InitEthernet(False, False, "0.0.0.0", "0.0.0.0", 52001, "127.0.0.1", 42001) #server, tcp, gateway_ip, local_ip, local_port, remote_ip, remote_port

# Add plot
obj.AddDigitalMeter(False, 0, 3, "yy_mm_dd") #data_type_real, data_index, title
obj.AddPlotter(False, 3, 1, "gps_active_nsats") #data_type_real, data_index, data_size, title
obj.AddDigitalMeter(True, 4, 2, "latitude_longitude")

# Finalize plotter
obj.Finalize()

# Set simulation to real time (by setting simulation speed factor to 1).
casp.SimSetupSpeedFactor(1)

# Build and program the board.
casp.SimStart()

# Open project folder. Go through the log files (log_build_wnd.txt and log_msg_wnd.txt) in the project folder for any error/warning messages.
#casp.FolderProject()

# Promptly close CASP model editor program. simulation panel program will still be running.
casp.Close()
