|
|
@ -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<string>("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<string, object> Machines_DAT = new Dictionary<string, object>();//缓存函数
|
|
|
@ -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)); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|