预览曲线
This commit is contained in:
commit
6836f6f108
6 files changed
+298
-2
No files matched your search
@@ -149,6 +149,7 @@
|
||||
<Compile Include="UserClass\AsyncTcpServer.cs" />
|
||||
<Compile Include="UserClass\NetFwManger.cs" />
|
||||
<Compile Include="ViewModel\CurveDiagramViewModel.cs" />
|
||||
<Compile Include="ViewModel\CurveTempModel.cs" />
|
||||
<Compile Include="ViewModel\HistoryRecordsViewModel.cs" />
|
||||
<Compile Include="ViewModel\MainWindowViewModel.cs" />
|
||||
<Compile Include="ViewModel\ViewModelLocator.cs" />
|
||||
@@ -159,6 +160,9 @@
|
||||
<Compile Include="View\CurveDiagramView.xaml.cs">
|
||||
<DependentUpon>CurveDiagramView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\CurveTemp.xaml.cs">
|
||||
<DependentUpon>CurveTemp.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\EngineerSetView.xaml.cs">
|
||||
<DependentUpon>EngineerSetView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -218,6 +222,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="View\CurveTemp.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="View\EngineerSetView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<UserControl x:Class="DyeingComputer.View.CurveTemp"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:DyeingComputer.View"
|
||||
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.WPF;assembly=LiveChartsCore.SkiaSharpView.WPF"
|
||||
xmlns:ConvertMoels="clr-namespace:DyeingComputer.ConvertMoels"
|
||||
xmlns:viewmodel="clr-namespace:DyeingComputer.ViewModel"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance Type=viewmodel:CurveTempModel}"
|
||||
d:DesignHeight="300" d:DesignWidth="400">
|
||||
<Grid>
|
||||
<lvc:CartesianChart x:Name="OscChart" EasingFunction="{x:Null}" ZoomMode="X"
|
||||
Series="{Binding Series}" YAxes="{Binding YAxes}" XAxes="{Binding XAxes}" Margin="0,0,0,0"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,35 @@
|
||||
using DyeingComputer.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace DyeingComputer.View
|
||||
{
|
||||
/// <summary>
|
||||
/// CurveDiagram.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class CurveTemp : UserControl
|
||||
{
|
||||
public static DataTable dataTable;
|
||||
public CurveTemp(DataTable db)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
dataTable = db;
|
||||
|
||||
DataContext = new CurveTempModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,8 +89,9 @@
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<Grid VerticalAlignment="Bottom" Height="300">
|
||||
<lvc:CartesianChart Margin="0,0,200,0" x:Name="chart" Series="{Binding Series}" YAxes="{Binding YAxes}" XAxes="{Binding XAxes}"/>
|
||||
<Button x:Name="inf" FontSize="20" HorizontalAlignment="Right" Height="100" VerticalAlignment="Top" Width="200" Click="start_Click">
|
||||
<ContentControl x:Name="Picture" Margin="0,0,200,0"/>
|
||||
|
||||
<Button x:Name="inf" FontSize="20" HorizontalAlignment="Right" Height="100" VerticalAlignment="Top" Width="200" Click="inf_Click">
|
||||
<Button.Background>
|
||||
<ImageBrush ImageSource="/Lmage/inf.png" TileMode="None" Stretch="Uniform"/>
|
||||
</Button.Background>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using DyeingComputer.ViewModel;
|
||||
using DyeingComputer.Windows;
|
||||
using ScottPlot;
|
||||
using SkiaSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@@ -51,6 +52,10 @@ namespace DyeingComputer.View
|
||||
if (S10 == "0") WorkOrderView_del.IsEnabled = false;
|
||||
if (S11 == "0") WorkOrderView_redy.IsEnabled = false;
|
||||
|
||||
|
||||
TEMPTable.Columns.Add("Time", Type.GetType("System.String"));
|
||||
TEMPTable.Columns.Add("MST", Type.GetType("System.Double"));
|
||||
|
||||
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
|
||||
{
|
||||
Interval = TimeSpan.FromSeconds(1)//秒
|
||||
@@ -67,6 +72,8 @@ namespace DyeingComputer.View
|
||||
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
|
||||
DataSet sql; //内存数据缓存
|
||||
Dictionary<string, object> updata_temp = new Dictionary<string, object>();//缓存函数
|
||||
DataTable dat = new DataTable();
|
||||
DataTable TEMPTable = new DataTable();
|
||||
|
||||
string WorkOrder_Numder;
|
||||
string Process_Name;
|
||||
@@ -170,6 +177,14 @@ namespace DyeingComputer.View
|
||||
_lock = (Grid.Columns[3].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第1列,
|
||||
|
||||
SQL_UPDATE = true;
|
||||
|
||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||
SQLiteHelpers.Open(); //打开数据库
|
||||
dat = SQLiteHelpers.ExecuteDataSet(
|
||||
"select * from WorkorderSteps where WorkOrder='" + WorkOrder_Numder + "'", null).Tables[0]; //读取表写入缓存
|
||||
SQLiteHelpers.Close(); //关闭连接
|
||||
|
||||
TEMP();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,5 +241,93 @@ namespace DyeingComputer.View
|
||||
{
|
||||
|
||||
}
|
||||
private void inf_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void TEMP()
|
||||
{
|
||||
//处理计划温度图表
|
||||
TEMPTable.Clear();
|
||||
string TIMET = "00:00:00";
|
||||
Double MSTT = 30.0;
|
||||
Double TT;
|
||||
Double TC;
|
||||
TEMPTable.Rows.Add(new object[] { TIMET, MSTT });
|
||||
for (int i = 0; i < dat.Rows.Count; i++)
|
||||
{
|
||||
switch (dat.Rows[i][5].ToString())//步骤用时计算
|
||||
{
|
||||
case "001":
|
||||
TT = MSTT;
|
||||
TC = (Double)dat.Rows[i][9];
|
||||
if (TC > 9.9 || TC < 0.1) TC = 9.9;//计算限制
|
||||
MSTT = (Double)dat.Rows[i][8];
|
||||
TT = Math.Abs(MSTT - TT) / TC * 60;
|
||||
TIMET = Convert.ToDateTime(TIMET).AddSeconds(TT).ToString("HH:mm:ss");
|
||||
TEMPTable.Rows.Add(new object[] { TIMET, MSTT });
|
||||
TIMET = Convert.ToDateTime(TIMET).AddMinutes((Double)dat.Rows[i][12]).ToString("HH:mm:ss");
|
||||
TEMPTable.Rows.Add(new object[] { TIMET, MSTT });
|
||||
break;
|
||||
case "007":
|
||||
TIMET = Convert.ToDateTime(TIMET).AddMinutes(5).ToString("HH:mm:ss");
|
||||
TEMPTable.Rows.Add(new object[] { TIMET, MSTT });
|
||||
break;
|
||||
case "008":
|
||||
TIMET = Convert.ToDateTime(TIMET).AddMinutes(5).ToString("HH:mm:ss");
|
||||
TEMPTable.Rows.Add(new object[] { TIMET, MSTT });
|
||||
break;
|
||||
case "013":
|
||||
TIMET = Convert.ToDateTime(TIMET).AddMinutes((Double)dat.Rows[i][10] * (Double)dat.Rows[i][11]).ToString("HH:mm:ss");
|
||||
TEMPTable.Rows.Add(new object[] { TIMET, MSTT });
|
||||
break;
|
||||
case "015":
|
||||
TIMET = Convert.ToDateTime(TIMET).AddMinutes((Double)dat.Rows[i][10]).ToString("HH:mm:ss");
|
||||
TEMPTable.Rows.Add(new object[] { TIMET, MSTT });
|
||||
break;
|
||||
case "017":
|
||||
TIMET = Convert.ToDateTime(TIMET).AddMinutes((Double)dat.Rows[i][10]).ToString("HH:mm:ss");
|
||||
TEMPTable.Rows.Add(new object[] { TIMET, MSTT });
|
||||
break;
|
||||
case "020":
|
||||
TIMET = Convert.ToDateTime(TIMET).AddMinutes(5).ToString("HH:mm:ss");
|
||||
TEMPTable.Rows.Add(new object[] { TIMET, MSTT });
|
||||
break;
|
||||
case "022":
|
||||
TIMET = Convert.ToDateTime(TIMET).AddMinutes(5).ToString("HH:mm:ss");
|
||||
TEMPTable.Rows.Add(new object[] { TIMET, MSTT });
|
||||
break;
|
||||
case "031":
|
||||
TIMET = Convert.ToDateTime(TIMET).AddMinutes((int)dat.Rows[i][8]).ToString("HH:mm:ss");
|
||||
TEMPTable.Rows.Add(new object[] { TIMET, MSTT });
|
||||
break;
|
||||
case "065":
|
||||
TIMET = Convert.ToDateTime(TIMET).AddMinutes((int)dat.Rows[i][10]).ToString("HH:mm:ss");
|
||||
TEMPTable.Rows.Add(new object[] { TIMET, MSTT });
|
||||
break;
|
||||
case "091":
|
||||
TT = MSTT;
|
||||
TC = (Double)dat.Rows[i][9];
|
||||
if (TC > 9.9 || TC < 0.1) TC = 9.9;//计算限制
|
||||
MSTT = (Double)dat.Rows[i][8];
|
||||
TT = Math.Abs(MSTT - TT) / TC * 60;
|
||||
TIMET = Convert.ToDateTime(TIMET).AddSeconds(TT).ToString("HH:mm:ss");
|
||||
TEMPTable.Rows.Add(new object[] { TIMET, MSTT });
|
||||
break;
|
||||
case "093":
|
||||
TIMET = Convert.ToDateTime(TIMET).AddMinutes((int)dat.Rows[i][8]).ToString("HH:mm:ss");
|
||||
TEMPTable.Rows.Add(new object[] { TIMET, MSTT });
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
Picture.Content = new View.CurveTemp(TEMPTable);
|
||||
} //计划温度图表
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
using LiveChartsCore.SkiaSharpView;
|
||||
using LiveChartsCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using LiveChartsCore.Kernel.Sketches;
|
||||
using LiveChartsCore.SkiaSharpView.Painting;
|
||||
using ScottPlot.Colormaps;
|
||||
using System.Drawing;
|
||||
using System.Windows.Media.TextFormatting;
|
||||
using System.Xml.Linq;
|
||||
using SkiaSharp;
|
||||
using LiveChartsCore.Defaults;
|
||||
using static System.Net.WebRequestMethods;
|
||||
using System.Collections.ObjectModel;
|
||||
using DyeingComputer.Properties;
|
||||
using LiveChartsCore.Measure;
|
||||
using LiveChartsCore.Motion;
|
||||
using DyeingComputer.Properties;
|
||||
using static DyeingComputer.UserClass.SqliteHelper;
|
||||
using TouchSocket.Core;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
using DyeingComputer.View;
|
||||
|
||||
namespace DyeingComputer.ViewModel
|
||||
{
|
||||
public partial class CurveTempModel : ObservableObject//ViewModelBase
|
||||
{
|
||||
public static ISeries[] Series { get; set; }
|
||||
public static ObservableCollection<ObservableValue> ObservableValues { get; set; }
|
||||
//x轴时间格式
|
||||
public Axis[] XAxes { get; set; } =
|
||||
{
|
||||
new DateTimeAxis(TimeSpan.FromSeconds(5) , date => date.ToString("HH:mm"))
|
||||
{
|
||||
CrosshairLabelsBackground = SKColors.DarkGray.AsLvcColor(),
|
||||
CrosshairLabelsPaint = new SolidColorPaint(SKColors.DarkSlateBlue, 1),
|
||||
CrosshairPaint = new SolidColorPaint(SKColors.DarkSlateGray, 1),
|
||||
},
|
||||
};
|
||||
//颜色
|
||||
private static readonly SKColor s_blue = new SKColor(25, 118, 210);
|
||||
private static readonly SKColor s_blue_0 = new SKColor(25, 18, 210);
|
||||
private static readonly SKColor s_blue_1 = new SKColor(25, 118, 170);
|
||||
private static readonly SKColor s_blue_2 = new SKColor(25, 118, 130);
|
||||
private static readonly SKColor s_blue_3 = new SKColor(25, 118, 90);
|
||||
private static readonly SKColor s_blue_4 = new SKColor(25, 118, 50);
|
||||
private static readonly SKColor s_red = new SKColor(229, 57, 53);
|
||||
private static readonly SKColor s_red_1 = new SKColor(189, 57, 53);
|
||||
private static readonly SKColor s_red_2 = new SKColor(149, 57, 53);
|
||||
private static readonly SKColor s_red_3 = new SKColor(109, 57, 53);
|
||||
private static readonly SKColor s_yellow = new SKColor(198, 167, 0);
|
||||
public ICartesianAxis[] YAxes { get; set; } ={
|
||||
new Axis //y在此轴上缩放
|
||||
{
|
||||
MinLimit =0,
|
||||
MaxLimit =160,
|
||||
Name = Properties.Resources.Temperature +" ( °C )",
|
||||
NameTextSize = 15,
|
||||
NamePaint = new SolidColorPaint(s_blue),
|
||||
NamePadding = new LiveChartsCore.Drawing.Padding(0, 20),
|
||||
Padding = new LiveChartsCore.Drawing.Padding(0, 0, 20, 0),
|
||||
TextSize = 12,
|
||||
LabelsPaint = new SolidColorPaint(s_blue),
|
||||
TicksPaint = new SolidColorPaint(s_blue),
|
||||
SubticksPaint = new SolidColorPaint(s_blue),
|
||||
DrawTicksPath = true,
|
||||
CrosshairSnapEnabled = true,
|
||||
Position = LiveChartsCore.Measure.AxisPosition.Start
|
||||
},//温度轴
|
||||
|
||||
};
|
||||
|
||||
private static Random _r = new Random();
|
||||
private static ObservableCollection<DateTimePoint> MST_values;
|
||||
static DataTable CDB = new DataTable();
|
||||
private static int CDB_Count;//长度
|
||||
|
||||
public CurveTempModel()
|
||||
{
|
||||
CDB = View.CurveTemp.dataTable;
|
||||
Curve();
|
||||
}
|
||||
public static void Curve()
|
||||
{
|
||||
CDB_Count = CDB.Rows.Count;
|
||||
var MTT_items = new List<DateTimePoint>();
|
||||
var MTL_items = new List<DateTimePoint>();
|
||||
var MTH_items = new List<DateTimePoint>();
|
||||
var MST_items = new List<DateTimePoint>();
|
||||
var MUT_items = new List<DateTimePoint>();
|
||||
var STTA_items = new List<DateTimePoint>();
|
||||
var STLA_items = new List<DateTimePoint>();
|
||||
var STTB_items = new List<DateTimePoint>();
|
||||
var STLB_items = new List<DateTimePoint>();
|
||||
var STTC_items = new List<DateTimePoint>();
|
||||
var STLC_items = new List<DateTimePoint>();
|
||||
for (var i = 0; i < CDB_Count; i++)
|
||||
{
|
||||
DateTime TIME = Convert.ToDateTime(CDB.Rows[i].Field<string>("Time"));
|
||||
MST_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("MST")));
|
||||
}
|
||||
|
||||
MST_values = new ObservableCollection<DateTimePoint>(MST_items);
|
||||
|
||||
Series = new ISeries[]
|
||||
{
|
||||
|
||||
new LineSeries<DateTimePoint>
|
||||
{
|
||||
Name = Resources.Target + Resources.Temperature,
|
||||
Values = MST_values,
|
||||
Stroke = new SolidColorPaint(s_blue_0, 2),
|
||||
GeometrySize = 0,
|
||||
GeometryStroke = new SolidColorPaint(s_blue_0, 2),
|
||||
Fill = null,
|
||||
LineSmoothness = 0,
|
||||
ScalesYAt = 0,
|
||||
}, //目标温度
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user