diff --git a/SlnMesnac.Common/StringChange.cs b/SlnMesnac.Common/StringChange.cs
index e1910d5..24ac349 100644
--- a/SlnMesnac.Common/StringChange.cs
+++ b/SlnMesnac.Common/StringChange.cs
@@ -163,6 +163,77 @@ namespace SlnMesnac.Common
return encode.GetString(b);
}
+ ///
+ /// 将整数转换为指定位数的byte数组(大端序)
+ ///
+ /// 目标byte数组长度
+ /// 要转换的整数
+ /// 指定长度的byte数组
+ public byte[] IntToBytes(int length, int num)
+ {
+ if (length <= 0)
+ throw new ArgumentException("长度必须大于0", nameof(length));
+
+ byte[] result = new byte[length];
+
+ // 从最高位开始填充
+ for (int i = 0; i < length; i++)
+ {
+ // 计算当前字节的位置(从高位到低位)
+ // 例如 length=2, i=0 时,移位 8 位;i=1 时,移位 0 位
+ int shift = (length - 1 - i) * 8;
+ result[i] = (byte)((num >> shift) & 0xFF);
+ }
+
+ return result;
+ }
+
+ ///
+ /// 将byte数组转换为整数(大端序)
+ ///
+ public int BytesToInt(byte[] bytes)
+ {
+ if (bytes == null || bytes.Length == 0)
+ Console.WriteLine("字节数组不能为空");
+
+ if (bytes.Length > 4)
+ Console.WriteLine("字节数组长度不能超过4(int最大4字节)");
+
+ int result = 0;
+
+ // 从高位到低位组合(大端序)
+ for (int i = 0; i < bytes.Length; i++)
+ {
+ result = (result << 8) | bytes[i];
+ }
+
+ return result;
+ }
+
+ ///
+ /// 将byte数组转换为整数(小端序)
+ ///
+ public int BytesToIntLittleEndian(byte[] bytes)
+ {
+ if (bytes == null || bytes.Length == 0)
+ throw new ArgumentException("字节数组不能为空", nameof(bytes));
+
+ if (bytes.Length > 4)
+ throw new ArgumentException("字节数组长度不能超过4(int最大4字节)", nameof(bytes));
+
+ int result = 0;
+
+ // 从低位到高位组合(小端序)
+ for (int i = 0; i < bytes.Length; i++)
+ {
+ result |= (bytes[i] << (i * 8));
+ }
+
+ return result;
+ }
+
+
+
public byte[] Swap16Bytes(byte[] OldU16)
{
byte[] ReturnBytes = new byte[2];
diff --git a/SlnMesnac.Config/AppConfig.cs b/SlnMesnac.Config/AppConfig.cs
index 2f1780f..c09d404 100644
--- a/SlnMesnac.Config/AppConfig.cs
+++ b/SlnMesnac.Config/AppConfig.cs
@@ -62,6 +62,11 @@ namespace SlnMesnac.Config
///
public List visionConfig { get; set; }
+ ///
+ /// 视觉机械臂连接配置
+ ///
+ public List deviceInfoConfig { get; set; }
+
///
/// Redis配置
///
@@ -77,6 +82,11 @@ namespace SlnMesnac.Config
///
public string StationCode { get; set; }
+ ///
+ /// MES配置
+ ///
+ public string MESConfig { get; set; }
+
public AppConfig Value => this;
}
}
diff --git a/SlnMesnac.Config/DeviceInfoConfig.cs b/SlnMesnac.Config/DeviceInfoConfig.cs
new file mode 100644
index 0000000..0b111f9
--- /dev/null
+++ b/SlnMesnac.Config/DeviceInfoConfig.cs
@@ -0,0 +1,62 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+namespace SlnMesnac.Config
+{
+ ///
+ ///
+ ///
+ public class DeviceInfoConfig
+ {
+
+
+ ///
+ /// 备 注:
+ /// 默认值:
+ ///
+ public string Deviceid { get; set; } = null!;
+
+ ///
+ /// 备 注:
+ /// 默认值:
+ ///
+ public string? Name { get; set; }
+
+ ///
+ /// 备 注:
+ /// 默认值:
+ ///
+ public string? Connectstr { get; set; }
+
+ ///
+ /// 备 注:
+ /// 默认值:
+ ///
+ public decimal? Connectmode { get; set; }
+
+ ///
+ /// 备 注:
+ /// 默认值:
+ ///
+ public string? Devicetype { get; set; }
+
+ ///
+ /// 备 注:所属汇集软件ID
+ /// 默认值:
+ ///
+ public string? Collectid { get; set; }
+
+ ///
+ /// 备 注:
+ /// 默认值:
+ ///
+ public string? Addr { get; set; }
+
+ ///
+ /// 备 注:
+ /// 默认值:
+ ///
+ public int? Deleteflag { get; set; }
+ }
+
+}
\ No newline at end of file
diff --git a/SlnMesnac.Extensions/RfidFactorySetup.cs b/SlnMesnac.Extensions/RfidFactorySetup.cs
index 42f3ed4..30cef5c 100644
--- a/SlnMesnac.Extensions/RfidFactorySetup.cs
+++ b/SlnMesnac.Extensions/RfidFactorySetup.cs
@@ -14,7 +14,7 @@ using SqlSugar;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
-
+using System.Linq;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* 版权所有 (c) 2024 WenJY 保留所有权利。
@@ -61,7 +61,8 @@ namespace SlnMesnac.Extensions
AppConfig appConfig = x.GetService();
_StringChange = x.GetService();
_TcpServer = x.GetService();
- List baseRfidInfos = sqlSugarClient.Queryable().Where(x=>x.Collectid == appConfig.StationCode).ToList();
+
+ List baseRfidInfos = appConfig.deviceInfoConfig.Where(x => x.Collectid == appConfig.StationCode).ToList();
//sensor_Infos = sqlSugarClient.Queryable().Where(x => x.Deleteflag == 0).ToList();
List absractFactories = new List();
diff --git a/SlnMesnac.Model/domain/Base_device_info.cs b/SlnMesnac.Model/domain/Base_device_info.cs
index 8cb150a..9156b66 100644
--- a/SlnMesnac.Model/domain/Base_device_info.cs
+++ b/SlnMesnac.Model/domain/Base_device_info.cs
@@ -96,10 +96,6 @@ namespace Models
[SugarColumn(ColumnName="objid" ,IsIdentity = true) ]
public int Objid { get; set; }
- public string State = "未连接";
-
- public Type FactoryType;
-
}
diff --git a/SlnMesnac.Model/domain/MesOrderInfo.cs b/SlnMesnac.Model/domain/MesOrderInfo.cs
index 5531c2f..6032763 100644
--- a/SlnMesnac.Model/domain/MesOrderInfo.cs
+++ b/SlnMesnac.Model/domain/MesOrderInfo.cs
@@ -25,5 +25,7 @@ namespace SlnMesnac.Model.domain
public string ProductName { get; set; }
[JsonPropertyName("PlanQty")]
public double PlanQty { get; set; }
+ [JsonPropertyName("NextProductNo")]
+ public int NextProductNo { get; set; }
}
}
diff --git a/SlnMesnac.Rfid/Factory/FuchsFactory.cs b/SlnMesnac.Rfid/Factory/FuchsFactory.cs
index eeeacd2..86b0671 100644
--- a/SlnMesnac.Rfid/Factory/FuchsFactory.cs
+++ b/SlnMesnac.Rfid/Factory/FuchsFactory.cs
@@ -4,6 +4,8 @@ using SlnMesnac.Model.domain;
using SlnMesnac.Model.dto;
using SlnMesnac.Rfid.Dto;
using SlnMesnac.Rfid.Enum;
+using SlnMesnac.Rfid.NewRFIDConnect;
+using SlnMesnac.Rfid.NewRFIDConnect.entity;
using SlnMesnac.Serilog;
using SlnMesnac.TouchSocket;
using System;
@@ -53,6 +55,57 @@ namespace SlnMesnac.Rfid.Factory
}
}
+ ///
+ /// 真心跳设置
+ ///
+ ///
+ public override async Task Set_HeartBeat(byte second)
+ {
+ byte[] data = new byte[3];
+ data[0] = 0x00;
+ data[1] = second;
+ data[2] = 0x01;
+
+ BaseSendDataEntity entity = new BaseSendDataEntity()
+ {
+ Code = 0xBF,
+ Data = data
+ };
+
+ byte[] result = BaseRFIDDataAnalyse.BaseSendDataAnalyse(entity);
+
+ var waitClient = _tcpClient.CreateWaitingClient(new WaitingOptions()
+ {
+ FilterFunc = response =>
+ {
+ // 检查响应数据是否符合预期
+ if (response.Memory.Length > 0)
+ {
+ // 可以根据实际情况添加更多的检查逻辑
+ return true;
+ }
+ return false;
+ }
+ });
+
+ using (var responsedData = await waitClient.SendThenResponseAsync(result, 2000))
+ {
+ var reciveBuffer = responsedData.Memory.ToArray();
+
+ byte[] resultBuffer = PareReceiveBufferData(reciveBuffer, reciveBuffer.Length);
+ Log.Information($"{m_deviceID}接收读取指令{_stringChange.bytesToHexStr(resultBuffer, resultBuffer.Length)}");
+
+ if (resultBuffer[3] == 0xBF || resultBuffer[4] == 0x00)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
public override async Task ConnectAsync(string ip, int port, string deviceid)
{
try
@@ -722,7 +775,7 @@ namespace SlnMesnac.Rfid.Factory
throw new NotImplementedException();
}
- public override Task Set_Write(string pSelectData, string pWriteData)
+ public override Task Set_Write(byte[] pSelectData, string pWriteData)
{
throw new NotImplementedException();
}
diff --git a/SlnMesnac.Rfid/Factory/RflyFactory.cs b/SlnMesnac.Rfid/Factory/RflyFactory.cs
index 8fbbbe1..418e25f 100644
--- a/SlnMesnac.Rfid/Factory/RflyFactory.cs
+++ b/SlnMesnac.Rfid/Factory/RflyFactory.cs
@@ -9,6 +9,8 @@ using SlnMesnac.Model.dto;
using SlnMesnac.Repository.service;
using SlnMesnac.Rfid.Dto;
using SlnMesnac.Rfid.Enum;
+using SlnMesnac.Rfid.NewRFIDConnect;
+using SlnMesnac.Rfid.NewRFIDConnect.entity;
using SlnMesnac.Serilog;
using SlnMesnac.TouchSocket;
using SqlSugar;
@@ -17,6 +19,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
+using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -47,7 +50,7 @@ using TouchSocket.Sockets;
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Rfid.Factory
{
- public class RflyFactory:RfidAbsractFactory
+ public class RflyFactory : RfidAbsractFactory
{
private SerilogHelper _logger;
private readonly TcpClient _tcpClient = new TcpClient();
@@ -56,13 +59,13 @@ namespace SlnMesnac.Rfid.Factory
private string m_deviceID;
private MeshttpClient _meshttpClient;
- public RflyFactory(SerilogHelper logger,StringChange stringChange, MeshttpClient meshttpClient)
+ public RflyFactory(SerilogHelper logger, StringChange stringChange, MeshttpClient meshttpClient)
{
_logger = logger;
_stringChange = stringChange;
_meshttpClient = meshttpClient;
}
-
+
///
/// 建立连接
///
@@ -90,7 +93,7 @@ namespace SlnMesnac.Rfid.Factory
///
///
///
- public override async Task ConnectAsync(string ip, int port,string deviceid)
+ public override async Task ConnectAsync(string ip, int port, string deviceid)
{
try
{
@@ -107,6 +110,18 @@ namespace SlnMesnac.Rfid.Factory
Array.Copy(e.Memory.Span.ToArray(), 0, receivedBuffer, 0, e.Memory.Span.Length);
if (receivedBuffer.Length > 3)
{
+ //心跳
+ if (e.Memory.Span.ToArray()[3] == 0xBF)
+ {
+ if (GloalVar.HeartBeatRecoard.TryGetValue(deviceid, out var value))
+ {
+ GloalVar.HeartBeatRecoard[deviceid] = DateTime.Now;
+ }
+ else
+ {
+ GloalVar.HeartBeatRecoard.Add(deviceid, DateTime.Now);
+ }
+ }
//连续盘点返回
if (e.Memory.Span.ToArray()[3] == 0x01)
{
@@ -145,7 +160,7 @@ namespace SlnMesnac.Rfid.Factory
}
else
{
- Log.Information($"{m_deviceID},IP:{m_strIP}接收原始报文{_stringChange.bytesToHexStr(receivedBuffer, receivedBuffer.Length)}");
+ //Log.Information($"{m_deviceID},IP:{m_strIP}接收原始报文{_stringChange.bytesToHexStr(receivedBuffer, receivedBuffer.Length)}");
}
}
@@ -154,9 +169,9 @@ namespace SlnMesnac.Rfid.Factory
}
- return EasyTask.CompletedTask;
+ return EasyTask.CompletedTask;
};
-
+ Log.Information($"{m_deviceID},IP:{m_strIP}连接成功");
return true;
}
catch (Exception e)
@@ -165,6 +180,58 @@ namespace SlnMesnac.Rfid.Factory
return false;
}
}
+
+ ///
+ /// 真心跳设置
+ ///
+ ///
+ public override async Task Set_HeartBeat(byte second)
+ {
+ byte[] data = new byte[3];
+ data[0] = 0x00;
+ data[1] = second;
+ data[2] = 0x01;
+
+ BaseSendDataEntity entity = new BaseSendDataEntity()
+ {
+ Code = 0xBF,
+ Data = data
+ };
+
+ byte[] result = BaseRFIDDataAnalyse.BaseSendDataAnalyse(entity);
+
+ var waitClient = _tcpClient.CreateWaitingClient(new WaitingOptions()
+ {
+ FilterFunc = response =>
+ {
+ // 检查响应数据是否符合预期
+ if (response.Memory.Length > 0)
+ {
+ // 可以根据实际情况添加更多的检查逻辑
+ return true;
+ }
+ return false;
+ }
+ });
+
+ using (var responsedData = await waitClient.SendThenResponseAsync(result, 2000))
+ {
+ var reciveBuffer = responsedData.Memory.ToArray();
+
+ byte[] resultBuffer = PareReceiveBufferData(reciveBuffer, reciveBuffer.Length);
+ Log.Information($"{m_deviceID}接收读取指令{_stringChange.bytesToHexStr(resultBuffer, resultBuffer.Length)}");
+
+ if (resultBuffer[3] == 0xBF || resultBuffer[4] == 0x00)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
///
/// 异步按时间段盘点
///
@@ -229,11 +296,11 @@ namespace SlnMesnac.Rfid.Factory
return tagInfoList;
}
-
+
}
catch (Exception e)
{
- Log.Information($"{m_deviceID}数据接收异常"+ e);
+ Log.Information($"{m_deviceID}数据接收异常" + e);
return tagInfoList;
//throw new InvalidOperationException($"{m_strIP}按时间段盘点异常:{e.Message}");
}
@@ -276,7 +343,7 @@ namespace SlnMesnac.Rfid.Factory
FilterFunc = response =>
{
// 检查响应数据是否符合预期
- if ( response.Memory.Length > 0)
+ if (response.Memory.Length > 0)
{
// 可以根据实际情况添加更多的检查逻辑
return true;
@@ -432,7 +499,7 @@ namespace SlnMesnac.Rfid.Factory
return DB.ToString();
}
}
-
+
return DB.ToString();
}
@@ -468,6 +535,11 @@ namespace SlnMesnac.Rfid.Factory
}
}
+
+ ///
+ /// 停止连续盘点
+ ///
+ ///
public override async Task Set_StopIdentify()
{
byte[] bCRC = new byte[4];
@@ -487,39 +559,46 @@ namespace SlnMesnac.Rfid.Factory
pMessagePack.m_pData[7] = 0x0D;
#endregion 指令封装
- var waitClient = _tcpClient.CreateWaitingClient(new WaitingOptions()
- {
- FilterFunc = response =>
- {
- // 检查响应数据是否符合预期
- if (response.Memory.Length > 0)
- {
- // 可以根据实际情况添加更多的检查逻辑
- return true;
- }
- return false;
- }
- });
- Log.Information($"{m_deviceID}发送停止连续盘点指令{_stringChange.bytesToHexStr(pMessagePack.m_pData, pMessagePack.m_pData.Length)}");
- using (var responsedData = await waitClient.SendThenResponseAsync(pMessagePack.m_pData, 2000))
- {
- var reciveBuffer = responsedData.Memory.ToArray();
- Log.Information($"{m_deviceID}接收停止连续盘点指令{_stringChange.bytesToHexStr(reciveBuffer, reciveBuffer.Length)}");
- if (reciveBuffer[3] == 0x12)
- {
- return true;
- }
- }
- return false;
+
+ _tcpClient.SendAsync(pMessagePack.m_pData).GetAwaiter().GetResult();
+ //var waitClient = _tcpClient.CreateWaitingClient(new WaitingOptions()
+ //{
+ // FilterFunc = response =>
+ // {
+ // // 检查响应数据是否符合预期
+ // if (response.Memory.Length > 0)
+ // {
+ // // 可以根据实际情况添加更多的检查逻辑
+ // return true;
+ // }
+ // return false;
+ // }
+ //});
+ //Log.Information($"{m_deviceID}发送停止连续盘点指令{_stringChange.bytesToHexStr(pMessagePack.m_pData, pMessagePack.m_pData.Length)}");
+ //using (var responsedData = await waitClient.SendThenResponseAsync(pMessagePack.m_pData, 2000))
+ //{
+ // var reciveBuffer = responsedData.Memory.ToArray();
+ // Log.Information($"{m_deviceID}接收停止连续盘点指令{_stringChange.bytesToHexStr(reciveBuffer, reciveBuffer.Length)}");
+ // if (reciveBuffer[3] == 0x12)
+ // {
+ // return true;
+ // }
+ //}
+ //return false;
+ return true;
}
catch (Exception e)
{
+ //throw new InvalidOperationException($"{m_strIP}暂停盘点异常:{e.Message}");
+ Log.Error($"{m_deviceID},IP:{m_strIP}暂停盘点异常:{e.Message}");
return false;
- //throw new InvalidOperationException($"{m_strIP}设置功率异常:{e.Message}");
}
}
-
+ ///
+ /// 开始连续盘点
+ ///
+ ///
public override async Task Set_BeginIdentify()
{
byte[] bCRC = new byte[4];
@@ -539,30 +618,32 @@ namespace SlnMesnac.Rfid.Factory
pMessagePack.m_pData[7] = 0x0D;
#endregion 指令封装
- var waitClient = _tcpClient.CreateWaitingClient(new WaitingOptions()
- {
- FilterFunc = response =>
- {
- // 检查响应数据是否符合预期
- if (response.Memory.Length > 0)
- {
- // 可以根据实际情况添加更多的检查逻辑
- return true;
- }
- return false;
- }
- });
- Log.Information($"{m_deviceID}发送连续盘点指令{_stringChange.bytesToHexStr(pMessagePack.m_pData, pMessagePack.m_pData.Length)}");
- using (var responsedData = await waitClient.SendThenResponseAsync(pMessagePack.m_pData, 2000))
- {
- var reciveBuffer = responsedData.Memory.ToArray();
- Log.Information($"{m_deviceID}接收连续盘点指令{_stringChange.bytesToHexStr(reciveBuffer, reciveBuffer.Length)}");
- if (reciveBuffer[3] == 0x11)
- {
- return true;
- }
- }
- return false;
+ _tcpClient.SendAsync(pMessagePack.m_pData).GetAwaiter().GetResult();
+
+ //var waitClient = _tcpClient.CreateWaitingClient(new WaitingOptions()
+ //{
+ // FilterFunc = response =>
+ // {
+ // // 检查响应数据是否符合预期
+ // if (response.Memory.Length > 0)
+ // {
+ // // 可以根据实际情况添加更多的检查逻辑
+ // return true;
+ // }
+ // return false;
+ // }
+ //});
+ //Log.Information($"{m_deviceID}发送连续盘点指令{_stringChange.bytesToHexStr(pMessagePack.m_pData, pMessagePack.m_pData.Length)}");
+ //using (var responsedData = await waitClient.SendThenResponseAsync(pMessagePack.m_pData, 2000))
+ //{
+ // var reciveBuffer = responsedData.Memory.ToArray();
+ // Log.Information($"{m_deviceID}接收连续盘点指令{_stringChange.bytesToHexStr(reciveBuffer, reciveBuffer.Length)}");
+ // if (reciveBuffer[3] == 0x11)
+ // {
+ // return true;
+ // }
+ //}
+ return true;
}
catch (Exception e)
{
@@ -571,22 +652,29 @@ namespace SlnMesnac.Rfid.Factory
}
}
- public override async Task Set_Write(string pSelectData, string pWriteData)
+ ///
+ /// 写入
+ ///
+ ///
+ ///
+ ///
+ public override async Task Set_Write(byte[] pSelectData, string pWriteData)
{
- byte[] bSelectData;
byte[] bWriteData = null;
if (Convert.ToByte(pWriteData.Length % 2) != 0)
{
- bWriteData = new byte [pWriteData.Length + 1];
- }
- if (string.IsNullOrEmpty(pSelectData))
- {
- bSelectData = Encoding.ASCII.GetBytes("JG26522604101");
+ bWriteData = new byte[pWriteData.Length + 1];
}
else
{
- bSelectData = Encoding.ASCII.GetBytes(pSelectData);
+ bWriteData = new byte[pWriteData.Length];
}
+
+ if (pSelectData == null || pSelectData.Count() == 0)
+ {
+ pSelectData = Encoding.ASCII.GetBytes("JG26522604101");
+ }
+
if (string.IsNullOrEmpty(pWriteData))
{
bWriteData = Encoding.ASCII.GetBytes("JG26522604102");
@@ -594,44 +682,76 @@ namespace SlnMesnac.Rfid.Factory
else
{
byte[] bytes = Encoding.ASCII.GetBytes(pWriteData);
- Array.Copy(bytes,0, bWriteData, 0, bytes.Length);
+ Array.Copy(bytes, 0, bWriteData, 0, bytes.Length);
//bWriteData = Encoding.ASCII.GetBytes(pWriteData);
-
}
- byte[] bCRC = new byte[21 + bSelectData.Length + bWriteData.Length];
- int length = 18 + bSelectData.Length + Convert.ToByte((bWriteData.Length % 2 == 0) ? bWriteData.Length : (bWriteData.Length + 1));
+
+ //计算PC并衔接
+ byte[] finalWriteData = new byte[bWriteData.Length + 2];
+ byte[] pc = _stringChange.IntToBytes(2, ((bWriteData.Length / 2) * 8)).Reverse().ToArray();
+ Array.Copy(pc, 0, finalWriteData, 0, 2);
+ Array.Copy(bWriteData, 0, finalWriteData, 2, bWriteData.Length);
+
try
{
#region 指令封装
- MessagePack pMessagePack = new MessagePack();
- pMessagePack.m_pData = new byte[24 + bSelectData.Length + bWriteData.Length];
- pMessagePack.m_pData[0] = 0xAA;
- pMessagePack.m_pData[1] = 0x55;
- pMessagePack.m_pData[2] = Convert.ToByte(length);
- pMessagePack.m_pData[3] = 0x03;
- pMessagePack.m_pData[4] = 0x01;
- pMessagePack.m_pData[5] = 0xF4;
- pMessagePack.m_pData[6] = 0x00;
- pMessagePack.m_pData[7] = 0x00;
- pMessagePack.m_pData[8] = 0x00;
- pMessagePack.m_pData[9] = 0x00;
- pMessagePack.m_pData[10] = 0x01;
- pMessagePack.m_pData[11] = 0x00;
- pMessagePack.m_pData[12] = 0x00;
- pMessagePack.m_pData[13] = 0x00;
- pMessagePack.m_pData[14] = 0x20;
- pMessagePack.m_pData[15] = 0x70;
- Array.Copy(bSelectData, 0, pMessagePack.m_pData, 16, bSelectData.Length); //写入数据
- pMessagePack.m_pData[16 + bSelectData.Length] = 0x01;
- pMessagePack.m_pData[17 + bSelectData.Length] = 0x00;
- pMessagePack.m_pData[18 + bSelectData.Length] = 0x00;
- pMessagePack.m_pData[19 + bSelectData.Length] = 0x00;
- pMessagePack.m_pData[20 + bSelectData.Length] = 0x02;
- pMessagePack.m_pData[21 + bSelectData.Length] = Convert.ToByte((bWriteData.Length % 2 == 0) ? bWriteData.Length / 2 : (bWriteData.Length + 1) / 2);
- Array.Copy(bWriteData, 0, pMessagePack.m_pData, 16 + Convert.ToByte((bWriteData.Length % 2 == 0) ? bWriteData.Length : (bWriteData.Length + 1)) + 6, bWriteData.Length); //写入数据
- Array.Copy(pMessagePack.m_pData, 2, bCRC, 0, 21 + bWriteData.Length + bSelectData.Length);
- pMessagePack.m_pData[22 + bSelectData.Length + bWriteData.Length] = _stringChange.CalculateVerify(bCRC, bCRC.Length);
- pMessagePack.m_pData[23 + bSelectData.Length + bWriteData.Length] = 0x0D;
+ //自动根据写入数据封装
+ Base03HENtity rawData = new Base03HENtity()
+ {
+ TimeOut = _stringChange.IntToBytes(2, 1000),
+ AccessPassword = _stringChange.IntToBytes(4, 0),
+ SelectBank = 01,
+ SelectAddress = _stringChange.IntToBytes(4, 32),
+ SelectLength = (byte)(pSelectData.Count() * 8),
+ SelectData = pSelectData,
+ WriteBank = 01,
+ WriteAddress = _stringChange.IntToBytes(4, 1),
+ WordCount = (byte)((finalWriteData.Count() / 2)),
+ WriteData = finalWriteData
+ };
+
+ int selectLength = rawData.SelectLength / 8;
+ int wordCount = rawData.WordCount * 2;
+ byte[] bytes = new byte[2 + 4 + 1 + 4 + 1 + selectLength + 1 + 4 + 1 + wordCount];
+
+ int index = 0;
+
+ Array.Copy(rawData.TimeOut, 0, bytes, index, 2);
+ index += 2;
+
+ Array.Copy(rawData.AccessPassword, 0, bytes, index, 4);
+ index += 4;
+
+ bytes[index] = rawData.SelectBank;
+ index++;
+
+ Array.Copy(rawData.SelectAddress, 0, bytes, index, 4);
+ index += 4;
+
+ bytes[index] = rawData.SelectLength;
+ index++;
+
+ Array.Copy(rawData.SelectData, 0, bytes, index, selectLength);
+ index += selectLength;
+
+ bytes[index] = rawData.WriteBank;
+ index++;
+
+ Array.Copy(rawData.WriteAddress, 0, bytes, index, 4);
+ index += 4;
+
+ bytes[index] = rawData.WordCount;
+ index++;
+
+ Array.Copy(rawData.WriteData, 0, bytes, index, wordCount);
+ index += wordCount;
+
+ BaseSendDataEntity entity = new BaseSendDataEntity()
+ {
+ Code = 0x03,
+ Data = bytes
+ };
+ byte[] result = BaseRFIDDataAnalyse.BaseSendDataAnalyse(entity);
#endregion 指令封装
var waitClient = _tcpClient.CreateWaitingClient(new WaitingOptions()
@@ -647,13 +767,14 @@ namespace SlnMesnac.Rfid.Factory
return false;
}
});
- Log.Information($"{m_deviceID}发送写入指令{_stringChange.bytesToHexStr(pMessagePack.m_pData, pMessagePack.m_pData.Length)}");
- using (var responsedData = await waitClient.SendThenResponseAsync(pMessagePack.m_pData, 2000))
+ Log.Information($"{m_deviceID}发送写入指令{_stringChange.bytesToHexStr(result, result.Length)}");
+ using (var responsedData = await waitClient.SendThenResponseAsync(result, 2000))
{
var reciveBuffer = responsedData.Memory.ToArray();
Log.Information($"{m_deviceID}接收写入指令{_stringChange.bytesToHexStr(reciveBuffer, reciveBuffer.Length)}");
if (reciveBuffer[3] == 0x03 && reciveBuffer[4] == 0x00)
{
+ Log.Information($"写入成功,写入数值{pWriteData}");
return true;
}
}
@@ -661,8 +782,7 @@ namespace SlnMesnac.Rfid.Factory
}
catch (Exception e)
{
- return false;
- //throw new InvalidOperationException($"{m_strIP}设置功率异常:{e.Message}");
+ throw new InvalidOperationException($"{m_strIP}写入异常:{e.Message}");
}
}
@@ -1355,7 +1475,7 @@ namespace SlnMesnac.Rfid.Factory
}
_Action?.Invoke(m_deviceID, tagInfoList);
}
-
+
}
catch (Exception ex)
{
@@ -1396,7 +1516,7 @@ namespace SlnMesnac.Rfid.Factory
using (var responsedData = await waitClient.SendThenResponseAsync(pMessagePack.m_pData, 2000))
{
var reciveBuffer = responsedData.Memory.ToArray();
-
+
if (reciveBuffer[3] == 0x90)
{
if (reciveBuffer.Length == 8)
@@ -1414,7 +1534,7 @@ namespace SlnMesnac.Rfid.Factory
Array.Copy(reciveBuffer, 8, messagebuffer, 0, reciveBuffer.Length - 8);
DealMessageData(messagebuffer);
}
-
+
}
if (reciveBuffer[3] == 0x02)
{
@@ -1430,6 +1550,60 @@ namespace SlnMesnac.Rfid.Factory
}
}
+ ///
+ /// 将byte数组转换为十六进制字符串(格式:00 0A 0B)
+ ///
+ public string BytesToHexString(byte[] bytes)
+ {
+ if (bytes == null || bytes.Length == 0)
+ return string.Empty;
+
+ StringBuilder sb = new StringBuilder();
+
+ for (int i = 0; i < bytes.Length; i++)
+ {
+ sb.Append(bytes[i].ToString("X2"));
+ if (i < bytes.Length - 1)
+ sb.Append(" ");
+ }
+
+ return sb.ToString();
+ }
+
+ ///
+ /// 将十六进制字符串转换回byte数组
+ ///
+ public byte[] HexStringToBytes(string hexString)
+ {
+ if (string.IsNullOrWhiteSpace(hexString))
+ {
+ Console.WriteLine("传入数据为空");
+ return new byte[0];
+ }
+
+ // 移除所有空格
+ hexString = hexString.Replace(" ", "");
+
+ // 检查长度是否为偶数
+ if (hexString.Length % 2 != 0)
+ Console.WriteLine("格式不正确16进制字符串必须为偶数");
+
+ byte[] bytes = new byte[hexString.Length / 2];
+
+ try
+ {
+
+ for (int i = 0; i < bytes.Length; i++)
+ {
+ bytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 16);
+ }
+ }
+ catch { Console.WriteLine("格式不正确"); }
+
+
+ return bytes;
+ }
+
#endregion
diff --git a/SlnMesnac.Rfid/GloalVar.cs b/SlnMesnac.Rfid/GloalVar.cs
new file mode 100644
index 0000000..52ee86c
--- /dev/null
+++ b/SlnMesnac.Rfid/GloalVar.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace SlnMesnac.Rfid
+{
+ ///
+ /// 全局变量
+ ///
+ public class GloalVar
+ {
+ public static Dictionary HeartBeatRecoard { get; set; } = new Dictionary();
+ }
+}
diff --git a/SlnMesnac.Rfid/NewRFIDConnect/BaseRFIDDataAnalyse.cs b/SlnMesnac.Rfid/NewRFIDConnect/BaseRFIDDataAnalyse.cs
new file mode 100644
index 0000000..8fa1816
--- /dev/null
+++ b/SlnMesnac.Rfid/NewRFIDConnect/BaseRFIDDataAnalyse.cs
@@ -0,0 +1,104 @@
+using SlnMesnac.Rfid.NewRFIDConnect.entity;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SlnMesnac.Rfid.NewRFIDConnect
+{
+ ///
+ /// RFID基础数据分析
+ ///
+ public class BaseRFIDDataAnalyse
+ {
+
+ ///
+ /// 基础接收数据解析
+ ///
+ ///
+ ///
+ public static BaseReciveDataEntity BaseReceiveAnalyse(byte[] data)
+ {
+ BaseReciveDataEntity result = new BaseReciveDataEntity();
+
+ int index = 0;
+ index += 2;
+
+ //取Length
+ result.DataLength = data[index];
+ index++;
+
+ //取Code
+ result.Code = data[index];
+ index++;
+
+ //取Status
+ result.Status = data[index];
+ index++;
+
+ result.Data = new byte[result.DataLength];
+
+ //取Data
+ Array.Copy(data, 5, result.Data, 0, result.DataLength);
+ index += result.DataLength;
+
+ //算Xor
+ result.Xor = data[index];
+ int xor = 0;
+ for (int i = 0; i < 3 + result.DataLength; i++)
+ {
+ xor ^= data[i + 2];
+ }
+ if(xor != data[data.Length - 2])
+ {
+ //_logHelper.Error("数据校验和未通过");
+ return null;
+ }
+
+ return result;
+ }
+
+ ///
+ /// 发送数据封装
+ ///
+ ///
+ ///
+ public static byte[] BaseSendDataAnalyse(BaseSendDataEntity entity)
+ {
+ byte[] result = new byte[entity.Data.Length + 6];
+
+ int index = 2;
+
+ //指令头
+ result[0] = 0xAA;
+ result[1] = 0x55;
+
+ //数据长度
+ result[index] = (byte)entity.Data.Length;
+ index++;
+
+ //指令编号
+ result[index] = entity.Code;
+ index++;
+
+ //数据
+ Array.Copy(entity.Data, 0, result, 4, entity.Data.Length);
+ index += entity.Data.Length;
+
+ //校验和
+ int xor = 0;
+ for (int i = 0; i < 2 + entity.Data.Length; i++)
+ {
+ xor ^= result[i + 2];
+ }
+ result[index] = (byte)xor;
+ index++;
+
+ //帧尾
+ result[index] = 0x0D;
+
+ return result;
+ }
+ }
+}
diff --git a/SlnMesnac.Rfid/NewRFIDConnect/RfidDataAnalyse.cs b/SlnMesnac.Rfid/NewRFIDConnect/RfidDataAnalyse.cs
new file mode 100644
index 0000000..e815089
--- /dev/null
+++ b/SlnMesnac.Rfid/NewRFIDConnect/RfidDataAnalyse.cs
@@ -0,0 +1,258 @@
+using SlnMesnac.Rfid.NewRFIDConnect.entity;
+using RFIDTest.entity;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace SlnMesnac.Rfid.NewRFIDConnect
+{
+ public class RfidDataAnalyse
+ {
+ ///
+ /// 02H时间段盘点发送
+ ///
+ /// 盘点时间毫秒数
+ ///
+ public byte[] Send02H(ushort millisecond)
+ {
+ byte[] bytes = BitConverter.GetBytes(millisecond);
+ bytes = bytes.Reverse().ToArray();
+ BaseSendDataEntity entity = new BaseSendDataEntity()
+ {
+ Code = 0x02,
+ Data = bytes
+ };
+
+ byte[] result = BaseRFIDDataAnalyse.BaseSendDataAnalyse(entity);
+
+ return result;
+ }
+
+ ///
+ /// 接受02H盘点数据 (默认EPC 4位)
+ ///
+ /// 数据体
+ ///
+ public Receive02HEntity Receive02H(byte[] data)
+ {
+ Receive02HEntity entity = new Receive02HEntity();
+
+ int index = 0;
+
+ if (data.Length != 0)
+ {
+ //取读到多少个标签
+ entity.TagCount = data[index];
+ entity.Data = new List();
+ index++;
+ }
+ else
+ {
+ entity.TagCount = 0;
+ }
+
+ //取每一个读到的标签
+ for (int i = 0; i < entity.TagCount; i++)
+ {
+ Single02HReceive EPCData = new Single02HReceive();
+
+ //取单个标签读取的次数
+ EPCData.Count = data[index];
+ index++;
+
+ //取信号强度
+ EPCData.RSSI = data[index];
+ index++;
+
+ //取天线端口
+ EPCData.Ant = data[index];
+ index++;
+
+ //取EPC区域
+ EPCData.PC = new byte[2];
+ Array.Copy(data, index, EPCData.PC, 0, 2);
+ index += 2;
+
+ //取读到标签的EPC
+ EPCData.EPC = new byte[12];
+ try
+ {
+ Array.Copy(data, index, EPCData.EPC, 0, 12);
+ }
+ catch (Exception ex)
+ {
+ return null;
+ }
+ index += 12;
+
+ entity.Data.Add(EPCData);
+ }
+
+ return entity;
+ }
+
+ ///
+ /// 发送心跳配置包
+ ///
+ ///
+ public byte[] SendBFH(byte second)
+ {
+ byte[] data = new byte[3];
+ data[0] = 0x00;
+ data[1] = second;
+ data[2] = 0x01;
+
+ BaseSendDataEntity entity = new BaseSendDataEntity()
+ {
+ Code = 0xBF,
+ Data = data
+ };
+
+ byte[] result = BaseRFIDDataAnalyse.BaseSendDataAnalyse(entity);
+
+ return result;
+ }
+
+ ///
+ /// 接收心跳包
+ ///
+ ///
+ public uint ReceiveBFH(byte[] data)
+ {
+ uint result = BitConverter.ToUInt32(data, 0);
+ return result;
+ }
+
+ ///
+ /// 发送连续盘点请求
+ ///
+ ///
+ ///
+ public byte[] Send11H()
+ {
+ byte[] bytes = new byte[2] { 0x00, 0x00 };
+ //byte[] bytes = BitConverter.GetBytes(millisecond);
+ //bytes = bytes.Reverse().ToArray();
+ BaseSendDataEntity entity = new BaseSendDataEntity()
+ {
+ Code = 0x11,
+ Data = bytes
+ };
+ byte[] result = BaseRFIDDataAnalyse.BaseSendDataAnalyse(entity);
+ return result;
+ }
+
+ ///
+ /// 发送停止盘点请求
+ ///
+ ///
+ public byte[] Send12H()
+ {
+ byte[] bytes = new byte[2] { 0x00, 0x00 };
+ //byte[] bytes = BitConverter.GetBytes(millisecond);
+ //bytes = bytes.Reverse().ToArray();
+ BaseSendDataEntity entity = new BaseSendDataEntity()
+ {
+ Code = 0x12,
+ Data = bytes
+ };
+ byte[] result = BaseRFIDDataAnalyse.BaseSendDataAnalyse(entity);
+ return result;
+ }
+
+ ///
+ /// 接受连续盘点结果
+ ///
+ ///
+ ///
+ public ReciveResult11HEntity Receive11H(byte[] data)
+ {
+ int index = 0;
+ ReciveResult11HEntity entity = new ReciveResult11HEntity();
+ entity.Count = data[index];
+ index++;
+
+ entity.RSSI = data[index];
+ index++;
+
+ entity.Ant = data[index];
+ index++;
+
+ entity.PC = new byte[2];
+ Array.Copy(data, index, entity.PC, 0, 2);
+ index += 2;
+
+ int restLength = data.Length - index;
+
+ entity.EPC = new byte[restLength];
+ Array.Copy(data, index, entity.EPC, 0, restLength);
+ index += 12;
+
+ return entity;
+ }
+
+ ///
+ /// 发送写入请求
+ ///
+ ///
+ public byte[] Send03H(Base03HENtity rawData)
+ {
+ int selectLength = rawData.SelectLength / 8;
+ int wordCount = rawData.WordCount * 2;
+ byte[] bytes = new byte[2 + 4 + 1 + 4 + 1 + selectLength + 1 + 4 + 1 + wordCount];
+
+ int index = 0;
+
+ Array.Copy(rawData.TimeOut, 0, bytes, index, 2);
+ index += 2;
+
+ Array.Copy(rawData.AccessPassword, 0, bytes, index, 4);
+ index += 4;
+
+ bytes[index] = rawData.SelectBank;
+ index++;
+
+ Array.Copy(rawData.SelectAddress, 0, bytes, index, 4);
+ index += 4;
+
+ bytes[index] = rawData.SelectLength;
+ index++;
+
+ Array.Copy(rawData.SelectData, 0, bytes, index, selectLength);
+ index += selectLength;
+
+ bytes[index] = rawData.WriteBank;
+ index++;
+
+ Array.Copy(rawData.WriteAddress, 0, bytes, index, 4);
+ index += 4;
+
+ bytes[index] = rawData.WordCount;
+ index++;
+
+ Array.Copy(rawData.WriteData, 0, bytes, index, wordCount);
+ index += wordCount;
+
+ BaseSendDataEntity entity = new BaseSendDataEntity()
+ {
+ Code = 0x03,
+ Data = bytes
+ };
+ byte[] result = BaseRFIDDataAnalyse.BaseSendDataAnalyse(entity);
+ return result;
+ }
+
+ ///
+ /// 发送功率设置包
+ ///
+ ///
+ ///
+ public byte[] Send42H(int power)
+ {
+ return new byte[0];
+ }
+ }
+}
diff --git a/SlnMesnac.Rfid/NewRFIDConnect/entity/BFHEntity.cs b/SlnMesnac.Rfid/NewRFIDConnect/entity/BFHEntity.cs
new file mode 100644
index 0000000..d012da0
--- /dev/null
+++ b/SlnMesnac.Rfid/NewRFIDConnect/entity/BFHEntity.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SlnMesnac.Rfid.NewRFIDConnect.entity
+{
+ ///
+ /// 心跳设置包
+ ///
+ public class BFHSendEntity
+ {
+ ///
+ /// 返回模式(00严格按时间 01空闲返回)
+ ///
+ public byte Mode { get; set; }
+
+ ///
+ /// 返回时间(单位秒)
+ ///
+ public byte Time { get; set; }
+
+ ///
+ /// 保留(一直等于01就行)
+ ///
+ public byte Rev { get; set; }
+ }
+}
diff --git a/SlnMesnac.Rfid/NewRFIDConnect/entity/Base03HEntity.cs b/SlnMesnac.Rfid/NewRFIDConnect/entity/Base03HEntity.cs
new file mode 100644
index 0000000..6c7cf54
--- /dev/null
+++ b/SlnMesnac.Rfid/NewRFIDConnect/entity/Base03HEntity.cs
@@ -0,0 +1,61 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SlnMesnac.Rfid.NewRFIDConnect.entity
+{
+ public class Base03HENtity
+ {
+ ///
+ /// 超时时间
+ ///
+ public byte[] TimeOut { get; set; }
+
+ ///
+ /// 访问密码
+ ///
+ public byte[] AccessPassword { get; set; }
+
+ ///
+ /// 选择区域,01 EPC, 02 TID, 03 User
+ ///
+ public byte SelectBank { get; set; }
+
+ ///
+ /// 选择地址
+ ///
+ public byte[] SelectAddress { get; set; }
+
+ ///
+ /// 选择匹配数据长度
+ ///
+ public byte SelectLength { get; set; }
+
+ ///
+ /// 选择匹配数据
+ ///
+ public byte[] SelectData { get; set; }
+
+ ///
+ /// 写入标签区域,00 Reserved, 01 EPC, 02 TID, 03 User
+ ///
+ public byte WriteBank { get; set; }
+
+ ///
+ /// 写入地址(word)
+ ///
+ public byte[] WriteAddress { get; set; }
+
+ ///
+ /// 写入数据量(word)
+ ///
+ public byte WordCount { get; set; }
+
+ ///
+ /// 写入数据
+ ///
+ public byte[] WriteData { get; set; }
+ }
+}
diff --git a/SlnMesnac.Rfid/NewRFIDConnect/entity/Base11HEntity.cs b/SlnMesnac.Rfid/NewRFIDConnect/entity/Base11HEntity.cs
new file mode 100644
index 0000000..80481a7
--- /dev/null
+++ b/SlnMesnac.Rfid/NewRFIDConnect/entity/Base11HEntity.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RFIDTest.entity
+{
+ public class Send11HEntity
+ {
+ public byte[] TimeOut { get; set; }
+ }
+
+ public class ReciveResult11HEntity
+ {
+ public byte Count { get; set; }
+
+ ///
+ /// 信号强度
+ ///
+ public byte RSSI { get; set; }
+
+ ///
+ /// 天线端口
+ ///
+ public byte Ant { get; set; }
+
+ ///
+ /// EPC区域 10h-20h
+ ///
+ public byte[] PC { get; set; }
+
+ ///
+ /// 读到的EPC内容
+ ///
+ public byte[] EPC { get; set; }
+ }
+}
diff --git a/SlnMesnac.Rfid/NewRFIDConnect/entity/BaseReciveDataEntity.cs b/SlnMesnac.Rfid/NewRFIDConnect/entity/BaseReciveDataEntity.cs
new file mode 100644
index 0000000..43bf803
--- /dev/null
+++ b/SlnMesnac.Rfid/NewRFIDConnect/entity/BaseReciveDataEntity.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SlnMesnac.Rfid.NewRFIDConnect.entity
+{
+ ///
+ /// 接收数据基础类
+ ///
+ public class BaseReciveDataEntity
+ {
+ ///
+ /// 数据长度2
+ ///
+ public byte DataLength { get; set; }
+
+ ///
+ /// 指令编号
+ ///
+ public byte Code { get; set; }
+
+ ///
+ /// 状态码
+ ///
+ public byte Status { get; set; }
+
+ ///
+ /// 数据
+ ///
+ public byte[] Data { get; set; }
+
+ ///
+ /// 校验位
+ ///
+ public byte Xor { get; set; }
+ }
+}
diff --git a/SlnMesnac.Rfid/NewRFIDConnect/entity/BaseSendDataEntity.cs b/SlnMesnac.Rfid/NewRFIDConnect/entity/BaseSendDataEntity.cs
new file mode 100644
index 0000000..8d66c1a
--- /dev/null
+++ b/SlnMesnac.Rfid/NewRFIDConnect/entity/BaseSendDataEntity.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SlnMesnac.Rfid.NewRFIDConnect.entity
+{
+ ///
+ /// 发送数据基础类
+ ///
+ public class BaseSendDataEntity
+ {
+ ///
+ /// 指令编号
+ ///
+ public byte Code { get; set; }
+
+ ///
+ /// 数据
+ ///
+ public byte[] Data { get; set; }
+ }
+}
diff --git a/SlnMesnac.Rfid/NewRFIDConnect/entity/Receive02HEntity.cs b/SlnMesnac.Rfid/NewRFIDConnect/entity/Receive02HEntity.cs
new file mode 100644
index 0000000..7bbdf12
--- /dev/null
+++ b/SlnMesnac.Rfid/NewRFIDConnect/entity/Receive02HEntity.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SlnMesnac.Rfid.NewRFIDConnect.entity
+{
+ public class Receive02HEntity
+ {
+ ///
+ /// 标签个数
+ ///
+ public byte TagCount { get; set; }
+
+ ///
+ /// 时间段内读到的数据集合
+ ///
+ public List Data { get; set; }
+
+ }
+
+ public class Single02HReceive
+ {
+ ///
+ /// 读取次数
+ ///
+ public byte Count { get; set; }
+
+ ///
+ /// 信号强度
+ ///
+ public byte RSSI { get; set; }
+
+ ///
+ /// 天线端口
+ ///
+ public byte Ant { get; set; }
+
+ ///
+ /// EPC区域
+ ///
+ public byte[] PC { get; set; }
+
+ ///
+ /// EPC内容
+ ///
+ public byte[] EPC { get; set; }
+ }
+}
diff --git a/SlnMesnac.Rfid/RfidAbsractFactory.cs b/SlnMesnac.Rfid/RfidAbsractFactory.cs
index 4fd5259..b3ac081 100644
--- a/SlnMesnac.Rfid/RfidAbsractFactory.cs
+++ b/SlnMesnac.Rfid/RfidAbsractFactory.cs
@@ -128,15 +128,26 @@ namespace SlnMesnac.Rfid
///
public abstract Task Set_BeginIdentify();
+ ///
+ /// 停止连续盘点
+ ///
+ ///
+ public abstract Task Set_StopIdentify();
+
+ ///
+ /// 心跳指令发送
+ ///
+ ///
+ public abstract Task Set_HeartBeat(byte second);
+
///
/// 写入指令
///
///
///
///
- public abstract Task Set_Write(string pSelectData,string pWriteData);
+ public abstract Task Set_Write(byte[] pSelectData,string pWriteData);
- public abstract Task Set_StopIdentify();
diff --git a/SlnMesnac.Rfid/TouchSocketSetup.cs b/SlnMesnac.Rfid/TouchSocketSetup.cs
index 7fc3ce7..0b5af20 100644
--- a/SlnMesnac.Rfid/TouchSocketSetup.cs
+++ b/SlnMesnac.Rfid/TouchSocketSetup.cs
@@ -45,8 +45,9 @@ namespace SlnMesnac.TouchSocket
var _server = service.GetService();
_server.Init(5656);
var _httpclient = service.GetService();
+ var _appSetting = service.GetService();
//_server.Init(6001);
- await _httpclient.CreateWebApiClientAsync("10.20.8.51:8005");
+ await _httpclient.CreateWebApiClientAsync(_appSetting.MESConfig);
//await _httpclient.CreateWebApiClientAsync("127.0.0.1:9881");
//_httpclient.CreateWebApiClient("127.0.0.1:9880");
diff --git a/SlnMesnac.WPF/MainWindow.xaml b/SlnMesnac.WPF/MainWindow.xaml
index b0e89c3..9bc7186 100644
--- a/SlnMesnac.WPF/MainWindow.xaml
+++ b/SlnMesnac.WPF/MainWindow.xaml
@@ -48,12 +48,12 @@
-
+
-
-
+
+
diff --git a/SlnMesnac.WPF/Model/Real_DataInfo.cs b/SlnMesnac.WPF/Model/Real_DataInfo.cs
index a6e8829..deb80ab 100644
--- a/SlnMesnac.WPF/Model/Real_DataInfo.cs
+++ b/SlnMesnac.WPF/Model/Real_DataInfo.cs
@@ -132,8 +132,34 @@ namespace SlnMesnac.WPF.Model
}
- public string WriteTime { get; set; }
- public string WriteStatus { get; set; }
+ public string _WriteTime = "";
+ public string WriteTime
+ {
+ get { return _WriteTime; }
+ set
+ {
+ if (_WriteTime != value)
+ {
+ _WriteTime = value;
+ OnPropertyChanged(nameof(WriteTime));
+ }
+ }
+ }
+
+
+ public string _WriteStatus = "";
+ public string WriteStatus
+ {
+ get { return _WriteStatus; }
+ set
+ {
+ if (_WriteStatus != value)
+ {
+ _WriteStatus = value;
+ OnPropertyChanged(nameof(WriteStatus));
+ }
+ }
+ }
private string _ReadTime = "";
public string ReadTime
@@ -163,6 +189,19 @@ namespace SlnMesnac.WPF.Model
}
}
+ private string _NextProductNo = "";
+ public string NextProductNo
+ {
+ get { return _NextProductNo; }
+ set
+ {
+ if (_NextProductNo != value)
+ {
+ _NextProductNo = value;
+ OnPropertyChanged(nameof(NextProductNo));
+ }
+ }
+ }
///
/// 备 注:
diff --git a/SlnMesnac.WPF/Page/IndexPage/AlarmRecord.xaml b/SlnMesnac.WPF/Page/IndexPage/AlarmRecord.xaml
deleted file mode 100644
index c1c6de0..0000000
--- a/SlnMesnac.WPF/Page/IndexPage/AlarmRecord.xaml
+++ /dev/null
@@ -1,235 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/SlnMesnac.WPF/Page/IndexPage/AlarmRecord.xaml.cs b/SlnMesnac.WPF/Page/IndexPage/AlarmRecord.xaml.cs
deleted file mode 100644
index f36425e..0000000
--- a/SlnMesnac.WPF/Page/IndexPage/AlarmRecord.xaml.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using SlnMesnac.WPF.Attribute;
-using SlnMesnac.WPF.ViewModel.IndexPage;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-
-namespace SlnMesnac.WPF.Page.IndexPage
-{
- [RegisterAsSingletonAttribute]
- ///
- /// AlarmRecord.xaml 的交互逻辑
- ///
- public partial class AlarmRecord : UserControl
- {
- AlarmRecordViewModel alarmRecordViewModel;
- public AlarmRecord()
- {
- InitializeComponent();
- alarmRecordViewModel = new AlarmRecordViewModel();
- this.DataContext = alarmRecordViewModel;
- }
- }
-}
diff --git a/SlnMesnac.WPF/Page/IndexPage/ChangeType.xaml b/SlnMesnac.WPF/Page/IndexPage/ChangeType.xaml
index c6275e1..430dd7f 100644
--- a/SlnMesnac.WPF/Page/IndexPage/ChangeType.xaml
+++ b/SlnMesnac.WPF/Page/IndexPage/ChangeType.xaml
@@ -86,7 +86,7 @@
-
+
@@ -96,7 +96,7 @@
-
+
@@ -119,8 +119,8 @@
+ Width="170" Height="30" Margin="10 0" BorderBrush="Black">
+
+ Content="从MES获取订单信息" Width="200" Height="50" FontSize="20" Command="{Binding GetOrderInfoCommand}" CommandParameter="{Binding Name, ElementName=Search}"
+ Background="#009999" Style="{StaticResource BUTTON_AGREE}"/>
+
-->
+
-
diff --git a/SlnMesnac.WPF/Page/IndexPage/ChangeType.xaml.cs b/SlnMesnac.WPF/Page/IndexPage/ChangeType.xaml.cs
index bd0d141..fa7d044 100644
--- a/SlnMesnac.WPF/Page/IndexPage/ChangeType.xaml.cs
+++ b/SlnMesnac.WPF/Page/IndexPage/ChangeType.xaml.cs
@@ -32,6 +32,5 @@ namespace SlnMesnac.WPF.Page.IndexPage
ChangeTypeView = new ChangeTypeViewModel();
this.DataContext = ChangeTypeView;
}
-
}
}
diff --git a/SlnMesnac.WPF/Page/IndexPage/DetailTaskContent.xaml b/SlnMesnac.WPF/Page/IndexPage/DetailTaskContent.xaml
deleted file mode 100644
index 113bb7b..0000000
--- a/SlnMesnac.WPF/Page/IndexPage/DetailTaskContent.xaml
+++ /dev/null
@@ -1,100 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/SlnMesnac.WPF/Page/IndexPage/DetailTaskContent.xaml.cs b/SlnMesnac.WPF/Page/IndexPage/DetailTaskContent.xaml.cs
deleted file mode 100644
index b47ec17..0000000
--- a/SlnMesnac.WPF/Page/IndexPage/DetailTaskContent.xaml.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-using SlnMesnac.Repository.service;
-using SlnMesnac.Repository;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-using static Microsoft.WindowsAPICodePack.Shell.PropertySystem.SystemProperties.System;
-using Microsoft.Extensions.DependencyInjection;
-using Task = System.Threading.Tasks.Task;
-using SlnMesnac.WPF.Attribute;
-
-namespace SlnMesnac.WPF.Page.IndexPage
-{
- ///
- /// DetailTaskContent.xaml 的交互逻辑
- ///
- [RegisterAsSingletonAttribute]
- public partial class DetailTaskContent : Window
- {
- public Action _Taskaction;
- private IAirportTaskService _taskservice;
- public AirportTask AirportTask;
- public DetailTaskContent()
- {
- InitializeComponent();
- }
-
- private async void LoadAreaTaskInfo()
- {
- try
- {
- List Task = _taskservice.GetTaskInfoListAsync(AirportTask.conveyorno).Result;
-
- this.AreaTaskDataGrid.ItemsSource = Task;
- }
- catch (Exception ex)
- {
-
- }
- }
- //在载入行的时候在行表头添加编号
- private void dgvMH_LoadingRow(object sender, DataGridRowEventArgs e)
- {
- e.Row.Header = (e.Row.GetIndex() + 1).ToString();
- }
-
- private void Window_Loaded(object sender, RoutedEventArgs e)
- {
- if (AirportTask != null)
- {
- AreaTask.Text = AirportTask.conveyorno + "号站台任务列表";
- }
- _taskservice = App.ServiceProvider.GetService();
- LoadAreaTaskInfo();
- }
- }
-}
diff --git a/SlnMesnac.WPF/Page/IndexPage/HistorySearch.xaml b/SlnMesnac.WPF/Page/IndexPage/HistorySearch.xaml
index e70082a..69e3782 100644
--- a/SlnMesnac.WPF/Page/IndexPage/HistorySearch.xaml
+++ b/SlnMesnac.WPF/Page/IndexPage/HistorySearch.xaml
@@ -103,7 +103,7 @@
-
+
@@ -113,7 +113,7 @@
-
+
@@ -132,8 +132,8 @@
+ Width="170" Margin="10 0" BorderBrush="Black">
+
+ Width="170" BorderBrush="Black" FontSize="20">
+
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/SlnMesnac.WPF/Page/IndexPage/MaterialBind.xaml.cs b/SlnMesnac.WPF/Page/IndexPage/MaterialBind.xaml.cs
deleted file mode 100644
index 762416b..0000000
--- a/SlnMesnac.WPF/Page/IndexPage/MaterialBind.xaml.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using ATC_MaterialBind.Entity;
-using SlnMesnac.Plc;
-using SlnMesnac.WPF.Attribute;
-using SlnMesnac.WPF.ViewModel.IndexPage;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Automation.Peers;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-
-namespace SlnMesnac.WPF.Page.IndexPage
-{
- ///
- /// MaterialBind.xaml 的交互逻辑
- ///
- [RegisterAsSingletonAttribute]
- public partial class MaterialBind : UserControl
- {
- IndexContentViewModel indexContentViewModel;
- public MaterialBind()
- {
- InitializeComponent();
- indexContentViewModel = new IndexContentViewModel();
- indexContentViewModel._Action += RefreshStationQuallity;
- this.DataContext = indexContentViewModel;
- //load();
- }
-
- private void RefreshStationQuallity(List stationQualityInfos)
- {
- Application.Current.Dispatcher.Invoke(new Action(() =>
- {
- stackpanel1.Children.Clear();
- if (stationQualityInfos != null && stationQualityInfos.Count > 0)
- {
- List buttons = new List();
- foreach (var item in stationQualityInfos)
- {
- buttons.Add(new Button { FontSize = 20, Background = item.State == "1" ? Brushes.Lime : Brushes.Red, Height = 50, Content = item.StationName });
- }
-
- foreach (UIElement button in buttons)
- {
- stackpanel1.Children.Add(button);
- }
- }
- else {
- stackpanel1.Children.Remove(this);
- }
-
- }));
-
- }
-
- //在载入行的时候在行表头添加编号
- private void dgv_LoadingRow(object sender, DataGridRowEventArgs e)
- {
- e.Row.Header = (e.Row.GetIndex() + 1).ToString();
- }
-
- }
-}
diff --git a/SlnMesnac.WPF/Page/IndexPage/ProductionLineUserControl.xaml b/SlnMesnac.WPF/Page/IndexPage/ProductionLineUserControl.xaml
index 4521e51..2010b7e 100644
--- a/SlnMesnac.WPF/Page/IndexPage/ProductionLineUserControl.xaml
+++ b/SlnMesnac.WPF/Page/IndexPage/ProductionLineUserControl.xaml
@@ -9,7 +9,7 @@
d:DesignHeight="500" d:DesignWidth="900">
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
-
-
+
+
+ VerticalAlignment="Center" Margin="10,0,0,0"/>
-
+ ColumnHeaderHeight="35" Height="{Binding Path=ActualHeight, ElementName=ScanPanel}"
+ RowHeight="50" AutoGenerateColumns="False" RowHeaderWidth="0" FontSize="15"
+ GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Auto"
+ ScrollViewer.VerticalScrollBarVisibility="Auto" BorderThickness="0" CanUserAddRows="False" SelectionMode="Single" IsReadOnly="True" VerticalScrollBarVisibility="Auto"
+ Foreground="Black" >
+
@@ -614,8 +672,9 @@
-
-
+
+
+
+
+
+
+