|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.IO.Ports;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace SerialCommApp.SeriallLibs
|
|
|
|
|
{
|
|
|
|
|
[DefaultProperty("Serial Communication")]
|
|
|
|
|
public class PSerialCommSetting : ICloneable
|
|
|
|
|
{
|
|
|
|
|
public enum PSerialBaudRate
|
|
|
|
|
{
|
|
|
|
|
B1200 = 1200,
|
|
|
|
|
B2400 = 2400,
|
|
|
|
|
B4800 = 4800,
|
|
|
|
|
B9600 = 9600,
|
|
|
|
|
B19200 = 19200,
|
|
|
|
|
B38400 = 38400,
|
|
|
|
|
B57600 = 57600,
|
|
|
|
|
B115200 = 115200,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum PSerailDataBit
|
|
|
|
|
{
|
|
|
|
|
D8 = 8,
|
|
|
|
|
D7 = 7,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Category("Communication")]
|
|
|
|
|
public PSerialBaudRate BaudRate { get; set; }
|
|
|
|
|
[Category("Communication")]
|
|
|
|
|
public PSerailDataBit DataBit { get; set; }
|
|
|
|
|
[Category("Communication")]
|
|
|
|
|
public Parity Parity { get; set; }
|
|
|
|
|
[Category("Communication")]
|
|
|
|
|
public StopBits StopBits { get; set; }
|
|
|
|
|
|
|
|
|
|
public PSerialCommSetting(PSerialBaudRate baudRate = PSerialBaudRate.B9600, PSerailDataBit dataBit = PSerailDataBit.D8, Parity parity = Parity.None, StopBits stopBits = StopBits.None)
|
|
|
|
|
{
|
|
|
|
|
this.BaudRate = baudRate;
|
|
|
|
|
this.DataBit = dataBit;
|
|
|
|
|
this.Parity = parity;
|
|
|
|
|
this.StopBits = stopBits;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public object Clone()
|
|
|
|
|
{
|
|
|
|
|
PSerialCommSetting cloned = new PSerialCommSetting();
|
|
|
|
|
cloned.BaudRate = this.BaudRate;
|
|
|
|
|
cloned.DataBit = this.DataBit;
|
|
|
|
|
cloned.Parity = this.Parity;
|
|
|
|
|
cloned.StopBits = this.StopBits;
|
|
|
|
|
|
|
|
|
|
return cloned;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|