diff --git a/DyeingComputer.csproj b/DyeingComputer.csproj
index 1f67d9e..2c89cda 100644
--- a/DyeingComputer.csproj
+++ b/DyeingComputer.csproj
@@ -145,6 +145,7 @@
+
diff --git a/Properties/Resources.zh-TW.resx b/Properties/Resources.zh-TW.resx
index 4f0ff68..56483cb 100644
--- a/Properties/Resources.zh-TW.resx
+++ b/Properties/Resources.zh-TW.resx
@@ -480,4 +480,7 @@
領料單
+
+ 底
+
\ No newline at end of file
diff --git a/View/HistoryRecordsView.xaml b/View/HistoryRecordsView.xaml
index 160e2c8..be577a0 100644
--- a/View/HistoryRecordsView.xaml
+++ b/View/HistoryRecordsView.xaml
@@ -3,11 +3,13 @@
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:viewmodel="clr-namespace:DyeingComputer.ViewModel"
+ xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.WPF;assembly=LiveChartsCore.SkiaSharpView.WPF"
mc:Ignorable="d"
- d:DesignHeight="630" d:DesignWidth="1280" VerticalAlignment="Top">
+ d:DataContext="{d:DesignInstance Type=viewmodel:HistoryRecordsViewModel}"
+ d:DesignHeight="630" d:DesignWidth="1280">
-
-
+
diff --git a/View/HistoryRecordsView.xaml.cs b/View/HistoryRecordsView.xaml.cs
index d62e712..5f722cf 100644
--- a/View/HistoryRecordsView.xaml.cs
+++ b/View/HistoryRecordsView.xaml.cs
@@ -1,4 +1,5 @@
-using System;
+using DyeingComputer.ViewModel;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -23,6 +24,7 @@ namespace DyeingComputer.View
public HistoryRecordsView()
{
InitializeComponent();
+ DataContext = new HistoryRecordsViewModel();
}
}
}
diff --git a/ViewModel/HistoryRecordsViewModel.cs b/ViewModel/HistoryRecordsViewModel.cs
new file mode 100644
index 0000000..3081060
--- /dev/null
+++ b/ViewModel/HistoryRecordsViewModel.cs
@@ -0,0 +1,311 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+using DyeingComputer.Properties;
+using LiveChartsCore.Defaults;
+using LiveChartsCore.Kernel.Sketches;
+using LiveChartsCore.SkiaSharpView.Painting;
+using LiveChartsCore.SkiaSharpView;
+using LiveChartsCore;
+using SkiaSharp;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using static DyeingComputer.UserClass.SqliteHelper;
+
+namespace DyeingComputer.ViewModel
+{
+ public partial class HistoryRecordsViewModel : ObservableObject
+ {
+ public ISeries[] Series { get; set; }
+ //x轴时间格式
+ public Axis[] XAxes { get; set; } =
+ {
+ new DateTimeAxis(TimeSpan.FromSeconds(5) , date => date.ToString("yyyy-MM-dd 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 =150,
+ Name = Properties.Resources.Temperature +" ( °C )",
+ NameTextSize = 24,
+ NamePaint = new SolidColorPaint(s_blue),
+ NamePadding = new LiveChartsCore.Drawing.Padding(0, 20),
+ Padding = new LiveChartsCore.Drawing.Padding(0, 0, 20, 0),
+ TextSize = 16,
+ LabelsPaint = new SolidColorPaint(s_blue),
+ TicksPaint = new SolidColorPaint(s_blue),
+ SubticksPaint = new SolidColorPaint(s_blue),
+ DrawTicksPath = true,
+ CrosshairSnapEnabled = true,
+ Position = LiveChartsCore.Measure.AxisPosition.Start
+ },//温度轴
+ new Axis // the "hundreds" series will be scaled on this axis
+ {
+ MinLimit =0,
+ Name = Properties.Resources.WaterLevel +" ( L )",
+ NameTextSize = 24,
+ NamePaint = new SolidColorPaint(s_red),
+ NamePadding = new LiveChartsCore.Drawing.Padding(0, 20),
+ Padding = new LiveChartsCore.Drawing.Padding(20, 0, 0, 0),
+ TextSize = 16,
+ LabelsPaint = new SolidColorPaint(s_red),
+ TicksPaint = new SolidColorPaint(s_red),
+ SubticksPaint = new SolidColorPaint(s_red),
+ DrawTicksPath = true,
+ CrosshairSnapEnabled = true,
+ Position = LiveChartsCore.Measure.AxisPosition.End
+ }, //液位轴
+ new Axis //
+ {
+ MinLimit =0,
+ MaxLimit =14,
+ Name = "PH ( pH )",
+ NameTextSize = 16,
+ NamePaint = new SolidColorPaint(s_yellow),
+ NamePadding = new LiveChartsCore.Drawing.Padding(0, 20),
+ Padding = new LiveChartsCore.Drawing.Padding(20, 0, 0, 0),
+ TextSize = 16,
+ LabelsPaint = new SolidColorPaint(s_yellow),
+ TicksPaint = new SolidColorPaint(s_yellow),
+ SubticksPaint = new SolidColorPaint(s_yellow),
+ DrawTicksPath = true,
+ CrosshairSnapEnabled = true,
+ Position = LiveChartsCore.Measure.AxisPosition.End
+ }, //PH轴
+
+ //new AnimatableAxisBounds
+ };
+
+ private readonly Random _r = new Random();
+ private readonly ObservableCollection MTT_values;
+ private readonly ObservableCollection MTL_values;
+ private readonly ObservableCollection MTH_values;
+ private readonly ObservableCollection MST_values;
+ private readonly ObservableCollection MUT_values;
+ private readonly ObservableCollection STTA_values;
+ private readonly ObservableCollection STLA_values;
+ private readonly ObservableCollection STTB_values;
+ private readonly ObservableCollection STLB_values;
+ private readonly ObservableCollection STTC_values;
+ private readonly ObservableCollection STLC_values;
+
+ private SQLiteHelper SQLiteHelpers = null; //定义数据库
+ private readonly string ChartAdress = Environment.CurrentDirectory + "\\DataBase\\Chart.db"; //数据库路径
+ DataTable CDB = new DataTable();
+ private int CDB_Count;//长度
+
+ public HistoryRecordsViewModel()
+ {
+ if (MainWindowViewModel.WorkNumder.ToString() != "----------")
+ {
+ SQLiteHelpers = new SQLiteHelper(ChartAdress); //数据库连接路径
+ SQLiteHelpers.Open(); //打开数据库
+ CDB = SQLiteHelpers.ExecuteDataSet("select * from Chart where DYELOT = '" + MainWindowViewModel.WorkNumder + "'order by Time", null).Tables[0];
+ SQLiteHelpers.Close();
+ CDB_Count = CDB.Rows.Count;
+
+ var MTT_items = new List();
+ var MTL_items = new List();
+ var MTH_items = new List();
+ var MST_items = new List();
+ var MUT_items = new List();
+ var STTA_items = new List();
+ var STLA_items = new List();
+ var STTB_items = new List();
+ var STLB_items = new List();
+ var STTC_items = new List();
+ var STLC_items = new List();
+ for (var i = 0; i < CDB_Count; i++)
+ {
+ DateTime TIME = Convert.ToDateTime(CDB.Rows[i].Field("Time"));
+ MTT_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field("MTT")));
+ MTL_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field("MTL")));
+ MTH_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field("MTH")));
+ MST_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field("MST")));
+ MUT_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field("MUT")));
+ if (MainWindowViewModel.SM01 == 1)
+ {
+ STTA_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field("STTA")));
+ STLA_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field("STLA")));
+ }
+ if (MainWindowViewModel.SM02 == 1)
+ {
+ STTB_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field("STTB")));
+ STLB_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field("STLB")));
+ }
+ if (MainWindowViewModel.SM03 == 1)
+ {
+ STTC_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field("STTC")));
+ STLC_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field("STLC")));
+ }
+ }
+
+ MTT_values = new ObservableCollection(MTT_items);
+ MTL_values = new ObservableCollection(MTL_items);
+ MTH_values = new ObservableCollection(MTH_items);
+ MST_values = new ObservableCollection(MST_items);
+ MUT_values = new ObservableCollection(MUT_items);
+ if (MainWindowViewModel.SM01 == 1)
+ {
+ STTA_values = new ObservableCollection(STTA_items);
+ STLA_values = new ObservableCollection(STLA_items);
+ }
+ if (MainWindowViewModel.SM02 == 1)
+ {
+ STTB_values = new ObservableCollection(STTB_items);
+ STLB_values = new ObservableCollection(STLB_items);
+ }
+ if (MainWindowViewModel.SM03 == 1)
+ {
+ STTC_values = new ObservableCollection(STTC_items);
+ STLC_values = new ObservableCollection(STLC_items);
+ }
+ Series = new ISeries[]
+ {
+ new LineSeries
+ {
+ Name = Properties.Resources.MasterCylinder +"PH",
+ Values = MTH_values,
+ Stroke = new SolidColorPaint(s_yellow, 2),
+ GeometrySize = 0,
+ GeometryStroke = new SolidColorPaint(s_yellow, 2),
+ Fill = null,
+ LineSmoothness = 0,
+ ScalesYAt = 2,
+ }, //PH
+ new LineSeries
+ {
+ 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,
+ }, //目标温度
+ new LineSeries
+ {
+ Name = Properties.Resources.Temperature +"1("+Properties.Resources.MasterCylinder+")",
+ Values = MTT_values,
+ Stroke = new SolidColorPaint(s_blue, 2),
+ GeometrySize = 0,
+ GeometryStroke = new SolidColorPaint(s_blue, 2),
+ Fill = null,
+ LineSmoothness = 0,
+ ScalesYAt = 0,
+ }, //主缸
+ new LineSeries
+ {
+ Name = Properties.Resources.Temperature +"2("+Properties.Resources.MasterCylinder+Properties.Resources.Bottom+")",
+ Values = MUT_values,
+ Stroke = new SolidColorPaint(s_blue_4, 2),
+ GeometrySize = 0,
+ GeometryStroke = new SolidColorPaint(s_blue_4, 2),
+ Fill = null,
+ LineSmoothness = 0,
+ ScalesYAt = 0,
+ }, //缸底
+ new LineSeries
+ {
+ Name = Properties.Resources.Temperature +"3("+Resources.Medicine + Resources.Tank +"1)",
+ Values = STTA_values,
+ Stroke = new SolidColorPaint(s_blue_1, 2),
+ GeometrySize = 0,
+ GeometryStroke = new SolidColorPaint(s_blue_1, 2),
+ Fill = null,
+ LineSmoothness = 0,
+ ScalesYAt = 0,
+ }, //附缸1
+ new LineSeries
+ {
+ Name = Properties.Resources.Temperature +"4("+Resources.Medicine + Resources.Tank +"2)",
+ Values = STTB_values,
+ Stroke = new SolidColorPaint(s_blue_2, 2),
+ GeometrySize = 0,
+ GeometryStroke = new SolidColorPaint(s_blue_2, 2),
+ Fill = null,
+ LineSmoothness = 0,
+ ScalesYAt = 0,
+ }, //附缸2
+ new LineSeries
+ {
+ Name = Properties.Resources.Temperature +"5("+Resources.Medicine + Resources.Tank +"3)",
+ Values = STTC_values,
+ Stroke = new SolidColorPaint(s_blue_3, 2),
+ GeometrySize = 0,
+ GeometryStroke = new SolidColorPaint(s_blue_3, 2),
+ Fill = null,
+ LineSmoothness = 0,
+ ScalesYAt = 0,
+ }, //附缸3
+ new LineSeries
+ {
+ Name = Properties.Resources.WaterLevel +"("+Properties.Resources.MasterCylinder+")",
+ Values = MTL_values,
+ Stroke = new SolidColorPaint(s_red, 2),
+ GeometrySize = 0,
+ GeometryStroke = new SolidColorPaint(s_red, 2),
+ Fill = null,
+ LineSmoothness = 0,
+ ScalesYAt = 1,
+ }, //主缸液位
+ new LineSeries
+ {
+ Name = Properties.Resources.WaterLevel +"("+Resources.Medicine + Resources.Tank +"1)",
+ Values = STLA_values,
+ Stroke = new SolidColorPaint(s_red_1, 2),
+ GeometrySize = 0,
+ GeometryStroke = new SolidColorPaint(s_red_1, 2),
+ Fill = null,
+ LineSmoothness = 0,
+ ScalesYAt = 1,
+ }, //附缸1液位
+ new LineSeries
+ {
+ Name = Properties.Resources.WaterLevel +"("+Resources.Medicine + Resources.Tank +"2)",
+ Values = STLB_values,
+ Stroke = new SolidColorPaint(s_red_2, 2),
+ GeometrySize = 0,
+ GeometryStroke = new SolidColorPaint(s_red_2, 2),
+ Fill = null,
+ LineSmoothness = 0,
+ ScalesYAt = 1,
+ }, //附缸2液位
+ new LineSeries
+ {
+ Name = Properties.Resources.WaterLevel +"("+Resources.Medicine + Resources.Tank +"3)",
+ Values = STLC_values,
+ Stroke = new SolidColorPaint(s_red_3, 2),
+ GeometrySize = 0,
+ GeometryStroke = new SolidColorPaint(s_red_3, 2),
+ Fill = null,
+ LineSmoothness = 0,
+ ScalesYAt = 1,
+ }, //附缸3 液位
+ };
+ }
+ }
+ }
+}
diff --git a/ViewModel/MainWindowViewModel.cs b/ViewModel/MainWindowViewModel.cs
index 8d8fdaa..3080577 100644
--- a/ViewModel/MainWindowViewModel.cs
+++ b/ViewModel/MainWindowViewModel.cs
@@ -483,27 +483,32 @@ namespace DyeingComputer.ViewModel
double T = Selet_dtm("1010"); //实际温度
if (THL_mode == 0) //保温
{
+ TO = pid.PID_iterate(STEP_P1, T, ts);
+ TEMP_co = STEP_P1;
+ if (TO < 0) TO = 0;
+
+ TIME_H = STEP_TIME / 3600;
+ TIME_M = (STEP_TIME - TIME_H * 3600) / 60;
+ TIME_S = STEP_TIME - TIME_H * 3600 - TIME_M * 60;
+ if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Heat_insulating + ":" + Resources.Time + string.Format(" {0:D2}", TIME_H) + ":" + string.Format(" {0:D2}", TIME_M) + ":" + string.Format(" {0:D2}", TIME_S);
if (STEP_TIME == 0)
{
STEP_finish = true;
+ Updata_dtm("1004", 0);
+ Updata_dtd("3009", false);
+ Updata_dtd("3010", false);
}
else
{
STEP_TIME--;
}
- TO = pid.PID_iterate(STEP_P1, T, ts);
- if (TO < 0) TO = 0;
-
- TIME_H = STEP_TIME / 3600;
- TIME_M = (STEP_TIME - TIME_H * 3600) / 60;
- TIME_S = STEP_TIME - TIME_H * 3600 - TIME_M * 60;
- if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Heat_insulating + ":" + Resources.Time + string.Format(" {0:D2}", TIME_H) + ":" + string.Format(" {0:D2}", TIME_M) + ":" + string.Format(" {0:D2}", TIME_S);
}
else if (THL_mode == 1)//升温
{
if (STEP_P1 > TEMP_co) TEMP_co = TEMP_co + (STEP_P2 / 600);
TO = pid.PID_iterate(TEMP_co, T, ts);
if (TO < 0) TO = 0;
+ if ((TEMP_co < T) || (T - TEMP_co > 3)) TO = 0;
if (STEP_P1 < T)
{
THL_mode = 0;
diff --git a/ViewModel/ViewModelLocator.cs b/ViewModel/ViewModelLocator.cs
index 2880829..f2ebe4a 100644
--- a/ViewModel/ViewModelLocator.cs
+++ b/ViewModel/ViewModelLocator.cs
@@ -33,5 +33,12 @@ namespace DyeingComputer.ViewModel
return ServiceLocator.Current.GetInstance();
}
}
+ public HistoryRecordsViewModel History
+ {
+ get
+ {
+ return ServiceLocator.Current.GetInstance();
+ }
+ }
}
}