Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        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");
            }
        }
Ejemplo n.º 7
0
 public bool RemoveMeasurements(Gateway gateway, KellerDevice device)
 {
     SendDeleteMeasurementRequest(gateway, device);
     return(true);
 }
Ejemplo n.º 8
0
 private void SelectData(KellerDevice kellerDevice)
 {
     SelectedRecord.Instance.ReadFromDeviceAndSelect(new Gateway(GatewayIp), kellerDevice);
     NavigateToVisualize();
 }