串口通讯部分修改
This commit is contained in:
commit
ebcd5b7182
2 files changed
+39
-37
No files matched your search
@@ -47,7 +47,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; }
|
||||||
@@ -68,7 +68,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
@"\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);
|
||||||
@@ -231,17 +231,17 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
drEmployee["ERR"] = _new.GetValue("ERR");
|
drEmployee["ERR"] = _new.GetValue("ERR");
|
||||||
drEmployee["LOCK"] = _new.GetValue("LOCK");
|
drEmployee["LOCK"] = _new.GetValue("LOCK");
|
||||||
drEmployee["Message"] = _new.GetValue("Status");
|
drEmployee["Message"] = _new.GetValue("Status");
|
||||||
drEmployee["WorkOrder"] = _new.GetValue("WorkNumder");
|
drEmployee["WorkOrder"] = _new.GetValue("Work");
|
||||||
drEmployee["Temperature"] = _new.GetValue("MTT");
|
drEmployee["Temperature"] = _new.GetValue("MTT");
|
||||||
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("UserButton");
|
drEmployee["UserButton"] = _new.GetValue("User");
|
||||||
if (_new.GetValue("UserInfoStart").ToString() != "900")
|
if (_new.GetValue("InfoS").ToString() != "900")
|
||||||
{ drEmployee["UserInfoStart"] = _new.GetValue("UserInfoStart"); }
|
{ drEmployee["UserInfoStart"] = _new.GetValue("InfoS"); }
|
||||||
drEmployee["UserInfo"] = _new.GetValue("UserInfo");
|
drEmployee["UserInfo"] = _new.GetValue("Info");
|
||||||
drEmployee["WORK_RUN"] = _new.GetValue("WORK_RUN");
|
drEmployee["WORK_RUN"] = _new.GetValue("RUN");
|
||||||
drEmployee["RUN_STEPID"] = _new.GetValue("RUN_STEPID");
|
drEmployee["RUN_STEPID"] = _new.GetValue("STEPID");
|
||||||
drEmployee["CALL"] = _new.GetValue("CALL");
|
drEmployee["CALL"] = _new.GetValue("CALL");
|
||||||
drEmployee.EndEdit();
|
drEmployee.EndEdit();
|
||||||
drEmployee.AcceptChanges();
|
drEmployee.AcceptChanges();
|
||||||
@@ -250,9 +250,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
if (_new.GetValue("Status").ToString() != "----------")
|
if (_new.GetValue("Status").ToString() != "----------")
|
||||||
{
|
{
|
||||||
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
|
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
|
||||||
Chart_new.Add("WorkOrder", _new.GetValue("WorkNumder"));
|
Chart_new.Add("WorkOrder", _new.GetValue("Work"));
|
||||||
Chart_new.Add("Machine", mac);
|
Chart_new.Add("Machine", mac);
|
||||||
Chart_new.Add("Time", _new.GetValue("Time"));
|
Chart_new.Add("Time", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
|
||||||
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"));
|
||||||
@@ -602,38 +602,40 @@ 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));
|
_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)
|
||||||
{
|
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" +
|
|
||||||
Station + "' AND Serial = 'PORT1'").First();
|
|
||||||
if (drEmployee.Field<int>("State") != 800)
|
|
||||||
{
|
{
|
||||||
drEmployee.BeginEdit();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" +
|
||||||
drEmployee["State"] = "800";
|
Station + "' AND Serial = 'PORT1'").First();
|
||||||
drEmployee["WorkOrder"] = "------";
|
if (drEmployee.Field<int>("State") != 800)
|
||||||
drEmployee["Dyelot"] = "";
|
{
|
||||||
drEmployee["Temperature"] = 0.0;
|
drEmployee.BeginEdit();
|
||||||
drEmployee["WaterLevel"] = 0.0;
|
drEmployee["State"] = "800";
|
||||||
drEmployee["Process"] = "";
|
drEmployee["WorkOrder"] = "------";
|
||||||
drEmployee["Step"] = "";
|
drEmployee["Dyelot"] = "";
|
||||||
drEmployee["Message"] = "";
|
drEmployee["Temperature"] = 0.0;
|
||||||
drEmployee["SYSKEY"] = "";
|
drEmployee["WaterLevel"] = 0.0;
|
||||||
drEmployee["WORK_RUN"] = "-1";
|
drEmployee["Process"] = "";
|
||||||
drEmployee["ERR"] = false;
|
drEmployee["Step"] = "";
|
||||||
drEmployee.EndEdit();
|
drEmployee["Message"] = "";
|
||||||
drEmployee.AcceptChanges();
|
drEmployee["SYSKEY"] = "";
|
||||||
|
drEmployee["WORK_RUN"] = "-1";
|
||||||
|
drEmployee["ERR"] = false;
|
||||||
|
drEmployee.EndEdit();
|
||||||
|
drEmployee.AcceptChanges();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 重置事件状态
|
||||||
|
_responseEvent.Set();
|
||||||
}
|
}
|
||||||
catch (Exception) { }
|
catch (Exception) { }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -771,7 +771,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((mac_s == "101") || (mac_s == "201") || (mac_s == "202") || (mac_s == "301") || (mac_s == "309"))//获取信息
|
if ((mac_s == "101") || (mac_s == "201") || (mac_s == "202") || (mac_s == "301") || (mac_s == "309")|| (mac_s == "802"))//获取信息
|
||||||
{
|
{
|
||||||
if (MachinesRow["Serial"].ToString() == "PORT1")
|
if (MachinesRow["Serial"].ToString() == "PORT1")
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user