laatzen/Common/Hardware/Interfaces/Protocols/TransmitProtocol/LedTransmitProtocol.cs
2023-12-11 13:26:15 +01:00

61 lines
2.2 KiB
C#

using System;
using System.Collections.Generic;
using Xylem.Common.Hardware.Interfaces.Ports.PortCore;
namespace Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol
{
public class LedTransmitProtocol : BaseTransmitProtocol
{
private readonly Byte? _protSyncByte = null;
private const UInt16 ProtAddLength = 0;
private readonly UInt16? _protLengthIndex = null;
private const Int32 DefaultResponseTimeoutMs = 50;
private Int32 _responseTimeoutMs = DefaultResponseTimeoutMs;
private const UInt32 BaudRate = 115200;
private readonly UInt32? _receiveBufferFlushThreshold = 1000;
/// <inheritdoc />
public override void SetResponseTimeout(Int32 responseTimeoutMs)
{
_responseTimeoutMs = responseTimeoutMs;
}
/// <inheritdoc />
public override void SetDefaultResponseTimeout()
{
_responseTimeoutMs = DefaultResponseTimeoutMs;
}
public LedTransmitProtocol(String portName) : base (portName)
{
}
public override TransmitPortSettings GetTransmitPortSettings()
{
return new TransmitPortSettings(_protSyncByte, _protLengthIndex, ProtAddLength, _responseTimeoutMs, BaudRate,
_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)
{
throw new ApplicationException("Streaming port cannot send data");
}
/// <inheritdoc />
public override List<Byte> DecodeDataForLogicLayer(String ident, List<Byte> rawData, Boolean hideDataInLog = false)
{
return rawData;
}
public override List<Byte> DecodeDataForPhysicalLayerUI1236(String ident, Byte[] payload, Boolean hideDataInLog = false)
=> throw new ApplicationException("Streaming port cannot send data");
}
}