1
0
Fork 0
- RFID工位识别PLC写入功能完成
- 新增读写器和标签维护页面
master
SoulStar 1 month ago
parent bac20bdcd3
commit 5fce13039a

@ -51,7 +51,7 @@
<Compile Include="PlcEntity\RgvStationEnum.cs" />
<Compile Include="PlcHelper\BasePlcHelper.cs" />
<Compile Include="PlcHelper\RfidResult.cs" />
<Compile Include="PlcHelper\WorkStationWrite.cs" />
<Compile Include="PlcHelper\WorkStationHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>

@ -41,7 +41,7 @@ namespace HighWayIot.Plc
{
plc.CommunicationPipe = new HslCommunication.Core.Pipe.PipeTcpNet(Ip, 2001)
{
ConnectTimeOut = 1000, // 连接超时时间,单位毫秒
ConnectTimeOut = 3000, // 连接超时时间,单位毫秒
SleepTime = 0,
SocketKeepAliveTime = -1,
IsPersistentConnection = true,

@ -8,12 +8,12 @@ namespace HighWayIot.Plc.PlcHelper
{
public class BasePlcHelper
{
public PlcConnect PlcInstance = PlcConnect.Instance;
//public PlcConnect PlcInstance = PlcConnect.Instance;
public BasePlcHelper()
{
//public BasePlcHelper()
//{
}
//}
}
}

@ -14,11 +14,15 @@ namespace HighWayIot.Plc.PlcHelper
/// </summary>
/// <param name="rgvStation"></param>
/// <returns></returns>
public bool WriteStationSingal(RgvStationEnum rgvStation, int deviceNo)
public bool WriteStationSingal(int rgvStationNo, int deviceNo)
{
int point = 0x600;
//选择是哪个小车
point += deviceNo * 32;
point += (int)rgvStation;
//选择是小车的哪个点位
point += rgvStationNo;
bool result = PlcConnect.PlcWrite($"B{point.ToString("X")}", true, DataTypeEnum.Bool).IsSuccess;

@ -62,13 +62,15 @@
<Compile Include="domain\ZxMaterialTypeEntity.cs" />
<Compile Include="domain\ZxMaterialChildTypeEntity.cs" />
<Compile Include="domain\ZxMaterialEntity.cs" />
<Compile Include="domain\ZxTagSettingEntity.cs" />
<Compile Include="domain\ZxRecipeEntity.cs" />
<Compile Include="domain\ZxRecipeParaEntity.cs" />
<Compile Include="domain\ZxWeightEntity.cs" />
<Compile Include="domain\Zx_rfid_setting.cs" />
<Compile Include="domain\ZxReaderSettingEntity.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Repository.cs" />
<Compile Include="service\Zx_rfid_settingService.cs" />
<Compile Include="service\ZxTagSettingService.cs" />
<Compile Include="service\ZxReaderSettingService.cs" />
<Compile Include="service\SysLogService.cs" />
<Compile Include="service\SysErrorLogService.cs" />
<Compile Include="service\ZxCarParaService.cs" />

@ -9,12 +9,11 @@ using System.Threading.Tasks;
namespace HighWayIot.Repository.domain
{
/// <summary>
///
/// RFID配置表
///</summary>
[SugarTable("zx_rfid_setting")]
public class Zx_rfid_setting
[SugarTable("zx_rfid_reader_setting")]
public class ZxReaderSettingEntity
{
/// <summary>
/// 备 注:
@ -28,23 +27,28 @@ namespace HighWayIot.Repository.domain
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "rfid_ip")]
public string RfidIp { get; set; }
public string RfidIp { get; set; } = string.Empty;
/// <summary>
/// 备 注:RFID编号
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "rfid_epc")]
public string RfidEpc { get; set; }
///// <summary>
///// 备 注:RFID编号
///// 默认值:
/////</summary>
//[SugarColumn(ColumnName = "rfid_epc")]
//public string RfidEpc { get; set; } = string.Empty;
/// <summary>
/// 备 注:工位编号
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "workstate_no")]
public int? WorkstateNo { get; set; }
[SugarColumn(ColumnName = "workstation_no")]
public string WorkstationNo { get; set; } = string.Empty;
///// <summary>
///// 备 注:是否连接成功
///// 默认值:
/////</summary>
//[SugarColumn(ColumnName = "is_connected")]
//public bool? IsConnected { get; set; }
}
}

@ -0,0 +1,54 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Repository.domain
{
/// <summary>
/// RFID配置表
///</summary>
[SugarTable("zx_rfid_tag_setting")]
public class ZxTagSettingEntity
{
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
/// <summary>
/// 备 注:标签EPC
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "rfid_epc")]
public string RfidEpc { get; set; } = string.Empty;
///// <summary>
///// 备 注:RFID编号
///// 默认值:
/////</summary>
//[SugarColumn(ColumnName = "rfid_epc")]
//public string RfidEpc { get; set; } = string.Empty;
/// <summary>
/// 备 注:小车编号
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "device_no")]
public string DeviceNo { get; set; } = string.Empty;
///// <summary>
///// 备 注:是否连接成功
///// 默认值:
/////</summary>
//[SugarColumn(ColumnName = "is_connected")]
//public bool? IsConnected { get; set; }
}
}

