This commit is contained in:
sc committed 2024-10-05 00:26:10 +08:00
commit ff59c77d54
5 files changed
+118 -28

No files matched your search

+82 -9
View File
@@ -8,24 +8,97 @@ using System.Text;
using System.Threading.Tasks;
using static DyeingComputer.UserClass.SqliteHelper;
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;
namespace DyeingComputer.ViewModel
{
public class CurveDiagramViewModel : ObservableObject
{
public ISeries[] Series { get; set; } = new ISeries[]
{
public partial class CurveDiagramViewModel : ObservableObject//ViewModelBase
{
public ISeries[] Series { get; set; } =
{
new LineSeries<double>
{
Values = new double[] { 2, 1, 3, 5, 3, 4, 6 },
Fill = null
{
Name = Properties.Resources.Temperature +"1",
Values = new double[] { 5, 0, 1000, 0, 5, 0 },
Fill = null,
GeometrySize = 0,
// use the line smoothness property to control the curve
// it goes from 0 to 1
// where 0 is a straight line and 1 the most curved
LineSmoothness = 1,
ScalesYAt = 0,
},
new LineSeries<double>
{
Name = Properties.Resources.Temperature +"2",
Values = new double[] { 7, 2, 7, 2, 7, 2 ,6,67,5,66,56,5},
Fill = null,
GeometrySize = 0,
LineSmoothness = 1,
ScalesYAt = 0,
},
new LineSeries<double>
{
Name = Properties.Resources.Flowmeter,
Values = new double[] { 7, 2, 7, 5467,6,67,5,66,56,5},
Fill = null,
GeometrySize = 0,
LineSmoothness = 1,
ScalesYAt = 1,
}
};
// You can use the DateTimeAxis class to define a date time based axis
// The first parameter is the time between each point, in this case 1 day
// you can also use 1 year, 1 month, 1 hour, 1 minute, 1 second, 1 millisecond, etc
// The second parameter is a function that receives the value and returns the label
public Axis[] XAxes { get; set; } =
{ new DateTimeAxis(TimeSpan.FromSeconds(5) , date => date.ToString("yyyy-MM-dd HH:mm:ss")) };
private static readonly SKColor s_blue = new SKColor(25, 118, 210);
private static readonly SKColor s_red = new SKColor(229, 57, 53);
private static readonly SKColor s_yellow = new SKColor(198, 167, 0);
public ICartesianAxis[] YAxes { get; set; } ={
new Axis //“units” 和 “tens” 系列将在此轴上缩放
{
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
},
new Axis // the "hundreds" series will be scaled on this axis
{
Name = Properties.Resources.Flowmeter +" ( 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,
ShowSeparatorLines = false,
Position = LiveChartsCore.Measure.AxisPosition.End
}, };
public CurveDiagramViewModel()
{
}
}
}
+15 -3
View File
@@ -67,9 +67,9 @@ namespace DyeingComputer.ViewModel
Sys_workSTEPID = -1;
WorkNumder = "----------";
SYS_SET(); //crbl
CountDown(); //启动循环任务
SQL_data(); //读数据库
UPort(); //启动串口
UPort(); //启动串口
CountDown(); //启动循环任务
}
private static int MT05;//主缸排水延时
@@ -118,6 +118,9 @@ namespace DyeingComputer.ViewModel
MT40 = Convert.ToInt16(Selet_con("MT40"));//
MT41 = Convert.ToInt16(Selet_con("MT41"));//
MU01 = Convert.ToInt16(Selet_con("MU01"));//呼叫操作员
MS01 = Convert.ToDouble(Selet_con("MS01"));
MS02 = Convert.ToDouble(Selet_con("MS02"));
MS03 = Convert.ToDouble(Selet_con("MS03"));
S16 = Convert.ToInt16(Selet_sys("S16"));//工作信息
SM01 = Convert.ToInt16(Selet_sys("SM01"));//FG
@@ -234,7 +237,16 @@ namespace DyeingComputer.ViewModel
LOG_view();
IO_view();
if (!string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Name_err.ToString();
if (!string.IsNullOrEmpty(Name_err.ToString()))
{
Status_Str = Name_err.ToString();
if (Alert_red) { Alert_red = false; Alert_bell = false; }//关报警
}
else
{
Alert_red = !Alert_red;
Alert_bell = !Alert_bell;
}
}
void Tick_Event_5S(object sender, EventArgs e)//Tick_Event周期执行事件5S
{