1 using SpeedportHybridControl.Data;
2 using SpeedportHybridControl.Implementations;
3 using SpeedportHybridControl.Model;
5 using System.Threading;
8 using System.Windows.Controls;
9 using System.Windows.Media;
11 namespace SpeedportHybridControl.PageModel {
12 class LteInfoModel : SuperViewModel {
13 private DelegateCommand _reloadCommand;
14 private DelegateCommand _autoReloadCommand;
15 private DelegateCommand _saveCommand;
16 private DelegateCommand _popupCommand;
17 private System.Timers.Timer _timer;
18 private bool _autoReload;
19 private ltepopup _ltepopup;
20 private ComboBoxItem _selectedItem;
25 private string _device_status;
26 private string _card_status;
27 private string _antenna_mode;
28 private string _antenna_mode2;
29 private string _phycellid;
30 private string _cellid;
32 private Brush _rsrp_bg = Brushes.Transparent;
34 private Brush _rsrq_bg = Brushes.Transparent;
35 private string _service_status;
37 private string _datetime;
38 private string _frequenz;
40 public DelegateCommand ReloadCommand {
41 get { return _reloadCommand; }
42 set { SetProperty(ref _reloadCommand, value); }
45 public DelegateCommand AutoReloadCommand {
46 get { return _autoReloadCommand; }
47 set { SetProperty(ref _autoReloadCommand, value); }
50 public DelegateCommand SaveCommand {
51 get { return _saveCommand; }
52 set { SetProperty(ref _saveCommand, value); }
55 public DelegateCommand PopupCommand {
56 get { return _popupCommand; }
57 set { SetProperty(ref _popupCommand, value); }
60 public ComboBoxItem SelectedItem {
61 get { return _selectedItem; }
62 set { SetProperty(ref _selectedItem, value); }
65 private void OnReloadCommandExecute () {
66 new Thread(() => { SpeedportHybrid.initLTE(); }).Start();
69 private void OnAutoReloadCommandExecute () {
70 if (AutoReload.Equals(true)) {
78 private void OnSaveCommandExecute () {
79 SpeedportHybridAPI.getInstance().setAntennaMode(SelectedItem.Name);
80 OnReloadCommandExecute();
83 private void OnPopupCommandExecute () {
84 if (Object.Equals(_ltepopup, null)) {
85 _ltepopup = new ltepopup();
87 else if (Object.Equals(_ltepopup, null).Equals(false) && _ltepopup.IsLoaded.Equals(false)) {
89 _ltepopup = new ltepopup();
92 if (_ltepopup.Visibility.Equals(Visibility.Visible).Equals(false)) {
96 ltepopupModel lm = Application.Current.FindResource("ltepopupModel") as ltepopupModel;
101 public bool AutoReload {
102 get { return _autoReload; }
103 set { SetProperty(ref _autoReload, value); }
106 public void StopTimer () {
107 if (Object.Equals(_timer, null).Equals(false)) {
111 if (AutoReload.Equals(true)) {
116 private void StartTimer () {
117 _timer = new System.Timers.Timer {
118 Interval = 1000, // every second
121 _timer.Elapsed += timer_Elapsed;
125 private void timer_Elapsed (object sender, ElapsedEventArgs e) {
126 OnReloadCommandExecute();
130 get { return _imei; }
131 set { SetProperty(ref _imei, value); }
135 get { return _imsi; }
136 set { SetProperty(ref _imsi, value); }
139 public string device_status {
140 get { return _device_status; }
141 set { SetProperty(ref _device_status, value); }
144 public string card_status {
145 get { return _card_status; }
146 set { SetProperty(ref _card_status, value); }
149 public string antenna_mode {
150 get { return _antenna_mode; }
151 set { SetProperty(ref _antenna_mode, value); }
154 public string antenna_mode2 {
155 get { return _antenna_mode2; }
156 set { SetProperty(ref _antenna_mode2, value); }
159 public string phycellid {
160 get { return _phycellid; }
161 set { SetProperty(ref _phycellid, value); }
164 public string cellid {
165 get { return _cellid; }
166 set { SetProperty(ref _cellid, value); }
170 get { return _rsrp; }
171 set { SetProperty(ref _rsrp, value); }
174 public Brush rsrp_bg {
175 get { return _rsrp_bg; }
176 set { SetProperty(ref _rsrp_bg, value); }
180 get { return _rsrq; }
181 set { SetProperty(ref _rsrq, value); }
184 public Brush rsrq_bg {
185 get { return _rsrq_bg; }
186 set { SetProperty(ref _rsrq_bg, value); }
189 public string service_status {
190 get { return _service_status; }
191 set { SetProperty(ref _service_status, value); }
196 set { SetProperty(ref _tac, value); }
199 public string datetime {
200 get { return _datetime; }
201 set { SetProperty(ref _datetime, value); }
204 public string frequenz {
205 get { return _frequenz; }
206 set { SetProperty(ref _frequenz, value); }
209 public LteInfoModel () {
210 ReloadCommand = new DelegateCommand(new Action(OnReloadCommandExecute));
211 AutoReloadCommand = new DelegateCommand(new Action(OnAutoReloadCommandExecute));
212 SaveCommand = new DelegateCommand(new Action(OnSaveCommandExecute));
213 PopupCommand = new DelegateCommand(new Action(OnPopupCommandExecute));