@ -9,11 +9,11 @@ using System.Threading.Tasks;
namespace HighWayIot.Repository.service
{
public class Zx_rfid_settingService
public class ZxReaderSettingService
{
private static readonly Lazy<Zx_rfid_settingService> lazy = new Lazy<Zx_rfid_settingService>(() => new Zx_rfid_settingService());
private static readonly Lazy<ZxReaderSettingService> lazy = new Lazy<ZxReaderSettingService>(() => new ZxReaderSettingService());
public static Zx_rfid_settingService Instance
public static ZxReaderSettingService Instance
{
get
{
@ -22,17 +22,17 @@ namespace HighWayIot.Repository.service
}
private LogHelper log = LogHelper.Instance;
Repository<Zx_rfid_setting> _repository => new Repository<Zx_rfid_setting>("sqlserver");
Repository<ZxReaderSettingEntity> _repository => new Repository<ZxReaderSettingEntity>("sqlserver");
/// <summary>
/// 查询所有RFID设备信息
/// </summary>
/// <returns></returns>
public List<Zx_rfid_setting> GetRfidInfos(Expression<Func<Zx_rfid_setting, bool>> expression = null)
public List<ZxReaderSettingEntity> GetReaderInfos(Expression<Func<ZxReaderSettingEntity, bool>> expression = null)
{
try
{
List<Zx_rfid_setting> entity;
List<ZxReaderSettingEntity> entity;
if (expression != null)
{
entity = _repository.GetList(expression);
@ -51,17 +51,17 @@ namespace HighWayIot.Repository.service
}
/// <summary>
/// 查询指定RFID设备信息
/// 根据IP查询读写器工位信息
/// </summary>
/// <returns></returns>
public Zx_rfid_setting GetRfidInfoById(int id)
public string GetWorkstateNoByIp(string ip)
{
try
{
Zx_rfid_setting entity;
entity = _repository.GetById(id);
ZxReaderSettingEntity entity;
entity = _repository.GetFirst(x => x.RfidIp == ip);
return entity;
return entity.WorkstationNo;
}
catch (Exception ex)
{
@ -75,7 +75,7 @@ namespace HighWayIot.Repository.service
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public bool UpdateRfidInfo(Zx_rfid_setting entity)
public bool UpdateReaderInfo(ZxReaderSettingEntity entity)
{
try
{
@ -87,5 +87,23 @@ namespace HighWayIot.Repository.service
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public bool UpdateRangeReaderInfo(List<ZxReaderSettingEntity> entitys)
{
try
{
return _repository.UpdateRange(entitys);
}
catch (Exception ex)
{
log.Error("RFID集合信息修改异常", ex);
return false;
}
}
}
}

@ -0,0 +1,109 @@
using HighWayIot.Log4net;
using HighWayIot.Repository.domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Repository.service
{
public class ZxTagSettingService
{
private static readonly Lazy<ZxTagSettingService> lazy = new Lazy<ZxTagSettingService>(() => new ZxTagSettingService());
public static ZxTagSettingService Instance
{
get
{
return lazy.Value;
}
}
private LogHelper log = LogHelper.Instance;
Repository<ZxTagSettingEntity> _repository => new Repository<ZxTagSettingEntity>("sqlserver");
/// <summary>
/// 查询所有RFID标签信息
/// </summary>
/// <returns></returns>
public List<ZxTagSettingEntity> GetTagInfos(Expression<Func<ZxTagSettingEntity, bool>> expression = null)
{
try
{
List<ZxTagSettingEntity> entity;
if (expression != null)
{
entity = _repository.GetList(expression);
}
else
{
entity = _repository.GetList();
}
return entity;
}
catch (Exception ex)
{
log.Error("RFID标签信息获取异常", ex);
return null;
}
}
/// <summary>
/// 根据EPC查询指定RFID标签DeviceNo信息
/// </summary>
/// <returns></returns>
public string GetTagDeviceNoByEPC(string Epc)
{
try
{
ZxTagSettingEntity entity;
entity = _repository.GetFirst(x => x.RfidEpc == Epc);
return entity.DeviceNo;
}
catch (Exception ex)
{
log.Error("RFID标签信息获取异常", ex);
return null;
}
}
/// <summary>
/// 修改标签信息
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public bool UpdateTagInfo(ZxTagSettingEntity entity)
{
try
{
return _repository.Update(entity);
}
catch (Exception ex)
{
log.Error("RFID标签信息修改异常", ex);
return false;
}
}
/// <summary>
/// 修改标签信息
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public bool UpdateRangeTagInfo(List<ZxTagSettingEntity> entitys)
{
try
{
return _repository.UpdateRange(entitys);
}
catch (Exception ex)
{
log.Error("RFID标签集合信息修改异常", ex);
return false;
}
}
}
}

@ -67,8 +67,8 @@ namespace HighWayIot.Rfid
index += 2;
//取读到标签的EPC
Array.Copy(DataBytes, index, EPCData.EPC, 0, 12);
index += 12;
Array.Copy(DataBytes, index, EPCData.EPC, 0, 4);
index += 4;
entity.Data.Add(EPCData);
}

@ -36,22 +36,22 @@
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
<Reference Include="System.Buffers, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
<Reference Include="System.Memory, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
<Reference Include="System.Numerics.Vectors, Version=4.1.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.6.0\lib\net462\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
@ -59,11 +59,11 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="TouchSocket, Version=3.0.9.0, Culture=neutral, PublicKeyToken=5f39d7da98dac6a9, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.3.0.9\lib\net472\TouchSocket.dll</HintPath>
<Reference Include="TouchSocket, Version=3.0.12.0, Culture=neutral, PublicKeyToken=5f39d7da98dac6a9, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.3.0.12\lib\net472\TouchSocket.dll</HintPath>
</Reference>
<Reference Include="TouchSocket.Core, Version=3.0.9.0, Culture=neutral, PublicKeyToken=d6c415a2f58eda72, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.Core.3.0.9\lib\net472\TouchSocket.Core.dll</HintPath>
<Reference Include="TouchSocket.Core, Version=3.0.12.0, Culture=neutral, PublicKeyToken=d6c415a2f58eda72, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.Core.3.0.12\lib\net472\TouchSocket.Core.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@ -71,16 +71,17 @@
<Compile Include="TouchSocketTcpClient.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\TouchSocket.Core.3.0.9\analyzers\dotnet\cs\TouchSocket.Core.SourceGenerator.dll" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HighWayIot.Log4net\HighWayIot.Log4net.csproj">
<Project>{DEABC30C-EC6F-472E-BD67-D65702FDAF74}</Project>
<Name>HighWayIot.Log4net</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\TouchSocket.Core.3.0.12\analyzers\dotnet\cs\TouchSocket.Core.SourceGenerator.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -1,5 +1,7 @@
using HighWayIot.Log4net;
using System;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using TouchSocket.Core;
@ -10,40 +12,51 @@ namespace HighWayIot.TouchSocket
{
public class TouchSocketTcpClient
{
/// <summary>
/// 日志
/// </summary>
private static LogHelper _logHelper = LogHelper.Instance;
/// <summary>
/// 懒加载
/// </summary>
private static readonly Lazy<TouchSocketTcpClient> lazy = new Lazy<TouchSocketTcpClient>(() => new TouchSocketTcpClient());
public static TouchSocketTcpClient Instance => lazy.Value;
TcpClient client = new TcpClient();
/// <summary>
/// 所有的客户端
/// </summary>
public Dictionary<string, TcpClient> Clients = new Dictionary<string, TcpClient>();
public Action<byte[], string> GetMessageAction;
public async void TcpClient(string ip, string port)
public async Task<bool> CreateTcpClient(string ip, string port)
{
client.Connecting = (client, e) =>
TcpClient tcpClient = new TcpClient();
tcpClient.Connecting = (client, e) =>
{
return EasyTask.CompletedTask;
};//有客户端正在连接
client.Connected = (client, e) =>
tcpClient.Connected = (client, e) =>
{
return EasyTask.CompletedTask;
};//有客户端成功连接
client.Closing = (client, e) =>
tcpClient.Closing = (client, e) =>
{
return EasyTask.CompletedTask;
};//有客户端正在断开连接,只有当主动断开时才有效。
client.Closed = (client, e) =>
tcpClient.Closed = (client, e) =>
{
return EasyTask.CompletedTask;
};//有客户端断开连接
client.Received = async (client, e) =>
tcpClient.Received = async (client, e) =>
{
//从客户端收到信息
var mes = e.ByteBlock.Span.ToString(Encoding.UTF8);
client.Logger.Info($"已从{client.IP}接收到信息:{mes}");
GetMessageAction.Invoke(e.ByteBlock.Span.ToArray(), client.IP);
};
await client.SetupAsync(new TouchSocketConfig()
await tcpClient.SetupAsync(new TouchSocketConfig()
.SetRemoteIPHost($"{ip}:{port}")
.ConfigureContainer(a =>
{
@ -53,11 +66,14 @@ namespace HighWayIot.TouchSocket
Result result = Result.Default; //不断尝试重连
do
{
result = await client.TryConnectAsync();
_logHelper.Info($"连接{ip}:{port}");
result = await tcpClient.TryConnectAsync();
}
while (!result.IsSuccess);
return;
_logHelper.Info($"{ip}:{port}连接成功");
Clients.Add(ip, tcpClient);
return true;
}
/// <summary>
@ -65,11 +81,11 @@ namespace HighWayIot.TouchSocket
/// </summary>
/// <param name="message">Bytes</param>
/// <returns></returns>
public async Task<bool> Send(byte[] message)
public async Task<bool> Send(string ip, byte[] message)
{
try
{
await client.SendAsync(message);
await Clients[ip].SendAsync(message);
return true;
}
catch (Exception e)
@ -79,5 +95,26 @@ namespace HighWayIot.TouchSocket
}
}
/// <summary>
/// 客户端释放
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
public async Task<bool> DisposeClient(string ip)
{
try
{
await Clients[ip].CloseAsync();
Clients[ip].Dispose();
Clients.Remove(ip);
return true;
}
catch (Exception e)
{
_logHelper.Error("释放客户端发生错误" + e);
return false;
}
}
}
}

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="TouchSocket" publicKeyToken="5f39d7da98dac6a9" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.12.0" newVersion="3.0.12.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="TouchSocket.Core" publicKeyToken="d6c415a2f58eda72" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.12.0" newVersion="3.0.12.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.1.0" newVersion="6.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.Memory" version="4.5.5" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
<package id="TouchSocket" version="3.0.9" targetFramework="net48" />
<package id="TouchSocket.Core" version="3.0.9" targetFramework="net48" />
<package id="System.Buffers" version="4.6.0" targetFramework="net48" />
<package id="System.Memory" version="4.6.0" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.6.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.1.0" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.6.0" targetFramework="net48" />
<package id="TouchSocket" version="3.0.12" targetFramework="net48" />
<package id="TouchSocket.Core" version="3.0.12" targetFramework="net48" />
</packages>

@ -13,6 +13,26 @@
<assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.122.21.1" newVersion="4.122.21.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<!--<dependentAssembly>
<assemblyIdentity name="TouchSocket.Core" publicKeyToken="d6c415a2f58eda72" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.12.0" newVersion="3.0.12.0" />
</dependentAssembly>-->
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.1.0" newVersion="6.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

@ -1,12 +1,184 @@
using System;
using HighWayIot.Log4net;
using HighWayIot.Plc.PlcEntity;
using HighWayIot.Plc.PlcHelper;
using HighWayIot.Repository.domain;
using HighWayIot.Repository.service;
using HighWayIot.Rfid;
using HighWayIot.Rfid.Entity;
using HighWayIot.TouchSocket;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TouchSocket.Core;
using Timer = System.Threading.Timer;
namespace HighWayIot.Winform.Business
{
/// <summary>
/// 工位RFID识别业务
/// </summary>
public class WorkStationBusiness
{
/// <summary>
/// 日志
/// </summary>
private LogHelper _logHelper = LogHelper.Instance;
/// <summary>
/// PLC
/// </summary>
private WorkStationHelper _workStationHelper = new WorkStationHelper();
/// <summary>
/// 读写器服务类
/// </summary>
private ZxReaderSettingService _readerService = ZxReaderSettingService.Instance;
/// <summary>
/// 读写器实体类
/// </summary>
private List<ZxReaderSettingEntity> _readerSetting;
/// <summary>
/// 标签服务类
/// </summary>
private ZxTagSettingService _tagrService = ZxTagSettingService.Instance;
/// <summary>
/// 标签实体类
/// </summary>
private List<ZxTagSettingEntity> _tagSetting;
/// <summary>
/// RFID数据分析
/// </summary>
private RfidDataAnalyse _rfidDataAnalyse = new RfidDataAnalyse();
/// <summary>
/// TCP客户端
/// </summary>
private TouchSocketTcpClient _touchSocketTcpClient = TouchSocketTcpClient.Instance;
/// <summary>
/// 刷新器
/// </summary>
private Timer timer;
/// <summary>
/// 是否全部连接成功
/// </summary>
private bool IsAllConnected = false;
public WorkStationBusiness()
{
_readerSetting = _readerService.GetReaderInfos();
CreateAllRFIDClient();
_touchSocketTcpClient.GetMessageAction += ReciveRFIDSingal;
timer = new Timer(new System.Threading.TimerCallback(SingalMonitor), null, 0, 2000);
}
/// <summary>
/// 自动监视
/// </summary>
/// <param name="o"></param>
public void SingalMonitor(object o)
{
bool[] singals = _workStationHelper.ReadStationSingal();
for (int i = 1; i <= singals.Length; i++)
{
if (singals[i - 1] == true)
{
SendRFIDSingal(i);
}
}
}
/// <summary>
/// 创建所有RFID客户端
/// </summary>
public async void CreateAllRFIDClient()
{
foreach (var setting in _readerSetting)
{
await _touchSocketTcpClient.CreateTcpClient(setting.RfidIp, "20108");
}
_logHelper.Info("所有读写器均连接成功");
IsAllConnected = true;
}
/// <summary>
/// 向指定RFID读写器发送读信号
/// </summary>
public async void SendRFIDSingal(int no)
{
if (IsAllConnected == true)
{
ZxReaderSettingEntity setting = _readerSetting.FirstOrDefault(x => x.WorkstationNo == no.ToString());
if (setting == null)
{
return;
}
int i = 0;
bool result = false;
do
{
result = await _touchSocketTcpClient.Send(setting.RfidIp, _rfidDataAnalyse.Send02H(1000));
i++;
}
while (i < 3 && result == false);
if(result == false)
{
_logHelper.Error($"[{no}] 工位 [{setting.RfidIp}] 读写器指令发送失败!");
}
}
}
/// <summary>
/// 接收信息的信号
/// </summary>
/// <param name="bytes"></param>
public void ReciveRFIDSingal(byte[] bytes, string ip)
{
Receive02HEntity entity = _rfidDataAnalyse.Receive02H(bytes);
if(entity.TagCount != 1)
{
_logHelper.Error("返回多标签!");
return;
}
byte[] data = entity.Data[0].EPC;
string result = string.Join(" ", data.Select(x => x.ToString("X2")));
string deviceNo = _tagrService.GetTagDeviceNoByEPC(result);
string workstationNo = _readerService.GetWorkstateNoByIp(ip);
if (string.IsNullOrEmpty(deviceNo))
{
_logHelper.Error($"没有查询到 [{result}] 标签相关的信息!");
return;
}
if (string.IsNullOrEmpty(workstationNo))
{
_logHelper.Error($"没有查询到 [{ip}] 读写器相关的信息!");
return;
}
try
{
_workStationHelper.WriteStationSingal(int.Parse(workstationNo), int.Parse(deviceNo));
}
catch (Exception ex)
{
_logHelper.Error("数值转换发生错误", ex);
}
}
}
}

@ -55,6 +55,7 @@
<Compile Include="Business\GeneralUtils.cs" />
<Compile Include="Business\RoleBusiness.cs" />
<Compile Include="Business\SqlLogHelper.cs" />
<Compile Include="Business\WorkStationBusiness.cs" />
<Compile Include="Business\XmlUtil.cs" />
<Compile Include="MainForm\BaseForm.cs">
<SubType>Form</SubType>
@ -118,12 +119,6 @@
<Compile Include="UserControlPages\MonitorMainPages\MonitorMainPage.Designer.cs">
<DependentUpon>MonitorMainPage.cs</DependentUpon>
</Compile>
<Compile Include="UserControlPages\ParamConfigPages\UpdateRfidWindow.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UserControlPages\ParamConfigPages\UpdateRfidWindow.Designer.cs">
<DependentUpon>UpdateRfidWindow.cs</DependentUpon>
</Compile>
<Compile Include="UserControlPages\RecipeConfigPages\AddRecipeForm.cs">
<SubType>Form</SubType>
</Compile>
@ -216,6 +211,7 @@
</Compile>
<EmbeddedResource Include="MainForm\BaseForm.resx">
<DependentUpon>BaseForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="MainForm\LoginForm.resx">
<DependentUpon>LoginForm.cs</DependentUpon>
@ -254,9 +250,6 @@
<EmbeddedResource Include="UserControlPages\MonitorMainPages\MonitorMainPage.resx">
<DependentUpon>MonitorMainPage.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UserControlPages\ParamConfigPages\UpdateRfidWindow.resx">
<DependentUpon>UpdateRfidWindow.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UserControlPages\RecipeConfigPages\AddRecipeForm.resx">
<DependentUpon>AddRecipeForm.cs</DependentUpon>
</EmbeddedResource>
@ -331,6 +324,14 @@
<Project>{D0DC3CFB-6748-4D5E-B56A-76FDC72AB4B3}</Project>
<Name>HighWayIot.Repository</Name>
</ProjectReference>
<ProjectReference Include="..\HighWayIot.Rfid\HighWayIot.Rfid.csproj">
<Project>{29813574-49c0-4979-a5a6-47eb7c4288a0}</Project>
<Name>HighWayIot.Rfid</Name>
</ProjectReference>
<ProjectReference Include="..\HighWayIot.TouchSocket\HighWayIot.TouchSocket.csproj">
<Project>{DD18A634-1F9C-409A-8C32-C3C81B1B55B5}</Project>
<Name>HighWayIot.TouchSocket</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="Static\海威.ico" />

@ -34,6 +34,11 @@ namespace HighWayIot.Winform.MainForm
/// </summary>
RoleBusiness roleBusiness = new RoleBusiness();
/// <summary>
/// 工位RFID刷新类
/// </summary>
WorkStationBusiness workStationBusiness = new WorkStationBusiness();
public BaseForm()
{
InitializeComponent();

@ -31,105 +31,297 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages
/// </summary>
private void InitializeComponent()
{
this.GetRfidButton = new System.Windows.Forms.Button();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
this.GetReaderButton = new System.Windows.Forms.Button();
this.ButtonPanel = new System.Windows.Forms.Panel();
this.rfidDataGridView = new System.Windows.Forms.DataGridView();
this.UpdateReaderButton = new System.Windows.Forms.Button();
this.ReaderDataGridView = new System.Windows.Forms.DataGridView();
this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.RfidIp = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.WorkstationNo = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.RFIDSettingGroupBox = new System.Windows.Forms.GroupBox();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.panel1 = new System.Windows.Forms.Panel();
this.UpdateRFIDButton = new System.Windows.Forms.Button();
this.SelectRfidButton = new System.Windows.Forms.Button();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.TagDataGridView = new System.Windows.Forms.DataGridView();
this.RfidId = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.RfidEpc = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.WorkstateNo = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.DeviceNo = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ButtonPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.rfidDataGridView)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.ReaderDataGridView)).BeginInit();
this.RFIDSettingGroupBox.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
this.panel1.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.TagDataGridView)).BeginInit();
this.SuspendLayout();
//
// GetRfidButton
// GetReaderButton
//
this.GetRfidButton.Location = new System.Drawing.Point(3, 2);
this.GetRfidButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.GetRfidButton.Name = "GetRfidButton";
this.GetRfidButton.Size = new System.Drawing.Size(103, 39);
this.GetRfidButton.TabIndex = 1;
this.GetRfidButton.Text = "查 询";
this.GetRfidButton.UseVisualStyleBackColor = true;
this.GetRfidButton.Click += new System.EventHandler(this.GetRfidButton_Click);
this.GetReaderButton.Location = new System.Drawing.Point(6, 11);
this.GetReaderButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.GetReaderButton.Name = "GetReaderButton";
this.GetReaderButton.Size = new System.Drawing.Size(103, 39);
this.GetReaderButton.TabIndex = 1;
this.GetReaderButton.Text = "查读写器信息";
this.GetReaderButton.UseVisualStyleBackColor = true;
this.GetReaderButton.Click += new System.EventHandler(this.GetReaderButton_Click);
//
// ButtonPanel
//
this.ButtonPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.ButtonPanel.Controls.Add(this.GetRfidButton);
this.ButtonPanel.Location = new System.Drawing.Point(0, 0);
this.ButtonPanel.Controls.Add(this.UpdateReaderButton);
this.ButtonPanel.Controls.Add(this.GetReaderButton);
this.ButtonPanel.Location = new System.Drawing.Point(3, 2);
this.ButtonPanel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.ButtonPanel.Name = "ButtonPanel";
this.ButtonPanel.Size = new System.Drawing.Size(1171, 61);
this.ButtonPanel.Size = new System.Drawing.Size(694, 61);
this.ButtonPanel.TabIndex = 4;
//
// rfidDataGridView
// UpdateReaderButton
//
this.rfidDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.rfidDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.UpdateReaderButton.Location = new System.Drawing.Point(115, 11);
this.UpdateReaderButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.UpdateReaderButton.Name = "UpdateReaderButton";
this.UpdateReaderButton.Size = new System.Drawing.Size(103, 39);
this.UpdateReaderButton.TabIndex = 2;
this.UpdateReaderButton.Text = "修改读写器信息";
this.UpdateReaderButton.UseVisualStyleBackColor = true;
this.UpdateReaderButton.Click += new System.EventHandler(this.UpdateReaderButton_Click);
//
// ReaderDataGridView
//
this.ReaderDataGridView.AllowUserToAddRows = false;
this.ReaderDataGridView.AllowUserToDeleteRows = false;
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
this.ReaderDataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle3;
this.ReaderDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.ReaderDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Id,
this.RfidIp,
this.RfidEpc,
this.WorkstateNo});
this.rfidDataGridView.Location = new System.Drawing.Point(20, 66);
this.rfidDataGridView.Name = "rfidDataGridView";
this.rfidDataGridView.RowTemplate.Height = 23;
this.rfidDataGridView.Size = new System.Drawing.Size(1135, 724);
this.rfidDataGridView.TabIndex = 5;
this.rfidDataGridView.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.rfidDataGridView_CellDoubleClick);
this.WorkstationNo});
this.ReaderDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.ReaderDataGridView.Location = new System.Drawing.Point(3, 17);
this.ReaderDataGridView.Name = "ReaderDataGridView";
this.ReaderDataGridView.RowHeadersVisible = false;
this.ReaderDataGridView.RowTemplate.Height = 23;
this.ReaderDataGridView.Size = new System.Drawing.Size(688, 842);
this.ReaderDataGridView.TabIndex = 5;
//
// Id
//
this.Id.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.Id.FillWeight = 10F;
this.Id.HeaderText = "ID";
this.Id.DataPropertyName = "Id";
this.Id.HeaderText = "编号";
this.Id.Name = "Id";
this.Id.Width = 40;
//
// RfidIp
//
this.RfidIp.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.RfidIp.FillWeight = 20F;
this.RfidIp.DataPropertyName = "RfidIp";
this.RfidIp.FillWeight = 5F;
this.RfidIp.HeaderText = "设备ip";
this.RfidIp.Name = "RfidIp";
//
// WorkstationNo
//
this.WorkstationNo.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.WorkstationNo.DataPropertyName = "WorkstationNo";
this.WorkstationNo.FillWeight = 5F;
this.WorkstationNo.HeaderText = "工位编号";
this.WorkstationNo.Name = "WorkstationNo";
//
// RFIDSettingGroupBox
//
this.RFIDSettingGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.RFIDSettingGroupBox.Controls.Add(this.ReaderDataGridView);
this.RFIDSettingGroupBox.Location = new System.Drawing.Point(3, 3);
this.RFIDSettingGroupBox.Name = "RFIDSettingGroupBox";
this.RFIDSettingGroupBox.Size = new System.Drawing.Size(694, 862);
this.RFIDSettingGroupBox.TabIndex = 6;
this.RFIDSettingGroupBox.TabStop = false;
this.RFIDSettingGroupBox.Text = "读写器配置";
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tableLayoutPanel1.ColumnCount = 2;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.Controls.Add(this.panel1, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.ButtonPanel, 0, 0);
this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 3);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 1;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(1401, 65);
this.tableLayoutPanel1.TabIndex = 7;
//
// panel1
//
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.panel1.Controls.Add(this.UpdateRFIDButton);
this.panel1.Controls.Add(this.SelectRfidButton);
this.panel1.Location = new System.Drawing.Point(703, 2);
this.panel1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(695, 61);
this.panel1.TabIndex = 5;
//
// UpdateRFIDButton
//
this.UpdateRFIDButton.Location = new System.Drawing.Point(115, 11);
this.UpdateRFIDButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.UpdateRFIDButton.Name = "UpdateRFIDButton";
this.UpdateRFIDButton.Size = new System.Drawing.Size(103, 39);
this.UpdateRFIDButton.TabIndex = 2;
this.UpdateRFIDButton.Text = "修改标签信息";
this.UpdateRFIDButton.UseVisualStyleBackColor = true;
this.UpdateRFIDButton.Click += new System.EventHandler(this.UpdateRFIDButton_Click);
//
// SelectRfidButton
//
this.SelectRfidButton.Location = new System.Drawing.Point(6, 11);
this.SelectRfidButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.SelectRfidButton.Name = "SelectRfidButton";
this.SelectRfidButton.Size = new System.Drawing.Size(103, 39);
this.SelectRfidButton.TabIndex = 1;
this.SelectRfidButton.Text = "查询标签信息";
this.SelectRfidButton.UseVisualStyleBackColor = true;
this.SelectRfidButton.Click += new System.EventHandler(this.SelectRfidButton_Click);
//
// tableLayoutPanel2
//
this.tableLayoutPanel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tableLayoutPanel2.ColumnCount = 2;
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel2.Controls.Add(this.groupBox1, 1, 0);
this.tableLayoutPanel2.Controls.Add(this.RFIDSettingGroupBox, 0, 0);
this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 74);
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.RowCount = 1;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel2.Size = new System.Drawing.Size(1401, 868);
this.tableLayoutPanel2.TabIndex = 8;
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.TagDataGridView);
this.groupBox1.Location = new System.Drawing.Point(703, 3);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(695, 862);
this.groupBox1.TabIndex = 7;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "标签配置";
//
// TagDataGridView
//
this.TagDataGridView.AllowUserToAddRows = false;
this.TagDataGridView.AllowUserToDeleteRows = false;
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle4.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
this.TagDataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4;
this.TagDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.TagDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.RfidId,
this.RfidEpc,
this.DeviceNo});
this.TagDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.TagDataGridView.Location = new System.Drawing.Point(3, 17);
this.TagDataGridView.Name = "TagDataGridView";
this.TagDataGridView.RowHeadersVisible = false;
this.TagDataGridView.RowTemplate.Height = 23;
this.TagDataGridView.Size = new System.Drawing.Size(689, 842);
this.TagDataGridView.TabIndex = 5;
//
// RfidId
//
this.RfidId.DataPropertyName = "Id";
this.RfidId.HeaderText = "编号";
this.RfidId.Name = "RfidId";
this.RfidId.Width = 40;
//
// RfidEpc
//
this.RfidEpc.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.RfidEpc.FillWeight = 20F;
this.RfidEpc.HeaderText = "RFID编号";
this.RfidEpc.DataPropertyName = "RfidEpc";
this.RfidEpc.FillWeight = 5F;
this.RfidEpc.HeaderText = "标签EPC";
this.RfidEpc.Name = "RfidEpc";
//
// WorkstateNo
// DeviceNo
//
this.WorkstateNo.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.WorkstateNo.FillWeight = 20F;
this.WorkstateNo.HeaderText = "工位编号";
this.WorkstateNo.Name = "WorkstateNo";
this.DeviceNo.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.DeviceNo.DataPropertyName = "DeviceNo";
this.DeviceNo.FillWeight = 5F;
this.DeviceNo.HeaderText = "工位编号";
this.DeviceNo.Name = "DeviceNo";
//
// RFIDParamSettingPage
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.ControlLight;
this.Controls.Add(this.rfidDataGridView);
this.Controls.Add(this.ButtonPanel);
this.Controls.Add(this.tableLayoutPanel2);
this.Controls.Add(this.tableLayoutPanel1);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "RFIDParamSettingPage";
this.Size = new System.Drawing.Size(1171, 807);
this.Size = new System.Drawing.Size(1407, 945);
this.ButtonPanel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.rfidDataGridView)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.ReaderDataGridView)).EndInit();
this.RFIDSettingGroupBox.ResumeLayout(false);
this.tableLayoutPanel1.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.tableLayoutPanel2.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.TagDataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private Button GetRfidButton;
private Button GetReaderButton;
private Panel ButtonPanel;
private DataGridView rfidDataGridView;
private DataGridView ReaderDataGridView;
private GroupBox RFIDSettingGroupBox;
private TableLayoutPanel tableLayoutPanel1;
private TableLayoutPanel tableLayoutPanel2;
private Panel panel1;
private Button SelectRfidButton;
private GroupBox groupBox1;
private DataGridView TagDataGridView;
private DataGridViewTextBoxColumn Id;
private DataGridViewTextBoxColumn RfidIp;
private DataGridViewTextBoxColumn WorkstationNo;
private DataGridViewTextBoxColumn RfidId;
private DataGridViewTextBoxColumn RfidEpc;
private DataGridViewTextBoxColumn WorkstateNo;
private DataGridViewTextBoxColumn DeviceNo;
private Button UpdateReaderButton;
private Button UpdateRFIDButton;
}
}

