diff --git a/HighWayAssemble/App.config b/HighWayAssemble/App.config
index e5c8734..2ff0ef7 100644
--- a/HighWayAssemble/App.config
+++ b/HighWayAssemble/App.config
@@ -12,10 +12,7 @@
-
-
-
-
+
diff --git a/HighWayAssemble/FrmDisplayView.Designer.cs b/HighWayAssemble/FrmDisplayView.Designer.cs
index 1eb28b9..c7e8612 100644
--- a/HighWayAssemble/FrmDisplayView.Designer.cs
+++ b/HighWayAssemble/FrmDisplayView.Designer.cs
@@ -63,9 +63,6 @@
this.columnHeader19 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader20 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader21 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
- this.columnHeader22 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
- this.columnHeader23 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
- this.columnHeader24 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.label_Version = new System.Windows.Forms.Label();
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
@@ -120,8 +117,8 @@
// v20230913ToolStripMenuItem
//
this.v20230913ToolStripMenuItem.Name = "v20230913ToolStripMenuItem";
- this.v20230913ToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
- this.v20230913ToolStripMenuItem.Text = "V20230920";
+ this.v20230913ToolStripMenuItem.Size = new System.Drawing.Size(148, 34);
+ this.v20230913ToolStripMenuItem.Text = "V2.0";
//
// panel1
//
@@ -149,7 +146,7 @@
//
this.splitContainer1.Panel2.Controls.Add(this.groupBox3);
this.splitContainer1.Size = new System.Drawing.Size(1425, 945);
- this.splitContainer1.SplitterDistance = 293;
+ this.splitContainer1.SplitterDistance = 292;
this.splitContainer1.SplitterWidth = 6;
this.splitContainer1.TabIndex = 0;
//
@@ -167,7 +164,7 @@
// splitContainer2.Panel2
//
this.splitContainer2.Panel2.Controls.Add(this.groupBox2);
- this.splitContainer2.Size = new System.Drawing.Size(1425, 293);
+ this.splitContainer2.Size = new System.Drawing.Size(1425, 292);
this.splitContainer2.SplitterDistance = 271;
this.splitContainer2.SplitterWidth = 6;
this.splitContainer2.TabIndex = 0;
@@ -180,7 +177,7 @@
this.groupBox1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
- this.groupBox1.Size = new System.Drawing.Size(271, 293);
+ this.groupBox1.Size = new System.Drawing.Size(271, 292);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "MES软件";
@@ -198,7 +195,7 @@
this.adapter_list.Location = new System.Drawing.Point(4, 26);
this.adapter_list.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.adapter_list.Name = "adapter_list";
- this.adapter_list.Size = new System.Drawing.Size(263, 262);
+ this.adapter_list.Size = new System.Drawing.Size(263, 261);
this.adapter_list.TabIndex = 0;
this.adapter_list.UseCompatibleStateImageBehavior = false;
this.adapter_list.View = System.Windows.Forms.View.Details;
@@ -239,7 +236,7 @@
this.groupBox2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
- this.groupBox2.Size = new System.Drawing.Size(1148, 293);
+ this.groupBox2.Size = new System.Drawing.Size(1148, 292);
this.groupBox2.TabIndex = 1;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "设备信息";
@@ -259,7 +256,7 @@
this.equip_list.Location = new System.Drawing.Point(4, 26);
this.equip_list.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.equip_list.Name = "equip_list";
- this.equip_list.Size = new System.Drawing.Size(1140, 262);
+ this.equip_list.Size = new System.Drawing.Size(1140, 261);
this.equip_list.TabIndex = 1;
this.equip_list.UseCompatibleStateImageBehavior = false;
this.equip_list.View = System.Windows.Forms.View.Details;
@@ -267,13 +264,13 @@
// columnHeader6
//
this.columnHeader6.Text = "编号";
- this.columnHeader6.Width = 78;
+ this.columnHeader6.Width = 50;
//
// columnHeader7
//
this.columnHeader7.Text = "名称";
this.columnHeader7.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
- this.columnHeader7.Width = 95;
+ this.columnHeader7.Width = 120;
//
// columnHeader8
//
@@ -309,7 +306,7 @@
this.groupBox3.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
- this.groupBox3.Size = new System.Drawing.Size(1425, 646);
+ this.groupBox3.Size = new System.Drawing.Size(1425, 647);
this.groupBox3.TabIndex = 1;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "传感器信息";
@@ -324,16 +321,13 @@
this.columnHeader15,
this.columnHeader19,
this.columnHeader20,
- this.columnHeader21,
- this.columnHeader22,
- this.columnHeader23,
- this.columnHeader24});
+ this.columnHeader21});
this.sensor_list.Dock = System.Windows.Forms.DockStyle.Fill;
this.sensor_list.HideSelection = false;
this.sensor_list.Location = new System.Drawing.Point(4, 26);
this.sensor_list.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.sensor_list.Name = "sensor_list";
- this.sensor_list.Size = new System.Drawing.Size(1417, 615);
+ this.sensor_list.Size = new System.Drawing.Size(1417, 616);
this.sensor_list.TabIndex = 1;
this.sensor_list.UseCompatibleStateImageBehavior = false;
this.sensor_list.View = System.Windows.Forms.View.Details;
@@ -341,11 +335,13 @@
// columnHeader11
//
this.columnHeader11.Text = "编号";
+ this.columnHeader11.Width = 80;
//
// columnHeader12
//
this.columnHeader12.Text = "名称";
this.columnHeader12.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
+ this.columnHeader12.Width = 120;
//
// columnHeader13
//
@@ -381,23 +377,6 @@
this.columnHeader21.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader21.Width = 100;
//
- // columnHeader22
- //
- this.columnHeader22.Text = "多组上传";
- this.columnHeader22.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
- this.columnHeader22.Width = 70;
- //
- // columnHeader23
- //
- this.columnHeader23.Text = "超时时间(ms)";
- this.columnHeader23.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
- this.columnHeader23.Width = 100;
- //
- // columnHeader24
- //
- this.columnHeader24.Text = "立即返回";
- this.columnHeader24.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
- //
// timer1
//
this.timer1.Enabled = true;
@@ -516,9 +495,6 @@
private System.Windows.Forms.ColumnHeader columnHeader19;
private System.Windows.Forms.ColumnHeader columnHeader20;
private System.Windows.Forms.ColumnHeader columnHeader21;
- private System.Windows.Forms.ColumnHeader columnHeader22;
- private System.Windows.Forms.ColumnHeader columnHeader23;
- private System.Windows.Forms.ColumnHeader columnHeader24;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Label label_Version;
private System.Windows.Forms.NotifyIcon notifyIcon1;
diff --git a/HighWayAssemble/Main/FrmDisplayModel.cs b/HighWayAssemble/Main/FrmDisplayModel.cs
index 27a6917..1f67499 100644
--- a/HighWayAssemble/Main/FrmDisplayModel.cs
+++ b/HighWayAssemble/Main/FrmDisplayModel.cs
@@ -6,6 +6,7 @@ using Highway.Assemble.Sql;
using Highway.Assemble.SqlSugar.serviceImpl;
using Highway.SocketServer;
using HighWayAssemble.Protocol;
+using Mesnac.DeviceAdapter;
using RRQMCore.XREF.Newtonsoft.Json.Serialization;
using RRQMSocket;
using System;
@@ -20,6 +21,7 @@ using TouchSocket.Core;
using TouchSocket.Http;
using TouchSocket.Rpc;
using TouchSocket.Sockets;
+using static System.Net.Mime.MediaTypeNames;
using IPHost = TouchSocket.Sockets.IPHost;
using SocketClient = TouchSocket.Sockets.SocketClient;
@@ -62,79 +64,97 @@ namespace HighWayAssemble
///
void Init()
{
- SoftInfo = App.Make();
- SoftInfo.CollectInfo = new Collect();
- // configInfo = App.Make();
- m_BoxDB = App.Make();
- GetConfiginfo();
- Sql = App.Make(SoftInfo.CollectInfo.sqlstring);
- GetSoftInfo();
- m_EquipClient = App.Make();
- //创建webapi
-
- var t = Task.Run(async delegate
+ try
{
- await Task.Delay(10);
- CreateTcp();
- MesHttpClient = new MesHttpClient();
- MesHttpClient.init();
- var service = new HttpService();
- await service.SetupAsync(new TouchSocketConfig()
- .SetListenIPHosts(int.Parse(System.Configuration.ConfigurationManager.AppSettings["ApiPort"]))
- .ConfigureContainer(a =>
- {
- a.AddConsoleLogger();
- a.AddRpcStore(store =>
- {
- store.RegisterServer();//注册服务
- });
- })
- .ConfigurePlugins(a =>
- {
- a.UseCheckClear();
-
- a.UseWebApi()
- .ConfigureConverter(converter =>
- {
- converter.AddJsonSerializerFormatter(new Newtonsoft.Json.JsonSerializerSettings() { Formatting = Newtonsoft.Json.Formatting.None });
- });
-
- //此插件是http的兜底插件,应该最后添加。作用是当所有路由不匹配时返回404.且内部也会处理Option请求。可以更好的处理来自浏览器的跨域探测。
- a.UseDefaultHttpServicePlugin();
- }
- ));
- await service.StartAsync();
- await m_service.StartAsync();//启动
-
- //CreatSocketServer();
+ SoftInfo = App.Make();
+ SoftInfo.CollectInfo = new Collect();
+ // configInfo = App.Make();
+ m_BoxDB = App.Make();
+ GetConfiginfo();
+ Sql = App.Make(SoftInfo.CollectInfo.sqlstring);
+ GetSoftInfo();
+ m_EquipClient = App.Make();
InitEquipClient();
- if (IsOPCFlag == 1)
- {
- LoadOPCInfo();
- }
- FrmDisplayView.LogInfo.Info("创建SockteSvr成功!");
- });
- Task.Run(async delegate
- {
- while (true)
- {//每十分钟将软件状态插入数据库
- Sql.InsertCollectState(SoftInfo.CollectInfo.collectID, 1);
- await Task.Delay(1000 * 60 * 10);
- }
- });
+ //创建webapi
- if (SoftInfo.mode == Mode.Triangle)
- {
+ var t = Task.Run(async delegate
+ {
+ await Task.Delay(10);
+ CreateTcp();
+ MesHttpClient = new MesHttpClient();
+ MesHttpClient.init();
+ var service = new HttpService();
+ await service.SetupAsync(new TouchSocketConfig()
+ .SetListenIPHosts(SoftInfo.CollectInfo.Port)
+ .ConfigureContainer(a =>
+ {
+ ////添加跨域服务
+ //a.AddCors(corsOption =>
+ //{
+ // //添加跨域策略,后续使用policyName即可应用跨域策略。
+ // corsOption.Add("cors", corsBuilder =>
+ // {
+ // corsBuilder.AllowAnyMethod()
+ // .AllowAnyOrigin();
+ // });
+ //});
+
+ a.AddConsoleLogger();
+ a.AddRpcStore(store =>
+ {
+ store.RegisterServer();//注册服务
+ });
+ })
+ .ConfigurePlugins(a =>
+ {
+ a.UseWebApi()
+ .ConfigureConverter(converter =>
+ {
+ converter.AddJsonSerializerFormatter(new Newtonsoft.Json.JsonSerializerSettings() { Formatting = Newtonsoft.Json.Formatting.None });
+ });
+
+ //此插件是http的兜底插件,应该最后添加。作用是当所有路由不匹配时返回404.且内部也会处理Option请求。可以更好的处理来自浏览器的跨域探测。
+ a.UseDefaultHttpServicePlugin();
+ }
+ ));
+ await service.StartAsync();
+ await m_service.StartAsync();//启动
+
+ //CreatSocketServer();
+
+ if (IsOPCFlag == 1)
+ {
+ LoadOPCInfo();
+ }
+ FrmDisplayView.LogInfo.Info("创建SockteSvr成功!");
+ });
Task.Run(async delegate
{
- await Task.Delay(1000);
- //SendHeard();
+ while (true)
+ {//每十分钟将软件状态插入数据库
+ Sql.InsertCollectState(SoftInfo.CollectInfo.collectID, 1);
+ await Task.Delay(1000 * 60 * 10);
+ }
});
- //Thread th = new Thread(SendHeard);
- //th.Start();
+
+ //if (SoftInfo.mode == Mode.Triangle)
+ //{
+ // Task.Run(async delegate
+ // {
+ // await Task.Delay(1000);
+ // //SendHeard();
+ // });
+ // //Thread th = new Thread(SendHeard);
+ // //th.Start();
+ //}
+ //DealProcessReceive();
+ DeleteLogFile();
}
- //DealProcessReceive();
- DeleteLogFile();
+ catch (Exception ex)
+ {
+
+ }
+
}
private Object obj = new object();
@@ -316,23 +336,23 @@ namespace HighWayAssemble
for (int i = 0; i < state.Count; i++)
{
//add by 2024-08-26 OPC新增设备断线后写入空格
- if (state[i].m_ConnectState == 2)
- {
- if (state[i].m_iDeviceId == 30101)
- {
- string strTag1 = string.Format(@"\\172.18.19.21\HMMLZD.No{0}_IntoStack_RFIDMessage.Value", 1);
- opc.WriteTag(strTag1, "NoRead");
- string strTag2 = string.Format(@"\\172.18.19.21\HMMLZD.No{0}_IntoStack_RealStack.Value", 1);
- opc.WriteTag(strTag2, "NoRead");
- }
- if (state[i].m_iDeviceId == 30102)
- {
- string strTag = string.Format(@"\\172.18.19.21\HMMLZD.No{0}_IntoStack_RFIDMessage.Value", 2);
- opc.WriteTag(strTag, "NoRead");
- string strTag2 = string.Format(@"\\172.18.19.21\HMMLZD.No{0}_IntoStack_RealStack.Value", 2);
- opc.WriteTag(strTag2, "NoRead");
- }
- }
+ //if (state[i].m_ConnectState == 2)
+ //{
+ // if (state[i].m_iDeviceId == 30101)
+ // {
+ // string strTag1 = string.Format(@"\\172.18.19.21\HMMLZD.No{0}_IntoStack_RFIDMessage.Value", 1);
+ // opc.WriteTag(strTag1, "NoRead");
+ // string strTag2 = string.Format(@"\\172.18.19.21\HMMLZD.No{0}_IntoStack_RealStack.Value", 1);
+ // opc.WriteTag(strTag2, "NoRead");
+ // }
+ // if (state[i].m_iDeviceId == 30102)
+ // {
+ // string strTag = string.Format(@"\\172.18.19.21\HMMLZD.No{0}_IntoStack_RFIDMessage.Value", 2);
+ // opc.WriteTag(strTag, "NoRead");
+ // string strTag2 = string.Format(@"\\172.18.19.21\HMMLZD.No{0}_IntoStack_RealStack.Value", 2);
+ // opc.WriteTag(strTag2, "NoRead");
+ // }
+ //}
//Sql.InsertEquipState(state[i].m_iDeviceId.ToString(), state[i].m_ConnectState);
await InsertDeviceState(state[i].m_iDeviceId, state[i].m_ConnectState);
}
@@ -381,13 +401,16 @@ namespace HighWayAssemble
}
else
{
+ //data = data.Where((x, i) => data.FindIndex(z => z.EPCstring == x.EPCstring) == i).ToList();
+
if (data != null && data.Any())
{
+
info = string.Join(",", data.Select(item => item.EPCstring));
}
else
{
- info = string.Empty; // 处理空集合的情况
+ info = "NoData"; // 处理空集合的情况
}
//dataInfo = data;
// dataInfo = Encoding.ASCII.GetBytes(MsgUtil.bytesToHexStr(data, data.Length));//dataInfo = data;
@@ -410,7 +433,7 @@ namespace HighWayAssemble
//FrmDisplayView.LogInfo.Info(string.Format("发送MES主动读取到的数据 MES地址:{0},消息内容:{1} --{2}", addr, MsgUtil.bytesToHexStr(sendbuf, sendbuf.Length), token == null ? "MES断开" : ""));
//2022-11-17 添加注释,等待时间10s
//Sql.InsertReadData(id.ToString(), info, 0);
- //await InsertRealWorkData(id.ToString(), info, 0);
+ await InsertRealWorkData(id.ToString(), info, 0);
}
});
@@ -439,13 +462,15 @@ namespace HighWayAssemble
}
else
{
+ //data = data.Where((x, i) => data.FindIndex(z => z.EPCstring == x.EPCstring) == i).ToList();
if (data != null && data.Any())
{
+
info = string.Join(",", data.Select(item => item.EPCstring));
}
else
{
- info = string.Empty; // 处理空集合的情况
+ info = "NoData"; // 处理空集合的情况
}
//dataInfo = data;// dataInfo = Encoding.ASCII.GetBytes(MsgUtil.bytesToHexStr(data, data.Length));//dataInfo = data;
//info = MsgUtil.bytesToHexStr(data, data.Length);
@@ -473,10 +498,10 @@ namespace HighWayAssemble
mesParaData.EPCID = info;
mesParaData.READSTATUS = info == "NoData" ? "1" : "0";
mesParaData.READTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- //MesHttpClient.autoread(mesParaData);
+ MesHttpClient.autoread(mesParaData);
- //await InsertRealWorkData(id.ToString(), info, 2);
+ await InsertRealWorkData(id.ToString(), info, 2);
});
//自报数据回调
@@ -542,7 +567,7 @@ namespace HighWayAssemble
// await Task.Delay(1);
// m_EquipClient.Device_BeginIdentify(MsgUtil.ParseToInt(sensorInfo.CallCombineID));//设置读写器连续读
//});
- Thread m_bgwWaitingForData = new Thread(() => m_EquipClient.Device_BeginIdentify(MsgUtil.ParseToInt(sensorInfo.CallCombineID)));
+ Thread m_bgwWaitingForData = new Thread(() => m_EquipClient.Device_BeginIdentify(sensorInfo.CallCombineID));
m_bgwWaitingForData.IsBackground = true;
m_bgwWaitingForData.Start();
//m_EquipClient.Device_BeginIdentify(MsgUtil.ParseToInt(sensorInfo.CallCombineID));//设置读写器连续读
@@ -685,6 +710,27 @@ namespace HighWayAssemble
return false;
}
}
+ public bool InsertRealMesData(string CombID, string data,string response, int type)
+ {
+ try
+ {
+ RealMesdata realWorkdata = new RealMesdata();
+ realWorkdata.Combineid = CombID.ToString();
+ realWorkdata.Data = data;
+ realWorkdata.Response = response;
+ realWorkdata.Reportmode = type;
+ realWorkdata.Tm = DateTime.Now;
+ realWorkdata.Edittime = DateTime.Now;
+ realWorkdata.Deleteflag = 0;
+ var MaterialTypeList = new BaseServices().Add1(realWorkdata);
+ return true;
+ }
+ catch (Exception ex)
+ {
+ FrmDisplayView.LogInfo.Fatal("插入数据失败" + ex.ToString());
+ return false;
+ }
+ }
///
/// 获取汇集软件、适配软件、设备信息数据
///
@@ -1182,7 +1228,7 @@ namespace HighWayAssemble
}
else
{
- await m_EquipClient.Device_MESBeginIdentify(num); //主动盘点
+ await m_EquipClient.Device_MESBeginIdentify(num.ToString()); //主动盘点
}
//Thread m_bgwWaitingForData = new Thread(() => m_EquipClient.Device_MESBeginIdentify(num));
diff --git a/HighWayAssemble/Protocol/ApiServer.cs b/HighWayAssemble/Protocol/ApiServer.cs
index 0179236..f7bb3a3 100644
--- a/HighWayAssemble/Protocol/ApiServer.cs
+++ b/HighWayAssemble/Protocol/ApiServer.cs
@@ -3,15 +3,18 @@ using Highway.Assemble.common;
using Highway.Assemble.Common;
using Highway.Assemble.EquipClient;
using Highway.Assemble.Sql;
+using Highway.Assemble.SqlSugar.serviceImpl;
using log4net;
using Mesnac.DeviceAdapter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.Text.Json;
using System.Threading.Tasks;
using TouchSocket.Rpc;
using TouchSocket.WebApi;
+using static System.Windows.Forms.AxHost;
namespace HighWayAssemble.Protocol
{
@@ -30,8 +33,9 @@ namespace HighWayAssemble.Protocol
///
///
///
+ [Router("/[action]")]
[WebApi(Method = HttpMethodType.Post)]
- public async Task> RFIDcontrol(MesParaData mesParaData)
+ public async Task> autoread()
{
return new ApiResponse
@@ -40,6 +44,7 @@ namespace HighWayAssemble.Protocol
Data = null,
Msg = "sucess",
};
+
}
///
/// 查询设备信息
@@ -56,6 +61,7 @@ namespace HighWayAssemble.Protocol
Data = rFIDDeviceInfos,
Msg = "sucess",
};
+
}
///
@@ -67,10 +73,14 @@ namespace HighWayAssemble.Protocol
[WebApi(Method = HttpMethodType.Post)]
public async Task> readAsync(MesReadPara mesReadPara)
{
- FrmDisplayView.LogInfo.InfoFormat("接收MES主动读取指令{0},{1}",mesReadPara.EQUID ,mesReadPara.requesttime);
+ ApiResponse response = new ApiResponse();
+ int code = 400;
+ string Msg = "error";
+ FrmDisplayView.LogInfo.InfoFormat("接收MES主动读取指令{0}", JsonSerializer.Serialize(mesReadPara));
+ //FrmDisplayView.LogInfo.InfoFormat("接收MES主动读取指令{0},{1}",mesReadPara.EQUID ,mesReadPara.requesttime);
MesReadRespon mesReadRespon = new MesReadRespon();
- List rfid = null;
- m_EquipClient.ReadRFID(Int32.Parse(mesReadPara.EQUID), out rfid);
+ List rfid = m_EquipClient.ReadRFID(mesReadPara.EQUID);
+
if (rfid != null && rfid.Count > 0)
{
if (rfid.Count > 1)
@@ -78,21 +88,37 @@ namespace HighWayAssemble.Protocol
if (rfid != null && rfid.Any())
{
mesReadRespon.EPCID = string.Join(",", rfid.Select(item => item.EPCstring));
+ Msg = "multiple EPC";
}
}
else
{
mesReadRespon.EPCID = rfid[0].EPCstring;
+ code = 200;
+ Msg = "sucess";
}
mesReadRespon.Respontime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
- return new ApiResponse
+ else
{
- Code = 200,
+ Msg = "nodata";
+ }
+ response = new ApiResponse()
+ {
+ Code = code,
Data = mesReadRespon,
- Msg = "sucess",
+ Msg = Msg,
};
+ FrmDisplayView.LogInfo.InfoFormat("发送MES主动读取指令{0}", JsonSerializer.Serialize(response));
+ InsertRealMesData(mesReadPara.EQUID.ToString(), JsonSerializer.Serialize(mesReadPara), JsonSerializer.Serialize(response), 0);
+ return response;
+ //return new ApiResponse
+ //{
+ // Code = code,
+ // Data = mesReadRespon,
+ // Msg = Msg,
+ //};
}
@@ -104,16 +130,65 @@ namespace HighWayAssemble.Protocol
///
[WebApi(Method = HttpMethodType.Post)]
public async Task> revresult(MesAlarmLightPara mesAlarmLightPara)
- {
- FrmDisplayView.LogInfo.InfoFormat("接收MES控制报警灯指令{0},{1}", mesAlarmLightPara.EQUID, mesAlarmLightPara.Sendtime);
+ {
+ ApiResponse response = new ApiResponse();
- m_EquipClient.WriteAlarmLight(Int32.Parse(mesAlarmLightPara.EQUID), mesAlarmLightPara.Code);
- return new ApiResponse
+ FrmDisplayView.LogInfo.InfoFormat("接收MES控制报警灯指令{0}", JsonSerializer.Serialize(mesAlarmLightPara));
+
+ //FrmDisplayView.LogInfo.InfoFormat("接收MES控制报警灯指令{0},{1},{2}", mesAlarmLightPara.EQUID, mesAlarmLightPara.Sendtime, mesAlarmLightPara.Code);
+
+ if (mesAlarmLightPara.Code == "0")
+ {
+ mesAlarmLightPara.Code = "2";
+ }
+ else if (mesAlarmLightPara.Code == "1")
+ {
+ mesAlarmLightPara.Code = "3";
+ }
+ else
+ {
+ mesAlarmLightPara.Code = "1";
+ }
+
+ m_EquipClient.WriteAlarmLight(mesAlarmLightPara.EQUID, mesAlarmLightPara.Code);
+
+ response = new ApiResponse()
{
Code = 200,
Data = null,
Msg = "sucess",
};
+ FrmDisplayView.LogInfo.InfoFormat("发送MES控制报警灯指令{0}", JsonSerializer.Serialize(response));
+ InsertRealMesData(mesAlarmLightPara.EQUID.ToString(), JsonSerializer.Serialize(mesAlarmLightPara), JsonSerializer.Serialize(response), 1);
+ return response;
+
+ //return new ApiResponse
+ //{
+ // Code = 200,
+ // Data = null,
+ // Msg = "sucess",
+ //};
+ }
+ public bool InsertRealMesData(string CombID, string data, string response, int type)
+ {
+ try
+ {
+ RealMesdata realWorkdata = new RealMesdata();
+ realWorkdata.Combineid = CombID.ToString();
+ realWorkdata.Data = data;
+ realWorkdata.Response = response;
+ realWorkdata.Reportmode = type;
+ realWorkdata.Tm = DateTime.Now;
+ realWorkdata.Edittime = DateTime.Now;
+ realWorkdata.Deleteflag = 0;
+ var MaterialTypeList = new BaseServices().Add1(realWorkdata);
+ return true;
+ }
+ catch (Exception ex)
+ {
+ FrmDisplayView.LogInfo.Fatal("插入数据失败" + ex.ToString());
+ return false;
+ }
}
}
}
diff --git a/HighWayAssemble/Protocol/MesHttpClient.cs b/HighWayAssemble/Protocol/MesHttpClient.cs
index ff9225c..2d8f52a 100644
--- a/HighWayAssemble/Protocol/MesHttpClient.cs
+++ b/HighWayAssemble/Protocol/MesHttpClient.cs
@@ -35,7 +35,8 @@ namespace HighWayAssemble.Protocol
{
_MeshttpClient = new WebApiClient();
await _MeshttpClient.SetupAsync(new TouchSocketConfig()
- .SetRemoteIPHost("127.0.0.1:6001")
+ .SetRemoteIPHost("172.16.0.106:9880")
+ //.SetRemoteIPHost("127.0.0.1:9880")
.ConfigurePlugins(a =>
{
@@ -55,8 +56,8 @@ namespace HighWayAssemble.Protocol
var requestForPost = new WebApiRequest();
requestForPost.Method = HttpMethodType.Post;
requestForPost.Body = new MesParaData() { EQUID = mesParaData.EQUID, EPCID = mesParaData.EPCID, READSTATUS = mesParaData.READSTATUS, ERRORMSG = mesParaData.ERRORMSG, READTIME = mesParaData.READTIME };
-
- JToken responseValue = _MeshttpClient.InvokeT("/ApiServer/RFIDcontrol", null, requestForPost);
+ FrmDisplayView.LogInfo.Info(JsonSerializer.Serialize(requestForPost.Body));
+ JToken responseValue = _MeshttpClient.InvokeT("/autoread", null, requestForPost);
return MsgUtil.JTokenToEntity>(responseValue);
}
diff --git a/Highway.Assemble.Common/Highway.Assemble.Common.csproj b/Highway.Assemble.Common/Highway.Assemble.Common.csproj
index a2b93cf..13e6102 100644
--- a/Highway.Assemble.Common/Highway.Assemble.Common.csproj
+++ b/Highway.Assemble.Common/Highway.Assemble.Common.csproj
@@ -52,6 +52,7 @@
+
diff --git a/Highway.Assemble.Common/RFIDDeviceInfo.cs b/Highway.Assemble.Common/RFIDDeviceInfo.cs
index 1e0b7d7..d9e0ca5 100644
--- a/Highway.Assemble.Common/RFIDDeviceInfo.cs
+++ b/Highway.Assemble.Common/RFIDDeviceInfo.cs
@@ -5,6 +5,6 @@
public string IPAddress { get; set; }
public string EQUID { get; set; }
public string position { get; set; }
-
+ public string ApiPort { get; set; }
}
}
\ No newline at end of file
diff --git a/Highway.Assemble.Common/RealMesdata.cs b/Highway.Assemble.Common/RealMesdata.cs
new file mode 100644
index 0000000..0873938
--- /dev/null
+++ b/Highway.Assemble.Common/RealMesdata.cs
@@ -0,0 +1,44 @@
+using SqlSugar;
+using System;
+namespace Highway.Assemble.common
+{
+ ///
+ ///
+ ///
+ [SugarTable("real_mesdata")]
+ public class RealMesdata
+ {
+ ///
+ ///
+ ///
+ [SugarColumn(ColumnName = "combineid")]
+ public string Combineid { get; set; }
+ ///
+ ///
+ ///
+ [SugarColumn(ColumnName = "tm")]
+ public DateTime? Tm { get; set; }
+ ///
+ ///
+ ///
+ [SugarColumn(ColumnName = "data")]
+ public string Data { get; set; }
+ [SugarColumn(ColumnName = "response")]
+ public string Response { get; set; }
+ ///
+ ///
+ ///
+ [SugarColumn(ColumnName = "reportmode")]
+ public decimal? Reportmode { get; set; }
+ ///
+ ///
+ ///
+ [SugarColumn(ColumnName = "edittime")]
+ public DateTime? Edittime { get; set; }
+ ///
+ ///
+ ///
+ [SugarColumn(ColumnName = "deleteflag")]
+ public int? Deleteflag { get; set; }
+ }
+}
diff --git a/Highway.Assemble.Common/Sensor.cs b/Highway.Assemble.Common/Sensor.cs
index ddc3452..000f51b 100644
--- a/Highway.Assemble.Common/Sensor.cs
+++ b/Highway.Assemble.Common/Sensor.cs
@@ -112,6 +112,8 @@ namespace Highway.Assemble.common
///
public int Readinterval;
+ public string FilterData;
+
public System.Threading.Timer m_Timer = null; //根据读取时间间隔设置的定时器
}
}
diff --git a/Highway.Assemble.EquipClient/DeviceInfo.cs b/Highway.Assemble.EquipClient/DeviceInfo.cs
index 5af9a9a..2ee3bee 100644
--- a/Highway.Assemble.EquipClient/DeviceInfo.cs
+++ b/Highway.Assemble.EquipClient/DeviceInfo.cs
@@ -63,7 +63,7 @@ namespace Mesnac.DeviceAdapterNet
public class AntInfo
{
- public int m_iCombineId;
+ public string m_iCombineId;
///
/// 是否超高频读头
///
diff --git a/Highway.Assemble.EquipClient/EquipClient.cs b/Highway.Assemble.EquipClient/EquipClient.cs
index a10b6aa..527d369 100644
--- a/Highway.Assemble.EquipClient/EquipClient.cs
+++ b/Highway.Assemble.EquipClient/EquipClient.cs
@@ -5,6 +5,7 @@ using Mesnac.DeviceAdapterNet;
using System;
using System.Collections.Generic;
using System.ComponentModel;
+using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
@@ -18,9 +19,9 @@ namespace Highway.Assemble.EquipClient
public Action> EquipStateAction;
- public Action> ReadDataAction;
+ public Action> ReadDataAction;
- public Action> RecSendDataAction;
+ public Action> RecSendDataAction;
public Action RecGetDataAction;
@@ -61,7 +62,7 @@ namespace Highway.Assemble.EquipClient
for (int i = 0; i < m_SensorInfoList.Count; i++)
{
AntInfo a = new AntInfo();
- a.m_iCombineId = Convert.ToInt32(m_SensorInfoList[i].combineid);
+ a.m_iCombineId = m_SensorInfoList[i].combineid;
AntList[i] = a;
}
}
@@ -213,7 +214,7 @@ namespace Highway.Assemble.EquipClient
item.m_ConnectState = 1;
break;
case 2:
- item.m_ConnectState = 2;
+ item.m_ConnectState = 0;
item.m_IDeviceAdapter.Device_Destroy();
break;
default:
@@ -249,11 +250,11 @@ namespace Highway.Assemble.EquipClient
///
private void RecvIdentifyDataToMES_Instance(ushort iLen, byte[] pData, byte Antenna, ushort iDeviceId, string strId, string sensorType)
{
- uint iCombineId = 0u;
+ string iCombineId = "";
try
{
iCombineId = GetCombineIdByDeviceIdAndSer(Antenna, iDeviceId, sensorType);
- if (iCombineId != 0)
+ if (iCombineId != "")
{
if (iLen > 0)
{
@@ -267,14 +268,14 @@ namespace Highway.Assemble.EquipClient
LogInfo.Info("------------------------------------------------------------------------------------------------------");
LogInfo.Info("MES主动读取合并编号[" + iCombineId + "]的第[" + Antenna + "]号传感器自报数据:NoData");
LogInfo.Info("------------------------------------------------------------------------------------------------------");
- ReadDataAction?.Invoke(Convert.ToInt32(iCombineId), null);
+ //ReadDataAction?.Invoke(Convert.ToInt32(iCombineId), null);
}
}
}
catch (Exception ex)
{
LogInfo.Info("RecvIdentifyDataToMES_Instance:" + ex.ToString());
- ReadDataAction?.Invoke(Convert.ToInt32(iCombineId), null);
+ //ReadDataAction?.Invoke(Convert.ToInt32(iCombineId), null);
}
}
@@ -285,20 +286,40 @@ namespace Highway.Assemble.EquipClient
/// 设备编号
/// 传感器类型
///
- private uint GetCombineIdByDeviceIdAndSer(byte iSensorSer, ushort iDeviceId, string sensorType)
+ private string GetCombineIdByDeviceIdAndSer(byte iSensorSer, ushort iDeviceId, string sensorType)
{
- uint iCombineId = 0u;
+ string iCombineId = "";
for (int i = 0; i < m_SensorInfoList.Count; i++)
{
if (iSensorSer == Convert.ToUInt16(m_SensorInfoList[i].sensorser) && iDeviceId == Convert.ToUInt16(m_SensorInfoList[i].deviceId) && sensorType == m_SensorInfoList[i].sensortypeid)
{
- iCombineId = Convert.ToUInt32(m_SensorInfoList[i].combineid);
+ iCombineId = m_SensorInfoList[i].combineid;
break;
}
}
return iCombineId;
}
+ private string GetFilterDataByDeviceIdAndSer(byte iSensorSer, UInt16 iDeviceId)
+ {
+ string FilterData = "";
+ for (int i = 0; i < m_SensorInfoList.Count; i++)
+ {
+ if ((iSensorSer == Convert.ToUInt16(m_SensorInfoList[i].sensorser)) && (iDeviceId == Convert.ToUInt16(m_SensorInfoList[i].deviceId)))
+ {
+ FilterData = m_SensorInfoList[i].FilterData;
+ break;
+ }
+ }
+ return FilterData;
+ }
+
+ private static List FilterByEPCString(List tagList, string searchText)
+ {
+ return tagList
+ .Where(tag => tag.EPCstring != null && tag.EPCstring.Contains(searchText))
+ .ToList();
+ }
///
/// 监听自动上报后数据返回事件
///
@@ -310,11 +331,13 @@ namespace Highway.Assemble.EquipClient
/// 传感器类型
public void RecvIdentifyData_Instance(ushort iLen, List tagInfos, byte Antenna, ushort iDeviceId, string strId, string sensorType)
{
- uint iCombineId = 0u;
+ string iCombineId = "";
+ string FilterData = "";
try
{
iCombineId = GetCombineIdByDeviceIdAndSer(Antenna, iDeviceId, sensorType);
- if (iCombineId == 0)
+ FilterData = GetFilterDataByDeviceIdAndSer(Antenna, iDeviceId);
+ if (iCombineId == "")
{
return;
}
@@ -329,8 +352,9 @@ namespace Highway.Assemble.EquipClient
// return;
//}
LogInfo.Info("------------------------------------------------------------------------------------------------------");
- //LogInfo.Info("读写器自报合并编号[" + iCombineId + "]的第[" + Antenna + "]号传感器,自报数据:" + Encoding.ASCII.GetString(pData, 0, pData.Length) + ",原始数据:" + bytesToHexStr(pData, pData.Length));
+ LogInfo.Info("读写器自报合并编号[" + iCombineId + "]的第[" + Antenna + "]号传感器,过滤规则[" + FilterData + "],自报数据:" + string.Join(",", tagInfos.Select(item => item.EPCstring)));
LogInfo.Info("------------------------------------------------------------------------------------------------------");
+ tagInfos = tagInfos.Where((x, i) => tagInfos.FindIndex(z => z.EPCstring == x.EPCstring) == i).ToList();
AntInfo[] antList = AntList;
foreach (AntInfo item in antList)
{
@@ -339,7 +363,11 @@ namespace Highway.Assemble.EquipClient
item.IsReading = false;
item.ReadData = new byte[tagInfos[0].EPC.Length];
Array.Copy(tagInfos[0].EPC, 0, item.ReadData, 0, tagInfos[0].EPC.Length);
- RecSendDataAction?.Invoke(Convert.ToInt32(iCombineId), tagInfos);
+ if (!string.IsNullOrEmpty(FilterData))
+ {
+ tagInfos = FilterByEPCString(tagInfos, FilterData);
+ }
+ RecSendDataAction?.Invoke(iCombineId, tagInfos);
}
}
}
@@ -348,7 +376,7 @@ namespace Highway.Assemble.EquipClient
LogInfo.Info("------------------------------------------------------------------------------------------------------");
LogInfo.Info("自报合并编号[" + iCombineId + "]的第[" + Antenna + "]号传感器自报数据:NoData");
LogInfo.Info("------------------------------------------------------------------------------------------------------");
- RecSendDataAction?.Invoke(Convert.ToInt32(iCombineId), null);
+ RecSendDataAction?.Invoke(iCombineId, null);
}
}
catch (Exception ex)
@@ -356,7 +384,7 @@ namespace Highway.Assemble.EquipClient
LogInfo.Info("空间名:" + ex.Source + ";\n方法名:" + ex.TargetSite?.ToString() + "\n故障点:" + ex.StackTrace.Substring(ex.StackTrace.LastIndexOf("\\") + 1, ex.StackTrace.Length - ex.StackTrace.LastIndexOf("\\") - 1) + "\n错误提示:" + ex.Message);
if (iLen == 0)
{
- RecAutoDataAction?.Invoke(Convert.ToInt32(iCombineId), null);
+ RecSendDataAction?.Invoke(iCombineId, null);
}
}
}
@@ -394,7 +422,7 @@ namespace Highway.Assemble.EquipClient
try
{
LogInfo.Info("接收到MES主动读取数据命令,合并编号:" + num);
- pDeviceInfo = GetIDeviceInfoByCombineId(Convert.ToUInt32(num));
+ //pDeviceInfo = GetIDeviceInfoByCombineId(Convert.ToUInt32(num));
pSensorInfo = GetSensorInfoByCombineId(Convert.ToUInt32(num));
if (pDeviceInfo.m_IDeviceAdapter != null)
{
@@ -410,19 +438,19 @@ namespace Highway.Assemble.EquipClient
LogInfo.Info("------------------------------------------------------------------------------------------------------");
LogInfo.Info("MES主动读取数据成功,合并编号:[" + num + "],读取数据:NoData");
LogInfo.Info("------------------------------------------------------------------------------------------------------");
- ReadDataAction?.Invoke(num, null);
+ //ReadDataAction?.Invoke(num, null);
}
}
else
{
LogInfo.Info("MES主动读取失败,合并编号:" + num);
- ReadDataAction?.Invoke(num, null);
+ //ReadDataAction?.Invoke(num, null);
}
}
catch (Exception ex)
{
LogInfo.Info("MES主动读取异常:" + ex.ToString());
- ReadDataAction?.Invoke(num, null);
+ //ReadDataAction?.Invoke(num, null);
}
}
@@ -448,12 +476,12 @@ namespace Highway.Assemble.EquipClient
///
/// 传感器编号
/// 设备信息
- private DeviceInfo GetIDeviceInfoByCombineId(uint iCombineId)
+ private DeviceInfo GetIDeviceInfoByCombineId(string iCombineId)
{
DeviceInfo pDeviceInfo = null;
for (int i = 0; i < m_SensorInfoList.Count; i++)
{
- if (iCombineId == Convert.ToUInt32(m_SensorInfoList[i].combineid))
+ if (iCombineId == m_SensorInfoList[i].combineid)
{
pDeviceInfo = GetDeviceInfoByDeviceId(Convert.ToUInt16(m_SensorInfoList[i].deviceId));
if (pDeviceInfo != null)
@@ -525,7 +553,7 @@ namespace Highway.Assemble.EquipClient
LogInfo.Info("方法:WriteData,接收合并编号[" + num + "]的第[" + Antenna + "]路IO,打开报警灯闪亮命令");
break;
}
- pDeviceInfo = GetIDeviceInfoByCombineId(Convert.ToUInt32(num));
+ //pDeviceInfo = GetIDeviceInfoByCombineId(Convert.ToUInt32(num));
pSensorInfo = GetSensorInfoByCombineId(Convert.ToUInt32(num));
try
{
@@ -558,7 +586,7 @@ namespace Highway.Assemble.EquipClient
byte[] array = null;
try
{
- LogInfo.Info("合并编号:" + id + ",识别单次标签命令自报");
+ //LogInfo.Info("合并编号:" + id + ",识别单次标签命令自报");
//array = GetOneEpcByCombineId(Convert.ToUInt32(id));
if (array != null)
{
@@ -572,35 +600,42 @@ namespace Highway.Assemble.EquipClient
LogInfo.Info("------------------------------------------------------------------------------------------------------");
LogInfo.Info("识别单次标签成功,合并编号[" + id + "],读取标签数据:NoData");
LogInfo.Info("------------------------------------------------------------------------------------------------------");
- ReadDataAction?.Invoke(id, null);
+ //ReadDataAction?.Invoke(id, null);
}
}
catch (Exception ex)
{
LogInfo.Info("Deal_IdentifyOneEpc异常:" + ex.ToString());
- ReadDataAction?.Invoke(id, null);
+ //ReadDataAction?.Invoke(id, null);
}
});
}
- public void ReadRFID(int id,out List rfiddata)
+ public List ReadRFID(string id)
{
List tags = new List();
- byte[] array = null;
- rfiddata = null;
+
+ string FilterData = "";
try
{
- LogInfo.Info("合并编号:" + id + ",识别单次标签命令自报");
- tags = GetOneEpcByCombineId(Convert.ToUInt32(id));
+ //LogInfo.Info("合并编号:" + id + ",识别单次标签命令自报");
+ FilterData = m_SensorInfoList.Find(x=>x.combineid == id).FilterData;
+ tags = GetOneEpcByCombineId(id);
if (tags != null)
{
- //LogInfo.Info("-------------------------------------------------------------------------------------------------------------");
- //LogInfo.Info("识别单次标签成功,合并编号[" + id + "],读取标签数据:" + Encoding.ASCII.GetString(array, 0, array.Length) + ",原始数据:" + bytesToHexStr(array, array.Length));
- //LogInfo.Info("-------------------------------------------------------------------------------------------------------------");
- //rfiddata = Encoding.ASCII.GetString(array, 0, array.Length);
- rfiddata = tags;
+ //有过滤
+ LogInfo.Info("-------------------------------------------------------------------------------------------------------------");
+ LogInfo.Info("识别单次标签成功,合并编号[" + id + "],过滤规则[" + FilterData +"],读取标签数据:" + string.Join(",", tags.Select(item => item.EPCstring)));
+ LogInfo.Info("-------------------------------------------------------------------------------------------------------------");
+ tags = tags.Where((x, i) => tags.FindIndex(z => z.EPCstring == x.EPCstring) == i).ToList();
+ //新增工位过滤
+ if (!string.IsNullOrEmpty(FilterData))
+ {
+ tags = FilterByEPCString(tags, FilterData);
+ }
ReadDataAction?.Invoke(id, tags);
+ return tags;
}
else
@@ -609,12 +644,14 @@ namespace Highway.Assemble.EquipClient
LogInfo.Info("识别单次标签成功,合并编号[" + id + "],读取标签数据:NoData");
LogInfo.Info("------------------------------------------------------------------------------------------------------");
ReadDataAction?.Invoke(id, null);
+ return tags;
}
}
catch (Exception ex)
{
- LogInfo.Info("Deal_IdentifyOneEpc异常:" + ex.ToString());
+ LogInfo.Info("异常:" + ex.ToString());
ReadDataAction?.Invoke(id, null);
+ return tags;
}
}
@@ -624,24 +661,31 @@ namespace Highway.Assemble.EquipClient
///
/// 传感器编号
/// 原始数据
- private List GetOneEpcByCombineId(uint iCombineId)
+ private List GetOneEpcByCombineId(string iCombineId)
{
List tagInfos = null;
- byte[] pReturnResult = null;
IDeviceAdapter pDeviceAdapter = null;
- byte iEpcLen = 0;
for (int i = 0; i < m_SensorInfoList.Count; i++)
{
- if (iCombineId != Convert.ToUInt32(m_SensorInfoList[i].combineid))
+ if (iCombineId != m_SensorInfoList[i].combineid)
{
continue;
}
pDeviceAdapter = GetDeviceAdapterByDeviceId(Convert.ToUInt16(m_SensorInfoList[i].deviceId));
if (pDeviceAdapter != null)
{
- tagInfos = pDeviceAdapter.Device_GetAllIdentifyData(Convert.ToByte(m_SensorInfoList[i].sensorser), Convert.ToUInt16(m_SensorInfoList[i].DelayTime), 1);
+ if (string.IsNullOrEmpty(m_SensorInfoList[i].readInterval))
+ {
+ m_SensorInfoList[i].readInterval = "1000";
+ }
+ tagInfos = pDeviceAdapter.Device_GetAllIdentifyData(Convert.ToByte(m_SensorInfoList[i].sensorser), Convert.ToUInt16(m_SensorInfoList[i].readInterval), 1);
if (tagInfos.Count > 0)
{
+ //新增工位过滤
+ //if (!string.IsNullOrEmpty(m_SensorInfoList[i].FilterData))
+ //{
+ // tagInfos = FilterByEPCString(tagInfos, m_SensorInfoList[i].FilterData);
+ //}
return tagInfos;
}
return null;
@@ -683,12 +727,12 @@ namespace Highway.Assemble.EquipClient
RecGetDataAction = action;
}
- public void RecSendData(Action> action)
+ public void RecSendData(Action> action)
{
RecSendDataAction = action;
}
- public void RetReadData(Action> action)
+ public void RetReadData(Action> action)
{
ReadDataAction = action;
}
@@ -706,7 +750,7 @@ namespace Highway.Assemble.EquipClient
/// 根据传感器合并编号处理数据
///
/// 传感器合并编号
- private void Deal_Data(int num)
+ private void Deal_Data(string num)
{
AntInfo[] antList = AntList;
foreach (AntInfo item in antList)
@@ -737,12 +781,12 @@ namespace Highway.Assemble.EquipClient
/// 开始连续盘点
///
/// 传感器合并编号
- public void Device_BeginIdentify(int num)
+ public void Device_BeginIdentify(string num)
{
bool bResult = false;
DeviceInfo pDeviceInfo = null;
Sensor pSensorInfo = null;
- pDeviceInfo = GetIDeviceInfoByCombineId(Convert.ToUInt32(num));
+ //pDeviceInfo = GetIDeviceInfoByCombineId(Convert.ToUInt32(num));
pSensorInfo = GetSensorInfoByCombineId(Convert.ToUInt32(num));
AntInfo[] antList = AntList;
foreach (AntInfo item in antList)
@@ -762,13 +806,13 @@ namespace Highway.Assemble.EquipClient
{
if (pDeviceInfo.m_IDeviceAdapter != null)
{
- bResult = pDeviceInfo.m_IDeviceAdapter.Device_BeginIdentify(Convert.ToByte(pSensorInfo.sensorser), Convert.ToInt32(pSensorInfo.timeout), AutoRead: true, num);
+ //bResult = pDeviceInfo.m_IDeviceAdapter.Device_BeginIdentify(Convert.ToByte(pSensorInfo.sensorser), Convert.ToInt32(pSensorInfo.timeout), AutoRead: true, num);
if (!bResult)
{
- bResult = pDeviceInfo.m_IDeviceAdapter.Device_BeginIdentify(Convert.ToByte(pSensorInfo.sensorser), Convert.ToInt32(pSensorInfo.timeout), AutoRead: true, num);
+ //bResult = pDeviceInfo.m_IDeviceAdapter.Device_BeginIdentify(Convert.ToByte(pSensorInfo.sensorser), Convert.ToInt32(pSensorInfo.timeout), AutoRead: true, num);
if (!bResult)
{
- bResult = pDeviceInfo.m_IDeviceAdapter.Device_BeginIdentify(Convert.ToByte(pSensorInfo.sensorser), Convert.ToInt32(pSensorInfo.timeout), AutoRead: true, num);
+ //bResult = pDeviceInfo.m_IDeviceAdapter.Device_BeginIdentify(Convert.ToByte(pSensorInfo.sensorser), Convert.ToInt32(pSensorInfo.timeout), AutoRead: true, num);
}
}
Thread.Sleep(1);
@@ -782,7 +826,7 @@ namespace Highway.Assemble.EquipClient
{
item2.IsReading = false;
item2.readType = 0;
- DealNoData(num, v: true);
+ //DealNoData(num, v: true);
item2.ReadData = null;
}
}
@@ -815,12 +859,12 @@ namespace Highway.Assemble.EquipClient
if (v)
{
LogInfo.Info("》》》触发读取时间超时,返回Nodata,合并编号:" + num);
- RecSendDataAction?.Invoke(Convert.ToInt32(num), null);
+ //RecSendDataAction?.Invoke(Convert.ToInt32(num), null);
}
else
{
LogInfo.Info("》》》MES主动读取时间超时,返回Nodata,合并编号:" + num);
- ReadDataAction?.Invoke(Convert.ToInt32(num), null);
+ //ReadDataAction?.Invoke(Convert.ToInt32(num), null);
}
Device_StopIdentify(num);
if (!Device_StopIdentify(num))
@@ -842,7 +886,7 @@ namespace Highway.Assemble.EquipClient
bool bResult = false;
DeviceInfo pDeviceInfo = null;
Sensor pSensorInfo = null;
- pDeviceInfo = GetIDeviceInfoByCombineId(Convert.ToUInt32(num));
+ //pDeviceInfo = GetIDeviceInfoByCombineId(num);
pSensorInfo = GetSensorInfoByCombineId(Convert.ToUInt32(num));
LogInfo.Info("合并编号:" + num + ",发送停止连续读取标签命令自报");
try
@@ -871,14 +915,14 @@ namespace Highway.Assemble.EquipClient
///
/// 传感器合并编号
///
- public async Task Device_MESBeginIdentify(int num)
+ public async Task Device_MESBeginIdentify(string num)
{
await Task.Run(delegate
{
bool flag = false;
DeviceInfo deviceInfo = null;
Sensor sensor = null;
- deviceInfo = GetIDeviceInfoByCombineId(Convert.ToUInt32(num));
+ deviceInfo = GetIDeviceInfoByCombineId(num);
sensor = GetSensorInfoByCombineId(Convert.ToUInt32(num));
LogInfo.Info("合并编号:" + num + ",MES主动发送连续读取标签命令");
AntInfo[] antList = AntList;
@@ -899,7 +943,7 @@ namespace Highway.Assemble.EquipClient
{
if (deviceInfo.m_IDeviceAdapter != null)
{
- flag = deviceInfo.m_IDeviceAdapter.Device_BeginIdentify(Convert.ToByte(sensor.sensorser), Convert.ToInt32(sensor.timeout), AutoRead: false, num);
+ //flag = deviceInfo.m_IDeviceAdapter.Device_BeginIdentify(Convert.ToByte(sensor.sensorser), Convert.ToInt32(sensor.timeout), AutoRead: false, num);
AntInfo[] antList2 = AntList;
foreach (AntInfo item in antList2)
{
@@ -909,7 +953,7 @@ namespace Highway.Assemble.EquipClient
}).Wait(Convert.ToInt32(sensor.timeout)))
{
item.IsReading = false;
- DealNoData(num, v: false);
+ //DealNoData(num, v: false);
item.ReadData = null;
}
}
@@ -951,25 +995,25 @@ namespace Highway.Assemble.EquipClient
LogInfo.Info("------------------------------------------------------------------------------------------------------");
LogInfo.Info("识别单次标签成功,合并编号[" + id + "],读取标签数据:NoData");
LogInfo.Info("------------------------------------------------------------------------------------------------------");
- ReadDataAction?.Invoke(id, null);
+ //ReadDataAction?.Invoke(id, null);
}
}
catch (Exception ex)
{
LogInfo.Info("Deal_IdentifyOneEpc异常:" + ex.ToString());
- ReadDataAction?.Invoke(id, null);
+ //ReadDataAction?.Invoke(id, null);
}
return m_data;
}
- public void WriteAlarmLight(int num,string code)
+ public void WriteAlarmLight(string num,string code)
{
bool flag = false;
try
{
DeviceInfo deviceInfo = null;
//Sensor sensor = null;
- deviceInfo = GetIDeviceInfoByCombineId(Convert.ToUInt32(num));
+ deviceInfo = GetIDeviceInfoByCombineId(num);
//sensor = GetSensorInfoByCombineId(Convert.ToUInt32(num));
if (deviceInfo.m_IDeviceAdapter != null)
{
diff --git a/Highway.Assemble.EquipClient/IEquipClient.cs b/Highway.Assemble.EquipClient/IEquipClient.cs
index 03d6c0e..2322d7c 100644
--- a/Highway.Assemble.EquipClient/IEquipClient.cs
+++ b/Highway.Assemble.EquipClient/IEquipClient.cs
@@ -19,9 +19,9 @@ namespace Highway.Assemble.EquipClient
Task ReadEPC(int id);
- void ReadRFID(int id, out List rfiddata);
+ List ReadRFID(string id);
- void RecSendData(Action> action);
+ void RecSendData(Action> action);
void RecAutoData(Action action);
@@ -29,20 +29,20 @@ namespace Highway.Assemble.EquipClient
void ReadData(int num, byte filterMembank, ushort filterWordPtr, ushort filterWordCnt, byte[] filterData, byte Membank, ushort WordPtr, ushort WordCnt);
- void RetReadData(Action> action);
+ void RetReadData(Action> action);
void WriteData(int num, byte filterMembank, ushort filterWordPtr, ushort filterWordCnt, byte[] filterData, byte Membank, ushort WordPtr, ushort WordCnt, byte[] pWriteData, byte Antenna);
void RecGetData(Action action);
- void Device_BeginIdentify(int num);
+ void Device_BeginIdentify(string num);
bool Device_StopIdentify(int num);
- Task Device_MESBeginIdentify(int num);
+ Task Device_MESBeginIdentify(string num);
string ReadEPCData(int id);
- void WriteAlarmLight(int num, string code);
+ void WriteAlarmLight(string num, string code);
}
}
diff --git a/Highway.Assemble.Sql/DbHandler.cs b/Highway.Assemble.Sql/DbHandler.cs
index 2ffcc0e..32fc65c 100644
--- a/Highway.Assemble.Sql/DbHandler.cs
+++ b/Highway.Assemble.Sql/DbHandler.cs
@@ -129,7 +129,7 @@ namespace Highway.Assemble.Sql
//sensorcode.CallAdapter = Convert.ToInt16(row["calladapter"]);
//sensorcode.CallAdapterid = row["calladapterid"].ToString().Trim();
//sensorcode.CallCombineID = row["callcombineid"].ToString().Trim();
- // sensorcode.DelayTime = TryToInt(row["DelayTime"].ToString());
+ sensorcode.FilterData = row["mapid"].ToString().Trim();
sensorcode.mesID = row["MesID"].ToString().Trim();
sensorcode.DelayTime = TryToInt(row["DelayTime"].ToString().Trim());
sensorcode.ReadCounts = TryToInt(row["ReadCounts"].ToString().Trim());
@@ -422,7 +422,7 @@ namespace Highway.Assemble.Sql
dbHelper.ClearParameter();
dbHelper.CommandType = CommandType.Text;//adapterid ="+mesID+"
dbHelper.CommandText = "";
- string sql = "select t1.connectstr, t2.sensorid,t1.addr from base_device_info t1 left join [dbo].[base_sensor_info] t2 on t1.deviceid = t2.deviceid where t1.deleteflag != 1";
+ string sql = "select t1.connectstr, t2.combineid,t1.addr,t3.port from base_device_info t1 left join [dbo].[base_sensor_info] t2 on t1.deviceid = t2.deviceid left join [dbo].[base_collect_info] t3 on t1.collectid = t3.collectId where t1.deleteflag != 1";
dbHelper.CommandText = sql;
DataTable dt = dbHelper.ToDataTable();
@@ -432,10 +432,10 @@ namespace Highway.Assemble.Sql
for (int i = 0; i < dt.Rows.Count; i++)
{
RFIDDeviceInfo mes = new RFIDDeviceInfo();
- mes.EQUID = dt.Rows[i]["sensorid"].ToString();
+ mes.EQUID = dt.Rows[i]["combineid"].ToString();
mes.IPAddress = dt.Rows[i]["connectstr"].ToString();
mes.position = dt.Rows[i]["addr"].ToString();
-
+ mes.ApiPort = dt.Rows[i]["port"].ToString();
mesList.Add(mes);
}
diff --git a/Highway.Assemble.Sql/ISql.cs b/Highway.Assemble.Sql/ISql.cs
index c11546e..88ef097 100644
--- a/Highway.Assemble.Sql/ISql.cs
+++ b/Highway.Assemble.Sql/ISql.cs
@@ -38,6 +38,10 @@ namespace Highway.Assemble.Sql
/// 设备状态
bool InsertCollectState(string ID, int state);
+ ///
+ /// MES获取设备信息列表
+ ///
+ ///
List GetRFIDEquipList();
}
diff --git a/Highway.Assemble.SqlSugar/Highway.Assemble.SqlSugar.csproj b/Highway.Assemble.SqlSugar/Highway.Assemble.SqlSugar.csproj
index 18b83eb..466da4f 100644
--- a/Highway.Assemble.SqlSugar/Highway.Assemble.SqlSugar.csproj
+++ b/Highway.Assemble.SqlSugar/Highway.Assemble.SqlSugar.csproj
@@ -7,8 +7,8 @@
{59C06619-BED8-45D8-85CF-ED55D6516C65}
Library
Properties
- AUCMA.SCADA.SqlSugar
- AUCMA.SCADA.SqlSugar
+ Highway.Assemble.SqlSugar
+ Highway.Assemble.SqlSugar
v4.6.1
512
true
diff --git a/Highway.Assemble.SqlSugar/serviceImpl/BaseServices.cs b/Highway.Assemble.SqlSugar/serviceImpl/BaseServices.cs
index 533007c..4f98d4d 100644
--- a/Highway.Assemble.SqlSugar/serviceImpl/BaseServices.cs
+++ b/Highway.Assemble.SqlSugar/serviceImpl/BaseServices.cs
@@ -18,8 +18,8 @@ namespace Highway.Assemble.SqlSugar.serviceImpl
{
_dbBase = new SqlSugarClient(new ConnectionConfig()
{
- ConnectionString = "server = 119.45.202.115; uid = sa; pwd = haiwei@123; database = XJMIDDBTOMES",
- //ConnectionString = "server = 127.0.0.1; uid = sa; pwd = 123456; database = WLDB",
+ //ConnectionString = "server = 119.45.202.115; uid = sa; pwd = haiwei@123; database = XJMIDDBTOMES",
+ ConnectionString = "server = 127.0.0.1; uid = sa; pwd = 123456; database = WLDB",
DbType = DbType.SqlServer,
InitKeyType = InitKeyType.Attribute,//从特性读取主键和自增列信息
IsAutoCloseConnection = true,//开启自动释放模式和EF原理一样我就不多解释了
diff --git a/Mesnac.DeviceAdapter.RFly_I160/RFly_I160Device.cs b/Mesnac.DeviceAdapter.RFly_I160/RFly_I160Device.cs
index ed364f6..ea9af36 100644
--- a/Mesnac.DeviceAdapter.RFly_I160/RFly_I160Device.cs
+++ b/Mesnac.DeviceAdapter.RFly_I160/RFly_I160Device.cs
@@ -115,7 +115,7 @@ namespace Mesnac.DeviceAdapter.RFly_I160
}
catch (Exception ex)
{
- LogInfo.Info("连接读写器异常:" + ex.Message);
+ LogInfo.Fatal("IP:" + m_strIp + "端口号:" + m_iPort + "连接读写器异常:" + ex.Message);
return false;
}
return true;
@@ -141,7 +141,8 @@ namespace Mesnac.DeviceAdapter.RFly_I160
}
else
{
- LogInfo.Info("Device_Connect:连接失败");
+ //LogInfo.Info("设备初始化成功,IP:" + m_strIp + "端口号:" + m_iPort);
+ LogInfo.Fatal("IP:" + m_strIp + "端口号: " + m_iPort + ",Device_Connect:连接失败");
return false;
}
}
@@ -169,7 +170,7 @@ namespace Mesnac.DeviceAdapter.RFly_I160
public bool Device_ReConnect()
{
- LogInfo.Info("Device_Connect 调用重连函数!");
+ LogInfo.Fatal("IP:" + m_strIp + "端口号: " + m_iPort + ",Device_ReConnect:调用重连函数");
return Device_Connect();
}
#endregion
@@ -309,14 +310,14 @@ namespace Mesnac.DeviceAdapter.RFly_I160
}
else //超时
{
- LogInfo.Info("发送心跳报文超时。");
+ //LogInfo.Info("发送心跳报文超时。");
iResult = 2; //通讯连接器正常,读写器故障
};
}
else
{
//通讯连接器失败或网络故障
- LogInfo.Info("发送心跳报文失败,通讯故障。");
+ //LogInfo.Info("发送心跳报文失败,通讯故障。");
iResult = 3;
}
}
@@ -432,7 +433,7 @@ namespace Mesnac.DeviceAdapter.RFly_I160
}
else
{
- LogInfo.Info("Device_GetOneIdentifyData长度不正确");
+ //LogInfo.Info("Device_GetOneIdentifyData长度不正确");
m_OneEpcDataLen = 0;
m_OneEpcAntenna = 254;
iResult = 0;
@@ -445,7 +446,7 @@ namespace Mesnac.DeviceAdapter.RFly_I160
m_OneEpcDataLen = 0;
m_OneEpcAntenna = 254;
m_ReadDataSuccessful = false;
- LogInfo.Info("Device_GetOneIdentifyData超时");
+ //LogInfo.Info("Device_GetOneIdentifyData超时");
}
}
else
@@ -525,7 +526,7 @@ namespace Mesnac.DeviceAdapter.RFly_I160
}
else
{
- LogInfo.Info("Device_GetOneIdentifyData长度不正确");
+ //LogInfo.Info("Device_GetOneIdentifyData长度不正确");
m_OneEpcDataLen = 0;
m_OneEpcAntenna = 254;
iResult = 0;