tbf/TBFTests/Rig/RegisterReaders/AllyReader/AllyOpticalTelegramFactory.cs
Michal Buzik c71fe75446 Ally iPerl initial - reader,test method, unit test
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.
2026-08-18 10:01:02 +02:00

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";
}
}
}