Compare commits

...
4 Commits
2 changed files with 45 additions and 238 deletions

No files matched your search

+26 -186
View File
@@ -2,7 +2,6 @@
using ScottPlot.Plottables; using ScottPlot.Plottables;
using SunlightCentralizedControlManagement_SCCM_.View; using SunlightCentralizedControlManagement_SCCM_.View;
using SunlightCentralizedControlManagement_SCCM_.ViewModel; using SunlightCentralizedControlManagement_SCCM_.ViewModel;
using SunlightCentralizedControlManagement_SCCM_.WindowsView;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
@@ -16,10 +15,8 @@ using System.Windows;
using TouchSocket.Core; using TouchSocket.Core;
using TouchSocket.SerialPorts; using TouchSocket.SerialPorts;
using TouchSocket.Sockets; using TouchSocket.Sockets;
using static OpenTK.Graphics.OpenGL.GL;
using static SkiaSharp.HarfBuzz.SKShaper; using static SkiaSharp.HarfBuzz.SKShaper;
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper; using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
using static SunlightCentralizedControlManagement_SCCM_.ViewModel.MainWindowViewModel;
using static System.Net.Mime.MediaTypeNames; using static System.Net.Mime.MediaTypeNames;
namespace SunlightCentralizedControlManagement_SCCM_.UserClass namespace SunlightCentralizedControlManagement_SCCM_.UserClass
@@ -47,7 +44,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
int contentLength = endIndex - startIndex - 1; int contentLength = endIndex - startIndex - 1;
return contentLength > 0 ? source.Substring(contentStart, contentLength) : string.Empty; return contentLength > 0 ? source.Substring(contentStart, contentLength) : string.Empty;
} }
}//获取字符串指定字符的范围的值 }
public static string PortCOM1 { get; set; } public static string PortCOM1 { get; set; }
public static string PortCOM2 { get; set; } public static string PortCOM2 { get; set; }
@@ -63,17 +60,19 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
portclient.Closed = (client, e) => { return EasyTask.CompletedTask; };//从端口断开连接,当连接不成功时不会触发。 portclient.Closed = (client, e) => { return EasyTask.CompletedTask; };//从端口断开连接,当连接不成功时不会触发。
portclient.Received = (client, e) => portclient.Received = (client, e) =>
{ {
//接受重置事件状态
_responseEvent.Set(); _responseEvent.Set();
string[] sArray = Regex.Split(e.ByteBlock.Span.ToString(Encoding.UTF8), string[] sArray = Regex.Split(e.ByteBlock.Span.ToString(Encoding.UTF8),
@"\n", RegexOptions.IgnoreCase); @"\n", RegexOptions.IgnoreCase);
for (int i = 0; i < sArray.Length; i++) for (int i = 0; i < sArray.Length; i++)
{ {
if (sArray[i].Length>5) if (sArray[i].Length > 5)
{ {
string SYSAPI = sArray[i].Substring(0, 5); string SYSAPI = sArray[i].Substring(0, 5);
string Station = ClipBetween(sArray[i], '[', ']'); string Station = ClipBetween(sArray[i], '[', ']');
string DAT = sArray[i].Substring(sArray[i].IndexOf("]") + 1); string DAT = sArray[i].Substring(sArray[i].IndexOf("]") + 1);
if (SYSAPI == "SC800") if (SYSAPI == "SC800")
{ {
try try
@@ -98,10 +97,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
try try
{ {
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
Dictionary<string, object> _dat; Dictionary<string, object> _dat;
_dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT); _dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 111 } }, MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 111 } },
"WorkOrder ='" + _dat.GetValue("Work").ToString() + "' AND ReDye ='" + _dat.GetValue("ReDye") + "'", null); "WorkOrder ='" + _dat.GetValue("Work") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "'", null);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -112,14 +112,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
try try
{ {
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
Dictionary<string, object> _dat; Dictionary<string, object> _dat;
_dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT); _dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
MainWindowViewModel.SQLiteHelpers.Update("WorkorderSteps", new Dictionary<string, object> { { "Mode", 1 } }, MainWindowViewModel.SQLiteHelpers.Update("WorkorderSteps", new Dictionary<string, object> { { "Mode", 1 } },
"WorkOrder ='" + _dat.GetValue("Work") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "' AND Step ='" + "WorkOrder ='" + _dat.GetValue("Work") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "' AND Step ='" +
_dat.GetValue("Step") + "'", null); _dat.GetValue("Step") + "'", null);
int x = MainWindowViewModel.SQLiteHelpers.ExecuteDataSet("select * from WorkorderSteps where WorkOrder='"+ int x = MainWindowViewModel.SQLiteHelpers.ExecuteDataSet("select * from WorkorderSteps where WorkOrder='" +
_dat.GetValue("Order") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "' AND Mode <> '1'", null).Tables[0].Rows.Count; _dat.GetValue("Work") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "' AND Mode <> '1'", null).Tables[0].Rows.Count;
if (x == 0) if (x == 0)
{ {
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 113 } }, MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 113 } },
@@ -132,6 +133,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
try try
{ {
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
Dictionary<string, object> _dat; Dictionary<string, object> _dat;
_dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT); _dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 101 } }, MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 101 } },
@@ -143,79 +145,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
try try
{ {
Dictionary<string, object> _dat;
_dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
DataTable dataTable = MainWindowViewModel.SQLiteHelpers.ExecuteDataSet("select * from Dyelot where WorkOrder='" +
_dat.GetValue("WorkOrder") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "' AND Step = '"+ _dat.GetValue("Step") + "'", null).Tables[0];
foreach (DataRow sourceRow in dataTable.Rows)
{
lock (MainWindowViewModel.Dyelot_CALL.Rows.SyncRoot)
{
// 创建新行(基于目标表结构)
DataRow newRow = MainWindowViewModel.Dyelot_CALL.NewRow();
// 复制源表中存在的列数据
foreach (DataColumn column in dataTable.Columns)
{
if (MainWindowViewModel.Dyelot_CALL.Columns.Contains(column.ColumnName))
{
newRow[column.ColumnName] = sourceRow[column.ColumnName];
}
}
MainWindowViewModel.Dyelot_CALL.Rows.Add(newRow);
Dictionary<string, object> Product_ = new Dictionary<string, object>();//缓存函数
Product_.Add("State", 202);
Product_.Add("Dyelot", newRow.Field<string>("Dyelot"));
Product_.Add("Step", newRow.Field<int>("Step"));
newRow.BeginEdit();
newRow["State"] = 202;
newRow.EndEdit();
MainWindowViewModel.SQLiteHelpers.InsertData("DyelotHistory", MainWindowViewModel.SQLiteHelpers.ToDictionary(newRow));// 执行插入
int index = MainWindowViewModel.SQLiteHelpers.ExecuteDataSet("select * from Machines where Serial='PORT1' AND Station ='" +
Station + "' ", null).Tables[0].Rows[0].Field<int>("ID");
string dat_ = "SC828[" + Station + "]" + Product_.ToJsonString();
bool exists = stringQueueSerial_1.Any(item => item.ID == index && item.DAT == dat_);
if (!exists)
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = dat_
});
}
}
}
} }
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
}//获取呼叫领料单 }//获取呼叫领料单
else if (SYSAPI == "SC822")
{
try
{
DataTable dataTable = JsonConvert.DeserializeObject<DataTable>(DAT).Copy();//反序列化
System.Windows.Application.Current.Dispatcher.Invoke(() =>
{
UserWorkOrder userWorkOrder = new UserWorkOrder();
userWorkOrder.WorkOrderTable = dataTable;
userWorkOrder.Show();
});
}
catch (Exception)
{
System.Windows.Application.Current.Dispatcher.Invoke(() =>
{
UserInf userInf = new UserInf();
userInf.Inf_DAT = "没有等待中的工艺";
userInf.Show();
userInf.Activate();
});
// LogGing.LogGingDATA("[ERR='" + ex + "']=Exception");
MainWindowViewModel.ERR_c++;
}
}//可用工单
else if (SYSAPI == "SC830") else if (SYSAPI == "SC830")
{ {
try try
@@ -236,7 +168,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
drEmployee["WaterLevel"] = _new.GetValue("MTL"); drEmployee["WaterLevel"] = _new.GetValue("MTL");
drEmployee["Process"] = _new.GetValue("Process"); drEmployee["Process"] = _new.GetValue("Process");
drEmployee["Step"] = _new.GetValue("Step"); drEmployee["Step"] = _new.GetValue("Step");
drEmployee["UserButton"] = _new.GetValue("User"); drEmployee["UserButton"] = _new.GetValue("UserB");
if (_new.GetValue("InfoS").ToString() != "900") if (_new.GetValue("InfoS").ToString() != "900")
{ drEmployee["UserInfoStart"] = _new.GetValue("InfoS"); } { drEmployee["UserInfoStart"] = _new.GetValue("InfoS"); }
drEmployee["UserInfo"] = _new.GetValue("Info"); drEmployee["UserInfo"] = _new.GetValue("Info");
@@ -251,8 +183,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数 Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
Chart_new.Add("WorkOrder", _new.GetValue("Work")); Chart_new.Add("WorkOrder", _new.GetValue("Work"));
Chart_new.Add("Machine", mac); //Chart_new.Add("Machine", mac);
Chart_new.Add("Time", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")); //Chart_new.Add("Time", _new.GetValue("Time"));
Chart_new.Add("MST", _new.GetValue("MST")); Chart_new.Add("MST", _new.GetValue("MST"));
Chart_new.Add("MTT", _new.GetValue("MTT")); Chart_new.Add("MTT", _new.GetValue("MTT"));
Chart_new.Add("MTL", _new.GetValue("MTL")); Chart_new.Add("MTL", _new.GetValue("MTL"));
@@ -268,20 +200,18 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
MainWindowViewModel.SQLiteChartAdress.InsertData("Chart", Chart_new);// 执行插入 MainWindowViewModel.SQLiteChartAdress.InsertData("Chart", Chart_new);// 执行插入
} }
} }
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; catch (Exception ex)
{
LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++;
} }
}//当前信息 }//当前信息
else if (SYSAPI == "SC831") else if (SYSAPI == "SC831")
{ {
try try
{ {
Dictionary<string, object> _dat;
_dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
MainWindowViewModel.dt_TP = MainWindowViewModel.SQLiteHelpers.ExecuteDataSet("select * WorkorderSteps Dyelot where WorkOrder='" +
_dat.GetValue("Work") + "' AND ReDye ='" + _dat.GetValue("Re") + "'", null).Tables[0];
} }
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
}//当前步骤信息 }
else if (SYSAPI == "SC832") else if (SYSAPI == "SC832")
{ {
try try
@@ -294,11 +224,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
try try
{ {
Dictionary<string, object> _dat;
_dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
MonitorView.Product_DAT = MainWindowViewModel.SQLiteHelpers.ExecuteDataSet("select * from Dyelot where WorkOrder='" +
_dat.GetValue("WorkOrder") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "'", null).Tables[0];
MonitorView.Product_bool = true;
} }
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
}//当前领料单信息 }//当前领料单信息
@@ -306,34 +231,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
try try
{ {
Dictionary<string, object> _dat;
_dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
string[] DO = _dat.GetValue("DO").ToString().Split(',');
string[] DQ = _dat.GetValue("DQ").ToString().Split(',');
DataTable dataTable = new DataTable();
dataTable.Columns.Add("ID", Type.GetType("System.String"));
dataTable.Columns.Add("type", Type.GetType("System.String"));
dataTable.Columns.Add("DIO", Type.GetType("System.Bool"));
dataTable.Columns.Add("PLC", Type.GetType("System.String"));
for (int DOi = 0; DOi < DO.Length; DOi++)
{
DataRow newRow = dataTable.NewRow();
newRow["ID"] = DOi+2001;
newRow["type"] = "DO";
newRow["DIO"] = DO[DOi];
newRow["PLC"] = DOi + 2001;
dataTable.Rows.Add(newRow);
}
for (int DQi = 0; DQi < DO.Length; DQi++)
{
DataRow newRow = dataTable.NewRow();
newRow["ID"] = DQi + 3001;
newRow["type"] = "DQ";
newRow["DIO"] = DQ[DQi];
newRow["PLC"] = DQi + 3001;
dataTable.Rows.Add(newRow);
}
MainWindowViewModel.dt_d = dataTable;
} }
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
}//数字开关表 }//数字开关表
@@ -341,34 +238,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
try try
{ {
Dictionary<string, object> _dat;
_dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
string[] AI = _dat.GetValue("DO").ToString().Split(',');
string[] AO = _dat.GetValue("DQ").ToString().Split(',');
DataTable dataTable = new DataTable();
dataTable.Columns.Add("ID", Type.GetType("System.String"));
dataTable.Columns.Add("type", Type.GetType("System.String"));
dataTable.Columns.Add("AIO", Type.GetType("System.Int"));
dataTable.Columns.Add("PLC", Type.GetType("System.String"));
for (int AIi = 0; AIi < AI.Length; AIi++)
{
DataRow newRow = dataTable.NewRow();
newRow["ID"] = AIi + 4001;
newRow["type"] = "DO";
newRow["AIO"] = AI[AIi];
newRow["PLC"] = AIi + 4001;
dataTable.Rows.Add(newRow);
}
for (int AOi = 0; AOi < AO.Length; AOi++)
{
DataRow newRow = dataTable.NewRow();
newRow["ID"] = AOi + 5001;
newRow["type"] = "DQ";
newRow["AIO"] = AO[AOi];
newRow["PLC"] = AOi + 5001;
dataTable.Rows.Add(newRow);
}
MainWindowViewModel.dt_a = dataTable;
} }
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
}//寄存器表 }//寄存器表
@@ -376,23 +245,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
try try
{ {
Dictionary<string, object> _dat;
_dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
string[] M = _dat.GetValue("M").ToString().Split(',');
DataTable dataTable = new DataTable();
dataTable.Columns.Add("ID", Type.GetType("System.String"));
dataTable.Columns.Add("type", Type.GetType("System.String"));
dataTable.Columns.Add("Value", Type.GetType("System.Double"));
dataTable.Columns.Add("PLC", Type.GetType("System.String"));
for (int Mi = 0; Mi < M.Length; Mi++)
{
DataRow newRow = dataTable.NewRow();
newRow["ID"] = Mi + 1001;
newRow["type"] = "M";
newRow["Value"] = M[Mi];
newRow["PLC"] = Mi + 1001;
dataTable.Rows.Add(newRow);
}
} }
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
@@ -425,8 +277,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
try try
{ {
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 109 } },
"WorkOrder ='" + DAT + "'", null);
} }
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
}//发布失败 }//发布失败
@@ -434,21 +285,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
try try
{ {
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 119 } },
"WorkOrder ='" + DAT + "'", null);
} }
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
}//细节错误 }//细节错误
else if (SYSAPI == "SC921")
{
try
{
}
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
}//错误
else if (SYSAPI == "SC980") else if (SYSAPI == "SC980")
{ {
MessageBox.Show(DAT, "SCCM", MessageBoxButton.OK, MessageBoxImage.Question);
} }
} }
} }
@@ -564,8 +407,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
string[] sArray = Regex.Split(e.ByteBlock.Span.ToString(Encoding.UTF8), string[] sArray = Regex.Split(e.ByteBlock.Span.ToString(Encoding.UTF8),
@"\n", RegexOptions.IgnoreCase); @"\n", RegexOptions.IgnoreCase);
return EasyTask.CompletedTask; ; return EasyTask.CompletedTask; ;
}; };
await portclient.SetupAsync(new TouchSocketConfig() await portclient.SetupAsync(new TouchSocketConfig()
@@ -577,7 +418,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
PortName = com,//COM PortName = com,//COM
StopBits = System.IO.Ports.StopBits.One,//停止位 StopBits = System.IO.Ports.StopBits.One,//停止位
}) })
.SetSerialDataHandlingAdapter(() => new PeriodPackageAdapter() { CacheTimeout = TimeSpan.FromMilliseconds(100) }) .SetSerialDataHandlingAdapter(() => new PeriodPackageAdapter() { CacheTimeout = TimeSpan.FromMilliseconds(500) })
.ConfigurePlugins(a => .ConfigurePlugins(a =>
{ {
//a.Add<MyPlugin>(); //a.Add<MyPlugin>();
@@ -602,14 +443,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
try try
{ {
// var t = CRCcheck16.ToCRC16(command); var t = CRCcheck16.ToCRC16(command);
_responseEvent.Reset(); _responseEvent.Reset();
serialPortClients.Send(command); // 发送指令 serialPortClients.Send(command); // 发送指令
// 等待500毫秒或直到收到响应 // 等待500毫秒或直到收到响应
_responseEvent.Wait(TimeSpan.FromMilliseconds(1000)); if (!_responseEvent.Wait(TimeSpan.FromMilliseconds(1000)))
if (!_responseEvent.IsSet)
{ {
//清机台状态 _responseEvent.Set();
//清楚了解状态
string Station = ClipBetween(command, '[', ']'); string Station = ClipBetween(command, '[', ']');
lock (MainWindowViewModel.Machines.Rows.SyncRoot) lock (MainWindowViewModel.Machines.Rows.SyncRoot)
{ {
@@ -634,8 +476,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
} }
} }
} }
// 重置事件状态
_responseEvent.Set();
} }
catch (Exception) { } catch (Exception) { }
} }
+19 -52
View File
@@ -79,7 +79,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
public static string SN_ID; public static string SN_ID;
public static string SN_KEY; public static string SN_KEY;
public static bool DyelotsDispenser; public static bool DyelotsDispenser;
public static SqlConnection conn_SC =new SqlConnection();//数据库 public static SqlConnection conn_SC = new SqlConnection();//数据库
public static SQLiteHelper SQLiteHelpers = null; //定义数据库 public static SQLiteHelper SQLiteHelpers = null; //定义数据库
private BDC_SQL.BDCSqlHelper bDCSqlHelper = new BDC_SQL.BDCSqlHelper(); private BDC_SQL.BDCSqlHelper bDCSqlHelper = new BDC_SQL.BDCSqlHelper();
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径 private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
@@ -258,6 +258,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
dat_.Add("Dye", dataRow["DYELOT"].ToString()); dat_.Add("Dye", dataRow["DYELOT"].ToString());
dat_.Add("Time", dataRow["StepTime"].ToString()); dat_.Add("Time", dataRow["StepTime"].ToString());
dat_.Add("ReDye", dataRow["ReDye"].ToString()); dat_.Add("ReDye", dataRow["ReDye"].ToString());
dat_.Add("Program", dataRow["Program"].ToString());
dat_.Add("Step", dataRow["Step"].ToString()); dat_.Add("Step", dataRow["Step"].ToString());
dat_.Add("StepID", dataRow["StepID"].ToString()); dat_.Add("StepID", dataRow["StepID"].ToString());
dat_.Add("P1", dataRow["Parameter1"].ToString()); dat_.Add("P1", dataRow["Parameter1"].ToString());
@@ -400,6 +401,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
dat_.Add("Dye", dt_temp["DYELOT"].ToString()); dat_.Add("Dye", dt_temp["DYELOT"].ToString());
dat_.Add("STime", dt_temp["StartTime"].ToString()); dat_.Add("STime", dt_temp["StartTime"].ToString());
dat_.Add("Time", dt_temp["Time"].ToString()); dat_.Add("Time", dt_temp["Time"].ToString());
dat_.Add("ReDye", 0);
int index = Convert.ToInt16(Selet_Machines(Machines, "ID", "Name='" + WorkOrderdata_m + "'").ToString()); int index = Convert.ToInt16(Selet_Machines(Machines, "ID", "Name='" + WorkOrderdata_m + "'").ToString());
string dat = "SC810[" + Selet_Machines(Machines, "Station", "ID='" + index + "'") + "]" + dat_.ToJsonString(); string dat = "SC810[" + Selet_Machines(Machines, "Station", "ID='" + index + "'") + "]" + dat_.ToJsonString();
@@ -648,6 +650,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
}); });
} }
} }
Updata_Machines(Machines, "State", "ID='" + MachinesRow["ID"] + "'", "101");
} }
else if (MachinesRow["Serial"].ToString() == "PORT2") else if (MachinesRow["Serial"].ToString() == "PORT2")
{ {
@@ -786,7 +789,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
} }
} }
} }
if ((mac_s == "101") || (mac_s == "201") || (mac_s == "202") || (mac_s == "301") || (mac_s == "309")|| (mac_s == "802"))//获取信息 if ((mac_s == "101") || (mac_s == "201") || (mac_s == "202") || (mac_s == "301") || (mac_s == "309"))//获取信息
{ {
if (MachinesRow["Serial"].ToString() == "PORT1") if (MachinesRow["Serial"].ToString() == "PORT1")
{ {
@@ -1129,24 +1132,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
} }
else else
{//串口 {//串口
int index = Convert.ToInt16(MachinesRow["ID"]);
string dat_ = "SC827[" + MachinesRow["Station"] + "]";
if (MachinesRow["Serial"].ToString() == "PORT1") if (MachinesRow["Serial"].ToString() == "PORT1")
{
bool exists = stringQueueSerial_1.Any(item => item.ID == index && item.DAT == dat_);
if (!exists)
{ {
stringQueueSerial_1.Enqueue(new QueueSerial stringQueueSerial_1.Enqueue(new QueueSerial
{ {
ID = index, ID = Convert.ToInt16(MachinesRow["ID"]),
DAT = dat_ DAT = "SC827[" + MachinesRow["Station"] + "]"
}); });
} }
}
else if (MachinesRow["Serial"].ToString() == "PORT2") else if (MachinesRow["Serial"].ToString() == "PORT2")
{
bool exists = stringQueueSerial_2.Any(item => item.ID == index && item.DAT == dat_);
if (!exists)
{ {
stringQueueSerial_2.Enqueue(new QueueSerial stringQueueSerial_2.Enqueue(new QueueSerial
{ {
@@ -1154,11 +1148,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
DAT = "SC827[" + MachinesRow["Station"] + "]" DAT = "SC827[" + MachinesRow["Station"] + "]"
}); });
} }
}
else if (MachinesRow["Serial"].ToString() == "PORT3") else if (MachinesRow["Serial"].ToString() == "PORT3")
{
bool exists = stringQueueSerial_3.Any(item => item.ID == index && item.DAT == dat_);
if (!exists)
{ {
stringQueueSerial_3.Enqueue(new QueueSerial stringQueueSerial_3.Enqueue(new QueueSerial
{ {
@@ -1166,11 +1156,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
DAT = "SC827[" + MachinesRow["Station"] + "]" DAT = "SC827[" + MachinesRow["Station"] + "]"
}); });
} }
}
else if (MachinesRow["Serial"].ToString() == "PORT4") else if (MachinesRow["Serial"].ToString() == "PORT4")
{
bool exists = stringQueueSerial_4.Any(item => item.ID == index && item.DAT == dat_);
if (!exists)
{ {
stringQueueSerial_4.Enqueue(new QueueSerial stringQueueSerial_4.Enqueue(new QueueSerial
{ {
@@ -1181,7 +1167,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
} }
} }
} }
}
catch (Exception EX) { LogGing.ERRDATA(EX); } catch (Exception EX) { LogGing.ERRDATA(EX); }
/**染机呼叫完成**/ /**染机呼叫完成**/
try try
@@ -1208,57 +1193,39 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
} }
else else
{//串口 {//串口
int index = Convert.ToInt16(MachinesRow["ID"]);
string dat_ = "SC828[" + MachinesRow["Station"] + "]" + Product_.ToJsonString();
if (MachinesRow["Serial"].ToString() == "PORT1") if (MachinesRow["Serial"].ToString() == "PORT1")
{
bool exists = stringQueueSerial_1.Any(item => item.ID == index && item.DAT == dat_);
if (!exists)
{ {
stringQueueSerial_1.Enqueue(new QueueSerial stringQueueSerial_1.Enqueue(new QueueSerial
{ {
ID = index, ID = Convert.ToInt16(MachinesRow["ID"]),
DAT = dat_ DAT = "SC828[" + MachinesRow["Station"] + "]" + Product_.ToJsonString()
}); });
} }
}
else if (MachinesRow["Serial"].ToString() == "PORT2") else if (MachinesRow["Serial"].ToString() == "PORT2")
{
bool exists = stringQueueSerial_2.Any(item => item.ID == index && item.DAT == dat_);
if (!exists)
{ {
stringQueueSerial_2.Enqueue(new QueueSerial stringQueueSerial_2.Enqueue(new QueueSerial
{ {
ID = index, ID = Convert.ToInt16(MachinesRow["ID"]),
DAT = dat_ DAT = "SC828[" + MachinesRow["Station"] + "]" + Product_.ToJsonString()
}); });
} }
}
else if (MachinesRow["Serial"].ToString() == "PORT3") else if (MachinesRow["Serial"].ToString() == "PORT3")
{
bool exists = stringQueueSerial_3.Any(item => item.ID == index && item.DAT == dat_);
if (!exists)
{ {
stringQueueSerial_3.Enqueue(new QueueSerial stringQueueSerial_3.Enqueue(new QueueSerial
{ {
ID = index, ID = Convert.ToInt16(MachinesRow["ID"]),
DAT = dat_ DAT = "SC828[" + MachinesRow["Station"] + "]" + Product_.ToJsonString()
}); });
} }
}
else if (MachinesRow["Serial"].ToString() == "PORT4") else if (MachinesRow["Serial"].ToString() == "PORT4")
{
bool exists = stringQueueSerial_4.Any(item => item.ID == index && item.DAT == dat_);
if (!exists)
{ {
stringQueueSerial_4.Enqueue(new QueueSerial stringQueueSerial_4.Enqueue(new QueueSerial
{ {
ID = index, ID = Convert.ToInt16(MachinesRow["ID"]),
DAT = dat_ DAT = "SC828[" + MachinesRow["Station"] + "]" + Product_.ToJsonString()
}); });
} }
} }
}
if (row["State"].ToString() == "309") if (row["State"].ToString() == "309")
{ {
@@ -1392,7 +1359,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
{ {
await Task.Run(() => await Task.Run(() =>
{ {
while (MachiensPortClient[0].Online ) while (MachiensPortClient[0].Online)
{ {
try try
{ {
@@ -1660,7 +1627,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
public static DataTable dt_TP = new DataTable(); public static DataTable dt_TP = new DataTable();
public static DataTable dt_ParameterSet = new DataTable(); public static DataTable dt_ParameterSet = new DataTable();
public static DataTable dt_SysSet = new DataTable(); public static DataTable dt_SysSet = new DataTable();
public static bool TechnologicalProcess_bool =true; public static bool TechnologicalProcess_bool = true;
// public static bool A_view =true; // public static bool A_view =true;
// public static bool D_view =true; // public static bool D_view =true;
public static bool IO_view; public static bool IO_view;
@@ -1672,8 +1639,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
public static string machin_LOG; public static string machin_LOG;
//通讯队列 //通讯队列
public static UInt32 RX=0; public static UInt32 RX = 0;
public static UInt32 TX=0; public static UInt32 TX = 0;
public class QueueSerial public class QueueSerial
{ {
public int ID { get; set; } public int ID { get; set; }