总览信息页面曲线图
This commit is contained in:
commit
8b7593dceb
4 files changed
+69
-24
No files matched your search
@@ -1078,6 +1078,6 @@
|
|||||||
<value>輸送異常</value>
|
<value>輸送異常</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="_Auto" xml:space="preserve">
|
<data name="_Auto" xml:space="preserve">
|
||||||
<value />
|
<value>手/自動</value>
|
||||||
</data>
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
<local:RoilingTextBlock Foreground="Black" x:Name="Step" Text="NO Information" FontSize="21" Height="30" Margin="120,50,0,0" VerticalAlignment="Top"/>
|
<local:RoilingTextBlock Foreground="Black" x:Name="Step" Text="NO Information" FontSize="21" Height="30" Margin="120,50,0,0" VerticalAlignment="Top"/>
|
||||||
<local:RoilingTextBlock Foreground="Black" x:Name="Message" Text="NO Information" FontSize="21" Height="30" Margin="120,100,0,0" VerticalAlignment="Top"/>
|
<local:RoilingTextBlock Foreground="Black" x:Name="Message" Text="NO Information" FontSize="21" Height="30" Margin="120,100,0,0" VerticalAlignment="Top"/>
|
||||||
<local:RoilingTextBlock Foreground="Black" x:Name="Orders" Text="NO Information" FontSize="21" Height="30" Margin="120,150,0,0" VerticalAlignment="Top"/>
|
<local:RoilingTextBlock Foreground="Black" x:Name="Orders" Text="NO Information" FontSize="21" Height="30" Margin="120,150,0,0" VerticalAlignment="Top"/>
|
||||||
<lvc:CartesianChart x:Name="OscChart" Margin="0,200 ,0,0" EasingFunction="{x:Null}" ZoomMode="PanX"
|
<lvc:CartesianChart x:Name="OscChart" Margin="0,200,0,0" EasingFunction="{x:Null}" ZoomMode="PanX"
|
||||||
Series="{Binding Series}" YAxes="{Binding YAxes}" XAxes="{Binding XAxes}"/>
|
Series="{Binding Series}" YAxes="{Binding YAxes}" XAxes="{Binding XAxes}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
+56
-20
@@ -4,13 +4,16 @@ using LiveChartsCore.Kernel.Sketches;
|
|||||||
using LiveChartsCore.SkiaSharpView;
|
using LiveChartsCore.SkiaSharpView;
|
||||||
using LiveChartsCore.SkiaSharpView.Painting;
|
using LiveChartsCore.SkiaSharpView.Painting;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using ScottPlot;
|
||||||
using ScottPlot.Plottables;
|
using ScottPlot.Plottables;
|
||||||
|
using ScottPlot.Statistics;
|
||||||
using SkiaSharp;
|
using SkiaSharp;
|
||||||
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
|
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -33,23 +36,36 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserControls
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// info.xaml 的交互逻辑
|
/// info.xaml 的交互逻辑
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class info : UserControl
|
public partial class info : UserControl, INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
public info()
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
protected virtual void OnPropertyChanged(string propertyName)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
if (PropertyChanged != null)
|
||||||
DataContext = this; //new infoModel();
|
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||||
}
|
}
|
||||||
|
public void RaisePropertyChanged(string propertyName)
|
||||||
public void DataAdd()
|
|
||||||
{
|
{
|
||||||
|
if (PropertyChanged != null)
|
||||||
|
{
|
||||||
|
if (propertyName != null)
|
||||||
|
{
|
||||||
|
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
}
|
}
|
||||||
private readonly Random _random = new Random();
|
}
|
||||||
private readonly List<DateTimePoint> _values = new List<DateTimePoint>();
|
}
|
||||||
private readonly DateTimeAxis _customAxis;
|
private ObservableCollection<DateTimePoint> MTH_values = new ObservableCollection<DateTimePoint>();
|
||||||
public ObservableCollection<ISeries> Series { get; set; }
|
|
||||||
public static ObservableCollection<ObservableValue> ObservableValues { get; set; }
|
|
||||||
|
|
||||||
|
public ObservableCollection<ISeries> _series { get; set; }
|
||||||
|
public ObservableCollection<ISeries> Series
|
||||||
|
{
|
||||||
|
get => _series;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_series = value;
|
||||||
|
OnPropertyChanged(nameof(Series));
|
||||||
|
}
|
||||||
|
}
|
||||||
//x轴时间格式
|
//x轴时间格式
|
||||||
public Axis[] XAxes { get; set; } =
|
public Axis[] XAxes { get; set; } =
|
||||||
{
|
{
|
||||||
@@ -83,12 +99,35 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserControls
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private static ObservableCollection<DateTimePoint> MTH_values;
|
public info()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
DataContext = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DataAdd(double dat)
|
||||||
|
{
|
||||||
|
DateTime dateTime = DateTime.Now;
|
||||||
|
|
||||||
|
Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
// 添加新数据点
|
||||||
|
MTH_values.Add(new DateTimePoint(dateTime, dat));
|
||||||
|
// 更新X轴范围,始终保持最近6小时
|
||||||
|
XAxes[0].MinLimit = dateTime.AddHours(-6).Ticks;
|
||||||
|
XAxes[0].MaxLimit = dateTime.AddMinutes(1).Ticks;
|
||||||
|
// 移除6小时前的旧数据
|
||||||
|
while (MTH_values.Count > 0 &&
|
||||||
|
MTH_values[0].DateTime < dateTime.AddHours(-6))
|
||||||
|
{
|
||||||
|
MTH_values.RemoveAt(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var MTH_items = new List<DateTimePoint>();
|
// 初始化系列
|
||||||
MTH_values = new ObservableCollection<DateTimePoint>(MTH_items);
|
|
||||||
|
|
||||||
Series = new ObservableCollection<ISeries>
|
Series = new ObservableCollection<ISeries>
|
||||||
{
|
{
|
||||||
new LineSeries<DateTimePoint>
|
new LineSeries<DateTimePoint>
|
||||||
@@ -100,13 +139,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserControls
|
|||||||
GeometryStroke = new SolidColorPaint(s_red, 2),
|
GeometryStroke = new SolidColorPaint(s_red, 2),
|
||||||
Fill = null,
|
Fill = null,
|
||||||
LineSmoothness = 0,
|
LineSmoothness = 0,
|
||||||
ScalesYAt = 2,
|
ScalesYAt = 0,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+11
-2
@@ -86,16 +86,18 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int t30S = 0;
|
||||||
private void CountDown()
|
private void CountDown()
|
||||||
{
|
{
|
||||||
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
|
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
|
||||||
{
|
{
|
||||||
Interval = TimeSpan.FromSeconds(1)//秒
|
Interval = TimeSpan.FromSeconds(1)//秒
|
||||||
};
|
};
|
||||||
timer1s.Tick += Tick_Event_1S;
|
timer1s.Tick += Tick_Event_S;
|
||||||
timer1s.Start();
|
timer1s.Start();
|
||||||
}//时间周期初始化
|
}//时间周期初始化
|
||||||
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
|
|
||||||
|
void Tick_Event_S(object sender, EventArgs e)//Tick_Event周期执行事件1S
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MainWindowViewModel.Machines.Rows.Count; i++)
|
for (int i = 0; i < MainWindowViewModel.Machines.Rows.Count; i++)
|
||||||
{
|
{
|
||||||
@@ -114,6 +116,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
inf[i].Message.Text = (string)Selet_Machines(MainWindowViewModel.Machines, "Message", i);
|
inf[i].Message.Text = (string)Selet_Machines(MainWindowViewModel.Machines, "Message", i);
|
||||||
inf[i].Orders.Text = (string)Selet_Machines(MainWindowViewModel.Machines, "WorkOrder", i);
|
inf[i].Orders.Text = (string)Selet_Machines(MainWindowViewModel.Machines, "WorkOrder", i);
|
||||||
inf[i].time.Text = (string)Selet_Machines(MainWindowViewModel.Machines, "time", i);
|
inf[i].time.Text = (string)Selet_Machines(MainWindowViewModel.Machines, "time", i);
|
||||||
|
|
||||||
|
if ((t30S > 30)&&(State_!="800"))
|
||||||
|
{
|
||||||
|
t30S = 0;
|
||||||
|
inf[i].DataAdd((double)Selet_Machines(MainWindowViewModel.Machines, "Temperature", i));
|
||||||
|
}
|
||||||
|
else { t30S++; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user