|
|
@ -69,29 +69,56 @@ namespace DyeingComputer.UserClass |
|
|
|
service.Received = (client, e) => |
|
|
|
{ |
|
|
|
string SYSAPI = e.ByteBlock.Span.ToString(Encoding.ASCII).Substring(0,5); |
|
|
|
string SYSDAT = e.ByteBlock.Span.ToString(Encoding.ASCII).Substring(5); |
|
|
|
string DAT = e.ByteBlock.Span.ToString(Encoding.ASCII).Substring(5); |
|
|
|
string SYSDAT ="";// = e.ByteBlock.Span.ToString(Encoding.ASCII).Substring(5);
|
|
|
|
string SYSKEY =""; |
|
|
|
if(DAT.Length>=16) SYSKEY = DAT.Substring(0,16); |
|
|
|
if (DAT.Length > 16) SYSDAT = DAT.Substring(16); |
|
|
|
//LogGing.LogSQLDATA("800", "TcpServer", "API:"+ SYSAPI);
|
|
|
|
if (SYSAPI == "SC800") client.SendAsync(MainWindowViewModel.S01); |
|
|
|
else if (SYSAPI == "SC801") client.SendAsync(MainWindowViewModel.S16.ToString()); |
|
|
|
else if (SYSAPI == "SC802") client.SendAsync(MainWindowViewModel.S03); |
|
|
|
else if (SYSAPI == "SC803") client.SendAsync(MainWindowViewModel.S05); |
|
|
|
else if (SYSAPI == "SC804") client.SendAsync(MainWindowViewModel.S06); |
|
|
|
if (SYSAPI == "SC800") |
|
|
|
{ |
|
|
|
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
|
|
|
|
Chart_new.Add("MACHINE", MainWindowViewModel.S01); |
|
|
|
Chart_new.Add("GROUP", MainWindowViewModel.S05); |
|
|
|
Chart_new.Add("SYSKEY", MainWindowViewModel.SYSKEY); |
|
|
|
Chart_new.Add("TIME", MainWindowViewModel.SYSTime); |
|
|
|
client.SendAsync("[" + MainWindowViewModel.S01 + "]" + Chart_new.ToJsonString()); |
|
|
|
} |
|
|
|
else if (SYSAPI == "SC810") |
|
|
|
{ |
|
|
|
if (SYSKEY == MainWindowViewModel.SYSKEY) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
Dictionary<string, object> Chart_dat; |
|
|
|
Chart_dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(SYSDAT); |
|
|
|
|
|
|
|
} |
|
|
|
catch |
|
|
|
{ |
|
|
|
client.SendAsync("SC910"); |
|
|
|
} |
|
|
|
} |
|
|
|
else { client.SendAsync("SC999"); } |
|
|
|
} |
|
|
|
else if (SYSAPI == "SC820") |
|
|
|
{ |
|
|
|
if (SYSKEY == MainWindowViewModel.SYSKEY) |
|
|
|
{ |
|
|
|
if (SYSDAT.Length == 21) |
|
|
|
{ |
|
|
|
SYSDAT = SYSDAT.Substring(1,19); |
|
|
|
SYSDAT = SYSDAT.Substring(1, 19); |
|
|
|
DateTime dt; |
|
|
|
if(DateTime.TryParse(SYSDAT,out dt)) |
|
|
|
if (DateTime.TryParse(SYSDAT, out dt)) |
|
|
|
SetLocalDateTime(dt); |
|
|
|
} |
|
|
|
client.SendAsync("[" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")+"]"); |
|
|
|
client.SendAsync("[" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "]"); |
|
|
|
} |
|
|
|
else { client.SendAsync("SC999"); } |
|
|
|
}//设置系统时间
|
|
|
|
else if (SYSAPI == "SC830") |
|
|
|
{ |
|
|
|
if (SYSKEY == MainWindowViewModel.SYSKEY) |
|
|
|
{ |
|
|
|
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
|
|
|
|
Chart_new.Add("DYELOT", MainWindowViewModel.WorkNumder); |
|
|
@ -107,19 +134,33 @@ namespace DyeingComputer.UserClass |
|
|
|
Chart_new.Add("STLB", MainWindowViewModel.Selet_dtm("1018")); |
|
|
|
Chart_new.Add("STTC", MainWindowViewModel.Selet_dtm("1014")); |
|
|
|
Chart_new.Add("STLC", MainWindowViewModel.Selet_dtm("1019")); |
|
|
|
client.SendAsync("["+ MainWindowViewModel.S01 + "]"+Chart_new.ToJsonString()); |
|
|
|
client.SendAsync("[" + MainWindowViewModel.S01 + "]" + Chart_new.ToJsonString()); |
|
|
|
} |
|
|
|
else { client.SendAsync("SC999"); } |
|
|
|
}//当前信息
|
|
|
|
else if (SYSAPI == "SC851") |
|
|
|
{ |
|
|
|
if (SYSKEY == MainWindowViewModel.SYSKEY) |
|
|
|
{ |
|
|
|
client.SendAsync("[" + MainWindowViewModel.S01 + "]" + MainWindowViewModel.dt_d.ToJsonString());//数字开关信息
|
|
|
|
} |
|
|
|
else { client.SendAsync("SC999"); } |
|
|
|
}//数字开关表
|
|
|
|
else if (SYSAPI == "SC852") |
|
|
|
{ |
|
|
|
if (SYSKEY == MainWindowViewModel.SYSKEY) |
|
|
|
{ |
|
|
|
client.SendAsync("[" + MainWindowViewModel.S01 + "]" + MainWindowViewModel.dt_a.ToJsonString());//寄存器信息
|
|
|
|
} |
|
|
|
else { client.SendAsync("SC999"); } |
|
|
|
}//寄存器表
|
|
|
|
else if (SYSAPI == "SC853") |
|
|
|
{ |
|
|
|
if (SYSKEY == MainWindowViewModel.SYSKEY) |
|
|
|
{ |
|
|
|
client.SendAsync("[" + MainWindowViewModel.S01 + "]" + MainWindowViewModel.dt_m.ToJsonString());//缓存信息
|
|
|
|
} |
|
|
|
else { client.SendAsync("SC999"); } |
|
|
|
}//缓存表
|
|
|
|
|
|
|
|
return EasyTask.CompletedTask; |
|
|
|