diff --git a/UserClass/AsyncTcpClient.cs b/UserClass/AsyncTcpClient.cs index 645011b..7b23ea7 100644 --- a/UserClass/AsyncTcpClient.cs +++ b/UserClass/AsyncTcpClient.cs @@ -251,8 +251,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass { Dictionary Chart_new = new Dictionary();//缓存函数 Chart_new.Add("WorkOrder", _new.GetValue("WorkNumder")); - Chart_new.Add("Machine", _new.GetValue("Machine")); - Chart_new.Add("Time", _new.GetValue("Time")); + Chart_new.Add("Machine", drEmployee["Name"]); + Chart_new.Add("Time", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")); Chart_new.Add("MST", _new.GetValue("MST")); Chart_new.Add("MTT", _new.GetValue("MTT")); Chart_new.Add("MTL", _new.GetValue("MTL")); diff --git a/View/MachinesSet.xaml b/View/MachinesSet.xaml index 524467e..9f6cc9a 100644 --- a/View/MachinesSet.xaml +++ b/View/MachinesSet.xaml @@ -65,6 +65,7 @@ + diff --git a/View/MachinesSet.xaml.cs b/View/MachinesSet.xaml.cs index e001d28..7000630 100644 --- a/View/MachinesSet.xaml.cs +++ b/View/MachinesSet.xaml.cs @@ -36,15 +36,16 @@ namespace SunlightCentralizedControlManagement_SCCM_.View // 获取所有可用串口端口,并添加到comboBoxCOM // string[] ports = System.IO.Ports.SerialPort.GetPortNames(); - string[] ports = { "PORT1", "PORT2", "PORT3", "PORT4" }; comboBoxCOM0.ItemsSource = ports; comboBoxCOM0.Text = Configini.IniReadvalue("SYS", "COM"); comboBoxMachine.ItemsSource = MainWindowViewModel.Machines.AsEnumerable().Select(rowdata => rowdata.Field("name")).ToList();//转换机台 - string[] type_ = { "828", "838" }; comboBoxtype.ItemsSource = type_; } - private readonly UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "SCCM.ini"); + string[] ports = { "PORT1", "PORT2", "PORT3", "PORT4" }; + string[] type_ = { "828", "838" }; + string link_model = "838" ; + private readonly UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "SCCM.ini"); //private string SYS_machines = null; int ID_; private void UserControl_Loaded(object sender, RoutedEventArgs e) @@ -70,6 +71,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View private void Save_Click(object sender, RoutedEventArgs e) { + if (string.IsNullOrEmpty(Station.Text)) Station.Text = "255"; if (!string.IsNullOrEmpty(comboBoxMachine.Text)) { Dictionary Machines_DAT = new Dictionary();//缓存函数 @@ -83,6 +85,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View dat_["PORT"] = PORT.Text; dat_["Serial"] = comboBoxCOM0.Text; dat_["Type"] = comboBoxtype.Text; + dat_["Model"] = comboBoxtype.Text; dat_["Station"] = Station.Text; dat_["ID"] = 999; dat_["ERR"] = false; @@ -94,10 +97,17 @@ namespace SunlightCentralizedControlManagement_SCCM_.View dat_["WaterLevel"] = 0; dat_["WORK_RUN"] = -1; dat_["UserInfoStart"] = 900; - if (comboBoxtype.Text == "838") - { dat_["Desktop"] = true; } - else { dat_["Desktop"] = false; } - dat_.EndEdit(); + if (comboBoxtype.Text.Contains( link_model)) + { + dat_["Desktop"] = true; + dat_["Type"] = true; + } + else + { + dat_["Desktop"] = false; + dat_["Type"] = false; + } + dat_.EndEdit(); MainWindowViewModel.Machines.Rows.Add(dat_); DatSteps(MainWindowViewModel.Machines); MainWindowViewModel.SQLiteHelpers.Delete("Machines", null, null);// @@ -113,6 +123,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View Machines_DAT.Add("Desktop", MainWindowViewModel.Machines.Rows[x]["Desktop"]); Machines_DAT.Add("Dispense", MainWindowViewModel.Machines.Rows[x]["Dispense"]); Machines_DAT.Add("Type", MainWindowViewModel.Machines.Rows[x]["Type"]); + Machines_DAT.Add("Model", MainWindowViewModel.Machines.Rows[x]["Model"]); MainWindowViewModel.SQLiteHelpers.InsertData("Machines", Machines_DAT);//行插入 Machines_DAT.Clear(); } @@ -126,18 +137,16 @@ namespace SunlightCentralizedControlManagement_SCCM_.View dr["IP"] = IP.Text; dr["PORT"] = PORT.Text; dr["Serial"] = comboBoxCOM0.Text; - dr["Type"] = comboBoxtype.Text; + dr["Model"] = comboBoxtype.Text; dr["Station"] = Station.Text; - dr["ID"] = 999; - dr["ERR"] = false; - dr["AUTO"] = false; - dr["CALL"] = false; - dr["LOCK"] = false; - dr["State"] = 800; - dr["Temperature"] = 0; - dr["WaterLevel"] = 0; - dr["WORK_RUN"] = -1; - dr["UserInfoStart"] = 900; + if (comboBoxtype.Text.Contains(link_model)) + { dr["Desktop"] = true; + dr["Type"] = true; } + else + { + dr["Desktop"] = false; + dr["Type"] = false; + } dr.EndEdit(); MainWindowViewModel.SQLiteHelpers.Delete("Machines", null, null);// for (int x = 0; x < MainWindowViewModel.Machines.Rows.Count; x++) @@ -152,6 +161,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View Machines_DAT.Add("Desktop", MainWindowViewModel.Machines.Rows[x]["Desktop"]); Machines_DAT.Add("Dispense", MainWindowViewModel.Machines.Rows[x]["Dispense"]); Machines_DAT.Add("Type", MainWindowViewModel.Machines.Rows[x]["Type"]); + Machines_DAT.Add("Model", MainWindowViewModel.Machines.Rows[x]["Model"]); Machines_DAT.Add("LOCK", "FALSE"); MainWindowViewModel.SQLiteHelpers.InsertData("Machines", Machines_DAT);//行插入 Machines_DAT.Clear(); @@ -224,45 +234,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.View } private void Test_Click(object sender, RoutedEventArgs e)//测试按钮 { - if (comboBoxtype.Text == "828") - { - if (!string.IsNullOrEmpty(comboBoxCOM0.Text) && !string.IsNullOrEmpty(Station.Text)) - { - textlog.Text = "TEST"; - textlog.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 255)); - //------------使用ping类------ - string host = IP.Text; - Ping p1 = new Ping(); - PingReply reply = p1.Send(host); //发送主机名或Ip地址 - //StringBuilder sbuilder; - if (reply.Status == IPStatus.Success) - { - try - { - textlog.Text = "Link succeed"; - textlog.Foreground = new SolidColorBrush(Color.FromRgb(0, 255, 0)); - } - catch (Exception) - { - textlog.Text = "Link failed"; - textlog.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 0)); - } - } - else - { - textlog.Text = "No links"; - textlog.Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0)); - } - } - else - { - textlog.Text = "Invalid"; - textlog.Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0)); - } - - } - else if (comboBoxtype.Text == "838") - { + + if (comboBoxtype.Text.Contains(link_model)) + {//网络 if (!string.IsNullOrEmpty(IP.Text) && !string.IsNullOrEmpty(PORT.Text)) { textlog.Text = "TEST"; @@ -320,6 +294,43 @@ namespace SunlightCentralizedControlManagement_SCCM_.View } } + else + {//串口 + if (!string.IsNullOrEmpty(comboBoxCOM0.Text) && !string.IsNullOrEmpty(Station.Text)) + { + textlog.Text = "TEST"; + textlog.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 255)); + //------------使用ping类------ + string host = IP.Text; + Ping p1 = new Ping(); + PingReply reply = p1.Send(host); //发送主机名或Ip地址 + //StringBuilder sbuilder; + if (reply.Status == IPStatus.Success) + { + try + { + textlog.Text = "Link succeed"; + textlog.Foreground = new SolidColorBrush(Color.FromRgb(0, 255, 0)); + } + catch (Exception) + { + textlog.Text = "Link failed"; + textlog.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 0)); + } + } + else + { + textlog.Text = "No links"; + textlog.Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0)); + } + } + else + { + textlog.Text = "Invalid"; + textlog.Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0)); + } + + } } } } diff --git a/View/MonitorView.xaml b/View/MonitorView.xaml index 18726e0..f831eec 100644 --- a/View/MonitorView.xaml +++ b/View/MonitorView.xaml @@ -35,11 +35,12 @@