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)) {
98 public bool AutoReload {
99 get { return _autoReload; }
100 set { SetProperty(ref _autoReload, value); }
103 public void StopTimer () {
104 if (Object.Equals(_timer, null).Equals(false)) {
108 if (AutoReload.Equals(true)) {
113 private void StartTimer () {
114 _timer = new System.Timers.Timer {
115 Interval = 1000, // every second
118 _timer.Elapsed += timer_Elapsed;
122 private void timer_Elapsed (object sender, ElapsedEventArgs e) {
123 OnReloadCommandExecute();
127 get { return _imei; }
128 set { SetProperty(ref _imei, value); }
132 get { return _imsi; }
133 set { SetProperty(ref _imsi, value); }
136 public string device_status {
137 get { return _device_status; }
138 set { SetProperty(ref _device_status, value); }
141 public string card_status {
142 get { return _card_status; }
143 set { SetProperty(ref _card_status, value); }
146 public string antenna_mode {
147 get { return _antenna_mode; }
148 set { SetProperty(ref _antenna_mode, value); }
151 public string antenna_mode2 {
152 get { return _antenna_mode2; }
153 set { SetProperty(ref _antenna_mode2, value); }
156 public string phycellid {
157 get { return _phycellid; }
158 set { SetProperty(ref _phycellid, value); }
161 public string cellid {
162 get { return _cellid; }
163 set { SetProperty(ref _cellid, value); }
167 get { return _rsrp; }
168 set { SetProperty(ref _rsrp, value); }
171 public Brush rsrp_bg {
172 get { return _rsrp_bg; }
173 set { SetProperty(ref _rsrp_bg, value); }
177 get { return _rsrq; }
178 set { SetProperty(ref _rsrq, value); }
181 public Brush rsrq_bg {
182 get { return _rsrq_bg; }
183 set { SetProperty(ref _rsrq_bg, value); }
186 public string service_status {
187 get { return _service_status; }
188 set { SetProperty(ref _service_status, value); }
193 set { SetProperty(ref _tac, value); }
196 public string datetime {
197 get { return _datetime; }
198 set { SetProperty(ref _datetime, value); }
201 public string frequenz {
202 get { return _frequenz; }
203 set { SetProperty(ref _frequenz, value); }
206 public LteInfoModel () {
207 ReloadCommand = new DelegateCommand(new Action(OnReloadCommandExecute));
208 AutoReloadCommand = new DelegateCommand(new Action(OnAutoReloadCommandExecute));
209 SaveCommand = new DelegateCommand(new Action(OnSaveCommandExecute));
210 PopupCommand = new DelegateCommand(new Action(OnPopupCommandExecute));