using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DTS.SensorDB.TDCINI { /// /// helper class for RS232 section of INI file /// public class TDCINIRS232Info { /// /// Communication port /// public int ComPortNumber { get; set; } /// /// Max speed of com port /// public int MaxComSpeed { get; set; } /// /// max number of ports /// public int MaxComPorts { get; set; } public TDCINIRS232Info() { } /// /// read section from a line /// returns true if read successfully, false if there were errors /// /// /// /// public bool ReadFrom(string line, ref List errors) { string[] tokens = line.Split(new char[] { ',' }); if (3 != tokens.Length) { errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_COMINFO_INVALID, line)); return false; } int i; if (!int.TryParse(tokens[0], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out i)) { errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_COMINFO_INVALID, line)); return false; } else { ComPortNumber = i; } if (!int.TryParse(tokens[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out i)) { errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_COMINFO_INVALID, line)); return false; } else { MaxComSpeed = i; } if (!int.TryParse(tokens[2], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out i)) { errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_COMINFO_INVALID, line)); return false; } else { MaxComPorts = i; } return true; } } }