public FormMain() { InitializeComponent(); try { // Open the text file using a stream reader. using (StreamReader sr = new StreamReader(configuration_filename)) { // Read the stream to a string, and write the string to the console. String json = sr.ReadToEnd(); board_settings = JsonConvert.DeserializeObject <board_settings_t>(json); println("Configuration was read from configuration file"); } } catch (Exception e) { println("There is no configuration file"); using (StreamWriter sw = new StreamWriter(configuration_filename)) { string json = JsonConvert.SerializeObject(board_settings, Formatting.Indented); sw.Write(json); } println("Configuration file was created with default settings"); } form = this; start_serial_communication(); }
public MiniModbusDeviceTableShell_ExternalControl(MiniModbusDevice device, board_settings_t settings) : base(device) { _device = device; _device.readingIsComplete += this.readingIsComplete; _device.deviceWasChanged += this.deviceWasChanged; this.settings = settings; }