public void Read() { try { // Changes from idle to wait-for-trigger state. // May want to move to "Open". Unsure if state is changed back to idle upon scan completion. _v3497x.SCPI.INITiate.Command(); // Sends trigger via bus source. _v3497x.SCPI.TRG.Command(); // Transfers NVM readings to output buffer. _v3497x.SCPI.FETCh.QueryAllData(out string data); string[] dataSeparated = data.Split(','); // Remove previous readings. Readings.Clear(); for (int i = 0; i < dataSeparated.Length; i += 2) { // Parse sensor output from string into double and add to list of readings. uint key = uint.Parse(dataSeparated[(i + 1)]) % 100; double value = double.Parse(dataSeparated[i], System.Globalization.NumberStyles.Any); Readings.Add(key, value); } } catch (Exception ex) { throw new DeviceCommandFailedException("Could not read from Keysight datalogger." + Environment.NewLine + ex.Message); } }
private async Task RefreshDevices() { IsLoading = true; var registeredDevices = (await metersDatabase.GetMetersAsync()).ToList(); var results = registeredDevices.Select(d => DownloadDeviceDataAsync(d)).ToArray(); await Task.WhenAll(results); Readings.Clear(); results .SelectMany(p => p.Result) .ToList() .ForEach(i => Readings.Add(i)); IsLoading = false; }