sc 11 months ago
parent
commit
37516e883e
  1. 30
      UserClass/AsyncTcpServer.cs
  2. 3
      View/TechnologicalProcessView.xaml
  3. 16
      View/TechnologicalProcessView.xaml.cs
  4. 37
      ViewModel/MainWindowViewModel.cs

30
UserClass/AsyncTcpServer.cs

@ -217,19 +217,22 @@ namespace DyeingComputer.UserClass
/**编辑行信息**/
DataRow drtt = TechnologicalProcessView.sql.Tables[0].Rows[d - 1];
drtt.BeginEdit();
drtt["StepID"] = dat_821.GetValue("STEPID").ToString();
drtt["StepName"] = dat_821.GetValue("STEPNAME").ToString();
drtt["ParameterName"] = dat_821.GetValue("PNAME").ToString();
drtt["Parameter1"] = dat_821.GetValue("P1").ToString();
drtt["Parameter2"] = dat_821.GetValue("P2").ToString();
drtt["Parameter3"] = dat_821.GetValue("P3").ToString();
drtt["Parameter4"] = dat_821.GetValue("P4").ToString();
drtt["Parameter5"] = dat_821.GetValue("P5").ToString();
drtt["StepID"] = dat_821.GetValue("StepID").ToString();
drtt["StepName"] = dat_821.GetValue("StepName").ToString();
drtt["ParameterName"] = dat_821.GetValue("ParameterName").ToString();
drtt["Parameter1"] = dat_821.GetValue("Parameter1").ToString();
drtt["Parameter2"] = dat_821.GetValue("Parameter2").ToString();
drtt["Parameter3"] = dat_821.GetValue("Parameter3").ToString();
drtt["Parameter4"] = dat_821.GetValue("Parameter4").ToString();
drtt["Parameter5"] = dat_821.GetValue("Parameter5").ToString();
drtt["RUN"] = "0";
drtt["DYELOT"] = MainWindowViewModel.WorkNumder;
drtt.EndEdit();
var _TechnologicalProcessView = Application.Current.Windows.Cast<UserControl>().FirstOrDefault(window => window is TechnologicalProcessView) as TechnologicalProcessView;//跨页面
_TechnologicalProcessView.Grid.ItemsSource = TechnologicalProcessView.sql.Tables[0].DefaultView;
_TechnologicalProcessView.Grid.SelectedIndex = -1;
// var _TechnologicalProcessView = Application.Current.Windows.Cast<UserControl>().FirstOrDefault(window => window is TechnologicalProcessView) as TechnologicalProcessView;//跨页面
// _TechnologicalProcessView.Grid.ItemsSource = TechnologicalProcessView.sql.Tables[0].DefaultView;
//_TechnologicalProcessView.Grid.SelectedIndex = -1;
/**存入信息**/
TechnologicalProcessView.SQLiteHelpers.Delete("RUN", null, null);
DataTable data_t = new DataTable();
@ -244,9 +247,6 @@ namespace DyeingComputer.UserClass
DataRow drT = data_t.NewRow();
drT.ItemArray = dt.ItemArray;
data_t.Rows.InsertAt(drT, 0);
drT.BeginEdit(); //添加订单号
drT["DYELOT"] = MainWindowViewModel.WorkNumder;
drT.EndEdit();
TechnologicalProcessView.SQLiteHelpers.InsertData("RUN", TechnologicalProcessView.SQLiteHelpers.DataTableToDictionary(data_t));//行插入
}
@ -349,7 +349,7 @@ namespace DyeingComputer.UserClass
if (SYSKEY == MainWindowViewModel.SYSKEY)
{
client.SendAsync("SC831" + "[" + MainWindowViewModel.S01 + "]" +TechnologicalProcessView.sql.Tables[0].ToJsonString());
client.SendAsync("SC831" + "[" + MainWindowViewModel.S01 + "]" +MainWindowViewModel.dt_TP.ToJsonString());
}
else { client.SendAsync("SC999"); }
}//当前工作表

3
View/TechnologicalProcessView.xaml

@ -12,7 +12,8 @@
d:DesignHeight="630" d:DesignWidth="1280">
<Grid Focusable="True">
<DataGrid x:Name="Grid" AlternationCount="2" IsReadOnly="True" SelectionChanged="Grid_SelectionChanged"
Margin="630,40,0,0" d:ItemsSource="{d:SampleData ItemCount=90}" AutoGenerateColumns="False" MinColumnWidth="30"
Margin="630,40,0,0" d:ItemsSource="{d:SampleData ItemCount=90}" AutoGenerateColumns="False" MinColumnWidth="30"
ItemsSource="{Binding Path=TechnologicalProcess_View,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="{x:Null}"
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" Grid.ColumnSpan="2" AllowDrop="False"
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"

16
View/TechnologicalProcessView.xaml.cs

