<pagemodel:LanPageModel x:Key="LanPageModel"></pagemodel:LanPageModel>
<pagemodel:ControlsPageModel x:Key="ControlsPageModel"></pagemodel:ControlsPageModel>
<pagemodel:AboutPageModel x:Key="AboutPageModel"></pagemodel:AboutPageModel>
+ <pagemodel:ltepopupModel x:Key="ltepopupModel"></pagemodel:ltepopupModel>
</ResourceDictionary>
</Application.Resources>
</Application>
namespace SpeedportHybridControl.Data {
public class SpeedportHybrid {
public SpeedportHybrid() { }
-
+
public static void initOverview () {
try {
if (SpeedportHybridAPI.getInstance().checkLogin().Equals(false))
LogManager.WriteToLog(ex.Message);
}
}
-
- public static void initLTE (bool popup = false) {
+
+ public static void initLTE () {
try {
if (SpeedportHybridAPI.getInstance().checkLogin().Equals(false))
return;
- LteInfoModel lte = null;
- if (popup.Equals(true)) {
- //lte = Application.Current.FindResource("LTE2") as LTE;
- }
- else {
- lte = Application.Current.FindResource("LteInfoModel") as LteInfoModel;
- }
+ LteInfoModel lte = Application.Current.FindResource("LteInfoModel") as LteInfoModel;
string response = SpeedportHybridAPI.getInstance().sendEnryptedRequest("data/lteinfo.json");
if (response.IsNullOrEmpty())
DateTime time = DateTime.Now;
string format = "dd.MM.yyyy HH:mm:ss";
lte.datetime = time.ToString(format);
- if (popup.Equals(false)) {
- initSyslog(true);
- }
+
+ initSyslog(true);
obj = null;
}
LogManager.WriteToLog(ex.Message);
}
}
-
+
+ public static void initLtePopup () {
+ try {
+ if (SpeedportHybridAPI.getInstance().checkLogin().Equals(false))
+ return;
+
+ ltepopupModel lte = Application.Current.FindResource("ltepopupModel") as ltepopupModel;
+
+ string response = SpeedportHybridAPI.getInstance().sendEnryptedRequest("data/lteinfo.json");
+ if (response.IsNullOrEmpty())
+ return;
+
+ LteInfoModel obj = JsonConvert.DeserializeObject<LteInfoModel>(response);
+ response = null;
+
+ lte.phycellid = obj.phycellid;
+ lte.cellid = obj.cellid;
+ lte.rsrp = obj.rsrp;
+ lte.rsrp_bg = util.getRSRPColor(obj.rsrp.ToInt());
+ lte.rsrq = obj.rsrq;
+ lte.rsrq_bg = util.getRSRQColor(obj.rsrq.ToInt());
+
+ DateTime time = DateTime.Now;
+ string format = "dd.MM.yyyy HH:mm:ss";
+ lte.datetime = time.ToString(format);
+
+ obj = null;
+ }
+ catch (Exception ex) {
+ LogManager.WriteToLog(ex.Message);
+ }
+ }
+
public static void initDSL () {
if (SpeedportHybridAPI.getInstance().checkLogin().Equals(false))
return;
string response = SpeedportHybridAPI.getInstance().sendEnryptedRequest("data/dsl.json");
if (response.IsNullOrEmpty())
return;
-
+
try {
DslPageModel obj = JsonConvert.DeserializeObject<DslPageModel>(response);
obj.Line.uFECsec = Math.Ceiling(obj.Line.uFEC / difference);
obj.Line.dFECsec = Math.Ceiling(obj.Line.dFEC / difference);
-
+
dsl.Connection = obj.Connection;
dsl.Line = obj.Line;
DateTime time = DateTime.Now;
string format = "dd.MM.yyyy HH:mm:ss";
dsl.datetime = time.ToString(format);
-
+
obj = null;
}
catch (Exception ex) {
string response = SpeedportHybridAPI.getInstance().sendRequest("data/status.json");
if (response.IsNullOrEmpty())
return;
-
+
JToken jArray = JToken.Parse(response);
response = null;
LogManager.WriteToLog(ex.Message);
}
}
-
+
public static void initSyslog (bool isLTE = false) {
try {
if (SpeedportHybridAPI.getInstance().checkLogin().Equals(false))
// Funkzellen Info
if (msg.ToString().Contains("(LT004)") && isLTE.Equals(true)) {
LteInfoModel lte = Application.Current.FindResource("LteInfoModel") as LteInfoModel;
- //LTE lte2 = Application.Current.FindResource("LTE2") as LTE;
string[] parts = msg.ToString().Split(',');
string frequenz = parts[2];
}
lte.frequenz = frequenz;
- //lte2.frequenz = frequenz;
varid = null;
jArray = null;
LogManager.WriteToLog(ex.Message);
}
}
-
+
public static void initLan () {
try {
if (SpeedportHybridAPI.getInstance().checkLogin().Equals(false))
--- /dev/null
+using Microsoft.Research.DynamicDataDisplay.Common;
+
+namespace SpeedportHybridControl.Model {
+ public class LTECollection : RingArray<LTEData> {
+ private const int TOTAL_POINTS = 200;
+
+ public LTECollection () : base(TOTAL_POINTS) {
+ }
+ }
+}
--- /dev/null
+using System;
+
+namespace SpeedportHybridControl.Model {
+ public class LTEData {
+ public DateTime Date { get; set; }
+
+ public int Data { get; set; }
+ }
+}
--- /dev/null
+using System;
+using SpeedportHybridControl.Data;
+using SpeedportHybridControl.Model;
+using SpeedportHybridControl.Implementations;
+using Microsoft.Research.DynamicDataDisplay.DataSources;
+using Microsoft.Research.DynamicDataDisplay.Charts;
+using System.Timers;
+using System.Windows.Media;
+using System.IO;
+using System.Windows;
+using System.Threading;
+
+namespace SpeedportHybridControl.PageModel {
+ class ltepopupModel : SuperViewModel {
+ private System.Timers.Timer _timer;
+ private DelegateCommand _pinCommand;
+ private DelegateCommand _closeWindowCommand;
+ private bool _pinActive;
+ private bool _logActive;
+
+ private bool _topmost = false;
+ private LTECollection _lteCollection;
+ private LTECollection _lteCollection2;
+ private EnumerableDataSource<LTEData> _rsrqGraph;
+ private EnumerableDataSource<LTEData> _rsrpGraph;
+ private HorizontalDateTimeAxis _dateTimeAxis1;
+ private HorizontalDateTimeAxis _dateTimeAxis2;
+
+ private string _phycellid;
+ private string _cellid;
+ private string _rsrp;
+ private Brush _rsrp_bg = Brushes.Transparent;
+ private string _rsrq;
+ private Brush _rsrq_bg = Brushes.Transparent;
+ private string _datetime;
+
+ public DelegateCommand PinCommand {
+ get { return _pinCommand; }
+ set { SetProperty(ref _pinCommand, value); }
+ }
+
+ public DelegateCommand CloseWindowCommand {
+ get { return _closeWindowCommand; }
+ set { SetProperty(ref _closeWindowCommand, value); }
+ }
+
+ public bool PinActive {
+ get { return _pinActive; }
+ set { SetProperty(ref _pinActive, value); }
+ }
+
+ public bool LogActive {
+ get { return _logActive; }
+ set { SetProperty(ref _logActive, value); }
+ }
+
+ public bool Topmost {
+ get { return _topmost; }
+ set { SetProperty(ref _topmost, value); }
+ }
+
+ public LTECollection LTECollection {
+ get { return _lteCollection; }
+ set { SetProperty(ref _lteCollection, value); }
+ }
+
+ public LTECollection LTECollection2 {
+ get { return _lteCollection2; }
+ set { SetProperty(ref _lteCollection2, value); }
+ }
+
+ public EnumerableDataSource<LTEData> RsrqGraph {
+ get { return _rsrqGraph; }
+ set { SetProperty(ref _rsrqGraph, value); }
+ }
+
+ public EnumerableDataSource<LTEData> RsrpGraph {
+ get { return _rsrpGraph; }
+ set { SetProperty(ref _rsrpGraph, value); }
+ }
+
+ public HorizontalDateTimeAxis DateTimeAxis1 {
+ get { return _dateTimeAxis1; }
+ set { SetProperty(ref _dateTimeAxis1, value); }
+ }
+
+ public HorizontalDateTimeAxis DateTimeAxis2 {
+ get { return _dateTimeAxis2; }
+ set { SetProperty(ref _dateTimeAxis2, value); }
+ }
+
+ public string phycellid {
+ get { return _phycellid; }
+ set { SetProperty(ref _phycellid, value); }
+ }
+
+ public string cellid {
+ get { return _cellid; }
+ set { SetProperty(ref _cellid, value); }
+ }
+
+ public string rsrp {
+ get { return _rsrp; }
+ set { SetProperty(ref _rsrp, value); }
+ }
+
+ public Brush rsrp_bg {
+ get { return _rsrp_bg; }
+ set { SetProperty(ref _rsrp_bg, value); }
+ }
+
+ public string rsrq {
+ get { return _rsrq; }
+ set { SetProperty(ref _rsrq, value); }
+ }
+
+ public Brush rsrq_bg {
+ get { return _rsrq_bg; }
+ set { SetProperty(ref _rsrq_bg, value); }
+ }
+
+ public string datetime {
+ get { return _datetime; }
+ set { SetProperty(ref _datetime, value); }
+ }
+
+ public void StopTimer () {
+ if (Object.Equals(_timer, null).Equals(false)) {
+ _timer.Stop();
+ }
+ }
+
+ private void StartTimer () {
+ _timer = new System.Timers.Timer {
+ Interval = 1000, // every second
+ };
+
+ _timer.Elapsed += timer_Elapsed;
+ _timer.Start();
+ }
+
+ void timer_Elapsed (object sender, ElapsedEventArgs e) {
+ new Thread(() => {
+ SpeedportHybrid.initLtePopup();
+ Application.Current.Dispatcher.BeginInvoke(new Action(() => {
+ LTECollection.Add(new LTEData() { Date = DateTime.Now, Data = rsrq.ToInt() });
+ LTECollection2.Add(new LTEData() { Date = DateTime.Now, Data = rsrp.ToInt() });
+
+ if (LogActive.Equals(true)) {
+ // log
+ log(string.Concat("Pysical Cell ID: ", phycellid, ", Cell ID: ", cellid, ", RSRP: ", rsrp, ", RSRQ: ", rsrq));
+ }
+ }));
+ }).Start();
+ }
+
+ private void log (string value) {
+ DateTime time = DateTime.Now;
+
+ if (Directory.Exists("log/").Equals(false))
+ Directory.CreateDirectory("log/");
+
+ if (Directory.Exists("log/lte/").Equals(false))
+ Directory.CreateDirectory("log/lte/");
+
+ StreamWriter file = new StreamWriter(string.Concat("log/lte/", time.ToString("dd.MM.yyyy"), ".txt"), true);
+ file.WriteLine(string.Concat("[", time.ToString("dd.MM.yyyy HH:mm:ss"), "]: ", value));
+ file.Close();
+ }
+
+ private void OnPinCommandExecute () {
+ if (PinActive.Equals(true)) {
+ Topmost = true;
+ }
+ else {
+ Topmost = false;
+ }
+ }
+
+ private void OnCloseWindowCommandExecute () {
+ StopTimer();
+ }
+
+ public ltepopupModel () {
+ PinCommand = new DelegateCommand(new Action(OnPinCommandExecute));
+ CloseWindowCommand = new DelegateCommand(new Action(OnCloseWindowCommandExecute));
+
+ LTECollection = new LTECollection();
+ LTECollection2 = new LTECollection();
+ DateTimeAxis1 = new HorizontalDateTimeAxis();
+ DateTimeAxis2 = new HorizontalDateTimeAxis();
+
+ var ds = new EnumerableDataSource<LTEData>(LTECollection);
+ ds.SetXMapping(x => DateTimeAxis1.ConvertToDouble(x.Date));
+ ds.SetYMapping(y => y.Data);
+
+ RsrqGraph = ds;
+
+ var ds2 = new EnumerableDataSource<LTEData>(LTECollection2);
+ ds2.SetXMapping(x => DateTimeAxis1.ConvertToDouble(x.Date));
+ ds2.SetYMapping(y => y.Data);
+
+ RsrpGraph = ds2;
+
+ StartTimer();
+ }
+ }
+}
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
+ <Reference Include="System.Windows" />
+ <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Compile Include="Model\Connection.cs" />
<Compile Include="Model\DeviceList.cs" />
<Compile Include="Model\Line.cs" />
+ <Compile Include="Model\LTECollection.cs" />
+ <Compile Include="Model\LTEData.cs" />
<Compile Include="Model\PhoneCallList.cs" />
<Compile Include="Model\StatusPhoneList.cs" />
<Compile Include="Model\SyslogList.cs" />
<Compile Include="PageModel\LanPageModel.cs" />
<Compile Include="PageModel\LoginPageModel.cs" />
<Compile Include="PageModel\LteInfoModel.cs" />
+ <Compile Include="PageModel\ltepopupModel.cs" />
<Compile Include="PageModel\MainWindowModel.cs" />
<Compile Include="Model\SuperViewModel.cs" />
<Compile Include="Data\SpeedportHybridAPI.cs" />
xmlns:local="clr-namespace:SpeedportHybridControl"
mc:Ignorable="d"
xmlns:d3="http://research.microsoft.com/DynamicDataDisplay/1.0"
+ xmlns:ig="http://schemas.infragistics.com/xaml"
+ xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
Height="423.4"
Width="530"
- Closing="Window_Closing"
Title="LteInfo"
+ DataContext="{StaticResource ltepopupModel}"
+ Topmost="{Binding Path=Topmost}"
Icon="t-com icon.ico">
- <!--
- <Grid DataContext="{StaticResource LTE2}">
- <ToggleButton Background="Transparent" BorderBrush="Transparent" x:Name="btnPin" HorizontalAlignment="Left" Margin="10,2,0,0" Height="20" VerticalAlignment="Top" Click="button_click">
+ <i:Interaction.Triggers>
+ <i:EventTrigger EventName="Closing">
+ <i:InvokeCommandAction Command="{Binding CloseWindowCommand}" />
+ </i:EventTrigger>
+ </i:Interaction.Triggers>
+ <Grid>
+ <ToggleButton Command="{Binding Path=PinCommand}" IsChecked="{Binding Path=PinActive, Mode=TwoWay}" Background="Transparent" BorderBrush="Transparent" x:Name="btnPin" HorizontalAlignment="Left" Margin="10,2,0,0" Height="20" VerticalAlignment="Top">
<Image Source="assets/pin.png" x:Name="image" HorizontalAlignment="Left" VerticalAlignment="Top"/>
</ToggleButton>
- <ToggleButton x:Name="btnLog" Content="Log" HorizontalAlignment="Right" Margin="0,2,10,0" Height="20" VerticalAlignment="Top"/>
+ <ToggleButton IsChecked="{Binding Path=LogActive, Mode=TwoWay}" x:Name="btnLog" Content="Log" HorizontalAlignment="Right" Margin="0,2,10,0" Height="20" VerticalAlignment="Top"/>
<TextBlock TextAlignment="Center" HorizontalAlignment="Left" Margin="54,2,0,0" TextWrapping="Wrap" Text="Cell ID" VerticalAlignment="Top" Width="85"/>
<TextBlock FontSize="20" TextAlignment="Center" HorizontalAlignment="Left" Margin="39,15,0,0" TextWrapping="Wrap" Text="{Binding cellid}" VerticalAlignment="Top" Width="122" Height="27"/>
</d3:ChartPlotter.HorizontalAxis>
<d3:VerticalAxisTitle FontFamily="Georgia" Content="RSRQ" />
<d3:HorizontalAxisTitle FontFamily="Georgia" Content="Date"/>
+ <d3:LineGraph DataSource="{Binding Path=RsrqGraph}" Stroke="green" x:Name="line" StrokeThickness="1">
+ <d3:ViewportElement2D.Description >
+ <d3:PenDescription DescriptionString="rsrq"/>
+ </d3:ViewportElement2D.Description>
+ </d3:LineGraph>
</d3:ChartPlotter>
<d3:ChartPlotter x:Name="plotter2" Margin="241,225,0,0" HorizontalAlignment="Left" Width="271" Height="159" VerticalAlignment="Top" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
<d3:ChartPlotter.HorizontalAxis>
- <d3:HorizontalDateTimeAxis Name="dateAxis2"/>
+ <d3:HorizontalDateTimeAxis DataContext="{Binding Path=DateTimeAxis1, Mode=TwoWay}" Name="dateAxis2"/>
</d3:ChartPlotter.HorizontalAxis>
<d3:VerticalAxisTitle FontFamily="Georgia" Content="RSRP" />
<d3:HorizontalAxisTitle FontFamily="Georgia" Content="Date"/>
+ <d3:LineGraph DataSource="{Binding Path=RsrpGraph}" Stroke="green" x:Name="line2" StrokeThickness="1">
+ <d3:ViewportElement2D.Description >
+ <d3:PenDescription DescriptionString="rsrp"/>
+ </d3:ViewportElement2D.Description>
+ </d3:LineGraph>
</d3:ChartPlotter>
</Grid>
- -->
</Window>
-using System;
-using System.Windows;
-using System.Windows.Media;
-using System.Timers;
-using Microsoft.Research.DynamicDataDisplay.DataSources;
-using Microsoft.Research.DynamicDataDisplay;
-using Microsoft.Research.DynamicDataDisplay.Common;
-using System.ComponentModel;
-using System.IO;
-using SpeedportHybridControl.Data;
-using SpeedportHybridControl.Model;
+using System.Windows;
namespace SpeedportHybridControl {
- public class LTECollection : RingArray<LTEData> {
- private const int TOTAL_POINTS = 200;
-
- public LTECollection () : base(TOTAL_POINTS) {
- }
- }
-
- public class LTEData {
- public DateTime Date { get; set; }
-
- public int Data { get; set; }
- }
-
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class ltepopup : Window {
- public Timer _timer;
- public LTECollection lteCollection;
- public LTECollection lteCollection2;
-
public ltepopup () {
InitializeComponent();
- /*
- util.init("LTE2");
-
- lteCollection = new LTECollection();
- lteCollection2 = new LTECollection();
-
- var ds = new EnumerableDataSource<LTEData>(lteCollection);
- ds.SetXMapping(x => dateAxis.ConvertToDouble(x.Date));
- ds.SetYMapping(y => y.Data);
- plotter.AddLineGraph(ds, Colors.Green, 1, "rsrq");
-
- var ds2 = new EnumerableDataSource<LTEData>(lteCollection2);
- ds2.SetXMapping(x => dateAxis.ConvertToDouble(x.Date));
- ds2.SetYMapping(y => y.Data);
- plotter2.AddLineGraph(ds2, Colors.Green, 1, "rsrp");
-
- StartTimer();
- */
- }
-
- void Window_Closing (object sender, CancelEventArgs e) {
- //StopTimer();
- }
- /*
- public void StopTimer () {
- if (Object.Equals(_timer, null).Equals(false)) {
- _timer.Stop();
- }
- }
-
- private void StartTimer () {
- _timer = new Timer {
- Interval = 1000, // every second
- };
-
- _timer.Elapsed += timer_Elapsed;
- _timer.Start();
- }
-
- private void log (string value) {
- DateTime time = DateTime.Now;
-
- if (Directory.Exists("log/").Equals(false))
- Directory.CreateDirectory("log/");
-
- if (Directory.Exists("log/lte/").Equals(false))
- Directory.CreateDirectory("log/lte/");
-
- StreamWriter file = new StreamWriter(string.Concat("log/lte/", time.ToString("dd.MM.yyyy"), ".txt"), true);
- file.WriteLine(string.Concat("[", time.ToString("dd.MM.yyyy HH:mm:ss"), "]: ", value));
- file.Close();
- }
-
- void timer_Elapsed (object sender, ElapsedEventArgs e) {
- new System.Threading.Thread(() => {
- util.init("LTE2");
-
- LTE lte = Application.Current.FindResource("LTE2") as LTE;
- int rsrq = lte.rsrq.ToInt();
- int rsrp = lte.rsrp.ToInt();
- Application.Current.Dispatcher.BeginInvoke(new Action(() => {
- lteCollection.Add(new LTEData() { Date = DateTime.Now, Data = rsrq });
- lteCollection2.Add(new LTEData() { Date = DateTime.Now, Data = rsrp });
-
- if (btnLog.IsChecked.Equals(true)) {
- // log
- log(string.Concat("Pysical Cell ID: ", lte.phycellid, ", Cell ID: ", lte.cellid, ", RSRP: ", lte.rsrp, ", RSRQ: ", lte.rsrq));
- }
- }));
- }).Start();
- }
-
- private void button_click (object sender, RoutedEventArgs e) {
- if (sender.Equals(btnPin)) {
- if (btnPin.IsChecked.Equals(true)) {
- Topmost = true;
- }
- else {
- Topmost = false;
- }
- }
}
- */
}
}