sc 1 year ago
parent
commit
22344f433a
  1. 9
      Properties/Resources.Designer.cs
  2. 3
      Properties/Resources.en-US.resx
  3. 3
      Properties/Resources.resx
  4. 3
      Properties/Resources.zh-CN.resx
  5. 296
      ViewModel/CurveDiagramViewModel.cs
  6. 71
      ViewModel/MainWindowViewModel.cs

9
Properties/Resources.Designer.cs

@ -141,6 +141,15 @@ namespace DyeingComputer.Properties {
}
}
/// <summary>
/// 查找类似 Bottom 的本地化字符串。
/// </summary>
public static string Bottom {
get {
return ResourceManager.GetString("Bottom", resourceCulture);
}
}
/// <summary>
/// 查找类似 CallDistribution 的本地化字符串。
/// </summary>

3
Properties/Resources.en-US.resx

@ -480,4 +480,7 @@
<data name="Dyelot" xml:space="preserve">
<value>Dyelot</value>
</data>
<data name="Bottom" xml:space="preserve">
<value>Bottom</value>
</data>
</root>

3
Properties/Resources.resx

@ -480,4 +480,7 @@
<data name="Dyelot" xml:space="preserve">
<value>Dyelot</value>
</data>
<data name="Bottom" xml:space="preserve">
<value>Bottom</value>
</data>
</root>

3
Properties/Resources.zh-CN.resx

@ -480,4 +480,7 @@
<data name="Dyelot" xml:space="preserve">
<value>领料单</value>
</data>
<data name="Bottom" xml:space="preserve">
<value>底</value>
</data>
</root>

296
ViewModel/CurveDiagramViewModel.cs

