add eRegister (Streaming only) to common

This commit is contained in:
Roland Drabesch
2023-12-11 13:26:15 +01:00
parent e9403bf09f
commit 14cf1c7584
216 changed files with 38991 additions and 38103 deletions
@@ -56,30 +56,42 @@ namespace Xylem.Common.Hardware.Interfaces.Protocols.ProtocolCore
/// <remarks date="2018-Feb-14" author="T.Wiedebusch">
/// - Initial
/// </remarks>
/// <remarks date="2023-Oct-25" author="T.Wiedebusch">
/// - try catch block.
/// </remarks>
public virtual void Dispose()
{
//Cancel receive tokens
_decodingToken.Cancel();
//Run thread again to notice CancellationToken has changed
_onSyncDecodingThread.Set();
//this timeout counter is being used for dispose only
var timeoutCounter = 100;
while (_decodingThread.ThreadState != ThreadState.Stopped && timeoutCounter > 0)
try
{
Thread.Sleep(1);
timeoutCounter -= 1;
}
//Cancel receive tokens
_decodingToken.Cancel();
if (_decodingThread.ThreadState != ThreadState.Stopped)
{
//if thread still running, he stuck so try to abort
// try to avoid abort (takes age to run and is not safe)
_decodingThread.Abort();
//Run thread again to notice CancellationToken has changed
_onSyncDecodingThread.Set();
//this timeout counter is being used for dispose only
var timeoutCounter = 100;
while (_decodingThread.ThreadState != ThreadState.Stopped && timeoutCounter > 0)
{
Thread.Sleep(1);
timeoutCounter -= 1;
//Run thread again to notice CancellationToken has changed
_onSyncDecodingThread.Set();
}
if (_decodingThread.ThreadState != ThreadState.Stopped)
{
//if thread still running, he stuck so try to abort
// try to avoid abort (takes age to run and is not safe)
_decodingThread.Abort();
}
}
}
catch (Exception ex)
{
throw new ApplicationException(ex.Message);
}
}
/// <summary>
/// Fill FIFO with received data
@@ -36,6 +36,12 @@ namespace Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol
_receiveBufferFlushThreshold);
}
public TransmitPortSettings GetTransmitPortSettings(UInt32 baudRate)
{
return new TransmitPortSettings(_protSyncByte, _protLengthIndex, ProtAddLength, _responseTimeoutMs, baudRate,
_receiveBufferFlushThreshold);
}
/// <inheritdoc />
public override List<Byte> DecodeDataForPhysicalLayer(String ident, Byte command, Byte[] payload, Boolean hideDataInLog = false)
{