@ -14,45 +14,113 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages
{
public partial class RFIDParamSettingPage : UserControl
{
private Zx_rfid_settingService zx_rfid_settingService = Zx_rfid_settingService.Instance;
private ZxReaderSettingService zx_rfid_reader_settingService = ZxReaderSettingService.Instance;
private ZxTagSettingService zx_rfid_tag_settingService = ZxTagSettingService.Instance;
public RFIDParamSettingPage()
{
InitializeComponent();
RefreshReaderGridView();
RefreshTagGridView();
ReaderDataGridView.AutoGenerateColumns = false;
TagDataGridView.AutoGenerateColumns = false;
}
/// <summary>
/// 刷新读写器前端页面
/// </summary>
private void RefreshReaderGridView()
{
List<ZxReaderSettingEntity> list = zx_rfid_reader_settingService.GetReaderInfos();
ReaderDataGridView.DataSource = null;
ReaderDataGridView.DataSource = list;
}
private void GetRfidButton_Click(object sender, EventArgs e)
/// <summary>
/// 刷新标签前端页面
/// </summary>
private void RefreshTagGridView()
{
this.rfidDataGridView.Rows.Clear();
List<Zx_rfid_setting> list = zx_rfid_settingService.GetRfidInfos();
foreach (var item in list)
List<ZxTagSettingEntity> list = zx_rfid_tag_settingService.GetTagInfos();
TagDataGridView.DataSource = null;
TagDataGridView.DataSource = list;
}
/// <summary>
/// 查询读写器
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void GetReaderButton_Click(object sender, EventArgs e)
{
RefreshReaderGridView();
}
/// <summary>
/// 查询RFID
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SelectRfidButton_Click(object sender, EventArgs e)
{
RefreshTagGridView();
}
/// <summary>
/// 更改读写器
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void UpdateReaderButton_Click(object sender, EventArgs e)
{
List<ZxReaderSettingEntity> lists = new List<ZxReaderSettingEntity>();
DataGridViewRowCollection rows = ReaderDataGridView.Rows;
foreach (DataGridViewRow row in rows)
{
this.rfidDataGridView.Rows.Add(item.Id, item.RfidIp, item.RfidEpc, item.WorkstateNo);
ZxReaderSettingEntity entity = new ZxReaderSettingEntity()
{
Id = int.Parse(row.Cells["Id"].Value.ToString()),
RfidIp = row.Cells["RfidIp"].Value.ToString(),
WorkstationNo = row.Cells["WorkstationNo"].Value.ToString()
};
lists.Add(entity);
}
zx_rfid_reader_settingService.UpdateRangeReaderInfo(lists);
RefreshReaderGridView();
MessageBox.Show("读写器信息修改成功");
}
private void rfidDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
/// <summary>
/// 更改标签
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void UpdateRFIDButton_Click(object sender, EventArgs e)
{
// 检查是否双击了有效的行(排除列头)
if (e.RowIndex >= 0)
List<ZxTagSettingEntity> lists = new List<ZxTagSettingEntity>();
DataGridViewRowCollection rows = TagDataGridView.Rows;
foreach (DataGridViewRow row in rows)
{
// 获取双击的行
DataGridViewRow row = rfidDataGridView.Rows[e.RowIndex];
ZxTagSettingEntity entity = new ZxTagSettingEntity()
{
Id = int.Parse(row.Cells["RfidId"].Value.ToString()),
RfidEpc = row.Cells["RfidEpc"].Value.ToString(),
DeviceNo = row.Cells["DeviceNo"].Value.ToString()
};
lists.Add(entity);
}
// 获取该行的数据
int id = (int)row.Cells["Id"].Value;
string RfidIp = (string)row.Cells["RfidIp"].Value;
string RfidEpc = (string)row.Cells["RfidEpc"].Value;
string WorkstateNo = (string)row.Cells["WorkstateNo"].Value;
UpdateRfidWindow window = new UpdateRfidWindow(id, RfidIp,RfidEpc, WorkstateNo);
window.Show();
zx_rfid_tag_settingService.UpdateRangeTagInfo(lists);
RefreshReaderGridView();
}
MessageBox.Show("标签信息修改成功");
}
}
}

