namespace EC.Utils.SerialPortHelper
{
///
/// EC 串口管理类
///
public class SerialPortManager
{
///
/// 根据参数对象创建
///
///
///
public static ECSerialPort CreateSerialPort(SerialCustomer serialCustomer)
{
return new ECSerialPort(serialCustomer);
}
///
/// 获取默认参数串口
///
///
public static ECSerialPort CreateDefaultSerialPort(string comName)
{
SerialCustomer serialCustomer = new SerialCustomer
{
ComName = comName
};
return new ECSerialPort(serialCustomer);
}
///
/// 根据不同波特率创建串口
///
///
///
///
public static ECSerialPort CreateSerialPort(string comName, int baudRate)
{
SerialCustomer serialCustomer = new SerialCustomer
{
ComName = comName,
BaudRate = baudRate
};
return new ECSerialPort(serialCustomer);
}
///
/// 根据不同波特率创建串口
///
///
///
///
///
public static ECSerialPort CreateSerialPort(string comName, int baudRate, int receivedBytesThreshold)
{
SerialCustomer serialCustomer = new SerialCustomer
{
ComName = comName,
BaudRate = baudRate,
ReceivedBytesThreshold = receivedBytesThreshold
};
return new ECSerialPort(serialCustomer);
}
}
}