using HMI.Util;
|
using System;
|
using System.IO.Ports;
|
|
namespace Plugin.TestResult.Model
|
{
|
public class ScannerConfig
|
{
|
public string PortName { get; set; }
|
|
public int BaudRate { get; set; }
|
public Parity Parity { get; set; } = Parity.None;
|
public int DataBits { get; set; }
|
public StopBits StopBits { get; set; } = StopBits.One;
|
public Handshake Handshake { get; set; } = Handshake.None;
|
public bool DtrEnable { get; set; } = true;
|
public bool RtsEnable { get; set; } = true;
|
|
|
public static ScannerConfig ReadFromIni(string iniFile, string section)
|
{
|
var res = new ScannerConfig();
|
res.PortName = IniFileHelper.ReadIniData(section, "PortName", "", iniFile);
|
res.BaudRate = int.Parse(IniFileHelper.ReadIniData(section, "BaudRate", "0", iniFile));
|
res.Parity = (Parity)Enum.Parse(typeof(Parity), IniFileHelper.ReadIniData(section, "Parity", "None", iniFile));
|
res.DataBits = int.Parse(IniFileHelper.ReadIniData(section, "DataBits", "0", iniFile));
|
res.StopBits = (StopBits)Enum.Parse(typeof(StopBits), IniFileHelper.ReadIniData(section, "StopBits", "One", iniFile));
|
res.Handshake = (Handshake)Enum.Parse(typeof(Handshake), IniFileHelper.ReadIniData(section, "Handshake", "None", iniFile));
|
res.DtrEnable = bool.Parse(IniFileHelper.ReadIniData(section, "DtrEnable", "true", iniFile));
|
res.RtsEnable = bool.Parse(IniFileHelper.ReadIniData(section, "RtsEnable", "true", iniFile));
|
return res;
|
}
|
}
|
}
|