diff --git a/.vs/CodeClinic/v16/.suo b/.vs/CodeClinic/v16/.suo index 14c40a3..a66964b 100644 Binary files a/.vs/CodeClinic/v16/.suo and b/.vs/CodeClinic/v16/.suo differ diff --git a/Dashboard/ConstantChangesChart.xaml b/Dashboard/ConstantChangesChart.xaml index edf6864..e38a1bc 100644 --- a/Dashboard/ConstantChangesChart.xaml +++ b/Dashboard/ConstantChangesChart.xaml @@ -35,7 +35,7 @@ - public partial class ConstantChangesChart : UserControl, INotifyPropertyChanged { + private static long tickZero = DateTime.Parse("2018-01-01T08:00:00Z").Ticks; + + public Func X_Axis_LabelFormatter { get; set; } = d => TimeSpan.FromTicks((long)d - tickZero).TotalSeconds.ToString(); + public ConstantChangesChart() { InitializeComponent(); @@ -23,8 +28,9 @@ public ConstantChangesChart() DataContext = this; } + public ChartValues ChartValues { get; set; } = new ChartValues(); + private bool readingData = false; - private ChartValues chartValues { get; set; } = new ChartValues(); private void Button_Click(object sender, RoutedEventArgs e) { if (!readingData) @@ -36,25 +42,46 @@ private void Button_Click(object sender, RoutedEventArgs e) private void ReadData() { - // TODO: Populate the collection chartValues + // TODO: Populate the collection ChartValues string fileName = @"C:\Users\Millennium Singha\Downloads\Ex_Files_Code_Clinic_C_Sharp\Ex_Files_Code_Clinic_C_Sharp\Exercise Files\Ch06\dashBoardData.csv"; foreach (var ft in FactoryTelemetry.Load(fileName)) { - chartValues.Add(ft); + ChartValues.Add(ft); this.EngineEfficiency = ft.Efficiency; - if (chartValues.Count > 30) - chartValues.RemoveAt(0); + AdjustAxis(ft.TimeStamp.Ticks); + + if (ChartValues.Count > 30) + ChartValues.RemoveAt(0); Thread.Sleep(30); } } + public double AxisStep { get; set; } = TimeSpan.FromSeconds(5).Ticks; + public double AxisUnit { get; set; } = TimeSpan.FromSeconds(1).Ticks; + + private double axisMax = tickZero + TimeSpan.FromSeconds(30).Ticks; + public double AxisMax { get => axisMax; set { axisMax = value; OnPropertyChanged(nameof(AxisMax)); } } + + private double axisMin = tickZero; + public double AxisMin { get => axisMin; set { axisMin = value; OnPropertyChanged(nameof(AxisMin)); } } + + private void AdjustAxis(long ticks) + { + var width = TimeSpan.FromSeconds(30).Ticks; + + AxisMin = (ticks - tickZero < width) ? tickZero : ticks - width; + AxisMax = (ticks - tickZero < width) ? tickZero + width : ticks; + } + private double _EngineEfficiency = 65; - public double EngineEfficiency { + + public double EngineEfficiency + { get { return _EngineEfficiency; @@ -63,7 +90,7 @@ private void ReadData() { _EngineEfficiency = value; OnPropertyChanged(nameof(EngineEfficiency)); - } + } } public event PropertyChangedEventHandler PropertyChanged; diff --git a/Dashboard/bin/Debug/Dashboard.exe b/Dashboard/bin/Debug/Dashboard.exe index b9819e3..b8bedd0 100644 Binary files a/Dashboard/bin/Debug/Dashboard.exe and b/Dashboard/bin/Debug/Dashboard.exe differ diff --git a/Dashboard/bin/Debug/Dashboard.pdb b/Dashboard/bin/Debug/Dashboard.pdb index 70cc44a..ed9e09b 100644 Binary files a/Dashboard/bin/Debug/Dashboard.pdb and b/Dashboard/bin/Debug/Dashboard.pdb differ diff --git a/Dashboard/obj/Debug/ConstantChangesChart.baml b/Dashboard/obj/Debug/ConstantChangesChart.baml index 0091301..47d73a2 100644 Binary files a/Dashboard/obj/Debug/ConstantChangesChart.baml and b/Dashboard/obj/Debug/ConstantChangesChart.baml differ diff --git a/Dashboard/obj/Debug/ConstantChangesChart.g.cs b/Dashboard/obj/Debug/ConstantChangesChart.g.cs index 374010f..ea7ff69 100644 --- a/Dashboard/obj/Debug/ConstantChangesChart.g.cs +++ b/Dashboard/obj/Debug/ConstantChangesChart.g.cs @@ -1,4 +1,4 @@ -#pragma checksum "..\..\ConstantChangesChart.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "6F13C68C8B1A38462A90A7878446B99773475BD8C2B026FD8D177D7331F08391" +#pragma checksum "..\..\ConstantChangesChart.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "03D156A73DE64AC1BEF9F001BDFE132D7B1A431B01DFB9915E5599BAFDE9313C" //------------------------------------------------------------------------------ // // This code was generated by a tool. diff --git a/Dashboard/obj/Debug/ConstantChangesChart.g.i.cs b/Dashboard/obj/Debug/ConstantChangesChart.g.i.cs index 374010f..ea7ff69 100644 --- a/Dashboard/obj/Debug/ConstantChangesChart.g.i.cs +++ b/Dashboard/obj/Debug/ConstantChangesChart.g.i.cs @@ -1,4 +1,4 @@ -#pragma checksum "..\..\ConstantChangesChart.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "6F13C68C8B1A38462A90A7878446B99773475BD8C2B026FD8D177D7331F08391" +#pragma checksum "..\..\ConstantChangesChart.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "03D156A73DE64AC1BEF9F001BDFE132D7B1A431B01DFB9915E5599BAFDE9313C" //------------------------------------------------------------------------------ // // This code was generated by a tool. diff --git a/Dashboard/obj/Debug/Dashboard.csprojAssemblyReference.cache b/Dashboard/obj/Debug/Dashboard.csprojAssemblyReference.cache index 4b8a32b..95357c6 100644 Binary files a/Dashboard/obj/Debug/Dashboard.csprojAssemblyReference.cache and b/Dashboard/obj/Debug/Dashboard.csprojAssemblyReference.cache differ diff --git a/Dashboard/obj/Debug/Dashboard.exe b/Dashboard/obj/Debug/Dashboard.exe index b9819e3..b8bedd0 100644 Binary files a/Dashboard/obj/Debug/Dashboard.exe and b/Dashboard/obj/Debug/Dashboard.exe differ diff --git a/Dashboard/obj/Debug/Dashboard.g.resources b/Dashboard/obj/Debug/Dashboard.g.resources index 72a2208..955f329 100644 Binary files a/Dashboard/obj/Debug/Dashboard.g.resources and b/Dashboard/obj/Debug/Dashboard.g.resources differ diff --git a/Dashboard/obj/Debug/Dashboard.pdb b/Dashboard/obj/Debug/Dashboard.pdb index 70cc44a..ed9e09b 100644 Binary files a/Dashboard/obj/Debug/Dashboard.pdb and b/Dashboard/obj/Debug/Dashboard.pdb differ diff --git a/Dashboard/obj/Debug/Dashboard_MarkupCompile.i.lref b/Dashboard/obj/Debug/Dashboard_MarkupCompile.i.lref index 9a250ce..2f5edd1 100644 --- a/Dashboard/obj/Debug/Dashboard_MarkupCompile.i.lref +++ b/Dashboard/obj/Debug/Dashboard_MarkupCompile.i.lref @@ -1,4 +1,5 @@ - +C:\codeClinic_c_sharp\realTimeInfo\Dashboard\obj\Debug\GeneratedInternalTypeHelper.g.i.cs FC:\codeClinic_c_sharp\realTimeInfo\Dashboard\ConstantChangesChart.xaml;; +FC:\codeClinic_c_sharp\realTimeInfo\Dashboard\MainWindow.xaml;; diff --git a/Data/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/Data/obj/Debug/DesignTimeResolveAssemblyReferences.cache index 7ecb882..a15382e 100644 Binary files a/Data/obj/Debug/DesignTimeResolveAssemblyReferences.cache and b/Data/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