public async Task CheckAccelerationDataAsync() { List <Acceleration> actual = new List <Acceleration>(); var route = await metawear.GetModule <IAccelerometer>().Acceleration.AddRouteAsync(source => source.Log(data => actual.Add(data.Value <Acceleration>()))); List <Acceleration> expected = new List <Acceleration>(); platform.ReadFile("bmi160_expected_values", line => { int i = 0; float[] value = new float[3]; foreach (var v in JsonConvert.DeserializeObject <int[]>(line)) { value[i++] = BitConverter.ToSingle(BitConverter.GetBytes(v), 0); } expected.Add(new Acceleration(value[0], value[1], value[2])); }); List <sbyte[]> responses = new List <sbyte[]>(); platform.ReadFile("bmi160_log_dl", line => responses.Add(JsonConvert.DeserializeObject <sbyte[]>(line))); metawear.GetModule <IAccelerometer>().Configure(range: 8f); var task = logging.DownloadAsync(); responses.ForEach(it => platform.sendMockResponse(it)); await task; Assert.That(actual, Is.EqualTo(expected)); }
public async Task ReadoutProgess() { uint[] expected = new uint[] { 0x019e, 0x0271, 0x0251, 0x0231, 0x0211, 0x01f1, 0x01d1, 0x01b1, 0x0191, 0x0171, 0x0151, 0x0131, 0x0111, 0x00f1, 0x00d1, 0x00b1, 0x0091, 0x0071, 0x0051, 0x0031, 0x0011, 0x0000 }; uint[] actual = new uint[22]; int i = 0; byte[][] progressResponses = { new byte[] { 0x0b, 0x08, 0x71, 0x02, 0x00, 0x00 }, new byte[] { 0x0b, 0x08, 0x51, 0x02, 0x00, 0x00 }, new byte[] { 0x0b, 0x08, 0x31, 0x02, 0x00, 0x00 }, new byte[] { 0x0b, 0x08, 0x11, 0x02, 0x00, 0x00 }, new byte[] { 0x0b, 0x08, 0xf1, 0x01, 0x00, 0x00 }, new byte[] { 0x0b, 0x08, 0xd1, 0x01, 0x00, 0x00 }, new byte[] { 0x0b, 0x08, 0xb1, 0x01, 0x00, 0x00 }, new byte[] { 0x0b, 0x08, 0x91, 0x01, 0x00, 0x00 }, new byte[] { 0x0b, 0x08, 0x71, 0x01, 0x00, 0x00 }, new byte[] { 0x0b, 0x08, 0x51, 0x01, 0x00, 0x00 }, new byte[] { 0x0b, 0x08, 0x31, 0x01, 0x00, 0x00 }, new byte[] { 0x0b, 0x08, 0x11, 0x01, 0x00, 0x00 }, new byte[] { 0x0b, 0x08, 0xf1, 0x00, 0x00, 0x00 }, new byte[] { 0x0b, 0x08, 0xd1, 0x00, 0x00, 0x00 }, new byte[] { 0x0b, 0x08, 0xb1, 0x00, 0x00, 0x00 }, new byte[] { 0x0b, 0x08, 0x91, 0x00, 0x00, 0x00 }, new byte[] { 0x0b, 0x08, 0x71, 0x00, 0x00, 0x00 }, new byte[] { 0x0b, 0x08, 0x51, 0x00, 0x00, 0x00 }, new byte[] { 0x0b, 0x08, 0x31, 0x00, 0x00, 0x00 }, new byte[] { 0x0b, 0x08, 0x11, 0x00, 0x00, 0x00 }, new byte[] { 0x0b, 0x08, 0x00, 0x00, 0x00, 0x00 } }; var task = logging.DownloadAsync(22, (nEntries, totalEntries) => actual[i++] = nEntries); foreach (byte[] it in progressResponses) { platform.sendMockResponse(it); } await task; Assert.That(actual, Is.EqualTo(expected)); }
public async Task CheckRolloverAsync() { int actual = 0; DateTime?prev = null; var route = await metawear.GetModule <IAccelerometer>().Acceleration.AddRouteAsync(source => source.Log(data => { if (prev != null) { actual = Convert.ToInt32((data.Timestamp - prev.Value).TotalMilliseconds); } prev = data.Timestamp; })); var task = logging.DownloadAsync(); platform.sendMockResponse(new byte[] { 0x0b, 0x84, 0x15, 0x04, 0x00, 0x00, 0x05 }); platform.sendMockResponse(new byte[] { 11, 7, 0xa1, 0xff, 0xff, 0xff, 0xff, 0x91, 0xef, 0, 0, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x80, 0xff, 0xb7, 0xff }); platform.sendMockResponse(new byte[] { 11, 7, 0xa1, 13, 0, 0, 0, 116, 0xef, 0, 0, 0xa0, 13, 0, 0, 0, 125, 0xff, 0xba, 0xff }); platform.sendMockResponse(new byte[] { 11, 8, 0, 0, 0, 0 }); await task; Assert.That(actual, Is.EqualTo(21)); }