设备连线逻辑修改
This commit is contained in:
commit
61dbaa3c33
6 files changed
+112
-93
No files matched your search
@@ -251,8 +251,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
{
|
||||
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
|
||||
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"));
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
<DataGridTextColumn Binding="{Binding Serial}" Width="0" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Binding="{Binding Station}" Width="0" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Binding="{Binding ID}" Width="0" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Binding="{Binding Model}" Width="0" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Binding="{Binding Type}" Width="0" IsReadOnly="True"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
+68
-57
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,11 +35,12 @@
|
||||
<RowDefinition Height="60"/>
|
||||
</Grid.RowDefinitions>
|
||||
<DataGrid Grid.Row="0" Grid.Column="0" x:Name="Griddata" AlternationCount="2" IsReadOnly="True"
|
||||
SelectionChanged="Griddata_SelectionChanged"
|
||||
SelectionChanged="Griddata_SelectionChanged" EnableRowVirtualization="True" EnableColumnVirtualization="True"
|
||||
VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling"
|
||||
d:ItemsSource="{d:SampleData ItemCount=999}" AutoGenerateColumns="False" MinColumnWidth="30"
|
||||
ItemsSource="{Binding Path=TechnologicalMachine_View,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
|
||||
Background="White" GridLinesVisibility="All" ColumnHeaderHeight="40" HorizontalContentAlignment="Right"
|
||||
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"
|
||||
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="True"
|
||||
CanUserDeleteRows="False" SelectionMode="Single" FontSize="15" Focusable="True" >
|
||||
<DataGrid.RowStyle >
|
||||
<Style TargetType="{x:Type DataGridRow}">
|
||||
@@ -171,6 +172,8 @@
|
||||
<ColumnDefinition MinWidth="1200"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<DataGrid Grid.Column="2" x:Name="Gridstep" AlternationCount="2" SelectionChanged="Gridstep_SelectionChanged"
|
||||
EnableRowVirtualization="True" EnableColumnVirtualization="True"
|
||||
VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling"
|
||||
d:ItemsSource="{d:SampleData ItemCount=90}" AutoGenerateColumns="False" MinColumnWidth="30"
|
||||
ItemsSource="{Binding Path=TechnologicalProcess_View,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
|
||||
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" Background="White"
|
||||
@@ -309,10 +312,10 @@
|
||||
<TextBlock Grid.Column="0" x:Name="machin_LOG" TextWrapping="Wrap" FontSize="27" VerticalAlignment="Top" Height="40" Background="#FF2793FF" Foreground="White" FontWeight="Bold"/>
|
||||
<Grid Margin="0,40,0,0" Grid.ColumnSpan="2" Grid.Column="0" >
|
||||
<rdp:RemoteDesktopWpf x:Name="rdp" Visibility="Collapsed" />
|
||||
<ContentControl x:Name="Picture" Background="White"/>
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" PanningMode="VerticalOnly">
|
||||
<TextBlock x:Name="log" Text="{Binding Sys_machine}" TextWrapping="Wrap" FontSize="25" Background="White"/>
|
||||
</ScrollViewer>
|
||||
<ContentControl x:Name="Picture" Background="White"/>
|
||||
</Grid>
|
||||
<GridSplitter Grid.Row="0" Grid.Column="1" Width="5" HorizontalAlignment="Center" Background="#FF00204E"/>
|
||||
</Grid>
|
||||
|
||||
+18
-17
@@ -80,6 +80,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
|
||||
private void Griddata_SelectionChanged(object sender, SelectionChangedEventArgs e)//设备列表
|
||||
{
|
||||
if (rdp.IsConnected) rdp.Disconnect();
|
||||
int rownum = Griddata.SelectedIndex;//获取鼠标选中行并定义变量
|
||||
string mac_s = "800";
|
||||
if (rownum != -1)//判断鼠标定位是否有效
|
||||
@@ -141,6 +142,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
|
||||
private void ListViewItem_DyeingMachine(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (rdp.IsConnected)rdp.Disconnect();
|
||||
machines_info = 0;
|
||||
log.Visibility = Visibility.Visible;
|
||||
rdp.Visibility = Visibility.Collapsed;
|
||||
@@ -166,7 +168,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private async void ListViewItem_Screen(object sender, MouseButtonEventArgs e)
|
||||
private void ListViewItem_Screen(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||
string host = drEmployee.Field<string>("IP");
|
||||
@@ -182,27 +184,25 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
log.Visibility = Visibility.Collapsed;
|
||||
Picture.Visibility = Visibility.Collapsed;
|
||||
rdp.Visibility = Visibility.Visible;
|
||||
// RemoteDesktopWpf remoteDesktopWpf = new RemoteDesktopWpf();
|
||||
// Picture.Content = remoteDesktopWpf;
|
||||
if (await PingTest(host))
|
||||
// RemoteDesktopWpf remoteDesktopWpf = new RemoteDesktopWpf();
|
||||
// Picture.Content = remoteDesktopWpf;
|
||||
if (!rdp.IsConnected)
|
||||
{
|
||||
if (!rdp.IsConnected)
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
rdp.VncPort = port;
|
||||
rdp.Passwd = password;
|
||||
rdp.Connect(host, true, false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.ERRDATA(ex);
|
||||
}
|
||||
rdp.VncPort = port;
|
||||
rdp.Passwd = password;
|
||||
rdp.Connect(host, true, false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.ERRDATA(ex);
|
||||
}
|
||||
}
|
||||
}//远程
|
||||
private void ListViewItem_Receipt(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (rdp.IsConnected) rdp.Disconnect();
|
||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||
if (!drEmployee.Field<bool>("Dispense"))
|
||||
{
|
||||
@@ -289,10 +289,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
}//手自动
|
||||
private void ListViewItem_Curve(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (rdp.IsConnected) rdp.Disconnect();
|
||||
log.Visibility = Visibility.Collapsed;
|
||||
rdp.Visibility = Visibility.Collapsed;
|
||||
Picture.Visibility = Visibility.Visible;
|
||||
Picture.Content = new View.CurveDiagram(true, "", "", "", workOrder);
|
||||
Picture.Content = new View.CurveDiagram(false, machine, DateTime.Now.AddHours(-8).ToString("yyyy/MM/dd HH:mm:ss"), DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), workOrder);
|
||||
machines_info = 3;
|
||||
}//曲线
|
||||
|
||||
|
||||
@@ -160,21 +160,24 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
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=i+10)
|
||||
for (var i = 0; i < CDB_Count; i=i+4)
|
||||
{
|
||||
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")));
|
||||
STTA_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STTA")));
|
||||
STLA_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STLA")));
|
||||
STTB_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STTB")));
|
||||
STLB_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STLB")));
|
||||
STTC_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STTC")));
|
||||
STLC_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STLC")));
|
||||
|
||||
try
|
||||
{
|
||||
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")));
|
||||
STTA_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STTA")));
|
||||
STLA_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STLA")));
|
||||
STTB_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STTB")));
|
||||
STLB_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STLB")));
|
||||
STTC_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STTC")));
|
||||
STLC_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STLC")));
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
|
||||
MTT_values = new ObservableCollection<DateTimePoint>(MTT_items);
|
||||
|
||||
Reference in new issue
Block a user