Applied some refactoring
This commit is contained in:
parent
b11f56bfee
commit
55c3aefa2d
1
.gitignore
vendored
1
.gitignore
vendored
@ -29,3 +29,4 @@ _ReSharper*/
|
|||||||
[Tt]est[Rr]esult*
|
[Tt]est[Rr]esult*
|
||||||
*.testsettings
|
*.testsettings
|
||||||
PInvokeSerialPort.nupkg
|
PInvokeSerialPort.nupkg
|
||||||
|
/.vs/PInvokeSerialPort/v15/Server/sqlite3
|
||||||
|
@ -8,123 +8,132 @@ namespace PInvokeSerialPort
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public struct QueueStatus
|
public struct QueueStatus
|
||||||
{
|
{
|
||||||
private uint status;
|
private readonly uint _status;
|
||||||
private uint inQueue;
|
private readonly uint _inQueue;
|
||||||
private uint outQueue;
|
private readonly uint _outQueue;
|
||||||
private uint inQueueSize;
|
private readonly uint _inQueueSize;
|
||||||
private uint outQueueSize;
|
private readonly uint _outQueueSize;
|
||||||
|
|
||||||
internal QueueStatus(uint stat, uint inQ, uint outQ, uint inQs, uint outQs)
|
internal QueueStatus(uint stat, uint inQ, uint outQ, uint inQs, uint outQs)
|
||||||
{ status = stat; inQueue = inQ; outQueue = outQ; inQueueSize = inQs; outQueueSize = outQs; }
|
{
|
||||||
|
_status = stat;
|
||||||
|
_inQueue = inQ;
|
||||||
|
_outQueue = outQ;
|
||||||
|
_inQueueSize = inQs;
|
||||||
|
_outQueueSize = outQs;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Output is blocked by CTS handshaking.
|
/// Output is blocked by CTS handshaking.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ctsHold { get { return ((status & COMSTAT.fCtsHold) != 0); } }
|
public bool CtsHold => (_status & COMSTAT.fCtsHold) != 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Output is blocked by DRS handshaking.
|
/// Output is blocked by DRS handshaking.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool dsrHold { get { return ((status & COMSTAT.fDsrHold) != 0); } }
|
public bool DsrHold => (_status & COMSTAT.fDsrHold) != 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Output is blocked by RLSD handshaking.
|
/// Output is blocked by RLSD handshaking.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool rlsdHold { get { return ((status & COMSTAT.fRlsdHold) != 0); } }
|
public bool RlsdHold => (_status & COMSTAT.fRlsdHold) != 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Output is blocked because software handshaking is enabled and XOFF was received.
|
/// Output is blocked because software handshaking is enabled and XOFF was received.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool xoffHold { get { return ((status & COMSTAT.fXoffHold) != 0); } }
|
public bool XoffHold => (_status & COMSTAT.fXoffHold) != 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Output was blocked because XOFF was sent and this station is not yet ready to receive.
|
/// Output was blocked because XOFF was sent and this station is not yet ready to receive.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool xoffSent { get { return ((status & COMSTAT.fXoffSent) != 0); } }
|
public bool XoffSent => (_status & COMSTAT.fXoffSent) != 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// There is a character waiting for transmission in the immediate buffer.
|
/// There is a character waiting for transmission in the immediate buffer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool immediateWaiting { get { return ((status & COMSTAT.fTxim) != 0); } }
|
public bool ImmediateWaiting => (_status & COMSTAT.fTxim) != 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of bytes waiting in the input queue.
|
/// Number of bytes waiting in the input queue.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long InQueue { get { return inQueue; } }
|
public long InQueue => _inQueue;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of bytes waiting for transmission.
|
/// Number of bytes waiting for transmission.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long OutQueue { get { return outQueue; } }
|
public long OutQueue => _outQueue;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Total size of input queue (0 means information unavailable)
|
/// Total size of input queue (0 means information unavailable)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long InQueueSize { get { return inQueueSize; } }
|
public long InQueueSize => _inQueueSize;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Total size of output queue (0 means information unavailable)
|
/// Total size of output queue (0 means information unavailable)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long OutQueueSize { get { return outQueueSize; } }
|
public long OutQueueSize => _outQueueSize;
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
var m = new StringBuilder("The reception queue is ", 60);
|
var m = new StringBuilder("The reception queue is ", 60);
|
||||||
if (inQueueSize == 0)
|
if (_inQueueSize == 0)
|
||||||
{
|
|
||||||
m.Append("of unknown size and ");
|
m.Append("of unknown size and ");
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
m.Append(_inQueueSize + " bytes long and ");
|
||||||
m.Append(inQueueSize.ToString() + " bytes long and ");
|
if (_inQueue == 0)
|
||||||
}
|
|
||||||
if (inQueue == 0)
|
|
||||||
{
|
{
|
||||||
m.Append("is empty.");
|
m.Append("is empty.");
|
||||||
}
|
}
|
||||||
else if (inQueue == 1)
|
else if (_inQueue == 1)
|
||||||
{
|
{
|
||||||
m.Append("contains 1 byte.");
|
m.Append("contains 1 byte.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m.Append("contains ");
|
m.Append("contains ");
|
||||||
m.Append(inQueue.ToString());
|
m.Append(_inQueue.ToString());
|
||||||
m.Append(" bytes.");
|
m.Append(" bytes.");
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Append(" The transmission queue is ");
|
m.Append(" The transmission queue is ");
|
||||||
if (outQueueSize == 0)
|
if (_outQueueSize == 0)
|
||||||
{
|
|
||||||
m.Append("of unknown size and ");
|
m.Append("of unknown size and ");
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
m.Append(_outQueueSize + " bytes long and ");
|
||||||
m.Append(outQueueSize.ToString() + " bytes long and ");
|
if (_outQueue == 0)
|
||||||
}
|
|
||||||
if (outQueue == 0)
|
|
||||||
{
|
{
|
||||||
m.Append("is empty");
|
m.Append("is empty");
|
||||||
}
|
}
|
||||||
else if (outQueue == 1)
|
else if (_outQueue == 1)
|
||||||
{
|
{
|
||||||
m.Append("contains 1 byte. It is ");
|
m.Append("contains 1 byte. It is ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m.Append("contains ");
|
m.Append("contains ");
|
||||||
m.Append(outQueue.ToString());
|
m.Append(_outQueue.ToString());
|
||||||
m.Append(" bytes. It is ");
|
m.Append(" bytes. It is ");
|
||||||
}
|
}
|
||||||
if (outQueue > 0)
|
|
||||||
|
if (_outQueue > 0)
|
||||||
{
|
{
|
||||||
if (ctsHold || dsrHold || rlsdHold || xoffHold || xoffSent)
|
if (CtsHold || DsrHold || RlsdHold || XoffHold || XoffSent)
|
||||||
{
|
{
|
||||||
m.Append("holding on");
|
m.Append("holding on");
|
||||||
if (ctsHold) m.Append(" CTS");
|
if (CtsHold) m.Append(" CTS");
|
||||||
if (dsrHold) m.Append(" DSR");
|
if (DsrHold) m.Append(" DSR");
|
||||||
if (rlsdHold) m.Append(" RLSD");
|
if (RlsdHold) m.Append(" RLSD");
|
||||||
if (xoffHold) m.Append(" Rx XOff");
|
if (XoffHold) m.Append(" Rx XOff");
|
||||||
if (xoffSent) m.Append(" Tx XOff");
|
if (XoffSent) m.Append(" Tx XOff");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m.Append("pumping data");
|
m.Append("pumping data");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Append(". The immediate buffer is ");
|
m.Append(". The immediate buffer is ");
|
||||||
if (immediateWaiting)
|
if (ImmediateWaiting)
|
||||||
m.Append("full.");
|
m.Append("full.");
|
||||||
else
|
else
|
||||||
m.Append("empty.");
|
m.Append("empty.");
|
||||||
|
@ -625,7 +625,7 @@ namespace PInvokeSerialPort
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of stop bits (default: one)
|
/// Number of stop bits (default: one)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public StopBits StopBits = StopBits.one;
|
public StopBits StopBits = StopBits.One;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If true, transmission is halted unless CTS is asserted by the remote station (default: false)
|
/// If true, transmission is halted unless CTS is asserted by the remote station (default: false)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -8,14 +8,16 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Line is asserted for 1 bit duration at end of each character
|
/// Line is asserted for 1 bit duration at end of each character
|
||||||
/// </summary>
|
/// </summary>
|
||||||
one = 0,
|
One = 0,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Line is asserted for 1.5 bit duration at end of each character
|
/// Line is asserted for 1.5 bit duration at end of each character
|
||||||
/// </summary>
|
/// </summary>
|
||||||
onePointFive = 1,
|
OnePointFive = 1,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Line is asserted for 2 bit duration at end of each character
|
/// Line is asserted for 2 bit duration at end of each character
|
||||||
/// </summary>
|
/// </summary>
|
||||||
two = 2
|
Two = 2
|
||||||
};
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user