mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-02-15 20:54:46 +00:00
feat!: support only .NET Framework 4.7.2
In order to conform with the plugin format and the workflow, the .csproj file was moved up a level to the root of the `src` folder and the solution file was renamed. Workflows were also changed to match the plugin workflows. BREAKING CHANGE: Supports ONLY .NET Framework 4.7.2
This commit is contained in:
88
src/XSigUtility/Tokens/XSigAnalogToken.cs
Normal file
88
src/XSigUtility/Tokens/XSigAnalogToken.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
|
||||
namespace PepperDash.Core.Intersystem.Tokens
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an XSigAnalogToken
|
||||
/// </summary>
|
||||
public sealed class XSigAnalogToken : XSigToken, IFormattable
|
||||
{
|
||||
private readonly ushort _value;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="value"></param>
|
||||
public XSigAnalogToken(int index, ushort value)
|
||||
: base(index)
|
||||
{
|
||||
// 10-bits available for analog encoded data
|
||||
if (index >= 1024 || index < 0)
|
||||
throw new ArgumentOutOfRangeException("index");
|
||||
|
||||
_value = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public ushort Value
|
||||
{
|
||||
get { return _value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public override XSigTokenType TokenType
|
||||
{
|
||||
get { return XSigTokenType.Analog; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override byte[] GetBytes()
|
||||
{
|
||||
return new[] {
|
||||
(byte)(0xC0 | ((Value & 0xC000) >> 10) | (Index - 1 >> 7)),
|
||||
(byte)((Index - 1) & 0x7F),
|
||||
(byte)((Value & 0x3F80) >> 7),
|
||||
(byte)(Value & 0x7F)
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="offset"></param>
|
||||
/// <returns></returns>
|
||||
public override XSigToken GetTokenWithOffset(int offset)
|
||||
{
|
||||
if (offset == 0) return this;
|
||||
return new XSigAnalogToken(Index + offset, Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return Index + " = 0x" + Value.ToString("X4");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="format"></param>
|
||||
/// <param name="formatProvider"></param>
|
||||
/// <returns></returns>
|
||||
public string ToString(string format, IFormatProvider formatProvider)
|
||||
{
|
||||
return Value.ToString(format, formatProvider);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user