@ -4,6 +4,8 @@ using DyeingComputer.Windows;
using ScottPlot;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
@ -20,7 +22,9 @@ using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using static DyeingComputer.UserClass.SqliteHelper;
using static DyeingComputer.ViewModel.MainWindowViewModel;
using static DyeingComputer.Windows.ViewStep;
using static System.Net.WebRequestMethods;
namespace DyeingComputer.View
{
@ -49,7 +53,6 @@ namespace DyeingComputer.View
public static SQLiteHelper SQLiteHelpers = null; //定义数据库
public static readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
public static DataSet sql; //内存数据缓存
private void TechnologicalProcess_Import()
{
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
@ -98,7 +101,7 @@ namespace DyeingComputer.View
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
// FocusManager.SetFocusedElement(Grid, Grid);
// FocusManager.SetFocusedElement(Grid, Grid);
// Grid.DataContext = new MainWindowViewModel();
if (workName != null)
{
@ -300,7 +303,7 @@ namespace DyeingComputer.View
{
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
{
Interval = TimeSpan.FromSeconds(1)//秒
Interval = TimeSpan.FromSeconds(3)//秒
};
timer1s.Tick += Tick_Event_1S;
timer1s.Start();
@ -310,7 +313,12 @@ namespace DyeingComputer.View
if (MainWindowViewModel.WORK_RUN == 2) Grid.SelectedIndex = MainWindowViewModel.RUN_STEPID - 1;//设定图表显示
if (sql != null)
{
Grid.ItemsSource = sql.Tables[0].DefaultView; //转换显示计划表
// sqlDefaultView = sql.Tables[0].DefaultView;
// Grid.ItemsSource = null;
dt_TP= sql.Tables[0];
// MainWindowViewModel.TechnologicalProcess_View = MainWindowViewModel.ToObservableCollection<TechnologicalProcess>(sql.Tables[0]);
// Grid.ItemsSource = dt_m.DE sql.Tables[0].DefaultView; //转换显示计划表
name.Text = Program_Name;
}
}

37
ViewModel/MainWindowViewModel.cs

@ -1563,6 +1563,7 @@ namespace DyeingComputer.ViewModel
public static DataTable dt_d = new DataTable("DIO");
public static DataTable dt_a = new DataTable("AIO");
public static DataTable dt_m = new DataTable("M");
public static DataTable dt_TP = new DataTable();
public static void SQL_data()//获得io表
{
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
@ -1625,6 +1626,12 @@ namespace DyeingComputer.ViewModel
if ((bool)D_view) SYSData_D = ToObservableCollection<DATA_D>(dt_d);
}
catch (Exception ex) { Name_err = "IO_SYSData_D" + "(" + ex.Message + ")"; }
try
{
TechnologicalProcess_View = ToObservableCollection<TechnologicalProcess>(dt_TP);
}
catch (Exception) { }
});
}
public static double Selet_dtm(string key)//M寄存器
@ -1822,6 +1829,7 @@ namespace DyeingComputer.ViewModel
ObservableCollection<DATA_A> sysData_A = new ObservableCollection<DATA_A>();
ObservableCollection<DATA_D> sysData_D = new ObservableCollection<DATA_D>();
ObservableCollection<DATA_M> sysData_M = new ObservableCollection<DATA_M>();
ObservableCollection<TechnologicalProcess> technologicalProcess_View = new ObservableCollection<TechnologicalProcess>();
public ObservableCollection<DATA_A> SYSData_A
{
@ -1852,6 +1860,16 @@ namespace DyeingComputer.ViewModel
RaisePropertyChanged("SYSData_M");
}
}
public ObservableCollection<TechnologicalProcess> TechnologicalProcess_View
{
get { return technologicalProcess_View; }
set
{
technologicalProcess_View = value;
RaisePropertyChanged("TechnologicalProcess_View");
}
}
public class DATA_A
{
public string IOName { get; set; }
@ -1876,6 +1894,25 @@ namespace DyeingComputer.ViewModel
public string PLC { get; set; }
public string type { get; set; }
}
public class TechnologicalProcess
{
public string Program { get; set; }
public double Step { get; set; }
public string StepID { get; set; }
public string StepName { get; set; }
public string ParameterName { get; set; }
public string Parameter1 { get; set; }
public string Parameter2 { get; set; }
public string Parameter3 { get; set; }
public string Parameter4 { get; set; }
public string Parameter5 { get; set; }
public string Parameter6 { get; set; }
public string Parameter7 { get; set; }
public string Parameter8 { get; set; }
public string Parameter9 { get; set; }
public string Parameter10 { get; set; }
public string DYELOT { get; set; }
}
public ObservableCollection<T> ToObservableCollection<T>(DataTable dt) where T : class, new()
{
Type t = typeof(T);

Loading…
Cancel
Save