Merge branch 'master' of http://www.scserverddns.top:13000/sc/DyeingComputer
This commit is contained in:
commit
432184f348
3 files changed
+139
-19
No files matched your search
@@ -4,12 +4,60 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:viewmodel="clr-namespace:DyeingComputer.ViewModel"
|
xmlns:viewmodel="clr-namespace:DyeingComputer.ViewModel"
|
||||||
|
xmlns:lang="clr-namespace:DyeingComputer.Properties"
|
||||||
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.WPF;assembly=LiveChartsCore.SkiaSharpView.WPF"
|
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.WPF;assembly=LiveChartsCore.SkiaSharpView.WPF"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DataContext="{d:DesignInstance Type=viewmodel:HistoryRecordsViewModel}"
|
d:DataContext="{d:DesignInstance Type=viewmodel:HistoryRecordsViewModel}"
|
||||||
d:DesignHeight="630" d:DesignWidth="1280">
|
d:DesignHeight="630" d:DesignWidth="1280">
|
||||||
<Grid>
|
<Grid>
|
||||||
<lvc:CartesianChart x:Name="OscChart" MinWidth="1280" MinHeight="600" EasingFunction="{x:Null}"
|
<DataGrid x:Name="gridH" AlternationCount="2" IsReadOnly="True" SelectionChanged="Grid_SelectionChanged"
|
||||||
|
d:ItemsSource="{d:SampleData ItemCount=90}" AutoGenerateColumns="False" MinColumnWidth="30"
|
||||||
|
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="{x:Null}"
|
||||||
|
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" Grid.ColumnSpan="2" AllowDrop="False"
|
||||||
|
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"
|
||||||
|
CanUserAddRows="True" CanUserDeleteRows="False" HeadersVisibility ="Column"
|
||||||
|
Background="White" SelectionMode="Single" FontSize="15" TabIndex="1" Focusable="True" VerticalAlignment="Top" Height="300">
|
||||||
|
<DataGrid.RowStyle >
|
||||||
|
<Style TargetType="{x:Type DataGridRow}">
|
||||||
|
<Setter Property="Height" Value="30" />
|
||||||
|
<Setter Property="FontSize" Value="25" />
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
|
||||||
|
<Setter Property="Background" Value="#FFFFFFFF" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
|
||||||
|
<Setter Property="Background" Value="#FFF0F0F0" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsMouseOver" Value="False"/>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</DataGrid.RowStyle>
|
||||||
|
<DataGrid.CellStyle>
|
||||||
|
<Style TargetType="DataGridCell">
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Setter Property="MinWidth" Value="20"/>
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsSelected" Value="True">
|
||||||
|
<Setter Property="Background" Value="#FFC0C0C0"/>
|
||||||
|
<Setter Property="BorderBrush" Value="#FFC0C0C0"/>
|
||||||
|
<Setter Property="Foreground" Value="Black"/>
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</DataGrid.CellStyle>
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<!--列信息绑定-->
|
||||||
|
<!--列信息绑定-->
|
||||||
|
<DataGridTextColumn Header="{x:Static lang:Resources.WorkOrderNumder}" Width="300" Binding="{Binding WorkOrder}" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Header="{x:Static lang:Resources.ProcessName}" Width="300" Binding="{Binding ProcessName}" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Header="ProcessID" Binding="{Binding ProcessID}" Width="0" MinWidth="0" MaxWidth="0"/>
|
||||||
|
<DataGridTextColumn Header="lock" Binding="{Binding lock}" Width="0" MinWidth="0" MaxWidth="0"/>
|
||||||
|
<DataGridTextColumn Header="{x:Static lang:Resources.StartTime}" Width="300" Binding="{Binding StartTime}" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Header="{x:Static lang:Resources.EndTime}" Width="300" Binding="{Binding EndTime}" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Header="{x:Static lang:Resources.Remark}" Width="*" Binding="{Binding Remark}" IsReadOnly="True"/>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
<lvc:CartesianChart Margin="0,300,0,0" x:Name="chart"
|
||||||
Series="{Binding Series}" YAxes="{Binding YAxes}" XAxes="{Binding XAxes}"/>
|
Series="{Binding Series}" YAxes="{Binding YAxes}" XAxes="{Binding XAxes}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@@ -1,9 +1,14 @@
|
|||||||
using DyeingComputer.ViewModel;
|
using DyeingComputer.ViewModel;
|
||||||
|
using ScottPlot.Hatches;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Timers;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
@@ -13,6 +18,7 @@ using System.Windows.Media;
|
|||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using static DyeingComputer.UserClass.SqliteHelper;
|
||||||
|
|
||||||
namespace DyeingComputer.View
|
namespace DyeingComputer.View
|
||||||
{
|
{
|
||||||
@@ -21,10 +27,34 @@ namespace DyeingComputer.View
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class HistoryRecordsView : UserControl
|
public partial class HistoryRecordsView : UserControl
|
||||||
{
|
{
|
||||||
|
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
||||||
|
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
|
||||||
|
|
||||||
|
DataTable GRIDDB = new DataTable();
|
||||||
public HistoryRecordsView()
|
public HistoryRecordsView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
DataContext = new HistoryRecordsViewModel();
|
DataContext = new HistoryRecordsViewModel();
|
||||||
|
|
||||||
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||||
|
SQLiteHelpers.Open(); //打开数据库
|
||||||
|
GRIDDB = SQLiteHelpers.ExecuteDataSet("select * from WorkOrder where StartTime > '" + DateTime.Now.AddDays(-30).ToString("yyyy/MM/dd HH:mm:ss") + "order by StartTime'", null).Tables[0];
|
||||||
|
SQLiteHelpers.Close();
|
||||||
|
|
||||||
|
gridH.ItemsSource = GRIDDB.DefaultView;
|
||||||
}
|
}
|
||||||
|
private void Grid_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
int rownum = gridH.SelectedIndex;//获取鼠标选中行并定义变量
|
||||||
|
if (rownum != -1)//判断鼠标定位是否有效
|
||||||
|
{
|
||||||
|
HistoryRecordsViewModel.name = (gridH.Columns[0].GetCellContent(gridH.Items[rownum]) as TextBlock).Text;//定位第0列,
|
||||||
|
HistoryRecordsViewModel.stime = (gridH.Columns[5].GetCellContent(gridH.Items[rownum]) as TextBlock).Text;//定位第1列,
|
||||||
|
HistoryRecordsViewModel.etime = (gridH.Columns[6].GetCellContent(gridH.Items[rownum]) as TextBlock).Text;//定位第6列
|
||||||
|
HistoryRecordsViewModel.history_ = true;
|
||||||
|
// chart.Series = HistoryRecordsViewModel.Series;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,12 +14,19 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using static DyeingComputer.UserClass.SqliteHelper;
|
using static DyeingComputer.UserClass.SqliteHelper;
|
||||||
|
using ScottPlot.Hatches;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using ScottPlot;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
using ScottPlot.Statistics;
|
||||||
|
using System.Management.Instrumentation;
|
||||||
|
|
||||||
namespace DyeingComputer.ViewModel
|
namespace DyeingComputer.ViewModel
|
||||||
{
|
{
|
||||||
public partial class HistoryRecordsViewModel : ObservableObject
|
public partial class HistoryRecordsViewModel : ObservableObject
|
||||||
{
|
{
|
||||||
public ISeries[] Series { get; set; }
|
|
||||||
|
public static ISeries[] Series { get; set; }
|
||||||
//x轴时间格式
|
//x轴时间格式
|
||||||
public Axis[] XAxes { get; set; } =
|
public Axis[] XAxes { get; set; } =
|
||||||
{
|
{
|
||||||
@@ -97,34 +104,70 @@ namespace DyeingComputer.ViewModel
|
|||||||
//new AnimatableAxisBounds
|
//new AnimatableAxisBounds
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly Random _r = new Random();
|
private Random _r = new Random();
|
||||||
private readonly ObservableCollection<DateTimePoint> MTT_values;
|
private ObservableCollection<DateTimePoint> MTT_values;
|
||||||
private readonly ObservableCollection<DateTimePoint> MTL_values;
|
private ObservableCollection<DateTimePoint> MTL_values;
|
||||||
private readonly ObservableCollection<DateTimePoint> MTH_values;
|
private ObservableCollection<DateTimePoint> MTH_values;
|
||||||
private readonly ObservableCollection<DateTimePoint> MST_values;
|
private ObservableCollection<DateTimePoint> MST_values;
|
||||||
private readonly ObservableCollection<DateTimePoint> MUT_values;
|
private ObservableCollection<DateTimePoint> MUT_values;
|
||||||
private readonly ObservableCollection<DateTimePoint> STTA_values;
|
private ObservableCollection<DateTimePoint> STTA_values;
|
||||||
private readonly ObservableCollection<DateTimePoint> STLA_values;
|
private ObservableCollection<DateTimePoint> STLA_values;
|
||||||
private readonly ObservableCollection<DateTimePoint> STTB_values;
|
private ObservableCollection<DateTimePoint> STTB_values;
|
||||||
private readonly ObservableCollection<DateTimePoint> STLB_values;
|
private ObservableCollection<DateTimePoint> STLB_values;
|
||||||
private readonly ObservableCollection<DateTimePoint> STTC_values;
|
private ObservableCollection<DateTimePoint> STTC_values;
|
||||||
private readonly ObservableCollection<DateTimePoint> STLC_values;
|
private ObservableCollection<DateTimePoint> STLC_values;
|
||||||
|
|
||||||
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
||||||
private readonly string ChartAdress = Environment.CurrentDirectory + "\\DataBase\\Chart.db"; //数据库路径
|
private readonly string ChartAdress = Environment.CurrentDirectory + "\\DataBase\\Chart.db"; //数据库路径
|
||||||
DataTable CDB = new DataTable();
|
public DataTable CDB = new DataTable();
|
||||||
private int CDB_Count;//长度
|
private int CDB_Count;//长度
|
||||||
|
|
||||||
public HistoryRecordsViewModel()
|
public HistoryRecordsViewModel()
|
||||||
{
|
{
|
||||||
if (MainWindowViewModel.WorkNumder.ToString() != "----------")
|
string Sys_Time = DateTime.Now.AddDays(-2).ToString("yyyy/MM/dd HH:mm:ss");
|
||||||
{
|
|
||||||
SQLiteHelpers = new SQLiteHelper(ChartAdress); //数据库连接路径
|
SQLiteHelpers = new SQLiteHelper(ChartAdress); //数据库连接路径
|
||||||
SQLiteHelpers.Open(); //打开数据库
|
SQLiteHelpers.Open(); //打开数据库
|
||||||
CDB = SQLiteHelpers.ExecuteDataSet("select * from Chart where DYELOT = '" + MainWindowViewModel.WorkNumder + "'order by Time", null).Tables[0];
|
CDB = SQLiteHelpers.ExecuteDataSet("select * from Chart where Time > '" + Sys_Time + "'order by Time", null).Tables[0];
|
||||||
SQLiteHelpers.Close();
|
SQLiteHelpers.Close();
|
||||||
CDB_Count = CDB.Rows.Count;
|
CDB_Count = CDB.Rows.Count;
|
||||||
|
|
||||||
|
Chart_View();
|
||||||
|
CountDown();
|
||||||
|
}
|
||||||
|
public static bool history_ = false;
|
||||||
|
public static string name;
|
||||||
|
public static string stime;
|
||||||
|
public static string etime;
|
||||||
|
public void History()
|
||||||
|
{
|
||||||
|
SQLiteHelpers = new SQLiteHelper(ChartAdress); //数据库连接路径
|
||||||
|
SQLiteHelpers.Open(); //打开数据库
|
||||||
|
CDB = SQLiteHelpers.ExecuteDataSet("select * from Chart where DYELOT = '" + name + "'order by Time", null).Tables[0];
|
||||||
|
SQLiteHelpers.Close();
|
||||||
|
CDB_Count = CDB.Rows.Count;
|
||||||
|
|
||||||
|
Chart_View();
|
||||||
|
}
|
||||||
|
public void CountDown()
|
||||||
|
{
|
||||||
|
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
|
||||||
|
{
|
||||||
|
Interval = TimeSpan.FromSeconds(1)//秒
|
||||||
|
};
|
||||||
|
timer1s.Tick += Tick_Event_1S;
|
||||||
|
timer1s.Start();
|
||||||
|
}
|
||||||
|
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
|
||||||
|
{
|
||||||
|
if (history_)
|
||||||
|
{
|
||||||
|
History();
|
||||||
|
history_ = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Chart_View()
|
||||||
|
{
|
||||||
var MTT_items = new List<DateTimePoint>();
|
var MTT_items = new List<DateTimePoint>();
|
||||||
var MTL_items = new List<DateTimePoint>();
|
var MTL_items = new List<DateTimePoint>();
|
||||||
var MTH_items = new List<DateTimePoint>();
|
var MTH_items = new List<DateTimePoint>();
|
||||||
@@ -307,5 +350,4 @@ namespace DyeingComputer.ViewModel
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user