Merge branch 'master' of http://www.scserverddns.top:13000/sc/DyeingComputer
This commit is contained in:
commit
fa7a2bf34f
1 file changed
+64
-24
@@ -17,32 +17,27 @@ using System.Xml.Linq;
|
|||||||
using SkiaSharp;
|
using SkiaSharp;
|
||||||
using LiveChartsCore.Defaults;
|
using LiveChartsCore.Defaults;
|
||||||
using static System.Net.WebRequestMethods;
|
using static System.Net.WebRequestMethods;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
namespace DyeingComputer.ViewModel
|
namespace DyeingComputer.ViewModel
|
||||||
{
|
{
|
||||||
public partial class CurveDiagramViewModel : ObservableObject//ViewModelBase
|
public partial class CurveDiagramViewModel : ObservableObject//ViewModelBase
|
||||||
{
|
{
|
||||||
public ISeries[] Series { get; set; } =
|
/* public ISeries[] Series { get; set; } =
|
||||||
|
{
|
||||||
|
new LineSeries<DateTimePoint>
|
||||||
{
|
{
|
||||||
new LineSeries<DateTimePoint>
|
Name = Properties.Resources.Temperature +"1",
|
||||||
{
|
|
||||||
Name = Properties.Resources.Temperature +"2",
|
|
||||||
Values = new DateTimePoint[]
|
Values = new DateTimePoint[]
|
||||||
{
|
{
|
||||||
new DateTimePoint(Convert.ToDateTime( "2024-01-01 09:08:00"), 24),
|
new DateTimePoint(Convert.ToDateTime( "2024-01-01 09:08:00"), 24),
|
||||||
new DateTimePoint(Convert.ToDateTime( "2024-01-02 09:08:00"), 57),
|
new DateTimePoint(Convert.ToDateTime( "2024-01-02 09:08:00"), 57),
|
||||||
new DateTimePoint(Convert.ToDateTime( "2024-01-03 09:08:00"), 67),
|
new DateTimePoint(Convert.ToDateTime( "2024-01-03 09:08:00"), 67),
|
||||||
new DateTimePoint(Convert.ToDateTime( "2024-01-04 09:08:00"), 32),
|
},
|
||||||
new DateTimePoint(Convert.ToDateTime( "2024-01-05 09:08:00"), 57),
|
Stroke = new SolidColorPaint(s_blue, 2),
|
||||||
new DateTimePoint(Convert.ToDateTime( "2024-01-06 09:08:00"), 27),
|
GeometrySize = 2,
|
||||||
new DateTimePoint(Convert.ToDateTime( "2024-01-07 09:08:00"), 57),
|
GeometryStroke = new SolidColorPaint(s_blue, 2),
|
||||||
new DateTimePoint(Convert.ToDateTime( "2024-01-8 09:08:00"), 17),
|
|
||||||
},
|
|
||||||
Stroke = new SolidColorPaint(s_blue, 2),
|
|
||||||
GeometrySize = 1,
|
|
||||||
GeometryStroke = new SolidColorPaint(s_blue, 2),
|
|
||||||
Fill = null,
|
Fill = null,
|
||||||
|
|
||||||
LineSmoothness = 0,
|
LineSmoothness = 0,
|
||||||
ScalesYAt = 0,
|
ScalesYAt = 0,
|
||||||
},
|
},
|
||||||
@@ -62,7 +57,7 @@ namespace DyeingComputer.ViewModel
|
|||||||
},
|
},
|
||||||
Fill = null,
|
Fill = null,
|
||||||
Stroke = new SolidColorPaint(s_blue, 2),
|
Stroke = new SolidColorPaint(s_blue, 2),
|
||||||
GeometrySize = 0,
|
GeometrySize = 2,
|
||||||
GeometryStroke = new SolidColorPaint(s_blue, 2),
|
GeometryStroke = new SolidColorPaint(s_blue, 2),
|
||||||
LineSmoothness = 0,
|
LineSmoothness = 0,
|
||||||
ScalesYAt = 0,
|
ScalesYAt = 0,
|
||||||
@@ -70,7 +65,7 @@ namespace DyeingComputer.ViewModel
|
|||||||
|
|
||||||
new LineSeries<DateTimePoint>
|
new LineSeries<DateTimePoint>
|
||||||
{
|
{
|
||||||
Name = Properties.Resources.Flowmeter,
|
Name = Properties.Resources.WaterLevel,
|
||||||
Values = new DateTimePoint[]
|
Values = new DateTimePoint[]
|
||||||
{
|
{
|
||||||
new DateTimePoint(Convert.ToDateTime( "2024-01-01 09:08:00"), 4),
|
new DateTimePoint(Convert.ToDateTime( "2024-01-01 09:08:00"), 4),
|
||||||
@@ -85,14 +80,14 @@ namespace DyeingComputer.ViewModel
|
|||||||
|
|
||||||
Fill = null,
|
Fill = null,
|
||||||
Stroke = new SolidColorPaint(s_red, 2),
|
Stroke = new SolidColorPaint(s_red, 2),
|
||||||
GeometrySize = 0,
|
GeometrySize = 2,
|
||||||
GeometryStroke = new SolidColorPaint(s_red, 2),
|
GeometryStroke = new SolidColorPaint(s_red, 2),
|
||||||
LineSmoothness = 0,
|
LineSmoothness = 0,
|
||||||
ScalesYAt = 1,
|
ScalesYAt = 1,
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};*/
|
||||||
|
public ISeries[] Series { get; set; }
|
||||||
//x轴时间格式
|
//x轴时间格式
|
||||||
public Axis[] XAxes { get; set; } =
|
public Axis[] XAxes { get; set; } =
|
||||||
{
|
{
|
||||||
@@ -107,7 +102,6 @@ namespace DyeingComputer.ViewModel
|
|||||||
private static readonly SKColor s_blue = new SKColor(25, 118, 210);
|
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_red = new SKColor(229, 57, 53);
|
||||||
private static readonly SKColor s_yellow = new SKColor(198, 167, 0);
|
private static readonly SKColor s_yellow = new SKColor(198, 167, 0);
|
||||||
|
|
||||||
public ICartesianAxis[] YAxes { get; set; } ={
|
public ICartesianAxis[] YAxes { get; set; } ={
|
||||||
new Axis //y在此轴上缩放
|
new Axis //y在此轴上缩放
|
||||||
{
|
{
|
||||||
@@ -141,8 +135,54 @@ namespace DyeingComputer.ViewModel
|
|||||||
}, //液位轴
|
}, //液位轴
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private readonly Random _r = new Random();
|
||||||
|
private readonly ObservableCollection<DateTimePoint> _values;
|
||||||
|
private DateTimePoint _current;
|
||||||
|
|
||||||
|
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
||||||
|
private readonly string ChartAdress = Environment.CurrentDirectory + "\\DataBase\\Chart.db"; //数据库路径
|
||||||
|
DataTable CDB = new DataTable();
|
||||||
|
private int CDB_Count;//长度
|
||||||
|
|
||||||
public CurveDiagramViewModel()
|
public CurveDiagramViewModel()
|
||||||
{
|
{
|
||||||
|
// 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];
|
||||||
|
CDB = SQLiteHelpers.ExecuteDataSet("select * from Chart order by Time", null).Tables[0];
|
||||||
|
SQLiteHelpers.Close();
|
||||||
|
CDB_Count = CDB.Rows.Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var items = new List<DateTimePoint>();
|
||||||
|
for (var i = 0; i < CDB_Count; i++)
|
||||||
|
{
|
||||||
|
// _current += _r.Next(-9, 10);
|
||||||
|
// CDB.Rows[i].Field<string>("varchar")
|
||||||
|
items.Add(new DateTimePoint(Convert.ToDateTime(CDB.Rows[i].Field<string>("Time")), CDB.Rows[i].Field<double>("MTT")));
|
||||||
|
}
|
||||||
|
_values = new ObservableCollection<DateTimePoint>(items);
|
||||||
|
|
||||||
|
Series = new ISeries[]
|
||||||
|
{
|
||||||
|
new LineSeries<DateTimePoint>
|
||||||
|
{
|
||||||
|
Name = Properties.Resources.Temperature +"1",
|
||||||
|
Values = _values,
|
||||||
|
Stroke = new SolidColorPaint(s_blue, 2),
|
||||||
|
GeometrySize = 2,
|
||||||
|
GeometryStroke = new SolidColorPaint(s_blue, 2),
|
||||||
|
Fill = null,
|
||||||
|
LineSmoothness = 0,
|
||||||
|
ScalesYAt = 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user