Add AllyReader and AllyCalibration support with tests: Introduce new register readers, calibration methods, and comprehensive unit tests for integration and functionality validation. Update project files accordingly.
28 lines
897 B
C#
28 lines
897 B
C#
using System.Globalization;
|
|
|
|
namespace TBFTests.Rig.RegisterReaders.AllyReader
|
|
{
|
|
internal static class AllyOpticalTelegramFactory
|
|
{
|
|
public static string Create(short rawFlow, uint rawVolume, uint rawTimestamp)
|
|
{
|
|
string prefix = string.Join("\t", new[]
|
|
{
|
|
"000000",
|
|
"0000",
|
|
unchecked((ushort)rawFlow).ToString("X4", CultureInfo.InvariantCulture),
|
|
rawVolume.ToString("X6", CultureInfo.InvariantCulture),
|
|
"0000",
|
|
rawTimestamp.ToString("X8", CultureInfo.InvariantCulture),
|
|
string.Empty
|
|
});
|
|
|
|
byte checksum = 0;
|
|
for (int i = 0; i < prefix.Length; i++)
|
|
checksum += (byte)prefix[i];
|
|
|
|
return prefix + checksum.ToString("X2", CultureInfo.InvariantCulture) + "\r\n";
|
|
}
|
|
}
|
|
}
|