sc 5 months ago
parent
commit
2ea530d0b6
  1. 3
      View/TechnologicalProcessView.xaml.cs
  2. 53
      ViewModel/CurveDiagramViewModel.cs
  3. 45
      ViewModel/MainWindowViewModel.cs

3
View/TechnologicalProcessView.xaml.cs

@ -295,7 +295,8 @@ namespace DyeingComputer.View
catch (Exception) { }
SQLiteHelpers.Close(); //关闭连接
if (sql != null) dt_TP = sql.Tables[0]; //转换显示计划表
// if (sql != null)
MainWindowViewModel.dt_TP = sql.Tables[0]; //转换显示计划表
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)

53
ViewModel/CurveDiagramViewModel.cs

@ -21,6 +21,7 @@ using System.Collections.ObjectModel;
using DyeingComputer.Properties;
using LiveChartsCore.Measure;
using LiveChartsCore.Motion;
using System.Windows.Documents;
namespace DyeingComputer.ViewModel
{
@ -104,18 +105,18 @@ namespace DyeingComputer.ViewModel
//new AnimatableAxisBounds
};
private readonly Random _r = new Random();
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 Random _r = new Random();
private List<DateTimePoint> MTT_values;
private List<DateTimePoint> MTL_values;
private List<DateTimePoint> MTH_values;
private List<DateTimePoint> MST_values;
private List<DateTimePoint> MUT_values;
private List<DateTimePoint> STTA_values;
private List<DateTimePoint> STLA_values;
private List<DateTimePoint> STTB_values;
private List<DateTimePoint> STLB_values;
private List<DateTimePoint> STTC_values;
private List<DateTimePoint> STLC_values;
private SQLiteHelper SQLiteHelpers = null; //定义数据库
private readonly string ChartAdress = Environment.CurrentDirectory + "\\DataBase\\Chart.db"; //数据库路径
@ -168,25 +169,25 @@ namespace DyeingComputer.ViewModel
}
}
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);
MTT_values = new List<DateTimePoint>(MTT_items);
MTL_values = new List<DateTimePoint>(MTL_items);
MTH_values = new List<DateTimePoint>(MTH_items);
MST_values = new List<DateTimePoint>(MST_items);
MUT_values = new List<DateTimePoint>(MUT_items);
if (MainWindowViewModel.SM01 == 1)
{
STTA_values = new ObservableCollection<DateTimePoint>(STTA_items);
STLA_values = new ObservableCollection<DateTimePoint>(STLA_items);
STTA_values = new List<DateTimePoint>(STTA_items);
STLA_values = new List<DateTimePoint>(STLA_items);
}
if (MainWindowViewModel.SM02 == 1)
{
STTB_values = new ObservableCollection<DateTimePoint>(STTB_items);
STLB_values = new ObservableCollection<DateTimePoint>(STLB_items);
STTB_values = new List<DateTimePoint>(STTB_items);
STLB_values = new List<DateTimePoint>(STLB_items);
}
if (MainWindowViewModel.SM03 == 1)
{
STTC_values = new ObservableCollection<DateTimePoint>(STTC_items);
STLC_values = new ObservableCollection<DateTimePoint>(STLC_items);
STTC_values = new List<DateTimePoint>(STTC_items);
STLC_values = new List<DateTimePoint>(STLC_items);
}
Series = new ISeries[]
{
@ -223,7 +224,7 @@ namespace DyeingComputer.ViewModel
LineSmoothness = 0,
ScalesYAt = 0,
}, //主缸
new LineSeries<DateTimePoint>
/*new LineSeries<DateTimePoint>
{
Name = Properties.Resources.Temperature +"2("+Properties.Resources.MasterCylinder+Properties.Resources.Bottom+")",
Values = MUT_values,
@ -233,7 +234,7 @@ namespace DyeingComputer.ViewModel
Fill = null,
LineSmoothness = 0,
ScalesYAt = 0,
}, //缸底
}, */ //缸底
new LineSeries<DateTimePoint>
{
Name = Properties.Resources.Temperature +"3("+Resources.Medicine + Resources.Tank +"1)",
@ -310,7 +311,7 @@ namespace DyeingComputer.ViewModel
Fill = null,
LineSmoothness = 0,
ScalesYAt = 1,
}, //附缸3 液位
}, //附缸3液位
};
}
}

45
ViewModel/MainWindowViewModel.cs

@ -81,14 +81,54 @@ namespace DyeingComputer.ViewModel
SQL_data(); //读数据库
UPort(); //启动串口
CountDown(); //启动循环任务
dt_a.RowChanged += Dt_a_rowchanged;//添加行更新事件
dt_d.RowChanged += Dt_d_rowchanged;
dt_m.RowChanged += Dt_m_rowchanged;
dt_TP.RowChanged += Dt_tp_rowchanged;
dt_TP.RowDeleted += Dt_tp_rowchanged;
IO_view();
_ = AsyncTcpServer.Main();
IsInteractive = false;
UserButton = false;
ProgramgroupView_run = new RelayCommand(
execute:ProgramgroupView_run_ );//开始/暂停事件
}
private void Dt_tp_rowchanged(object sender, DataRowChangeEventArgs e)
{
try
{
TechnologicalProcess_View = ToObservableCollection<TechnologicalProcess>(dt_TP);
}
catch (Exception) { }
}//工艺步骤表更新事件
private void Dt_a_rowchanged(object sender,DataRowChangeEventArgs e)
{
try
{
if ((bool)A_view) SYSData_A = ToObservableCollection<DATA_A>(dt_a);
}
catch (Exception ex) { Name_err = "IO_SYSData_A" + "(" + ex.Message + ")"; }
}//aio表更新事件
private void Dt_d_rowchanged(object sender, DataRowChangeEventArgs e)
{
try
{
if ((bool)D_view) SYSData_D = ToObservableCollection<DATA_D>(dt_d);
}
catch (Exception ex) { Name_err = "IO_SYSData_D" + "(" + ex.Message + ")"; }
}//dio表更新事件
private void Dt_m_rowchanged(object sender, DataRowChangeEventArgs e)
{
try
{
SYSData_M = ToObservableCollection<DATA_M>(dt_m);
}
catch (Exception ex) { Name_err = "IO_SYSData_M" + "(" + ex.Message + ")"; }
}//寄存器表更新事件
DataTable dt_con = new DataTable();
DataTable dt_sys = new DataTable();
public string Selet_con(string key)//配置缓存
@ -317,7 +357,6 @@ namespace DyeingComputer.ViewModel
STEP_RUN();
LOG_view();
IO_view();
if (!string.IsNullOrEmpty(Name_err.ToString()))
{
@ -1697,7 +1736,7 @@ namespace DyeingComputer.ViewModel
public static object D_view=true;
public static object A_view=true;
private async void IO_view()//IO显示
public async void IO_view()//IO显示
{
await Task.Run(() =>
{

Loading…
Cancel
Save