47 lines
1.6 KiB
C#
47 lines
1.6 KiB
C#
using TuneBoss.Core.Models;
|
|
|
|
namespace TuneBoss.Core.Tests;
|
|
|
|
/// <summary>Shared builders for synthetic device data.</summary>
|
|
internal static class TestData
|
|
{
|
|
public const byte Gen1 = 245, Gen2 = 1, Gen3 = 2;
|
|
|
|
public static EcuInfo Ecu(byte appInfoVersion, byte fw, byte rpmMax = 130) => new()
|
|
{
|
|
Username = "SIM-RIDER",
|
|
UniqueId = "AABBCCDD-EEFF0011-22334455",
|
|
AppInfoVersion = appInfoVersion,
|
|
FwVersion = fw,
|
|
HwVersion = 10,
|
|
UpgradeRpmMax = rpmMax,
|
|
BikeManufacturer = 1,
|
|
};
|
|
|
|
/// <summary>Wraps a data block in the 4-byte response header the parsers skip (51 xx xx 00).</summary>
|
|
public static byte[] WithHeader(byte[] data, byte cmd = 0x43)
|
|
{
|
|
var p = new byte[4 + data.Length];
|
|
p[0] = 0x51; p[1] = cmd; p[2] = (byte)data.Length; p[3] = 0x00;
|
|
Buffer.BlockCopy(data, 0, p, 4, data.Length);
|
|
return p;
|
|
}
|
|
|
|
/// <summary>A valid 24-byte 1D block with chosen sign flags / multipliers.</summary>
|
|
public static byte[] OneDimWire(
|
|
byte[] axis, byte[] conv,
|
|
byte rawSigned = 0, byte convSigned = 0,
|
|
byte rawMult = 1, byte convMult = 1,
|
|
byte maxRaw = 255, byte minRaw = 0, byte rawRound = 0, sbyte convOffset = 0)
|
|
{
|
|
var d = new byte[OneDimTable.WireLength];
|
|
Array.Copy(axis, 0, d, 0, 8);
|
|
Array.Copy(conv, 0, d, 8, 8);
|
|
d[16] = maxRaw; d[17] = minRaw;
|
|
d[18] = rawSigned; d[19] = convSigned;
|
|
d[20] = rawMult; d[21] = convMult;
|
|
d[22] = rawRound; d[23] = unchecked((byte)convOffset);
|
|
return d;
|
|
}
|
|
}
|