public AnalogInput(string id, string description, Driver driver, string io_address, int scanTime, scanType scan, readType read, int lowLim, int highLim, string units) : base(id, description, driver, io_address, scanTime, scan, read) { this.lowLimits = lowLim; this.highLimits = highLim; this.units = units; }
public TagInput(string id, string description, Driver driver, string io_address, int scanTime, scanType scan, readType read) : base(id, description, driver, io_address) { this.scanTime = scanTime; this.scan = scan; this.read = read; this.alarms = new List <Alarm>(); }
public DigitalInput(string id, string description, Driver driver, string io_address, int scanTime, scanType scan, readType read) : base(id, description, driver, io_address, scanTime, scan, read) { }
private void processOutputFile(scanType newScanType,string filename) { switch (newScanType) { case scanType.scan: listBox1.Items.Clear(); checkedListBox1.Items.Clear(); break; case scanType.bootList: listBox1.Items.Clear(); break; } if (File.Exists(filename)) { try { using (StreamReader sr = new StreamReader(filename)) { String line; while ((line = sr.ReadLine()) != null) { line = line.Trim(); if (line.Length > 0) { string finalString = ""; switch (newScanType) { case scanType.scan: if (line.Contains("READY")) { finalString = line.Substring(30, 16) + " - " + line.Substring(11, 16); if (checkedListBox1.Items.IndexOf(finalString) == -1) { checkedListBox1.Items.Add(finalString); } } break; case scanType.bootList: if (line.Contains("Bootlist Node")) { finalString = line.Substring(9, 21); } else if (line.Contains("PID:")) { finalString = line.Substring(10, 7); } if (finalString != "") { listBox1.Items.Add(finalString); } break; } } } } } catch (Exception e) { return; } } }
private void processOutputFile(scanType newScanType) { nextScanType = newScanType; processOutputFile(nextScanType, "output.txt"); }
public bool addTag(bool editing, List <Alarm> alarms) { var tokens = tagTypeComboBox.SelectedItem.ToString().Split(':'); string id = tagNameTextBox.Text; string descr = tagDescrTextBox.Text; string driver = tagDriverComboBox.SelectedItem.ToString(); string address = tagAddressComboBox.SelectedItem.ToString(); scanType scan = scanType.ON; readType read = readType.AUTO; if (tagScanComboBox.SelectedItem != null) { if (tagScanComboBox.Text.ToLower().Equals("on")) { scan = scanType.ON; } else { scan = scanType.OFF; } } if (tagReadDataTypeComboBox.SelectedItem != null) { if (tagReadDataTypeComboBox.Text.ToLower().Equals("auto")) { read = readType.AUTO; } else { read = readType.MANUAL; } } var driverTokens = tagDriverComboBox.SelectedItem.ToString().Split(':'); bool response = true; switch (tokens[1].Trim()) { case "Digital input": DigitalInput di; try { di = new DigitalInput(id, descr, null, address, Int32.Parse(tagScanTimeTextBox.Text), scan, read); } catch (FormatException) { MessageBox.Show("Please enter a number on tag scan time"); return(false); } if (di.ScanTime < 1) { MessageBox.Show("Scan time must be > 1"); return(false); } if (editing) { di.Alarms = alarms; } response = service.addTag(di, driverTokens[1].Trim()); break; case "Digital output": DigitalOutput dig_out; try { dig_out = new DigitalOutput(id, descr, null, address, Int32.Parse(tagInitValueTextBox.Text)); } catch (FormatException) { MessageBox.Show("Please enter a number in init value"); return(false); } response = service.addTag(dig_out, driverTokens[1].Trim()); break; case "Analog input": AnalogInput analog_input; try { analog_input = new AnalogInput(id, descr, null, address, Int32.Parse(tagScanTimeTextBox.Text), scan, read, Int32.Parse(tagLowLimitTextBox.Text), Int32.Parse(tagHighLimitTextBox.Text), tagDescrTextBox.Text); } catch (FormatException) { MessageBox.Show("Please enter a number on scan time, low and high limits"); return(false); } if (analog_input.ScanTime < 1) { MessageBox.Show("Scan time must be > 1"); return(false); } if (editing) { analog_input.Alarms = alarms; } response = service.addTag(analog_input, driverTokens[1].Trim()); break; case "Analog output": AnalogOutput analog_output; try { analog_output = new AnalogOutput(id, descr, null, address, Int32.Parse(tagInitValueTextBox.Text), Int32.Parse(tagLowLimitTextBox.Text), Int32.Parse(tagHighLimitTextBox.Text), tagDescrTextBox.Text); } catch (FormatException) { MessageBox.Show("Please enter a number on scan time, low and high limits"); return(false); } response = service.addTag(analog_output, driverTokens[1].Trim()); break; } if (!response) { MessageBox.Show($"Tag name {tagNameTextBox.Text} already exists"); return(false); } displayAllTags(); return(true); }