@ -123,10 +123,16 @@
<metadata name="RfidIp.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="WorkstationNo.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="RfidId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="RfidEpc.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="WorkstateNo.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="DeviceNo.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

@ -1,127 +0,0 @@
namespace HighWayIot.Winform.UserControlPages.ParamConfigPages
{
partial class UpdateRfidWindow
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.RfidIptextBox = new System.Windows.Forms.TextBox();
this.RfidEpctextBox = new System.Windows.Forms.TextBox();
this.WorkstateNotextBox = new System.Windows.Forms.TextBox();
this.saveButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(174, 56);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(65, 12);
this.label1.TabIndex = 0;
this.label1.Text = "读写器IP";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(174, 135);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(65, 12);
this.label2.TabIndex = 1;
this.label2.Text = "RFID编号";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(174, 211);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(65, 12);
this.label3.TabIndex = 2;
this.label3.Text = "工位编号:";
//
// RfidIptextBox
//
this.RfidIptextBox.Location = new System.Drawing.Point(241, 53);
this.RfidIptextBox.Name = "RfidIptextBox";
this.RfidIptextBox.Size = new System.Drawing.Size(159, 21);
this.RfidIptextBox.TabIndex = 3;
//
// RfidEpctextBox
//
this.RfidEpctextBox.Location = new System.Drawing.Point(241, 135);
this.RfidEpctextBox.Name = "RfidEpctextBox";
this.RfidEpctextBox.Size = new System.Drawing.Size(159, 21);
this.RfidEpctextBox.TabIndex = 4;
//
// WorkstateNotextBox
//
this.WorkstateNotextBox.Location = new System.Drawing.Point(241, 211);
this.WorkstateNotextBox.Name = "WorkstateNotextBox";
this.WorkstateNotextBox.Size = new System.Drawing.Size(159, 21);
this.WorkstateNotextBox.TabIndex = 5;
//
// saveButton
//
this.saveButton.Location = new System.Drawing.Point(271, 315);
this.saveButton.Name = "saveButton";
this.saveButton.Size = new System.Drawing.Size(75, 23);
this.saveButton.TabIndex = 6;
this.saveButton.Text = "修改";
this.saveButton.UseVisualStyleBackColor = true;
this.saveButton.Click += new System.EventHandler(this.saveButton_Click);
//
// UpdateRfidWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(674, 450);
this.Controls.Add(this.saveButton);
this.Controls.Add(this.WorkstateNotextBox);
this.Controls.Add(this.RfidEpctextBox);
this.Controls.Add(this.RfidIptextBox);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "UpdateRfidWindow";
this.Text = "UpdateRfidWindow";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox RfidIptextBox;
private System.Windows.Forms.TextBox RfidEpctextBox;
private System.Windows.Forms.TextBox WorkstateNotextBox;
private System.Windows.Forms.Button saveButton;
}
}

