Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement
This commit is contained in:
commit
8ade983214
5 files changed
+298
-35
No files matched your search
@@ -8,10 +8,10 @@
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="630" d:DesignWidth="1280" VerticalAlignment="Top">
|
||||
<Grid>
|
||||
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,10,0,0" x:Name="comboBoxCOM0" VerticalAlignment="Top" Width="200" SelectionChanged="comboBoxCOM_SelectionChanged" FontSize="16" />
|
||||
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,10,0,0" x:Name="comboBoxCOM0" VerticalAlignment="Top" Width="200" SelectionChanged="comboBoxCOM_SelectionChanged0" FontSize="16" />
|
||||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,10,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.Port}" VerticalAlignment="Top" Width="120" FontSize="25"/>
|
||||
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,50,0,0" x:Name="comboBoxCOM1" VerticalAlignment="Top" Width="200" SelectionChanged="comboBoxCOM_SelectionChanged" FontSize="16"/>
|
||||
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,90,0,0" x:Name="comboBoxCOM2" VerticalAlignment="Top" Width="200" SelectionChanged="comboBoxCOM_SelectionChanged" FontSize="16"/>
|
||||
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,50,0,0" x:Name="comboBoxCOM1" VerticalAlignment="Top" Width="200" SelectionChanged="comboBoxCOM_SelectionChanged1" FontSize="16"/>
|
||||
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,90,0,0" x:Name="comboBoxCOM2" VerticalAlignment="Top" Width="200" SelectionChanged="comboBoxCOM_SelectionChanged2" FontSize="16"/>
|
||||
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,130,0,0" x:Name="comboBoxLanguage" VerticalAlignment="Top" Width="200" SelectionChanged="comboBoxLanguage_SelectionChanged" FontSize="16"/>
|
||||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,130,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.Language}" VerticalAlignment="Top" Width="120" FontSize="25"/>
|
||||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,170,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.SERVER}" VerticalAlignment="Top" Width="120" FontSize="25"/>
|
||||
|
||||
@@ -30,14 +30,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
InitializeComponent();
|
||||
// 获取所有可用串口端口,并添加到comboBoxCOM
|
||||
string[] ports = System.IO.Ports.SerialPort.GetPortNames();
|
||||
ports.Append("COM");
|
||||
comboBoxCOM0.ItemsSource = ports;
|
||||
comboBoxCOM0.Text = Configini.IniReadvalue("SYS", "COM");
|
||||
comboBoxCOM0.Text = Configini.IniReadvalue("SYS", "COMP1");
|
||||
|
||||
comboBoxCOM1.ItemsSource = ports;
|
||||
comboBoxCOM1.Text = Configini.IniReadvalue("SYS", "COM");
|
||||
comboBoxCOM1.Text = Configini.IniReadvalue("SYS", "COMP2");
|
||||
|
||||
comboBoxCOM2.ItemsSource = ports;
|
||||
comboBoxCOM2.Text = Configini.IniReadvalue("SYS", "COM");
|
||||
comboBoxCOM2.Text = Configini.IniReadvalue("SYS", "COMP3");
|
||||
|
||||
string[] Language = {"en-US","zh-CN","zh-TW" };
|
||||
string[] SQMOD = { "Windows Authentication", "SQL SERVER"};
|
||||
@@ -61,13 +62,24 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
private UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "SCCM.ini");
|
||||
private SpeechSynthesizer synth = new SpeechSynthesizer();//语音
|
||||
|
||||
private void comboBoxCOM_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
private void comboBoxCOM_SelectionChanged0(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
Configini.IniWritevalue("SYS", "COM0", comboBoxCOM0.SelectedValue.ToString());
|
||||
Configini.IniWritevalue("SYS", "COM1", comboBoxCOM1.SelectedValue.ToString());
|
||||
Configini.IniWritevalue("SYS", "COM2", comboBoxCOM2.SelectedValue.ToString());
|
||||
Configini.IniWritevalue("SYS", "COMP0", comboBoxCOM0.SelectedValue.ToString());
|
||||
// Configini.IniWritevalue("SYS", "COMP1", comboBoxCOM1.SelectedValue.ToString());
|
||||
// Configini.IniWritevalue("SYS", "COMP2", comboBoxCOM2.SelectedValue.ToString());
|
||||
}
|
||||
private void comboBoxCOM_SelectionChanged1(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
//Configini.IniWritevalue("SYS", "COMP0", comboBoxCOM0.SelectedValue.ToString());
|
||||
Configini.IniWritevalue("SYS", "COMP1", comboBoxCOM1.SelectedValue.ToString());
|
||||
// Configini.IniWritevalue("SYS", "COMP2", comboBoxCOM2.SelectedValue.ToString());
|
||||
}
|
||||
private void comboBoxCOM_SelectionChanged2(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
//Configini.IniWritevalue("SYS", "COMP0", comboBoxCOM0.SelectedValue.ToString());
|
||||
// Configini.IniWritevalue("SYS", "COMP1", comboBoxCOM1.SelectedValue.ToString());
|
||||
Configini.IniWritevalue("SYS", "COMP2", comboBoxCOM2.SelectedValue.ToString());
|
||||
}
|
||||
|
||||
private void comboBoxLanguage_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
Configini.IniWritevalue("SYS", "Language", comboBoxLanguage.SelectedValue.ToString());
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
<DataGridTextColumn Binding="{Binding IP}" Width="0" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Binding="{Binding PORT}" Width="0" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Binding="{Binding Serial}" Width="0" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Binding="{Binding Baud}" Width="0" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Binding="{Binding Station}" Width="0" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Binding="{Binding ID}" Width="0" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Binding="{Binding Type}" Width="0" IsReadOnly="True"/>
|
||||
</DataGrid.Columns>
|
||||
@@ -81,7 +81,7 @@
|
||||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,150,0,0" TextWrapping="Wrap" Text="IP/PORT" VerticalAlignment="Top" Width="120" FontSize="25"/>
|
||||
<ComboBox HorizontalAlignment="Left" Height="40" Margin="150,200,0,0" x:Name="comboBoxCOM0" VerticalAlignment="Top" Width="200" FontSize="20" />
|
||||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,200,0,0" TextWrapping="Wrap" Text="COM" VerticalAlignment="Top" Width="120" FontSize="25"/>
|
||||
<TextBox HorizontalAlignment="Left" Height="40" Margin="360,200,0,0" x:Name="BAUD" VerticalAlignment="Top" Width="60" FontSize="20" MaxLines="1" Text="57600"/>
|
||||
<TextBox HorizontalAlignment="Left" Height="40" Margin="360,200,0,0" x:Name="Station" VerticalAlignment="Top" Width="60" FontSize="20" MaxLines="1" Text="00"/>
|
||||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="350,200,0,0" TextWrapping="Wrap" Text=":" VerticalAlignment="Top" Width="20" FontSize="25"/>
|
||||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,250,0,0" x:Name="textlog" TextWrapping="Wrap" Text="------------" VerticalAlignment="Top" Width="140" FontSize="20"/>
|
||||
<Button Content="{x:Static lang:Resources.Save}" HorizontalAlignment="Left" Height="35" Margin="250,250,0,5" VerticalAlignment="Top" Width="80" Click="Save_Click"/>
|
||||
|
||||
@@ -35,7 +35,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
InitializeComponent();
|
||||
|
||||
// 获取所有可用串口端口,并添加到comboBoxCOM
|
||||
string[] ports = System.IO.Ports.SerialPort.GetPortNames();
|
||||
// string[] ports = System.IO.Ports.SerialPort.GetPortNames();
|
||||
string[] ports = { "PORT1", "PORT2", "PORT3" };
|
||||
comboBoxCOM0.ItemsSource = ports;
|
||||
comboBoxCOM0.Text = Configini.IniReadvalue("SYS", "COM");
|
||||
comboBoxMachine.ItemsSource = MainWindowViewModel.Machines.AsEnumerable().Select(rowdata => rowdata.Field<string>("name")).ToList();//转换机台
|
||||
@@ -64,7 +65,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
IP.Text = (Griddata.Columns[3].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;//定位第列,
|
||||
PORT.Text = (Griddata.Columns[4].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;//定位第列,
|
||||
comboBoxCOM0.Text = (Griddata.Columns[5].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;//定位第列,
|
||||
BAUD.Text = (Griddata.Columns[6].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;//定位第列,
|
||||
Station.Text = (Griddata.Columns[6].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;//定位第列,
|
||||
comboBoxtype.Text = (Griddata.Columns[8].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;
|
||||
}
|
||||
}
|
||||
@@ -86,7 +87,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
dat_["PORT"] = PORT.Text;
|
||||
dat_["Serial"] = comboBoxCOM0.Text;
|
||||
dat_["Type"] = comboBoxtype.Text;
|
||||
dat_["Baud"] = BAUD.Text;
|
||||
dat_["Station"] = Station.Text;
|
||||
dat_["ID"] = 999;
|
||||
dat_["ERR"] = false;
|
||||
dat_["AUTO"] = false;
|
||||
@@ -106,7 +107,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
Machines_DAT.Add("IP", MainWindowViewModel.Machines.Rows[x]["IP"]);
|
||||
Machines_DAT.Add("PORT", MainWindowViewModel.Machines.Rows[x]["PORT"]);
|
||||
Machines_DAT.Add("Serial", MainWindowViewModel.Machines.Rows[x]["Serial"]);
|
||||
Machines_DAT.Add("Baud", MainWindowViewModel.Machines.Rows[x]["Baud"]);
|
||||
Machines_DAT.Add("Station", MainWindowViewModel.Machines.Rows[x]["Station"]);
|
||||
Machines_DAT.Add("Groups", MainWindowViewModel.Machines.Rows[x]["Groups"]);
|
||||
Machines_DAT.Add("Desktop", MainWindowViewModel.Machines.Rows[x]["Desktop"]);
|
||||
Machines_DAT.Add("Dispense", MainWindowViewModel.Machines.Rows[x]["Dispense"]);
|
||||
@@ -125,7 +126,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
dr["PORT"] = PORT.Text;
|
||||
dr["Serial"] = comboBoxCOM0.Text;
|
||||
dr["Type"] = comboBoxtype.Text;
|
||||
dr["Baud"] = BAUD.Text;
|
||||
dr["Station"] = Station.Text;
|
||||
dr.EndEdit();
|
||||
SQLiteHelpers.Delete("Machines", null, null);//
|
||||
for (int x = 0; x < MainWindowViewModel.Machines.Rows.Count; x++)
|
||||
@@ -135,7 +136,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
Machines_DAT.Add("IP", MainWindowViewModel.Machines.Rows[x]["IP"]);
|
||||
Machines_DAT.Add("PORT", MainWindowViewModel.Machines.Rows[x]["PORT"]);
|
||||
Machines_DAT.Add("Serial", MainWindowViewModel.Machines.Rows[x]["Serial"]);
|
||||
Machines_DAT.Add("Baud", MainWindowViewModel.Machines.Rows[x]["Baud"]);
|
||||
Machines_DAT.Add("Station", MainWindowViewModel.Machines.Rows[x]["Station"]);
|
||||
Machines_DAT.Add("Groups", MainWindowViewModel.Machines.Rows[x]["Groups"]);
|
||||
Machines_DAT.Add("Desktop", MainWindowViewModel.Machines.Rows[x]["Desktop"]);
|
||||
Machines_DAT.Add("Dispense", MainWindowViewModel.Machines.Rows[x]["Dispense"]);
|
||||
@@ -152,7 +153,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
IP.Text = null;
|
||||
PORT.Text = "7789";
|
||||
comboBoxCOM0.Text = null;
|
||||
BAUD.Text = "57600";
|
||||
Station.Text = "00";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -182,7 +183,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
Machines_DAT.Add("IP", MainWindowViewModel.Machines.Rows[x]["IP"]);
|
||||
Machines_DAT.Add("PORT", MainWindowViewModel.Machines.Rows[x]["PORT"]);
|
||||
Machines_DAT.Add("Serial", MainWindowViewModel.Machines.Rows[x]["Serial"]);
|
||||
Machines_DAT.Add("Baud", MainWindowViewModel.Machines.Rows[x]["Baud"]);
|
||||
Machines_DAT.Add("Station", MainWindowViewModel.Machines.Rows[x]["Station"]);
|
||||
Machines_DAT.Add("Groups", MainWindowViewModel.Machines.Rows[x]["Groups"]);
|
||||
Machines_DAT.Add("Desktop", MainWindowViewModel.Machines.Rows[x]["Desktop"]);
|
||||
Machines_DAT.Add("Dispense", MainWindowViewModel.Machines.Rows[x]["Dispense"]);
|
||||
@@ -218,7 +219,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
{
|
||||
if (comboBoxtype.Text == "828")
|
||||
{
|
||||
if (!string.IsNullOrEmpty(comboBoxCOM0.Text) && !string.IsNullOrEmpty(BAUD.Text))
|
||||
if (!string.IsNullOrEmpty(comboBoxCOM0.Text) && !string.IsNullOrEmpty(Station.Text))
|
||||
{
|
||||
textlog.Text = "TEST";
|
||||
textlog.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 255));
|
||||
|
||||
@@ -16,8 +16,10 @@ using System.Data;
|
||||
using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder;
|
||||
using System.Data.SqlClient;
|
||||
using System.Diagnostics.Eventing.Reader;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Speech.Synthesis;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
@@ -84,6 +86,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
public static DataTable Whole_dat = new DataTable();
|
||||
public static UserControls.info[] inf = new UserControls.info[999]; //定义总览信息卡
|
||||
public static int ERR_c = 0;//错误计数器
|
||||
public bool UPort1, UPort2, UPort3;
|
||||
public static bool[] USER_Capacity { set; get; } = new bool[99];
|
||||
|
||||
public MainWindowViewModel()
|
||||
@@ -113,6 +116,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
Whole_dat.Columns.Add("DAT", Type.GetType("System.Double"));
|
||||
|
||||
USERCapacity(App.USER_Purview);//App.USER_Purview);
|
||||
UPort();//启动串口
|
||||
CountDown();
|
||||
TcpClientNEW();
|
||||
SQL_LINK();
|
||||
@@ -143,6 +147,113 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public static SerialPort port1 = new SerialPort();//创建串口
|
||||
public static SerialPort port2 = new SerialPort();//创建串口
|
||||
public static SerialPort port3 = new SerialPort();//创建串口
|
||||
void UPort()
|
||||
{
|
||||
try
|
||||
{
|
||||
int Ba = 9600;
|
||||
try { Ba = Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD1")); }
|
||||
catch (Exception) { Ba = 9600; }
|
||||
port1.PortName = Configini.IniReadvalue("SYS", "COMP1");
|
||||
port1.BaudRate = Ba;//配置
|
||||
port1.DataBits = 8;
|
||||
port1.Parity = Parity.Even;
|
||||
port1.StopBits = StopBits.One;
|
||||
port1.ReadTimeout = 500;
|
||||
port1.WriteTimeout = 500;
|
||||
port1.Open();//打开串口
|
||||
UPort1 = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UPort1 = false;
|
||||
LogGing.LogGingDATA(e.Message);
|
||||
}
|
||||
try
|
||||
{
|
||||
int Ba2 = 9600;
|
||||
try { Ba2 = Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD1")); }
|
||||
catch (Exception) { Ba2 = 9600; }
|
||||
port2.PortName = Configini.IniReadvalue("SYS", "COMP2");
|
||||
port2.BaudRate = Ba2;//配置
|
||||
port2.DataBits = 8;
|
||||
port2.Parity = Parity.Even;
|
||||
port2.StopBits = StopBits.One;
|
||||
port2.ReadTimeout = 500;
|
||||
port2.WriteTimeout = 500;
|
||||
port2.Open();//打开串口
|
||||
UPort2 = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UPort2 = false;
|
||||
LogGing.LogGingDATA(e.Message);
|
||||
}
|
||||
try
|
||||
{
|
||||
int Ba3 = 9600;
|
||||
try { Ba3 = Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD1")); }
|
||||
catch (Exception) { Ba3 = 9600; }
|
||||
port3.PortName = Configini.IniReadvalue("SYS", "COMP3");
|
||||
port3.BaudRate = Ba3;//配置
|
||||
port3.DataBits = 8;
|
||||
port3.Parity = Parity.Even;
|
||||
port3.StopBits = StopBits.One;
|
||||
port3.ReadTimeout = 500;
|
||||
port3.WriteTimeout = 500;
|
||||
port3.Open();//打开串口
|
||||
UPort3 = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UPort3 = false;
|
||||
LogGing.LogGingDATA(e.Message);
|
||||
}
|
||||
}//ck
|
||||
private async void Port_link()
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (stringQueueSerial.Count > 0) //信息发送队列
|
||||
{
|
||||
QueueSerial t = stringQueueSerial.Dequeue();
|
||||
if (t.ID == "PORT1")
|
||||
{
|
||||
if (UPort1)
|
||||
{
|
||||
port1.Write(t.DAT);
|
||||
}
|
||||
}
|
||||
else if (t.ID == "PORT2")
|
||||
{
|
||||
if (UPort2)
|
||||
{
|
||||
port2.Write(t.DAT);
|
||||
}
|
||||
}
|
||||
else if (t.ID == "PORT3")
|
||||
{
|
||||
if (UPort3)
|
||||
{
|
||||
port3.Write(t.DAT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
finally
|
||||
{
|
||||
Port_link();
|
||||
}
|
||||
});
|
||||
}//发送
|
||||
public async void SQL_LINK()//连接dbc数据库
|
||||
{
|
||||
if (conn_SC.State == ConnectionState.Open) conn_SC.Close();
|
||||
@@ -214,6 +325,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
DataTable WorkOrderstepdata = WorkOrderSQL.ExecuteDataSet("select * from WorkOrder where State='111' or State='112'" +
|
||||
"AND EndTime >'" + DateTime.Now.AddHours(-8).ToString("yyyy/MM/dd HH:mm:ss") + "'", null).Tables[0]; //读取表写入缓存
|
||||
for (int k = 0; k < WorkOrderstepdata.Rows.Count; k++)
|
||||
{
|
||||
if (Selet_Machines(Machines, "Type", "ID='" + k + "'").ToString() == "838")
|
||||
{
|
||||
string WorkOrderdata_m = WorkOrderstepdata.Select()[k].Field<object>("Machines").ToString();
|
||||
DataTable dataTable = WorkOrderSQL.ExecuteDataSet("select * from WorkorderSteps where WorkOrder='" +
|
||||
@@ -227,10 +340,17 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
WorkOrderSQL.Update("WorkOrder", new Dictionary<string, object> { { "State", 112 } },
|
||||
"WorkOrder ='" + WorkOrderstepdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null);
|
||||
}
|
||||
else if (Selet_Machines(Machines, "Type", "ID='" + k + "'").ToString() == "828")
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
/*下传工单总览*/
|
||||
DataTable WorkOrderdata = WorkOrderSQL.ExecuteDataSet("select * from WorkOrder where State='100' or State='110'" +
|
||||
"AND EndTime >'" + DateTime.Now.AddHours(-8).ToString("yyyy/MM/dd HH:mm:ss") + "'", null).Tables[0]; //读取表写入缓存
|
||||
for (int k = 0; k < WorkOrderdata.Rows.Count; k++)
|
||||
{
|
||||
if (Selet_Machines(Machines, "Type", "ID='" + k + "'").ToString() == "838")
|
||||
{
|
||||
string WorkOrderdata_m = WorkOrderdata.Select()[k].Field<object>("Machines").ToString();
|
||||
string State = Selet_Machines(Machines, "State", "Name='" + WorkOrderdata_m + "'").ToString();
|
||||
@@ -251,24 +371,43 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
ID = index,
|
||||
DAT = "SC810" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + DataTableToDictionary(dataTable).ToJsonString()
|
||||
});
|
||||
DataTable WorkOrderset = WorkOrderSQL.ExecuteDataSet("select * from WorkOrderSet where WorkOrder='" +
|
||||
dt_temp["WorkOrder"] + "'", null).Tables[0]; //读取表写入缓存
|
||||
if (WorkOrderset.Rows.Count > 0) {
|
||||
stringQueue.Enqueue(new QueueString
|
||||
{
|
||||
ID = index,
|
||||
DAT = "SC812" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + DataTableToDictionary(WorkOrderset).ToJsonString()
|
||||
});
|
||||
}
|
||||
|
||||
WorkOrderSQL.Update("WorkOrder", new Dictionary<string, object> { { "State", 110 } },
|
||||
"WorkOrder ='" + WorkOrderdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null);
|
||||
}
|
||||
}
|
||||
else if (Selet_Machines(Machines, "Type", "ID='" + k + "'").ToString() == "828")
|
||||
{
|
||||
string WorkOrderdata_m = WorkOrderdata.Select()[k].Field<object>("Machines").ToString();
|
||||
string State = Selet_Machines(Machines, "State", "Name='" + WorkOrderdata_m + "'").ToString();
|
||||
string POR = Selet_Machines(Machines, "Serial", "ID='" + k + "'").ToString();
|
||||
|
||||
if ((State == "101") || (State == "201") || (State == "202") || (State == "309"))
|
||||
{
|
||||
DataTable dataTable = WorkOrderdata.Clone();
|
||||
// WorkOrderdata.Columns.Remove("Machines");
|
||||
DataRow dt_temp = WorkOrderdata.Select()[k];
|
||||
dt_temp.BeginEdit();
|
||||
dt_temp["State"] = "101";
|
||||
dt_temp.EndEdit();
|
||||
dataTable.Rows.Add(dt_temp.ItemArray);
|
||||
|
||||
int index = Convert.ToInt16(Selet_Machines(Machines, "ID", "Name='" + WorkOrderdata_m + "'").ToString());
|
||||
stringQueueSerial.Enqueue(new QueueSerial
|
||||
{
|
||||
ID = POR,
|
||||
DAT = "SC810" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + DataTableToDictionary(dataTable).ToJsonString()
|
||||
});
|
||||
WorkOrderSQL.Update("WorkOrder", new Dictionary<string, object> { { "State", 110 } },
|
||||
"WorkOrder ='" + WorkOrderdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*下传工单设置*/
|
||||
DataTable WorkOrderset_ = WorkOrderSQL.ExecuteDataSet("select * from WorkOrder where State='113'"+
|
||||
"AND EndTime >'" + DateTime.Now.AddHours(-8).ToString("yyyy/MM/dd HH:mm:ss") + "'", null).Tables[0]; //读取表写入缓存
|
||||
for (int k = 0; k < WorkOrderset_.Rows.Count; k++)
|
||||
{
|
||||
if (Selet_Machines(Machines, "Type", "ID='" + k + "'").ToString() == "838")
|
||||
{
|
||||
string WorkOrderset_m = WorkOrderset_.Select()[k].Field<object>("Machines").ToString();
|
||||
string WorkOrderset_w = WorkOrderset_.Select()[k].Field<object>("WorkOrder").ToString();
|
||||
@@ -288,12 +427,37 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
WorkOrderSQL.Update("WorkOrder", new Dictionary<string, object> { { "State", 110 } },
|
||||
"WorkOrder ='" + WorkOrderdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null);
|
||||
}
|
||||
else if (Selet_Machines(Machines, "Type", "ID='" + k + "'").ToString() == "828")
|
||||
{
|
||||
string WorkOrderset_m = WorkOrderset_.Select()[k].Field<object>("Machines").ToString();
|
||||
string WorkOrderset_w = WorkOrderset_.Select()[k].Field<object>("WorkOrder").ToString();
|
||||
string POR = Selet_Machines(Machines, "Serial", "ID='" + k + "'").ToString();
|
||||
|
||||
DataTable WorkOrder_set = WorkOrderSQL.ExecuteDataSet("select * from WorkOrderSet where WorkOrder='" +
|
||||
WorkOrderset_w + "'", null).Tables[0]; //读取表写入缓存
|
||||
if (WorkOrder_set.Rows.Count > 0)
|
||||
{
|
||||
stringQueueSerial.Enqueue(new QueueSerial
|
||||
{
|
||||
ID = POR,
|
||||
DAT = "SC812[" +
|
||||
Selet_Machines(Machines, "Station", "ID='" + k + "'") + "]" +
|
||||
DataTableToDictionary(WorkOrder_set).ToJsonString()
|
||||
});
|
||||
}
|
||||
WorkOrderSQL.Update("WorkOrder", new Dictionary<string, object> { { "State", 110 } },
|
||||
"WorkOrder ='" + WorkOrderdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null);
|
||||
|
||||
}
|
||||
}
|
||||
WorkOrderSQL.Close();
|
||||
|
||||
//系统时间
|
||||
Sys_Time = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||||
//更新机台状态与发送指令
|
||||
for (int i = 0; i < Machinesdata_Count; i++)
|
||||
{
|
||||
if (Selet_Machines(Machines, "Type", "ID='" + i + "'").ToString() == "838")
|
||||
{
|
||||
if (Selet_Machines(Machines, "State", "ID='" + i + "'").ToString() == "802")
|
||||
{
|
||||
@@ -350,6 +514,72 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
});//信息插入队列
|
||||
}
|
||||
}
|
||||
else if (Selet_Machines(Machines, "Type", "ID='" + i + "'").ToString() == "828")
|
||||
{
|
||||
if (Selet_Machines(Machines, "State", "ID='" + i + "'").ToString() == "800")
|
||||
{//串口发送
|
||||
string POR = Selet_Machines(Machines, "Serial", "ID='" + i + "'").ToString();
|
||||
|
||||
stringQueueSerial.Enqueue(new QueueSerial
|
||||
{
|
||||
ID = POR,
|
||||
DAT = "SC830[" +
|
||||
Selet_Machines(Machines, "Station", "ID='" + i + "'") + "]"
|
||||
});
|
||||
|
||||
bool mode = Machines.Select("ID='" + i + "'").First().Field<bool>("LOCK");//发送锁定状态
|
||||
if (mode)
|
||||
{
|
||||
Dictionary<string, object> dat_829 = new Dictionary<string, object>();
|
||||
dat_829.Clear();
|
||||
dat_829.Add("NAME", "LOCK");
|
||||
dat_829.Add("VALUE", "True");
|
||||
DataRow drEmployee = Machines.Select("ID='" + i + "'").First();
|
||||
stringQueueSerial.Enqueue(new QueueSerial
|
||||
{
|
||||
ID = POR,
|
||||
DAT = "SC829[" +
|
||||
Selet_Machines(Machines, "Station", "ID='" + i + "'") + "]" +
|
||||
dat_829.ToJsonString()
|
||||
});
|
||||
}
|
||||
|
||||
Updata_Machines(Machines, "State", "ID='" + i + "'", "101");
|
||||
}
|
||||
|
||||
int m_run = (int)Selet_Machines(Machines, "WORK_RUN", "ID='" + i + "'");
|
||||
if (m_run == 0)
|
||||
{
|
||||
Updata_Machines(Machines, "State", "ID='" + i + "'", "101");//停止状态
|
||||
}
|
||||
else if (m_run == 1)
|
||||
{
|
||||
Updata_Machines(Machines, "State", "ID='" + i + "'", "101");//暂停状态
|
||||
}
|
||||
else if (m_run == 2)
|
||||
{
|
||||
Updata_Machines(Machines, "State", "ID='" + i + "'", "202");//运行
|
||||
}
|
||||
|
||||
if ((bool)Selet_Machines(Machines, "ERR", "ID='" + i + "'"))
|
||||
{
|
||||
Updata_Machines(Machines, "State", "ID='" + i + "'", "309");//错误
|
||||
}
|
||||
|
||||
string mac_s = Selet_Machines(Machines, "State", "ID='" + i + "'").ToString();
|
||||
if ((mac_s == "101") || (mac_s == "201") || (mac_s == "202") || (mac_s == "301") || (mac_s == "309"))//获取信息
|
||||
{
|
||||
string POR = Selet_Machines(Machines, "Serial", "ID='" + i + "'").ToString();
|
||||
stringQueueSerial.Enqueue(new QueueSerial
|
||||
{
|
||||
ID = POR,
|
||||
DAT = "SC830[" +
|
||||
Selet_Machines(Machines, "Station", "ID='" + i + "'") + "]"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Time5 > 5)
|
||||
{
|
||||
Tick_Event_5S();
|
||||
@@ -399,6 +629,19 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
try
|
||||
{
|
||||
if ((bool)Selet_Machines(Machines, "CALL", "ID='" + i + "'"))
|
||||
{
|
||||
if (Selet_Machines(Machines, "Type", "ID='" + i + "'").ToString() == "828")
|
||||
{
|
||||
string POR = Selet_Machines(Machines, "Serial", "ID='" + i + "'").ToString();
|
||||
|
||||
stringQueueSerial.Enqueue(new QueueSerial
|
||||
{
|
||||
ID = POR,
|
||||
DAT = "SC827[" +
|
||||
Selet_Machines(Machines, "Station", "ID='" + i + "'") + "]"
|
||||
});
|
||||
}
|
||||
else if (Selet_Machines(Machines, "Type", "ID='" + i + "'").ToString() == "838")
|
||||
{
|
||||
stringQueue.Enqueue(new QueueString
|
||||
{
|
||||
@@ -407,6 +650,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception EX) { LogGing.ERRDATA(EX); }
|
||||
try
|
||||
{//处理呼叫请求列表完成发送后(202》203)
|
||||
@@ -628,11 +872,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
Product_.Add("Amount", row.Field<object>("Amount"));
|
||||
Product_.Add("DispenseEndTime", row.Field<object>("DispenseEndTime"));
|
||||
|
||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||
stringQueue.Enqueue(new QueueString
|
||||
{
|
||||
ID = Convert.ToInt16(MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines,
|
||||
ID = Convert.ToInt16(Selet_Machines(Machines,
|
||||
"ID", "Name='" + row.Field<string>("Machine") + "'")),
|
||||
DAT = "SC828" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines,
|
||||
DAT = "SC828" + Selet_Machines(Machines,
|
||||
"SYSKEY", "Name='" + row.Field<string>("Machine") + "'") + Product_.ToJsonString()
|
||||
});
|
||||
if (row["State"].ToString() == "309")
|
||||
@@ -772,6 +1016,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
//通讯队列
|
||||
public static UInt32 RX=0;
|
||||
public static UInt32 TX=0;
|
||||
public class QueueSerial
|
||||
{
|
||||
public string ID { get; set; }
|
||||
public string DAT { get; set; }
|
||||
}
|
||||
public class QueueString
|
||||
{
|
||||
public int ID { get; set; }
|
||||
@@ -785,6 +1034,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
// 创建一个字符串类型的队列
|
||||
public static Queue<QueueString> stringQueue = new Queue<QueueString>();
|
||||
public static Queue<QueueString> stringQueueinf = new Queue<QueueString>();
|
||||
public static Queue<QueueSerial> stringQueueSerial = new Queue<QueueSerial>();
|
||||
|
||||
/// <summary>
|
||||
/// 将 DataTable 转换为 Dictionary 类型数据
|
||||
|
||||
Reference in new issue
Block a user