public async void ReadFromDeviceAndSelect(Gateway gateway, KellerDevice device) { var file = await Task.Run(() => _measurementService.GetMeasurements(gateway, device)); SelectedGateway = gateway; SelectedKellerDevice = device; IsSelectedFileLocal = false; SelectRecord(file); }
private void SendDeleteMeasurementRequest(Gateway gateway, KellerDevice device) { var uriBuilder = new UriBuilder("", gateway.GatewayIp, gateway.GatewayPort, ApiUrl); var channel = new Channel(uriBuilder.ToString(), ChannelCredentials.Insecure); var client = new Kiwi.Api.MeasurementService.MeasurementServiceClient(channel); var request = new DeleteMeasurementsRequest { DevEui = device.EUI }; client.Delete(request); channel.ShutdownAsync().Wait(); }
private GetMeasurementsResponse SendGetMeasurementRequest(Gateway gateway, KellerDevice device) { var uriBuilder = new UriBuilder("", gateway.GatewayIp, gateway.GatewayPort, ApiUrl); var channel = new Channel(uriBuilder.ToString(), ChannelCredentials.Insecure); var client = new Kiwi.Api.MeasurementService.MeasurementServiceClient(channel); var request = new GetMeasurementsRequest { DevEui = device.EUI }; var reply = client.Get(request); channel.ShutdownAsync().Wait(); return(reply); }
public MeasurementFileFormat GetMeasurements(Gateway gateway, KellerDevice device) { var reply = SendGetMeasurementRequest(gateway, device); var kellerFormat = _mapper.Map(reply); kellerFormat.Header.SerialNumber = device.SerialNumber; kellerFormat.Header.DeviceName = device.Name; kellerFormat.Header.DeviceType = device.DeviceType; kellerFormat.Header.UniqueSerialNumber = MeasurementFileFormatHelper.GenerateUniqueSerialNumber(kellerFormat.Header, device.EUI); kellerFormat.Header.RecordId = MeasurementFileFormatHelper.GenerateRecordId(kellerFormat.Header); kellerFormat.Header.CustomAttributes = new MeasurementFileFormatCustomAttributes { RecordName = MeasurementFileFormatHelper.GenerateDefaultRecordName(kellerFormat.Header), RecordNotes = string.Empty, }; return(kellerFormat); }
private async void DownloadDataAndRemove(KellerDevice kellerDevice) { var existingFiles = _fileService.FindFilesFromDevice(kellerDevice.UniqueSerialNumber); if (existingFiles != null && existingFiles.Count > 0) { var view = new CombineFilesDialog { DataContext = new CombineFilesDialogViewModel { FilesToCombine = existingFiles, Device = kellerDevice } }; await DialogHost.Show(view, "ContentDialog", DownloadDialogClosingHandler); } else { Download(false, kellerDevice); } }
private void Download(bool combineMeasurements, KellerDevice device, List <MeasurementFileFormatHeader> files = null) { var gateway = new Gateway(GatewayIp); try { var measurement = _measurementService.GetMeasurements(gateway, device); if (combineMeasurements && files != null) { _fileService.WriteFileCombinedWith(measurement, files); } else { _fileService.WriteFileFormat(measurement); } _measurementService.RemoveMeasurements(gateway, device); LoadLocal(); } catch (Exception e) { Logger.Warn(e, "Failed to read measurements from Chirpnest"); } }
public bool RemoveMeasurements(Gateway gateway, KellerDevice device) { SendDeleteMeasurementRequest(gateway, device); return(true); }
private void SelectData(KellerDevice kellerDevice) { SelectedRecord.Instance.ReadFromDeviceAndSelect(new Gateway(GatewayIp), kellerDevice); NavigateToVisualize(); }