@ -1,43 +0,0 @@
using HighWayIot.Repository.domain;
using HighWayIot.Repository.service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HighWayIot.Winform.UserControlPages.ParamConfigPages
{
public partial class UpdateRfidWindow : Form
{
private Zx_rfid_settingService zx_rfid_settingService = Zx_rfid_settingService.Instance;
private int _id;
public UpdateRfidWindow(int id,string ip,string epc,string no)
{
_id = id;
InitializeComponent();
RfidIptextBox.Text = ip;
RfidEpctextBox.Text = epc;
WorkstateNotextBox.Text = no;
}
private void saveButton_Click(object sender, EventArgs e)
{
if (!int.TryParse(WorkstateNotextBox.Text,out int result))
{
MessageBox.Show("工作状态编号必须是整数");
return;
}
Zx_rfid_setting zx_Rfid_Setting = zx_rfid_settingService.GetRfidInfoById(_id);
zx_Rfid_Setting.RfidIp = RfidIptextBox.Text;
zx_Rfid_Setting.RfidEpc = RfidEpctextBox.Text;
zx_Rfid_Setting.WorkstateNo = result;
zx_rfid_settingService.UpdateRfidInfo(zx_Rfid_Setting);
MessageBox.Show("修改成功");
}
}
}

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
Loading…
Cancel
Save