@ -18,75 +18,14 @@ using SkiaSharp;
using LiveChartsCore.Defaults;
using static System.Net.WebRequestMethods;
using System.Collections.ObjectModel;
using DyeingComputer.Properties;
using LiveChartsCore.Measure;
using LiveChartsCore.Motion;
namespace DyeingComputer.ViewModel
{
public partial class CurveDiagramViewModel : ObservableObject//ViewModelBase
{
/* public ISeries[] Series { get; set; } =
{
new LineSeries<DateTimePoint>
{
Name = Properties.Resources.Temperature +"1",
Values = new DateTimePoint[]
{
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-03 09:08:00"), 67),
},
Stroke = new SolidColorPaint(s_blue, 2),
GeometrySize = 2,
GeometryStroke = new SolidColorPaint(s_blue, 2),
Fill = null,
LineSmoothness = 0,
ScalesYAt = 0,
},
new LineSeries<DateTimePoint>
{
Name = Properties.Resources.Temperature +"2",
Values = new DateTimePoint[]
{
new DateTimePoint(Convert.ToDateTime( "2024-01-01 09:08:00"), 424),
new DateTimePoint(Convert.ToDateTime( "2024-01-02 09:08:00"), 57),
new DateTimePoint(Convert.ToDateTime( "2024-01-03 09:08:00"), 647),
new DateTimePoint(Convert.ToDateTime( "2024-01-04 09:08:00"), 532),
new DateTimePoint(Convert.ToDateTime( "2024-01-05 09:08:00"), 57),
new DateTimePoint(Convert.ToDateTime( "2024-01-06 09:08:00"), 287),
new DateTimePoint(Convert.ToDateTime( "2024-01-07 09:08:00"), 57),
new DateTimePoint(Convert.ToDateTime( "2024-01-8 09:08:00"), 17),
},
Fill = null,
Stroke = new SolidColorPaint(s_blue, 2),
GeometrySize = 2,
GeometryStroke = new SolidColorPaint(s_blue, 2),
LineSmoothness = 0,
ScalesYAt = 0,
},
new LineSeries<DateTimePoint>
{
Name = Properties.Resources.WaterLevel,
Values = new DateTimePoint[]
{
new DateTimePoint(Convert.ToDateTime( "2024-01-01 09:08:00"), 4),
new DateTimePoint(Convert.ToDateTime( "2024-01-02 09:08:00"), 57),
new DateTimePoint(Convert.ToDateTime( "2024-01-03 09:08:00"), 647),
new DateTimePoint(Convert.ToDateTime( "2024-01-04 09:08:00"), 5732),
new DateTimePoint(Convert.ToDateTime( "2024-01-05 09:08:00"), 5457),
new DateTimePoint(Convert.ToDateTime( "2024-01-06 09:08:00"), 2257),
new DateTimePoint(Convert.ToDateTime( "2024-01-07 09:08:00"), 57),
new DateTimePoint(Convert.ToDateTime( "2024-01-8 09:08:00"), 517),
},
Fill = null,
Stroke = new SolidColorPaint(s_red, 2),
GeometrySize = 2,
GeometryStroke = new SolidColorPaint(s_red, 2),
LineSmoothness = 0,
ScalesYAt = 1,
}
};*/
public ISeries[] Series { get; set; }
//x轴时间格式
public Axis[] XAxes { get; set; } =
@ -99,12 +38,22 @@ 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_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),
@ -115,11 +64,13 @@ namespace DyeingComputer.ViewModel
TicksPaint = new SolidColorPaint(s_blue),
SubticksPaint = new SolidColorPaint(s_blue),
DrawTicksPath = true,
CrosshairSnapEnabled = true
CrosshairSnapEnabled = true,
Position = LiveChartsCore.Measure.AxisPosition.Start
},//温度轴
new Axis // the "hundreds" series will be scaled on this axis
{
Name = Properties.Resources.Flowmeter +" ( L )",
MinLimit =0,
Name = Properties.Resources.WaterLevel +" ( L )",
NameTextSize = 24,
NamePaint = new SolidColorPaint(s_red),
NamePadding = new LiveChartsCore.Drawing.Padding(0, 20),
@ -129,15 +80,42 @@ namespace DyeingComputer.ViewModel
TicksPaint = new SolidColorPaint(s_red),
SubticksPaint = new SolidColorPaint(s_red),
DrawTicksPath = true,
ShowSeparatorLines = false,
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<DateTimePoint> _values;
private DateTimePoint _current;
private readonly ObservableCollection<DateTimePoint> MTT_values;
private readonly ObservableCollection<DateTimePoint> MTL_values;
private readonly ObservableCollection<DateTimePoint> MTH_values;
private readonly ObservableCollection<DateTimePoint> MST_values;
private readonly ObservableCollection<DateTimePoint> MUT_values;
private readonly ObservableCollection<DateTimePoint> STTA_values;
private readonly ObservableCollection<DateTimePoint> STLA_values;
private readonly ObservableCollection<DateTimePoint> STTB_values;
private readonly ObservableCollection<DateTimePoint> STLB_values;
private readonly ObservableCollection<DateTimePoint> STTC_values;
private readonly ObservableCollection<DateTimePoint> STLC_values;
private SQLiteHelper SQLiteHelpers = null; //定义数据库
private readonly string ChartAdress = Environment.CurrentDirectory + "\\DataBase\\Chart.db"; //数据库路径
@ -151,38 +129,190 @@ namespace DyeingComputer.ViewModel
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>();
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++)
{
// _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")));
DateTime TIME = Convert.ToDateTime(CDB.Rows[i].Field<string>("Time"));
MTT_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("MTT")));
MTL_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("MTL")));
MTH_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("MTH")));
MST_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("MST")));
MUT_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("MUT")));
if (MainWindowViewModel.SM01 == 1)
{
STTA_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STTA")));
STLA_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STLA")));
}
if (MainWindowViewModel.SM02 == 1)
{
STTB_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STTB")));
STLB_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STLB")));
}
if (MainWindowViewModel.SM03 == 1)
{
STTC_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STTC")));
STLC_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STLC")));
}
}
_values = new ObservableCollection<DateTimePoint>(items);
MTT_values = new ObservableCollection<DateTimePoint>(MTT_items);
MTL_values = new ObservableCollection<DateTimePoint>(MTL_items);
MTH_values = new ObservableCollection<DateTimePoint>(MTH_items);
MST_values = new ObservableCollection<DateTimePoint>(MST_items);
MUT_values = new ObservableCollection<DateTimePoint>(MUT_items);
if (MainWindowViewModel.SM01 == 1)
{
STTA_values = new ObservableCollection<DateTimePoint>(STTA_items);
STLA_values = new ObservableCollection<DateTimePoint>(STLA_items);
}
if (MainWindowViewModel.SM02 == 1)
{
STTB_values = new ObservableCollection<DateTimePoint>(STTB_items);
STLB_values = new ObservableCollection<DateTimePoint>(STLB_items);
}
if (MainWindowViewModel.SM03 == 1)
{
STTC_values = new ObservableCollection<DateTimePoint>(STTC_items);
STLC_values = new ObservableCollection<DateTimePoint>(STLC_items);
}
Series = new ISeries[]
{
new LineSeries<DateTimePoint>
{
Name = Properties.Resources.Temperature +"1",
Values = _values,
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<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,
}, //目标温度
new LineSeries<DateTimePoint>
{
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<DateTimePoint>
{
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<DateTimePoint>
{
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<DateTimePoint>
{
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<DateTimePoint>
{
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<DateTimePoint>
{
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<DateTimePoint>
{
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<DateTimePoint>
{
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<DateTimePoint>
{
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 液位
};
}
}
}
}

71
ViewModel/MainWindowViewModel.cs

@ -71,7 +71,36 @@ namespace DyeingComputer.ViewModel
UPort(); //启动串口
CountDown(); //启动循环任务
}
DataTable dt_con = new DataTable();
DataTable dt_sys = new DataTable();
public string Selet_con(string key)//配置缓存
{
try
{
DataRow[] arrRows = dt_con.Select("ParameterID ='" + key + "'");
string index = arrRows[0]["Value"].ToString();
return index;
}
catch (Exception ex)
{
LogGing.LogGingDATA(ex.ToString());
return "0";
}
}
public string Selet_sys(string key)//配置缓存
{
try
{
DataRow[] arrRows = dt_sys.Select("ParameterID ='" + key + "'");
string index = arrRows[0]["Value"].ToString();
return index;
}
catch (Exception ex)
{
LogGing.LogGingDATA(ex.ToString());
return "0";
}
}
private static int MT05;//主缸排水延时
private static int MT06;//主缸排水延时
private int MT12;
@ -84,14 +113,13 @@ namespace DyeingComputer.ViewModel
private int MT41;//安全水位
private static int MU01;//呼叫操作员
private int S16;//机型
private int SM01;//副缸
private int SM02;//副缸
private int SM03;//副缸
public static int SM01;//副缸
public static int SM02;//副缸
public static int SM03;//副缸
private double MS01;//1缸温度偏差
private double MS02;//2缸温度偏差
private double MS03;//3缸温度偏差
void SYS_SET()
{
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
@ -127,36 +155,6 @@ namespace DyeingComputer.ViewModel
SM02 = Convert.ToInt16(Selet_sys("SM02"));//FG
SM03 = Convert.ToInt16(Selet_sys("SM03"));//FG
}
DataTable dt_con = new DataTable();
DataTable dt_sys = new DataTable();
public string Selet_con(string key)//配置缓存
{
try
{
DataRow[] arrRows = dt_con.Select("ParameterID ='" + key + "'");
string index = arrRows[0]["Value"].ToString();
return index;
}
catch (Exception ex)
{
LogGing.LogGingDATA(ex.ToString());
return "0";
}
}
public string Selet_sys(string key)//配置缓存
{
try
{
DataRow[] arrRows = dt_sys.Select("ParameterID ='" + key + "'");
string index = arrRows[0]["Value"].ToString();
return index;
}
catch (Exception ex)
{
LogGing.LogGingDATA(ex.ToString());
return "0";
}
}
public string work_Temp; //显示温度
public string Work_Temp //通知UI控件参数改变
@ -278,10 +276,11 @@ namespace DyeingComputer.ViewModel
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
Chart_new.Add("DYELOT", work_Numder);
Chart_new.Add("Time", sys_Time);
Chart_new.Add("MST", string.Format(" {0:###.#}", TEMP_co));
Chart_new.Add("MST", string.Format(" {0:###.#}", TEMP_tar));
Chart_new.Add("MTT", Selet_dtm("1010"));
Chart_new.Add("MTL", Selet_dtm("1015"));
Chart_new.Add("MTH", Selet_dtm("1009"));
Chart_new.Add("MUT", Selet_dtm("1011"));
Chart_new.Add("STTA", Selet_dtm("1012"));
Chart_new.Add("STLA", Selet_dtm("1017"));
Chart_new.Add("STTB", Selet_dtm("1013"));

Loading…
Cancel
Save