部分数据库及串口逻辑修改
This commit is contained in:
commit
48eb8a0ad1
4 files changed
+381
-104
No files matched your search
@@ -480,9 +480,6 @@
|
|||||||
<PackageReference Include="MaterialDesignThemes">
|
<PackageReference Include="MaterialDesignThemes">
|
||||||
<Version>5.2.1</Version>
|
<Version>5.2.1</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.Web.WebView2">
|
|
||||||
<Version>1.0.3405.78</Version>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="NModbus">
|
<PackageReference Include="NModbus">
|
||||||
<Version>3.0.81</Version>
|
<Version>3.0.81</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|||||||
@@ -1,27 +1,54 @@
|
|||||||
using ScottPlot.Plottables;
|
using Newtonsoft.Json;
|
||||||
|
using ScottPlot.Plottables;
|
||||||
|
using SunlightCentralizedControlManagement_SCCM_.View;
|
||||||
|
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
using TouchSocket.Core;
|
using TouchSocket.Core;
|
||||||
using TouchSocket.SerialPorts;
|
using TouchSocket.SerialPorts;
|
||||||
using TouchSocket.Sockets;
|
using TouchSocket.Sockets;
|
||||||
using static SkiaSharp.HarfBuzz.SKShaper;
|
using static SkiaSharp.HarfBuzz.SKShaper;
|
||||||
|
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
||||||
|
using static System.Net.Mime.MediaTypeNames;
|
||||||
|
|
||||||
namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||||
{
|
{
|
||||||
public class AsyncSerialPortClient
|
public class AsyncSerialPortClient
|
||||||
{
|
{
|
||||||
|
public static string ClipBetween(string source, char startChar, char endChar, bool includeBounds = false)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(source))
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
|
int startIndex = source.IndexOf(startChar);
|
||||||
|
if (startIndex == -1) return string.Empty;
|
||||||
|
|
||||||
|
int endIndex = source.IndexOf(endChar, startIndex + 1);
|
||||||
|
if (endIndex == -1) return string.Empty;
|
||||||
|
|
||||||
|
if (includeBounds)
|
||||||
|
{
|
||||||
|
return source.Substring(startIndex, endIndex - startIndex + 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int contentStart = startIndex + 1;
|
||||||
|
int contentLength = endIndex - startIndex - 1;
|
||||||
|
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; }
|
||||||
public static string PortCOM3 { get; set; }
|
public static string PortCOM3 { get; set; }
|
||||||
public static string PortCOM4 { get; set; }
|
public static string PortCOM4 { get; set; }
|
||||||
public static void SCAPI(string dat)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async Task PortClient(SerialPortClient portclient, string com, int BAUD)
|
public static async Task PortClient(SerialPortClient portclient, string com, int BAUD)
|
||||||
{
|
{
|
||||||
@@ -33,11 +60,207 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
portclient.Received = (client, e) =>
|
portclient.Received = (client, e) =>
|
||||||
{
|
{
|
||||||
_responseEvent.Set();
|
_responseEvent.Set();
|
||||||
string DAT = e.ByteBlock.Span.ToString(Encoding.UTF8);
|
string[] sArray = Regex.Split(e.ByteBlock.Span.ToString(Encoding.UTF8),
|
||||||
SCAPI(DAT);
|
@"\n", RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
|
for (int i = 0; i < sArray.Length; i++)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(sArray[i]))
|
||||||
|
{
|
||||||
|
string SYSAPI = sArray[i].Substring(0, 5);
|
||||||
|
string Station = ClipBetween(sArray[i], '[', ']');
|
||||||
|
string DAT = sArray[i].Substring(sArray[i].IndexOf("]") + 1);
|
||||||
|
if (SYSAPI == "SC800")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Dictionary<string, object> _new = new Dictionary<string, object>();//缓存函数
|
||||||
|
_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
|
||||||
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" +
|
||||||
|
Station + "' AND Serial = 'PORT1'").First();
|
||||||
|
drEmployee.BeginEdit();
|
||||||
|
drEmployee["State"] = "802";
|
||||||
|
drEmployee.EndEdit();
|
||||||
|
drEmployee.AcceptChanges();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (SYSAPI == "SC810")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 111 } },
|
||||||
|
"WorkOrder ='" + DAT + "'", null);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (SYSAPI == "SC811")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 113 } },
|
||||||
|
"WorkOrder ='" + DAT + "'", null);
|
||||||
|
}
|
||||||
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||||
|
}
|
||||||
|
else if (SYSAPI == "SC812")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 101 } },
|
||||||
|
"WorkOrder ='" + DAT + "'", null);
|
||||||
|
}
|
||||||
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||||
|
}
|
||||||
|
else if (SYSAPI == "SC827")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
}
|
||||||
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||||
|
}//获取呼叫领料单
|
||||||
|
else if (SYSAPI == "SC830")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return EasyTask.CompletedTask; ;
|
||||||
|
Dictionary<string, object> _new = new Dictionary<string, object>();//缓存函数
|
||||||
|
_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
|
||||||
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" +
|
||||||
|
Station + "' AND Serial = 'PORT1'").First();
|
||||||
|
drEmployee.BeginEdit();
|
||||||
|
drEmployee["ERR"] = _new.GetValue("ERR");
|
||||||
|
drEmployee["LOCK"] = _new.GetValue("LOCK");
|
||||||
|
drEmployee["Message"] = _new.GetValue("Status");
|
||||||
|
drEmployee["WorkOrder"] = _new.GetValue("WorkNumder");
|
||||||
|
drEmployee["Temperature"] = _new.GetValue("MTT");
|
||||||
|
drEmployee["WaterLevel"] = _new.GetValue("MTL");
|
||||||
|
drEmployee["Process"] = _new.GetValue("Process");
|
||||||
|
drEmployee["Step"] = _new.GetValue("Step");
|
||||||
|
drEmployee["UserButton"] = _new.GetValue("UserButton");
|
||||||
|
if (_new.GetValue("UserInfoStart").ToString() != "900")
|
||||||
|
{ drEmployee["UserInfoStart"] = _new.GetValue("UserInfoStart"); }
|
||||||
|
drEmployee["UserInfo"] = _new.GetValue("UserInfo");
|
||||||
|
drEmployee["WORK_RUN"] = _new.GetValue("WORK_RUN");
|
||||||
|
drEmployee["RUN_STEPID"] = _new.GetValue("RUN_STEPID");
|
||||||
|
drEmployee["CALL"] = _new.GetValue("CALL");
|
||||||
|
drEmployee.EndEdit();
|
||||||
|
drEmployee.AcceptChanges();
|
||||||
|
|
||||||
|
if (_new.GetValue("Status").ToString() != "----------")
|
||||||
|
{
|
||||||
|
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("MST", _new.GetValue("MST"));
|
||||||
|
Chart_new.Add("MTT", _new.GetValue("MTT"));
|
||||||
|
Chart_new.Add("MTL", _new.GetValue("MTL"));
|
||||||
|
Chart_new.Add("MTH", _new.GetValue("MTH"));
|
||||||
|
Chart_new.Add("MUT", _new.GetValue("MUT"));
|
||||||
|
Chart_new.Add("STTA", _new.GetValue("STTA"));
|
||||||
|
Chart_new.Add("STLA", _new.GetValue("STLA"));
|
||||||
|
Chart_new.Add("STTB", _new.GetValue("STTB"));
|
||||||
|
Chart_new.Add("STLB", _new.GetValue("STLB"));
|
||||||
|
Chart_new.Add("STTC", _new.GetValue("STTC"));
|
||||||
|
Chart_new.Add("STLC", _new.GetValue("STLC"));
|
||||||
|
|
||||||
|
MainWindowViewModel.SQLiteChartAdress.InsertData("Chart", Chart_new);// 执行插入
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||||
|
}//当前信息
|
||||||
|
else if (SYSAPI == "SC831")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
}
|
||||||
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||||
|
}
|
||||||
|
else if (SYSAPI == "SC832")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MainWindowViewModel.MachineLOG = DAT;
|
||||||
|
}
|
||||||
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||||
|
}//当前细节信息
|
||||||
|
else if (SYSAPI == "SC833")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
}
|
||||||
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||||
|
}//当前领料单信息
|
||||||
|
else if (SYSAPI == "SC851")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
}
|
||||||
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||||
|
}//数字开关表
|
||||||
|
else if (SYSAPI == "SC852")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
}
|
||||||
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||||
|
}//寄存器表
|
||||||
|
else if (SYSAPI == "SC853")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||||
|
}//缓存表
|
||||||
|
else if (SYSAPI == "SC854")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||||
|
}//程序设置表
|
||||||
|
else if (SYSAPI == "SC855")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||||
|
}//系统设置表
|
||||||
|
else if (SYSAPI == "SC910")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||||
|
}//发布失败
|
||||||
|
else if (SYSAPI == "SC911")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||||
|
}//细节错误
|
||||||
|
else if (SYSAPI == "SC980")
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return EasyTask.CompletedTask; ;
|
return EasyTask.CompletedTask; ;
|
||||||
};
|
};
|
||||||
|
|
||||||
await portclient.SetupAsync(new TouchSocketConfig()
|
await portclient.SetupAsync(new TouchSocketConfig()
|
||||||
.SetSerialPortOption(new SerialPortOption()
|
.SetSerialPortOption(new SerialPortOption()
|
||||||
{
|
{
|
||||||
@@ -64,12 +287,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
portclient.Received = (client, e) =>
|
portclient.Received = (client, e) =>
|
||||||
{
|
{
|
||||||
_responseEvent2.Set();
|
_responseEvent2.Set();
|
||||||
string DAT = e.ByteBlock.Span.ToString(Encoding.UTF8);
|
string[] sArray = Regex.Split(e.ByteBlock.Span.ToString(Encoding.UTF8),
|
||||||
//string DAT1 = CRCcheck16.ToCRC16(e.ByteBlock.Span.ToString(Encoding.UTF8));
|
@"\n", RegexOptions.IgnoreCase);
|
||||||
SCAPI(DAT);
|
|
||||||
|
|
||||||
|
|
||||||
return EasyTask.CompletedTask; ;
|
return EasyTask.CompletedTask; ;
|
||||||
};
|
};
|
||||||
|
|
||||||
await portclient.SetupAsync(new TouchSocketConfig()
|
await portclient.SetupAsync(new TouchSocketConfig()
|
||||||
.SetSerialPortOption(new SerialPortOption()
|
.SetSerialPortOption(new SerialPortOption()
|
||||||
{
|
{
|
||||||
@@ -96,12 +320,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
portclient.Received = (client, e) =>
|
portclient.Received = (client, e) =>
|
||||||
{
|
{
|
||||||
_responseEvent3.Set();
|
_responseEvent3.Set();
|
||||||
string DAT = e.ByteBlock.Span.ToString(Encoding.UTF8);
|
string[] sArray = Regex.Split(e.ByteBlock.Span.ToString(Encoding.UTF8),
|
||||||
//string DAT1 = CRCcheck16.ToCRC16(e.ByteBlock.Span.ToString(Encoding.UTF8));
|
@"\n", RegexOptions.IgnoreCase);
|
||||||
SCAPI(DAT);
|
|
||||||
|
|
||||||
|
|
||||||
return EasyTask.CompletedTask; ;
|
return EasyTask.CompletedTask; ;
|
||||||
};
|
};
|
||||||
|
|
||||||
await portclient.SetupAsync(new TouchSocketConfig()
|
await portclient.SetupAsync(new TouchSocketConfig()
|
||||||
.SetSerialPortOption(new SerialPortOption()
|
.SetSerialPortOption(new SerialPortOption()
|
||||||
{
|
{
|
||||||
@@ -128,12 +353,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
portclient.Received = (client, e) =>
|
portclient.Received = (client, e) =>
|
||||||
{
|
{
|
||||||
_responseEvent4.Set();
|
_responseEvent4.Set();
|
||||||
string DAT = e.ByteBlock.Span.ToString(Encoding.UTF8);
|
string[] sArray = Regex.Split(e.ByteBlock.Span.ToString(Encoding.UTF8),
|
||||||
//string DAT1 = CRCcheck16.ToCRC16(e.ByteBlock.Span.ToString(Encoding.UTF8));
|
@"\n", RegexOptions.IgnoreCase);
|
||||||
SCAPI(DAT);
|
|
||||||
|
|
||||||
|
|
||||||
return EasyTask.CompletedTask; ;
|
return EasyTask.CompletedTask; ;
|
||||||
};
|
};
|
||||||
|
|
||||||
await portclient.SetupAsync(new TouchSocketConfig()
|
await portclient.SetupAsync(new TouchSocketConfig()
|
||||||
.SetSerialPortOption(new SerialPortOption()
|
.SetSerialPortOption(new SerialPortOption()
|
||||||
{
|
{
|
||||||
@@ -151,46 +377,66 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
await portclient.ConnectAsync();
|
await portclient.ConnectAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly ManualResetEventSlim _responseEvent = new ManualResetEventSlim(false);
|
public static readonly ManualResetEventSlim _responseEvent = new ManualResetEventSlim(false);
|
||||||
private static readonly ManualResetEventSlim _responseEvent2 = new ManualResetEventSlim(false);
|
public static readonly ManualResetEventSlim _responseEvent2 = new ManualResetEventSlim(false);
|
||||||
private static readonly ManualResetEventSlim _responseEvent3 = new ManualResetEventSlim(false);
|
public static readonly ManualResetEventSlim _responseEvent3 = new ManualResetEventSlim(false);
|
||||||
private static readonly ManualResetEventSlim _responseEvent4 = new ManualResetEventSlim(false);
|
public static readonly ManualResetEventSlim _responseEvent4 = new ManualResetEventSlim(false);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 发送指令并等待响应,超时时间为500ms
|
/// 发送指令并等待响应,超时时间为500ms
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="command">要发送的指令字节数组</param>
|
/// <param name="command">要发送的指令字节数组</param>
|
||||||
/// <returns>从机的响应数据,超时则为null</returns>
|
/// <returns>从机的响应数据,超时则为null</returns>
|
||||||
public static void SendCommandAndWait(SerialPortClient serialPortClients, string command)
|
public static void SendCommandAndWait(SerialPortClient serialPortClients, string command)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
_responseEvent.Reset();
|
_responseEvent.Reset();
|
||||||
serialPortClients.Send(command); // 发送指令
|
serialPortClients.Send(command); // 发送指令
|
||||||
// 等待500毫秒或直到收到响应
|
// 等待500毫秒或直到收到响应
|
||||||
_responseEvent.Wait(TimeSpan.FromMilliseconds(1000));
|
_responseEvent.Wait(TimeSpan.FromMilliseconds(1000));
|
||||||
// 重置事件状态
|
// 重置事件状态
|
||||||
|
_responseEvent.Set();
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
}
|
}
|
||||||
public static void SendCommandAndWait2(SerialPortClient serialPortClients, string command)
|
public static void SendCommandAndWait2(SerialPortClient serialPortClients, string command)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
_responseEvent2.Reset();
|
_responseEvent2.Reset();
|
||||||
serialPortClients.Send(command); // 发送指令
|
serialPortClients.Send(command); // 发送指令
|
||||||
// 等待500毫秒或直到收到响应
|
// 等待500毫秒或直到收到响应
|
||||||
_responseEvent2.Wait(TimeSpan.FromMilliseconds(1000));
|
_responseEvent2.Wait(TimeSpan.FromMilliseconds(1000));
|
||||||
// 重置事件状态
|
// 重置事件状态
|
||||||
|
_responseEvent2.Set();
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
}
|
}
|
||||||
public static void SendCommandAndWait3(SerialPortClient serialPortClients, string command)
|
public static void SendCommandAndWait3(SerialPortClient serialPortClients, string command)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
_responseEvent3.Reset();
|
_responseEvent3.Reset();
|
||||||
serialPortClients.Send(command); // 发送指令
|
serialPortClients.Send(command); // 发送指令
|
||||||
// 等待500毫秒或直到收到响应
|
// 等待500毫秒或直到收到响应
|
||||||
_responseEvent3.Wait(TimeSpan.FromMilliseconds(1000));
|
_responseEvent3.Wait(TimeSpan.FromMilliseconds(1000));
|
||||||
// 重置事件状态
|
// 重置事件状态
|
||||||
|
_responseEvent3.Set();
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
}
|
}
|
||||||
public static void SendCommandAndWait4(SerialPortClient serialPortClients, string command)
|
public static void SendCommandAndWait4(SerialPortClient serialPortClients, string command)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
_responseEvent4.Reset();
|
_responseEvent4.Reset();
|
||||||
serialPortClients.Send(command); // 发送指令
|
serialPortClients.Send(command); // 发送指令
|
||||||
// 等待500毫秒或直到收到响应
|
// 等待500毫秒或直到收到响应
|
||||||
_responseEvent4.Wait(TimeSpan.FromMilliseconds(1000));
|
_responseEvent4.Wait(TimeSpan.FromMilliseconds(1000));
|
||||||
// 重置事件状态
|
// 重置事件状态
|
||||||
|
_responseEvent4.Set();
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,9 +39,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class AsyncTcpClient
|
public class AsyncTcpClient
|
||||||
{
|
{
|
||||||
|
|
||||||
public static SQLiteHelper SQLiteChartAdress = null; //定义数据库
|
|
||||||
private static readonly string ChartAdress = Environment.CurrentDirectory + "\\DataBase\\Chart.db"; //数据库路径
|
|
||||||
public static async Task TcpClient(TcpClient tcpClient, string ip, string port)
|
public static async Task TcpClient(TcpClient tcpClient, string ip, string port)
|
||||||
{
|
{
|
||||||
//TcpClient tcpClient = new TcpClient();
|
//TcpClient tcpClient = new TcpClient();
|
||||||
@@ -268,10 +265,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
Chart_new.Add("STTC", _new.GetValue("STTC"));
|
Chart_new.Add("STTC", _new.GetValue("STTC"));
|
||||||
Chart_new.Add("STLC", _new.GetValue("STLC"));
|
Chart_new.Add("STLC", _new.GetValue("STLC"));
|
||||||
|
|
||||||
SQLiteChartAdress = new SQLiteHelper(ChartAdress); //数据库连接路径
|
MainWindowViewModel.SQLiteChartAdress.InsertData("Chart", Chart_new);// 执行插入
|
||||||
SQLiteChartAdress.Open(); //打开数据库
|
|
||||||
SQLiteChartAdress.InsertData("Chart", Chart_new);// 执行插入
|
|
||||||
SQLiteChartAdress.Close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using LiveChartsCore.Geo;
|
using LiveChartsCore.Geo;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using NModbus;
|
||||||
using OpenTK.Graphics.ES11;
|
using OpenTK.Graphics.ES11;
|
||||||
using ScottPlot.Palettes;
|
using ScottPlot.Palettes;
|
||||||
using ScottPlot.TickGenerators.TimeUnits;
|
using ScottPlot.TickGenerators.TimeUnits;
|
||||||
@@ -40,6 +41,7 @@ using static MaterialDesignThemes.Wpf.Theme;
|
|||||||
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
||||||
using static SunlightCentralizedControlManagement_SCCM_.View.MachinesView;
|
using static SunlightCentralizedControlManagement_SCCM_.View.MachinesView;
|
||||||
using static SunlightCentralizedControlManagement_SCCM_.ViewModel.ManualDyelotModel;
|
using static SunlightCentralizedControlManagement_SCCM_.ViewModel.ManualDyelotModel;
|
||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView;
|
||||||
|
|
||||||
namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||||
{
|
{
|
||||||
@@ -81,6 +83,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
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"; //数据库路径
|
||||||
|
public static SQLiteHelper SQLiteChartAdress = null; //定义数据库
|
||||||
|
private static readonly string ChartAdress = Environment.CurrentDirectory + "\\DataBase\\Chart.db"; //数据库路径
|
||||||
public static DataTable Machines = new DataTable(); //设备表缓存
|
public static DataTable Machines = new DataTable(); //设备表缓存
|
||||||
// public static DataRow MachinesROW;
|
// public static DataRow MachinesROW;
|
||||||
public static DataTable USER_data = new DataTable();
|
public static DataTable USER_data = new DataTable();
|
||||||
@@ -106,6 +110,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
catch (Exception ex) { LogGing.ERRDATA(ex); }
|
catch (Exception ex) { LogGing.ERRDATA(ex); }
|
||||||
|
|
||||||
|
SQLiteChartAdress = new SQLiteHelper(ChartAdress); //数据库连接路径
|
||||||
|
SQLiteChartAdress.Open(); //打开数据库
|
||||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||||
SQLiteHelpers.Open(); //打开数据库
|
SQLiteHelpers.Open(); //打开数据库
|
||||||
Machines = SQLiteHelpers.ExecuteDataSet("select * from Machines Order by id", null).Tables[0]; //读取表写入缓存
|
Machines = SQLiteHelpers.ExecuteDataSet("select * from Machines Order by id", null).Tables[0]; //读取表写入缓存
|
||||||
@@ -643,46 +649,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
async void Tick_Event_5S()//Tick_Event周期执行事件5S
|
async void Tick_Event_5S()//Tick_Event周期执行事件5S
|
||||||
{
|
{
|
||||||
DataTable Workorddr = SQLiteHelpers.ExecuteDataSet("select * from WorkorderSteps ", null).Tables[0]; //读取表写入缓存
|
|
||||||
int y = Workorddr.Rows.Count;
|
|
||||||
object[] datal = new object[19];
|
|
||||||
for (int i = 0; i < Workorddr.Rows.Count; i++)
|
|
||||||
{
|
|
||||||
|
|
||||||
/*AsyncSerialPortClient.SendCommandAndWait(
|
|
||||||
MachiensPortClient[2],
|
|
||||||
"SC800[" + MachinesRow["Station"] + "]" + f);*/
|
|
||||||
if (i >= 20) break;
|
|
||||||
|
|
||||||
datal[0] = Workorddr.Rows[i]["Step"];
|
|
||||||
datal[1] = Workorddr.Rows[i]["StepID"];
|
|
||||||
datal[2] = Workorddr.Rows[i]["Parameter1"] ?? 0;
|
|
||||||
datal[3] = Workorddr.Rows[i]["Parameter2"] ?? 0;
|
|
||||||
datal[4] = Workorddr.Rows[i]["Parameter3"] ?? 0;
|
|
||||||
datal[5] = Workorddr.Rows[i]["Parameter4"] ?? 0;
|
|
||||||
datal[6] = Workorddr.Rows[i]["Parameter5"] ?? 0;
|
|
||||||
datal[7] = Workorddr.Rows[i]["StepID_S1"];
|
|
||||||
datal[8] = Workorddr.Rows[i]["StepID_S2"];
|
|
||||||
datal[9] = Workorddr.Rows[i].Field<double?>("Parameter1_S1") ?? 0;
|
|
||||||
datal[10] = Workorddr.Rows[i].Field<double?>("Parameter1_S2") ?? 0;
|
|
||||||
datal[11] = Workorddr.Rows[i].Field<double?>("Parameter2_S1") ?? 0;
|
|
||||||
datal[12] = Workorddr.Rows[i].Field<double?>("Parameter2_S2") ?? 0;
|
|
||||||
datal[13] = Workorddr.Rows[i].Field<double?>("Parameter3_S1") ?? 0;
|
|
||||||
datal[14] = Workorddr.Rows[i].Field<double?>("Parameter3_S2") ?? 0;
|
|
||||||
datal[15] = Workorddr.Rows[i].Field<double?>("Parameter4_S1") ?? 0;
|
|
||||||
datal[16] = Workorddr.Rows[i].Field<double?>("Parameter4_S2") ?? 0;
|
|
||||||
datal[17] = Workorddr.Rows[i].Field<double?>("Parameter5_S1") ?? 0;
|
|
||||||
datal[18] = Workorddr.Rows[i].Field<double?>("Parameter5_S2") ?? 0;
|
|
||||||
|
|
||||||
stringQueueSerial_3.Enqueue(new QueueSerial
|
|
||||||
{
|
|
||||||
ID = 45,
|
|
||||||
DAT = "SC810[" + 1 + "]" + datal.ToJsonString()
|
|
||||||
});//信息插入队列
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach (DataRow MachinesRow in Machines.Rows)
|
foreach (DataRow MachinesRow in Machines.Rows)
|
||||||
{
|
{
|
||||||
/**发送800指令**/
|
/**发送800指令**/
|
||||||
@@ -1035,7 +1001,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
/*曲线图*/
|
/*曲线图*/
|
||||||
for (int i = 0; i < Machines.Rows.Count; i++)//曲线图
|
for (int i = 0; i < Machines.Rows.Count; i++)//曲线图
|
||||||
{
|
{
|
||||||
if (Selet_Machines(Machines, "State", "ID='" + i + "'").ToString() !="800")
|
string st = Selet_Machines(Machines, "State", "ID='" + i + "'").ToString();
|
||||||
|
if (st != "800" && st != "801" && st != "802")
|
||||||
{
|
{
|
||||||
DataRow whole_Dat = Whole_dat.NewRow();
|
DataRow whole_Dat = Whole_dat.NewRow();
|
||||||
whole_Dat["Machine"] = Selet_Machines(Machines, "NAME", "ID='" + i + "'").ToString();
|
whole_Dat["Machine"] = Selet_Machines(Machines, "NAME", "ID='" + i + "'").ToString();
|
||||||
@@ -1089,6 +1056,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
await AsyncSerialPortClient.PortClient(MachiensPortClient[0] //建立连接
|
await AsyncSerialPortClient.PortClient(MachiensPortClient[0] //建立连接
|
||||||
, Configini.IniReadvalue("SYS", "COMP1")
|
, Configini.IniReadvalue("SYS", "COMP1")
|
||||||
, Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD1")));
|
, Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD1")));
|
||||||
|
AsyncSerialPortClient._responseEvent.Set();
|
||||||
|
|
||||||
Thread myThread1 = new Thread(Port1_link);
|
Thread myThread1 = new Thread(Port1_link);
|
||||||
myThread1.Start();
|
myThread1.Start();
|
||||||
}
|
}
|
||||||
@@ -1100,6 +1069,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
await AsyncSerialPortClient.PortClient2(MachiensPortClient[1] //建立连接
|
await AsyncSerialPortClient.PortClient2(MachiensPortClient[1] //建立连接
|
||||||
, Configini.IniReadvalue("SYS", "COMP2")
|
, Configini.IniReadvalue("SYS", "COMP2")
|
||||||
, Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD2")));
|
, Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD2")));
|
||||||
|
AsyncSerialPortClient._responseEvent2.Set();
|
||||||
|
|
||||||
Thread myThread2 = new Thread(Port2_link);
|
Thread myThread2 = new Thread(Port2_link);
|
||||||
myThread2.Start();
|
myThread2.Start();
|
||||||
@@ -1112,6 +1082,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
await AsyncSerialPortClient.PortClient3(MachiensPortClient[2] //建立连接
|
await AsyncSerialPortClient.PortClient3(MachiensPortClient[2] //建立连接
|
||||||
, Configini.IniReadvalue("SYS", "COMP3")
|
, Configini.IniReadvalue("SYS", "COMP3")
|
||||||
, Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD3")));
|
, Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD3")));
|
||||||
|
AsyncSerialPortClient._responseEvent3.Set();
|
||||||
|
|
||||||
Thread myThread3 = new Thread(Port3_link);
|
Thread myThread3 = new Thread(Port3_link);
|
||||||
myThread3.Start();
|
myThread3.Start();
|
||||||
@@ -1124,6 +1095,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
await AsyncSerialPortClient.PortClient4(MachiensPortClient[3] //建立连接
|
await AsyncSerialPortClient.PortClient4(MachiensPortClient[3] //建立连接
|
||||||
, Configini.IniReadvalue("SYS", "COMP4")
|
, Configini.IniReadvalue("SYS", "COMP4")
|
||||||
, Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD4")));
|
, Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD4")));
|
||||||
|
AsyncSerialPortClient._responseEvent4.Set();
|
||||||
|
|
||||||
Thread myThread4 = new Thread(Port4_link);
|
Thread myThread4 = new Thread(Port4_link);
|
||||||
myThread4.Start();
|
myThread4.Start();
|
||||||
@@ -1131,22 +1103,39 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
private void Port1_link()
|
private void Port1_link()
|
||||||
{
|
{
|
||||||
try
|
while (true)
|
||||||
{
|
{
|
||||||
foreach (DataRow MachinesRow in Machines.Select("Type='false' AND Serial='PORT1'"))
|
try
|
||||||
{
|
{
|
||||||
if (stringQueueSerial_1.Count > 0) //信息发送队列
|
if (stringQueueSerial_1.Count > 0) //信息发送队列
|
||||||
|
{
|
||||||
|
if (AsyncSerialPortClient._responseEvent.IsSet)
|
||||||
{
|
{
|
||||||
QueueSerial t = stringQueueSerial_1.Dequeue();
|
QueueSerial t = stringQueueSerial_1.Dequeue();
|
||||||
|
|
||||||
AsyncSerialPortClient.SendCommandAndWait(MachiensPortClient[0], t.DAT + "\n");
|
AsyncSerialPortClient.SendCommandAndWait(MachiensPortClient[0], t.DAT + "\n");
|
||||||
//MachiensPortClient[t.ID].Send(t.DAT);
|
//MachiensPortClient[t.ID].Send(t.DAT);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Thread.Sleep(TimeSpan.FromMilliseconds(50));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (DataRow MachinesRow in Machines.Select("Type='false' AND Serial='PORT1'"))
|
||||||
|
{
|
||||||
if (MachinesRow["State"].ToString() == "800")
|
if (MachinesRow["State"].ToString() == "800")
|
||||||
{
|
{
|
||||||
AsyncSerialPortClient.SendCommandAndWait(
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
MachiensPortClient[0],
|
{
|
||||||
"SC800[" + MachinesRow["Station"] + "]\n");
|
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||||
|
DAT = "SC800[" + MachinesRow["Station"] + "]"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Thread.Sleep(TimeSpan.FromMilliseconds(5));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1155,27 +1144,44 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Port1_link();//回调
|
}
|
||||||
}
|
}
|
||||||
}//发送
|
}//发送
|
||||||
private void Port2_link()
|
private void Port2_link()
|
||||||
{
|
{
|
||||||
try
|
while (true)
|
||||||
{
|
{
|
||||||
foreach (DataRow MachinesRow in Machines.Select("Type='false' AND Serial='PORT2'"))
|
try
|
||||||
{
|
{
|
||||||
if (stringQueueSerial_2.Count > 0) //信息发送队列
|
if (stringQueueSerial_2.Count > 0) //信息发送队列
|
||||||
|
{
|
||||||
|
if (AsyncSerialPortClient._responseEvent2.IsSet)
|
||||||
{
|
{
|
||||||
QueueSerial t = stringQueueSerial_2.Dequeue();
|
QueueSerial t = stringQueueSerial_2.Dequeue();
|
||||||
|
|
||||||
AsyncSerialPortClient.SendCommandAndWait2(MachiensPortClient[1], t.DAT + "\n");
|
AsyncSerialPortClient.SendCommandAndWait2(MachiensPortClient[1], t.DAT + "\n");
|
||||||
//MachiensPortClient[t.ID].Send(t.DAT);
|
//MachiensPortClient[t.ID].Send(t.DAT);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Thread.Sleep(TimeSpan.FromMilliseconds(50));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (DataRow MachinesRow in Machines.Select("Type='false' AND Serial='PORT2'"))
|
||||||
|
{
|
||||||
if (MachinesRow["State"].ToString() == "800")
|
if (MachinesRow["State"].ToString() == "800")
|
||||||
{
|
{
|
||||||
AsyncSerialPortClient.SendCommandAndWait2(
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
MachiensPortClient[1],
|
{
|
||||||
"SC800[" + MachinesRow["Station"] + "]\n");
|
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||||
|
DAT = "SC800[" + MachinesRow["Station"] + "]"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Thread.Sleep(TimeSpan.FromMilliseconds(5));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1184,27 +1190,44 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Port2_link();//回调
|
}
|
||||||
}
|
}
|
||||||
}//发送
|
}//发送
|
||||||
private void Port3_link()
|
private void Port3_link()
|
||||||
{
|
{
|
||||||
try
|
while (true)
|
||||||
{
|
{
|
||||||
foreach (DataRow MachinesRow in Machines.Select("Type='false' AND Serial='PORT3'"))
|
try
|
||||||
{
|
{
|
||||||
if (stringQueueSerial_3.Count > 0) //信息发送队列
|
if (stringQueueSerial_3.Count > 0) //信息发送队列
|
||||||
|
{
|
||||||
|
if (AsyncSerialPortClient._responseEvent3.IsSet)
|
||||||
{
|
{
|
||||||
QueueSerial t = stringQueueSerial_3.Dequeue();
|
QueueSerial t = stringQueueSerial_3.Dequeue();
|
||||||
|
|
||||||
AsyncSerialPortClient.SendCommandAndWait3(MachiensPortClient[2], t.DAT + "\n");
|
AsyncSerialPortClient.SendCommandAndWait3(MachiensPortClient[2], t.DAT + "\n");
|
||||||
//MachiensPortClient[t.ID].Send(t.DAT);
|
//MachiensPortClient[t.ID].Send(t.DAT);
|
||||||
}
|
}
|
||||||
else if (MachinesRow["State"].ToString() == "800")
|
else
|
||||||
{
|
{
|
||||||
AsyncSerialPortClient.SendCommandAndWait3(
|
Thread.Sleep(TimeSpan.FromMilliseconds(50));
|
||||||
MachiensPortClient[2],
|
}
|
||||||
"SC800[" + MachinesRow["Station"] + "]\n");
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (DataRow MachinesRow in Machines.Select("Type='false' AND Serial='PORT3'"))
|
||||||
|
{
|
||||||
|
if (MachinesRow["State"].ToString() == "800")
|
||||||
|
{
|
||||||
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||||
|
DAT = "SC800[" + MachinesRow["Station"] + "]"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Thread.Sleep(TimeSpan.FromMilliseconds(50));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1213,27 +1236,44 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Port3_link();//回调
|
}
|
||||||
}
|
}
|
||||||
}//发送
|
}//发送
|
||||||
private void Port4_link()
|
private void Port4_link()
|
||||||
{
|
{
|
||||||
try
|
while (true)
|
||||||
{
|
{
|
||||||
foreach (DataRow MachinesRow in Machines.Select("Type='false' AND Serial='PORT4'"))
|
try
|
||||||
{
|
{
|
||||||
if (stringQueueSerial_4.Count > 0) //信息发送队列
|
if (stringQueueSerial_4.Count > 0) //信息发送队列
|
||||||
|
{
|
||||||
|
if (AsyncSerialPortClient._responseEvent4.IsSet)
|
||||||
{
|
{
|
||||||
QueueSerial t = stringQueueSerial_4.Dequeue();
|
QueueSerial t = stringQueueSerial_4.Dequeue();
|
||||||
|
|
||||||
AsyncSerialPortClient.SendCommandAndWait4(MachiensPortClient[3], t.DAT + "\n");
|
AsyncSerialPortClient.SendCommandAndWait4(MachiensPortClient[3], t.DAT + "\n");
|
||||||
//MachiensPortClient[t.ID].Send(t.DAT);
|
//MachiensPortClient[t.ID].Send(t.DAT);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Thread.Sleep(TimeSpan.FromMilliseconds(50));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (DataRow MachinesRow in Machines.Select("Type='false' AND Serial='PORT4'"))
|
||||||
|
{
|
||||||
if (MachinesRow["State"].ToString() == "800")
|
if (MachinesRow["State"].ToString() == "800")
|
||||||
{
|
{
|
||||||
AsyncSerialPortClient.SendCommandAndWait4(
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||||
MachiensPortClient[3],
|
{
|
||||||
"SC800[" + MachinesRow["Station"] + "]\n");
|
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||||
|
DAT = "SC800[" + MachinesRow["Station"] + "]"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Thread.Sleep(TimeSpan.FromMilliseconds(50));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1242,7 +1282,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Port4_link();//回调
|
}
|
||||||
}
|
}
|
||||||
}//发送
|
}//发送
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user