public void Initialize() { if (IsFirstLaunch) { IsScreenLocked = false; } if (IsScreenLocked) { return; } Messenger.Default.Send <BusyMessage>(new BusyMessage { IsBusy = true, Message = "Loading..." }); Task.Run(() => { try { System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => { loadForm(); })); Settings settings = TagDataProvider.GetSettings(); if (settings != null) { Antenna1ReceivePower = Convert.ToInt32(settings.Antennas.GetAntenna(1).RxSensitivityInDbm); Antenna1TransmitPower = Convert.ToInt32(settings.Antennas.GetAntenna(1).TxPowerInDbm); Antenna2ReceivePower = Convert.ToInt32(settings.Antennas.GetAntenna(2).RxSensitivityInDbm); Antenna2TransmitPower = Convert.ToInt32(settings.Antennas.GetAntenna(2).TxPowerInDbm); Antenna3ReceivePower = Convert.ToInt32(settings.Antennas.GetAntenna(3).RxSensitivityInDbm); Antenna3TransmitPower = Convert.ToInt32(settings.Antennas.GetAntenna(3).TxPowerInDbm); Antenna4ReceivePower = Convert.ToInt32(settings.Antennas.GetAntenna(4).RxSensitivityInDbm); Antenna4TransmitPower = Convert.ToInt32(settings.Antennas.GetAntenna(4).TxPowerInDbm); } if (Antenna1ReceivePower == 0) { Antenna1ReceivePower = -80; } if (Antenna2ReceivePower == 0) { Antenna2ReceivePower = -80; } if (Antenna3ReceivePower == 0) { Antenna3ReceivePower = -80; } if (Antenna4ReceivePower == 0) { Antenna4ReceivePower = -80; } if (Antenna1TransmitPower == 0) { Antenna1TransmitPower = 30; } if (Antenna2TransmitPower == 0) { Antenna2TransmitPower = 30; } if (Antenna3TransmitPower == 0) { Antenna3TransmitPower = 30; } if (Antenna4TransmitPower == 0) { Antenna4TransmitPower = 30; } } catch (Exception exc) { Logging.Logger.Log(exc); } Messenger.Default.Send <BusyMessage>(new BusyMessage { IsBusy = false, Message = "" }); }); }
public void Initialize() { Settings settings = TagDataProvider.GetSettings(); if (settings != null) { Antenna1ReceivePower = Convert.ToInt32(settings.Antennas.GetAntenna(1).RxSensitivityInDbm); Antenna1TransmitPower = Convert.ToInt32(settings.Antennas.GetAntenna(1).TxPowerInDbm); Antenna2ReceivePower = Convert.ToInt32(settings.Antennas.GetAntenna(2).RxSensitivityInDbm); Antenna2TransmitPower = Convert.ToInt32(settings.Antennas.GetAntenna(2).TxPowerInDbm); Antenna3ReceivePower = Convert.ToInt32(settings.Antennas.GetAntenna(3).RxSensitivityInDbm); Antenna3TransmitPower = Convert.ToInt32(settings.Antennas.GetAntenna(3).TxPowerInDbm); Antenna4ReceivePower = Convert.ToInt32(settings.Antennas.GetAntenna(4).RxSensitivityInDbm); Antenna4TransmitPower = Convert.ToInt32(settings.Antennas.GetAntenna(4).TxPowerInDbm); } if (Antenna1ReceivePower == 0) { Antenna1ReceivePower = -80; } if (Antenna2ReceivePower == 0) { Antenna2ReceivePower = -80; } if (Antenna3ReceivePower == 0) { Antenna3ReceivePower = -80; } if (Antenna4ReceivePower == 0) { Antenna4ReceivePower = -80; } if (Antenna1TransmitPower == 0) { Antenna1TransmitPower = 30; } if (Antenna2TransmitPower == 0) { Antenna2TransmitPower = 30; } if (Antenna3TransmitPower == 0) { Antenna3TransmitPower = 30; } if (Antenna4TransmitPower == 0) { Antenna4TransmitPower = 30; } foreach (var p in System.IO.Ports.SerialPort.GetPortNames().OrderBy(s => s)) { AvailablePorts.Add(p); } using (var dp = SimpleIoc.Default.GetInstance <IUnitOfWorkFactory>().CreateUnitOfWork()) { var repo = dp.SettingsRepository; var setting = repo.FindSingle(x => x.Key == TruckClientSettingKeys.RFID_READ_DELAY); if (setting != null && !string.IsNullOrWhiteSpace(setting.Value)) { RFIDReadDelay = int.Parse(setting.Value); } var portSetting = repo.FindSingle(x => x.Key == TruckClientSettingKeys.GPS_COM_PORT); if (portSetting != null && !string.IsNullOrWhiteSpace(portSetting.Value)) { PortName = portSetting.Value; } else { if (AvailablePorts.Count > 0) { PortName = AvailablePorts.First(); } else { PortName = ""; } } } }