Exemplo n.º 1
0
        protected async Task RunSensor(IProvider provider, CancellationToken token, string sensorName, string expectedValue)
        {
            provider.Activate(token);

            while (!token.IsCancellationRequested)
            {
                await Task.WhenAll(provider.WhenDataReady(), Task.Delay(250));

                var d = provider.GetType().GetProperty("Data").GetValue(provider);
                var l = d.GetType().GetMethod("Length")?.Invoke(d, new object[0]);
                if (expectedValue == "")
                {
                    UpdateInfo($"{sensorName} value: {d:f3} (magnitude {l:f3})");
                }
                else
                {
                    UpdateInfo($"{sensorName} value: {d:f3} (magnitude {l:f3}). Expect {expectedValue}.");
                }
            }
        }