private void OpenFile(object obj) { if (!File.Exists(obj.ToString())) { throw new FileNotFoundException(); } if (myDevices != null) { myDevices.KillAllDevices(); } myDevices = Creator.FromFile(obj.ToString()); if (myDevices == ModbusDevices.Empty) { System.Windows.MessageBox.Show("File not found or inaccessible", "File Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); } myDevices.DeviceStatusChanged += MyDevices_DeviceStatusChanged; Create(); }
static void Main() { myTimer = new Timer(); myTimer.Elapsed += MyTimer_Elapsed; myTimer.Interval = 10000; GlobalLogger.LogMessageReceived += GlobalLogger_LogMessageReceived; Console.WriteLine("Savronik.Tools.Modbus.Reader started"); myDevices = Creator.FromFile("address.csv"); if (myDevices == null) { return; } myDevices.TagStatusChanged += MyDevices_TagStatusChanged; foreach (var device in myDevices.Values) { device.ConnectionStatusChanged += Device_ConnectionStatusChanged; device.Collection.GetAllWriteTags(); } myDevices.StartDevices(); myTimer.Start(); Console.ReadLine(); }