fix - 优化RFID读写结构,添加心跳检测断线重连机制

master
SoulStar 2 months ago
parent e8e474719b
commit 36d608033f

@ -31,7 +31,7 @@
<logger name="rfidlog"> <logger name="rfidlog">
<level value="ALL" /> <level value="ALL" />
<appender-ref ref="RfidAppender" /> <appender-ref ref="RfidAppender" />
<!--<appender-ref ref="ColoredConsoleAppender" />--> <appender-ref ref="ColoredConsoleAppender" />
</logger> </logger>
<!--RFID日志类--> <!--RFID日志类-->

@ -32,10 +32,6 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="HslCommunication, Version=12.1.3.0, Culture=neutral, PublicKeyToken=3d72ad3b6b5ec0e3, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\HighWayIot.Library\HslCommunication.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />

@ -53,7 +53,7 @@ namespace HighWayIot.Plc
IsPersistentConnection = true, IsPersistentConnection = true,
}; };
var reslt = plc.ConnectServer(); var reslt = plc.ConnectServer();
logHelper.Info($"Plc连接 信息:[{reslt.Message}] 是否成功:[{(reslt.IsSuccess ? "" : "")}] 错误代码:[{reslt.ErrorCode}]"); logHelper.Info($"[{ip}] Plc连接 信息:[{reslt.Message}] 是否成功:[{(reslt.IsSuccess ? "" : "")}] 错误代码:[{reslt.ErrorCode}]");
if (!reslt.IsSuccess) if (!reslt.IsSuccess)
{ {
logHelper.Info("链接失败:"+reslt.Message); logHelper.Info("链接失败:"+reslt.Message);

@ -257,7 +257,7 @@ namespace HighWayIot.Plc.PlcHelper
for (int i = 1; i <= 10; i++) for (int i = 1; i <= 10; i++)
{ {
var prop = entity.GetType().GetProperty($"E{i}"); var prop = entity.GetType().GetProperty($"E{i}");
prop.SetValue(entity, (int)PlcConnect.MelsecInstance1.ByteTransform.TransInt16(data, add * 2)); prop.SetValue(entity, (int)PlcConnect.MelsecInstance2.ByteTransform.TransInt16(data, add * 2));
add++; add++;
} }

@ -86,7 +86,7 @@ namespace HighWayIot.Plc.PlcHelper
/// <returns>第一个Byte数组是第二个Byte数组是开始横裁信号第三个是结束横裁信号</returns> /// <returns>第一个Byte数组是第二个Byte数组是开始横裁信号第三个是结束横裁信号</returns>
public bool[][] ReadDrumReadyAndCountReadySignal() public bool[][] ReadDrumReadyAndCountReadySignal()
{ {
OperateResult<byte[]> operateResult = PlcConnect.MelsecInstance1.Read("B980", 3); OperateResult<byte[]> operateResult = PlcConnect.MelsecInstance2.Read("B980", 3);
if (!operateResult.IsSuccess) if (!operateResult.IsSuccess)
{ {
@ -123,7 +123,7 @@ namespace HighWayIot.Plc.PlcHelper
/// <returns></returns> /// <returns></returns>
public bool[][] ReadMonitorSingal() public bool[][] ReadMonitorSingal()
{ {
OperateResult<byte[]> operateResult = PlcConnect.MelsecInstance1.Read("B9B1", 5); OperateResult<byte[]> operateResult = PlcConnect.MelsecInstance2.Read("B9B1", 5);
if (!operateResult.IsSuccess) if (!operateResult.IsSuccess)
{ {
@ -150,7 +150,7 @@ namespace HighWayIot.Plc.PlcHelper
/// <returns></returns> /// <returns></returns>
public List<StationRecipeEntity> ReadStationRecipeInfo() public List<StationRecipeEntity> ReadStationRecipeInfo()
{ {
OperateResult<byte[]> operateResult = PlcConnect.MelsecInstance1.Read("W950", 80); OperateResult<byte[]> operateResult = PlcConnect.MelsecInstance2.Read("W950", 80);
if (!operateResult.IsSuccess) if (!operateResult.IsSuccess)
{ {

@ -54,10 +54,6 @@ namespace HighWayIot.Plc.PlcHelper
result[i] = data[dataCount].GetBoolByIndex(indexCount); result[i] = data[dataCount].GetBoolByIndex(indexCount);
} }
} }
else
{
return null;
}
return result; return result;
} }

@ -52,12 +52,14 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="domain\MonitorDataSource.cs" />
<Compile Include="domain\SysShiftTimeEntity.cs" /> <Compile Include="domain\SysShiftTimeEntity.cs" />
<Compile Include="domain\SysUserEntity.cs" /> <Compile Include="domain\SysUserEntity.cs" />
<Compile Include="domain\SysRoleEntity.cs" /> <Compile Include="domain\SysRoleEntity.cs" />
<Compile Include="domain\SysErrorLogEntity.cs" /> <Compile Include="domain\SysErrorLogEntity.cs" />
<Compile Include="domain\SysLogEntity.cs" /> <Compile Include="domain\SysLogEntity.cs" />
<Compile Include="domain\WeightDataSourceEntity.cs" /> <Compile Include="domain\WeightDataSourceEntity.cs" />
<Compile Include="domain\ZxDailyReportEntity.cs" />
<Compile Include="domain\ZxMaterialTypeEntity.cs" /> <Compile Include="domain\ZxMaterialTypeEntity.cs" />
<Compile Include="domain\ZxMaterialChildTypeEntity.cs" /> <Compile Include="domain\ZxMaterialChildTypeEntity.cs" />
<Compile Include="domain\ZxMaterialEntity.cs" /> <Compile Include="domain\ZxMaterialEntity.cs" />
@ -72,6 +74,7 @@
<Compile Include="domain\ZxReaderSettingEntity.cs" /> <Compile Include="domain\ZxReaderSettingEntity.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Repository.cs" /> <Compile Include="Repository.cs" />
<Compile Include="service\ZxDailyReportService.cs" />
<Compile Include="service\ZxMesPlanTransferService.cs" /> <Compile Include="service\ZxMesPlanTransferService.cs" />
<Compile Include="service\ZxOpenMixMaterialService.cs" /> <Compile Include="service\ZxOpenMixMaterialService.cs" />
<Compile Include="service\ZxRecipePositionParaService.cs" /> <Compile Include="service\ZxRecipePositionParaService.cs" />

@ -0,0 +1,75 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Repository.domain
{
public class MonitorDataSource
{
/// <summary>
/// 编号
/// </summary>
public int No { get; set; }
/// <summary>
/// 备 注:硫化机位
/// 默认值:
///</summary>
public string VulcanizationNo { get; set; } = string.Empty;
/// <summary>
/// 备 注:开始时间
/// 默认值:
///</summary>
public string StartTime { get; set; } = string.Empty;
/// <summary>
/// 备 注:成品代号
/// 默认值:
///</summary>
public string RecipeName { get; set; } = string.Empty;
/// <summary>
/// 备 注:标称尺度
/// 默认值:
///</summary>
public string SpecName { get; set; } = string.Empty;
/// <summary>
/// 备 注:SPEC编号
/// 默认值:
///</summary>
public string SpecCode { get; set; } = string.Empty;
/// <summary>
/// 备 注:小车编号
/// 默认值:
///</summary>
public int? DeviceNo { get; set; }
/// <summary>
/// 备 注:生胎重量
/// 默认值:
///</summary>
public int? RawTireWeight { get; set; }
/// <summary>
/// 基部胶耗时
/// </summary>
public string BaseRubTimeSpan { get; set; } = string.Empty;
/// <summary>
/// 中层胶耗时
/// </summary>
public string MidRubTimeSpan { get; set; } = string.Empty;
/// <summary>
/// 胎面胶耗时
/// </summary>
public string FaceRubTimeSpan { get; set; } = string.Empty;
}
}

@ -0,0 +1,123 @@
using System;
using System.Collections.Generic;
using System.Linq;
using SqlSugar;
namespace HighWayIot.Repository.domain
{
/// <summary>
///
///</summary>
[SugarTable("zx_daily_report")]
public class ZxDailyReportEntity
{
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "uuid", IsPrimaryKey = true)]
public string Uuid { get; set; }
/// <summary>
/// 备 注:硫化机位
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "vulcanization_no")]
public string VulcanizationNo { get; set; } = string.Empty;
/// <summary>
/// 备 注:开始时间
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "start_time")]
public DateTime? StartTime { get; set; }
/// <summary>
/// 备 注:成品代号
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "recipe_name")]
public string RecipeName { get; set; } = string.Empty;
/// <summary>
/// 备 注:标称尺度
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "spec_name")]
public string SpecName { get; set; } = string.Empty;
/// <summary>
/// 备 注:SPEC编号
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "spec_code")]
public string SpecCode { get; set; } = string.Empty;
/// <summary>
/// 备 注:小车编号
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "device_no")]
public int? DeviceNo { get; set; }
/// <summary>
/// 备 注:生胎重量
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "raw_tire_weight")]
public int? RawTireWeight { get; set; }
/// <summary>
/// 备 注:基部胶开始
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "base_start_time")]
public DateTime? BaseStartTime { get; set; }
/// <summary>
/// 备 注:基部胶结束
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "base_end_time")]
public DateTime? BaseEndTime { get; set; }
/// <summary>
/// 备 注:中层胶开始
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "mid_start_time")]
public DateTime? MidStartTime { get; set; }
/// <summary>
/// 备 注:中层胶结束
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "mid_end_time")]
public DateTime? MidEndTime { get; set; }
/// <summary>
/// 备 注:胎面胶开始
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "face_start_time")]
public DateTime? FaceStartTime { get; set; }
/// <summary>
/// 备 注:胎面胶结束(生胎完成)
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "face_end_time")]
public DateTime? FaceEndTime { get; set; }
/// <summary>
/// 备 注:是否已完成(0未完成 1完成 2中止)
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "is_done")]
public int? IsDone { get; set; }
}
}

@ -0,0 +1,104 @@
using HighWayIot.Log4net;
using HighWayIot.Repository.domain;
using Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Repository.service
{
/// <summary>
/// 报表服务类
/// </summary>
public class ZxDailyReportService
{
private static readonly Lazy<ZxDailyReportService> lazy = new Lazy<ZxDailyReportService>(() => new ZxDailyReportService());
public static ZxDailyReportService Instance
{
get
{
return lazy.Value;
}
}
private LogHelper log = LogHelper.Instance;
Repository<ZxDailyReportEntity> _repository => new Repository<ZxDailyReportEntity>("sqlserver");
/// <summary>
/// 查询报表信息
/// </summary>
/// <returns></returns>
public List<ZxDailyReportEntity> Get50DailyReportInfos()
{
try
{
List<ZxDailyReportEntity> entity = _repository.GetList().Take(50).ToList();
return entity;
}
catch (Exception ex)
{
log.Error("配方信息获取异常", ex);
return null;
}
}
/// <summary>
/// 根据条件查询报表信息
/// </summary>
/// <param name="whereExpression"></param>
/// <returns></returns>
public List<ZxDailyReportEntity> GetDailyReportInfos(Expression<Func<ZxDailyReportEntity, bool>> whereExpression)
{
try
{
List<ZxDailyReportEntity> entity = _repository.GetList(whereExpression);
return entity;
}
catch(Exception ex)
{
log.Error("配发信息获取异常", ex);
return null;
}
}
/// <summary>
/// 新增报表信息
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public bool InsertDailyReportInfo(ZxDailyReportEntity entity)
{
try
{
return _repository.Insert(entity);
}
catch (Exception ex)
{
log.Error("报表信息添加异常", ex);
return false;
}
}
/// <summary>
/// 删除报表信息
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public bool UpdateDailyReportInfo(ZxDailyReportEntity entity)
{
try
{
return _repository.Update(entity);
}
catch (Exception ex)
{
log.Error("报表信息修改异常", ex);
return false;
}
}
}
}

@ -84,6 +84,7 @@ namespace HighWayIot.Repository.service
} }
catch (Exception ex) catch (Exception ex)
{ {
log.Error("物料信息获取异常", ex);
return null; return null;
} }
} }

@ -95,6 +95,7 @@ namespace HighWayIot.Repository.service
} }
catch (Exception ex) catch (Exception ex)
{ {
log.Error("配方同步基准信息标识获取异常", ex);
return true; return true;
} }
} }

@ -54,7 +54,7 @@ namespace HighWayIot.Rfid
} }
if(xor != data[data.Length - 2]) if(xor != data[data.Length - 2])
{ {
_logHelper.Error("数据校验和未通过"); //_logHelper.Error("数据校验和未通过");
return null; return null;
} }

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Rfid.Entity
{
/// <summary>
/// 心跳设置包
/// </summary>
public class BFHSendEntity
{
/// <summary>
/// 返回模式00严格按时间 01空闲返回
/// </summary>
public byte Mode { get; set; }
/// <summary>
/// 返回时间(单位秒)
/// </summary>
public byte Time { get; set; }
/// <summary>
/// 保留一直等于01就行
/// </summary>
public byte Rev { get; set; }
}
}

@ -48,6 +48,7 @@
<Compile Include="BaseRFIDDataAnalyse.cs" /> <Compile Include="BaseRFIDDataAnalyse.cs" />
<Compile Include="Entity\BaseReciveDataEntity.cs" /> <Compile Include="Entity\BaseReciveDataEntity.cs" />
<Compile Include="Entity\BaseSendDataEntity.cs" /> <Compile Include="Entity\BaseSendDataEntity.cs" />
<Compile Include="Entity\BFHEntity.cs" />
<Compile Include="Entity\Receive02HEntity.cs" /> <Compile Include="Entity\Receive02HEntity.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RfidDataAnalyse.cs" /> <Compile Include="RfidDataAnalyse.cs" />

@ -32,24 +32,18 @@ namespace HighWayIot.Rfid
/// <summary> /// <summary>
/// 接受02H盘点数据 (默认EPC 4位) /// 接受02H盘点数据 (默认EPC 4位)
/// </summary> /// </summary>
/// <param name="bytes"></param> /// <param name="data">数据体</param>
/// <returns></returns> /// <returns></returns>
public Receive02HEntity Receive02H(byte[] bytes) public Receive02HEntity Receive02H(byte[] data)
{ {
BaseReciveDataEntity recive = BaseRFIDDataAnalyse.BaseReceiveAnalyse(bytes);
if (recive == null)
{
return null;
}
byte[] DataBytes = recive.Data;
Receive02HEntity entity = new Receive02HEntity(); Receive02HEntity entity = new Receive02HEntity();
int index = 0; int index = 0;
if (DataBytes.Length != 0)
if (data.Length != 0)
{ {
//取读到多少个标签 //取读到多少个标签
entity.TagCount = DataBytes[index]; entity.TagCount = data[index];
entity.Data = new List<Single02HReceive>(); entity.Data = new List<Single02HReceive>();
index++; index++;
} }
@ -64,27 +58,27 @@ namespace HighWayIot.Rfid
Single02HReceive EPCData = new Single02HReceive(); Single02HReceive EPCData = new Single02HReceive();
//取单个标签读取的次数 //取单个标签读取的次数
EPCData.Count = DataBytes[index]; EPCData.Count = data[index];
index++; index++;
//取信号强度 //取信号强度
EPCData.RSSI = DataBytes[index]; EPCData.RSSI = data[index];
index++; index++;
//取天线端口 //取天线端口
EPCData.Ant = DataBytes[index]; EPCData.Ant = data[index];
index++; index++;
//取EPC区域 //取EPC区域
EPCData.PC = new byte[2]; EPCData.PC = new byte[2];
Array.Copy(DataBytes, index, EPCData.PC, 0, 2); Array.Copy(data, index, EPCData.PC, 0, 2);
index += 2; index += 2;
//取读到标签的EPC //取读到标签的EPC
EPCData.EPC = new byte[12]; EPCData.EPC = new byte[12];
try try
{ {
Array.Copy(DataBytes, index, EPCData.EPC, 0, 12); Array.Copy(data, index, EPCData.EPC, 0, 12);
} }
catch catch
{ {
@ -97,5 +91,38 @@ namespace HighWayIot.Rfid
return entity; return entity;
} }
/// <summary>
/// 发送心跳配置包
/// </summary>
/// <returns></returns>
public byte[] SendBFH(ushort second)
{
byte[] data = new byte[3];
data[0] = 0x00;
data[1] = 0x05;
data[2] = 0x01;
BaseSendDataEntity entity = new BaseSendDataEntity()
{
Code = 0xBF,
Data = data
};
byte[] result = BaseRFIDDataAnalyse.BaseSendDataAnalyse(entity);
return result;
}
/// <summary>
/// 接收心跳包
/// </summary>
/// <returns></returns>
public uint ReceiveBFH(byte[] data)
{
uint result = BitConverter.ToUInt32(data, 0);
return result;
}
} }
} }

@ -33,7 +33,7 @@ namespace HighWayIot.TouchSocket
public Action<byte[], string> GetMessageAction; public Action<byte[], string> GetMessageAction;
public async Task<bool> CreateTcpClient(string ip, string port) public bool CreateTcpClient(string ip, string port)
{ {
TcpClient tcpClient = new TcpClient(); TcpClient tcpClient = new TcpClient();
@ -53,15 +53,13 @@ namespace HighWayIot.TouchSocket
{ {
return EasyTask.CompletedTask; return EasyTask.CompletedTask;
};//有客户端断开连接 };//有客户端断开连接
tcpClient.Received = async (client, e) => tcpClient.Received = (client, e) =>
{ {
await Task.Run(() => GetMessageAction.Invoke(e.ByteBlock.Span.ToArray(), client.IP);
{ return EasyTask.CompletedTask;
GetMessageAction.Invoke(e.ByteBlock.Span.ToArray(), client.IP);
});
}; //接收信号 }; //接收信号
await tcpClient.SetupAsync(new TouchSocketConfig() tcpClient.SetupAsync(new TouchSocketConfig()
.SetRemoteIPHost($"{ip}:{port}") .SetRemoteIPHost($"{ip}:{port}")
.ConfigureContainer(a => .ConfigureContainer(a =>
{ {
@ -74,20 +72,23 @@ namespace HighWayIot.TouchSocket
}) })
); );
Result result = Result.Default; //不断尝试重连 Result result = Result.Default; //不断尝试重连
do do
{ {
await Task.Run(async () => _logHelper.Info($"连接{ip}:{port}");
{ result = tcpClient.TryConnect();
_logHelper.Info($"连接{ip}:{port}");
result = await tcpClient.TryConnectAsync();
await Task.Delay(2000);
});
} }
while (!result.IsSuccess); while (!result.IsSuccess);
_logHelper.Info($"{ip}:{port}连接成功 {++ClientsCount}/17"); _logHelper.Info($"{ip}:{port}连接成功 {++ClientsCount}");
Clients.Add(ip, tcpClient); if (Clients.ContainsKey(ip))
{
Clients.Remove(ip);
Clients.Add(ip, tcpClient);
}
else
{
Clients.Add(ip, tcpClient);
}
return true; return true;
} }
@ -101,7 +102,14 @@ namespace HighWayIot.TouchSocket
{ {
try try
{ {
await Clients[ip].SendAsync(message); if (Clients.ContainsKey(ip))
{
await Clients[ip].SendAsync(message);
}
else
{
return false;
}
return true; return true;
} }
catch (Exception e) catch (Exception e)
@ -120,9 +128,16 @@ namespace HighWayIot.TouchSocket
{ {
try try
{ {
await Clients[ip].CloseAsync(); if (Clients.ContainsKey(ip))
Clients[ip].Dispose(); {
Clients.Remove(ip); await Clients[ip].CloseAsync();
Clients[ip].Dispose();
Clients.Remove(ip);
}
else
{
return false;
}
return true; return true;
} }
catch (Exception e) catch (Exception e)

@ -5,6 +5,7 @@ using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Reflection; using System.Reflection;
using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -117,6 +118,27 @@ namespace HighWayIot.Winform.Business
return descriptionAttribute.Description; return descriptionAttribute.Description;
} }
/// <summary>
/// 将DateTime间隔转换为字符串格式
/// </summary>
/// <param name="dateTime"></param>
/// <returns></returns>
public string DateTimeToString(DateTime dateTimeStart, DateTime dateTimeEnd)
{
TimeSpan span = dateTimeEnd - dateTimeStart;
string result;
if (span > TimeSpan.FromSeconds(60))
{
int spanMinutes = (int)span.TotalMinutes;
int spanSeconds = (int)span.TotalSeconds % 60;
result = $"{spanMinutes} 分 {spanSeconds} 秒";
}
else
{
result = span.ToString("ss 秒");
}
return result;
}
} }
} }

@ -54,12 +54,14 @@ namespace HighWayIot.Winform.Business
if (item.Value) if (item.Value)
{ {
var schedulingInfo = zxSchedulingService.GetSchedulingInfo(); var schedulingInfo = zxSchedulingService.GetSchedulingInfo();
string recipeNo;
ZxRecipeParaEntity recipeParaInfo;
List<ZxRecipePositionParaEntity> zxRecipePositionParaEntities;
if ((item.Key + 1) < 63) if ((item.Key + 1) < 63)
{ {
string recipeNo = schedulingInfo.Single(x => x.Id == item.Key + 1).RecipeNo1; recipeNo = schedulingInfo.Single(x => x.Id == item.Key + 1).RecipeNo1;
ZxRecipeParaEntity recipeParaInfo = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(recipeNo).FirstOrDefault(); recipeParaInfo = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(recipeNo).FirstOrDefault();
List<ZxRecipePositionParaEntity> zxRecipePositionParaEntities = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.RecipeCode == recipeNo); zxRecipePositionParaEntities = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.RecipeCode == recipeNo);
if (recipeParaInfo == null) if (recipeParaInfo == null)
{ {
LogHelper.Instance.Error("配方信息获取失败"); LogHelper.Instance.Error("配方信息获取失败");
@ -68,13 +70,14 @@ namespace HighWayIot.Winform.Business
if (recipeParaHelper.UploadToPLC(recipeParaInfo, zxRecipePositionParaEntities)) if (recipeParaHelper.UploadToPLC(recipeParaInfo, zxRecipePositionParaEntities))
{ {
PlcConnect.PlcWrite2($"B{(item.Key + 0x901).ToString("X")}", false, DataTypeEnum.Bool); PlcConnect.PlcWrite2($"B{(item.Key + 0x901).ToString("X")}", false, DataTypeEnum.Bool);
MonitorInsert(recipeNo);
} }
} }
else else
{ {
string recipeNo = schedulingInfo.Single(x => x.Id == item.Key + 1).RecipeNo2; recipeNo = schedulingInfo.Single(x => x.Id == item.Key + 1).RecipeNo2;
ZxRecipeParaEntity recipeParaInfo = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(recipeNo).FirstOrDefault(); recipeParaInfo = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(recipeNo).FirstOrDefault();
List<ZxRecipePositionParaEntity> zxRecipePositionParaEntities = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.RecipeCode == recipeNo); zxRecipePositionParaEntities = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.RecipeCode == recipeNo);
if (recipeParaInfo == null) if (recipeParaInfo == null)
{ {
LogHelper.Instance.Error("配方信息获取失败"); LogHelper.Instance.Error("配方信息获取失败");
@ -83,11 +86,20 @@ namespace HighWayIot.Winform.Business
if (recipeParaHelper.UploadToPLC(recipeParaInfo, zxRecipePositionParaEntities)) if (recipeParaHelper.UploadToPLC(recipeParaInfo, zxRecipePositionParaEntities))
{ {
PlcConnect.PlcWrite2($"B{(item.Key + 0x941).ToString("X")}", false, DataTypeEnum.Bool); PlcConnect.PlcWrite2($"B{(item.Key + 0x941).ToString("X")}", false, DataTypeEnum.Bool);
MonitorInsert(recipeNo);
} }
} }
return; return;
} }
} }
} }
/// <summary>
/// 监控画面信息插入
/// </summary>
public void MonitorInsert(string recipeCode)
{
}
} }
} }

@ -0,0 +1,189 @@
using HighWayIot.Log4net;
using HighWayIot.Plc.PlcHelper;
using HighWayIot.Repository.domain;
using HighWayIot.Repository.service;
using HighWayIot.Rfid;
using HighWayIot.Rfid.Entity;
using HighWayIot.TouchSocket;
using HighWayIot.Winform.Properties;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace HighWayIot.Winform.Business
{
/// <summary>
/// TCP数据工厂类
/// </summary>
public class TCPClientFactory
{
/// <summary>
/// 标签服务类
/// </summary>
private ZxTagSettingService _tagrService = ZxTagSettingService.Instance;
/// <summary>
/// 标签实体类
/// </summary>
private List<ZxTagSettingEntity> _tagSetting;
/// <summary>
/// 读写器服务类
/// </summary>
private ZxReaderSettingService _readerService = ZxReaderSettingService.Instance;
/// <summary>
/// 读写器实体类
/// </summary>
private List<ZxReaderSettingEntity> _readerSetting;
/// <summary>
/// RFID数据分析
/// </summary>
private RfidDataAnalyse _RfidDataAnalyse = new RfidDataAnalyse();
/// <summary>
/// PLC
/// </summary>
private WorkStationHelper _workStationHelper = new WorkStationHelper();
/// <summary>
/// TCP客户端
/// </summary>
private TouchSocketTcpClient _touchSocketTcpClient = TouchSocketTcpClient.Instance;
/// <summary>
/// 心跳检测
/// </summary>
private Dictionary<string, DateTime> _heartBeatRecord = new Dictionary<string, DateTime>();
/// <summary>
/// Timer
/// </summary>
private Timer _heartbeatTimer;
public TCPClientFactory()
{
_tagSetting = _tagrService.GetTagInfos();
_readerSetting = _readerService.GetReaderInfos();
_heartbeatTimer = new Timer(new TimerCallback(HeartbeatJudge), null, 0, 10000);
}
/// <summary>
/// 对接收到的数据进行初步解析分发到各个报文类型的解析类中
/// </summary>
public void ReciveDataRoute(byte[] bytes, string ip)
{
BaseReciveDataEntity reciveData = BaseRFIDDataAnalyse.BaseReceiveAnalyse(bytes);
if(reciveData == null)
{
return;
}
switch (reciveData.Code)
{
case 0x02: //盘点结果
Receive02HEntity data02Hentity = _RfidDataAnalyse.Receive02H(reciveData.Data);
if (data02Hentity == null || data02Hentity.Data == null)
{
return;
}
ReciveRFIDSingal(data02Hentity, ip);
ReciveHeartBeatSignal(ip);
break;
case 0xBF: //心跳信号
ReciveHeartBeatSignal(ip);
break;
default:
LogHelper.Instance.Error($"接收到未知报文,识别代码[{reciveData.Code.ToString("X2")}]");
return;
}
}
/// <summary>
/// 接收信息的信号
/// </summary>
/// <param name="bytes"></param>
public void ReciveRFIDSingal(Receive02HEntity entity, string ip)
{
//找到读取次数最大的标签EPC
byte[] epcData = entity.Data.Where(x => x.Count == entity.Data.Max(y => y.Count)).First().EPC;
//标签号byte数组转换成字符串
string epcResult = string.Join(" ", epcData.Select(x => x.ToString("X2")));
//根据IP和标签EPC获取工位和对应设备号
string deviceNo = _tagSetting.Where(x => x.RfidEpc == epcResult).FirstOrDefault().DeviceNo;
string workstationNo = _readerSetting.Where(x => x.RfidIp == ip).FirstOrDefault().WorkstationNo;
if (string.IsNullOrEmpty(deviceNo))
{
LogHelper.Instance.Error($"未查询到 [{epcResult}] 标签相关的信息!");
return;
}
if (string.IsNullOrEmpty(workstationNo))
{
LogHelper.Instance.Error($"未查询到 [{ip}] 读写器相关的信息!");
return;
}
try
{
///写入对应的PLC信号
_workStationHelper.WriteStationSingal(int.Parse(workstationNo), int.Parse(deviceNo));
LogHelper.Instance.RfidLog($"{workstationNo}工位, {deviceNo}号车");
}
catch (Exception ex)
{
LogHelper.Instance.Error("数值转换发生错误", ex);
}
}
/// <summary>
/// 心跳信号接收
/// </summary>
public void ReciveHeartBeatSignal(string ip)
{
//if(entity.Status != 0x00)
//{
// string workstationNo = _readerService.GetWorkstateNoByIp(ip);
// LogHelper.Instance.Error($"读写器编号[{workstationNo}]心跳返回异常,异常代码[{entity.Status.ToString("X2")}],系统时间[{entity.Systick}]");
//}
//初次心跳处理
if (!_heartBeatRecord.ContainsKey(ip))
{
LogHelper.Instance.RfidLog($"[{ip}] 初次心跳");
_heartBeatRecord.Add(ip, DateTime.Now);
return;
}
else //不是初次就更新
{
_heartBeatRecord[ip] = DateTime.Now;
}
//心跳异常处理
}
public void HeartbeatJudge(object o)
{
foreach (var kvp in _heartBeatRecord.ToArray())
{
DateTime lastTime = kvp.Value;
TimeSpan timeSpan = DateTime.Now - lastTime;
if (timeSpan > TimeSpan.FromSeconds(16))
{
LogHelper.Instance.RfidLog($"[{kvp.Key}] 可能掉线,准备重连");
_heartBeatRecord.Remove(kvp.Key);
_touchSocketTcpClient.DisposeClient(kvp.Key).GetAwaiter().GetResult();
_touchSocketTcpClient.CreateTcpClient(kvp.Key, "20108");
_touchSocketTcpClient.Send(kvp.Key, _RfidDataAnalyse.SendBFH(5)).GetAwaiter().GetResult();
}
}
}
}
}

@ -42,26 +42,21 @@ namespace HighWayIot.Winform.Business
/// </summary> /// </summary>
private List<ZxReaderSettingEntity> _readerSetting; private List<ZxReaderSettingEntity> _readerSetting;
/// <summary>
/// 标签服务类
/// </summary>
private ZxTagSettingService _tagrService = ZxTagSettingService.Instance;
/// <summary>
/// 标签实体类
/// </summary>
private List<ZxTagSettingEntity> _tagSetting;
/// <summary> /// <summary>
/// RFID数据分析 /// RFID数据分析
/// </summary> /// </summary>
private RfidDataAnalyse _rfidDataAnalyse = new RfidDataAnalyse(); private RfidDataAnalyse _RfidDataAnalyse = new RfidDataAnalyse();
/// <summary> /// <summary>
/// TCP客户端 /// TCP客户端
/// </summary> /// </summary>
private TouchSocketTcpClient _touchSocketTcpClient = TouchSocketTcpClient.Instance; private TouchSocketTcpClient _touchSocketTcpClient = TouchSocketTcpClient.Instance;
/// <summary>
/// TCP客户端工厂
/// </summary>
private TCPClientFactory tcpClientFactory = new TCPClientFactory();
/// <summary> /// <summary>
/// 刷新器 /// 刷新器
/// </summary> /// </summary>
@ -76,10 +71,27 @@ namespace HighWayIot.Winform.Business
{ {
_readerSetting = _readerService.GetReaderInfos(); _readerSetting = _readerService.GetReaderInfos();
this.CreateAllRFIDClient(); this.CreateAllRFIDClient();
_touchSocketTcpClient.GetMessageAction += ReciveRFIDSingal; _touchSocketTcpClient.GetMessageAction += tcpClientFactory.ReciveDataRoute;
timer = new Timer(new System.Threading.TimerCallback(SingalMonitor), null, 0, 1000); timer = new Timer(new System.Threading.TimerCallback(SingalMonitor), null, 0, 1000);
} }
/// <summary>
/// 创建所有RFID客户端
/// </summary>
public void CreateAllRFIDClient()
{
foreach (var setting in _readerSetting)
{
Task.Run(() =>
{
_touchSocketTcpClient.CreateTcpClient(setting.RfidIp, "20108");
_touchSocketTcpClient.Send(setting.RfidIp, _RfidDataAnalyse.SendBFH(5)).GetAwaiter().GetResult();
});
}
IsAllConnected = true;
}
/// <summary> /// <summary>
/// 自动监视 获取PLC信号 /// 自动监视 获取PLC信号
/// </summary> /// </summary>
@ -102,23 +114,7 @@ namespace HighWayIot.Winform.Business
} }
} }
} }
/// <summary>
/// 创建所有RFID客户端
/// </summary>
public async void CreateAllRFIDClient()
{
foreach (var setting in _readerSetting)
{
await Task.Run(() =>
{
_touchSocketTcpClient.CreateTcpClient(setting.RfidIp, "20108");
});
}
IsAllConnected = true;
}
/// <summary> /// <summary>
/// 向指定RFID读写器发送读信号 /// 向指定RFID读写器发送读信号
/// </summary> /// </summary>
@ -138,6 +134,7 @@ namespace HighWayIot.Winform.Business
if (setting == null) if (setting == null)
{ {
LogHelper.Instance.Error($"找不到第[{no}]个读写器");
return; return;
} }
@ -145,7 +142,7 @@ namespace HighWayIot.Winform.Business
bool result = false; bool result = false;
do do
{ {
result = await _touchSocketTcpClient.Send(setting.RfidIp, _rfidDataAnalyse.Send02H(1000)); result = await _touchSocketTcpClient.Send(setting.RfidIp, _RfidDataAnalyse.Send02H(1000));
i++; i++;
} }
while (i < 3 && result == false); while (i < 3 && result == false);
@ -156,57 +153,5 @@ namespace HighWayIot.Winform.Business
} }
} }
} }
/// <summary>
/// 接收信息的信号
/// </summary>
/// <param name="bytes"></param>
public void ReciveRFIDSingal(byte[] bytes, string ip)
{
Receive02HEntity entity = _rfidDataAnalyse.Receive02H(bytes);
if (entity == null || entity.Data == null)
{
return ;
}
//if(entity.TagCount != 1)
//{
// _logHelper.Error("返回多标签!");
// return;
//}
//找到读取次数最大的标签EPC
byte[] data = entity.Data.Where(x => x.Count == entity.Data.Max(y => y.Count)).First().EPC;
//标签号byte数组转换成字符串
string result = string.Join(" ", data.Select(x => x.ToString("X2")));
//根据IP和标签EPC获取工位和对应设备号
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
{
///写入对应的PLC信号
_workStationHelper.WriteStationSingal(int.Parse(workstationNo), int.Parse(deviceNo));
LogHelper.Instance.Info($"{workstationNo}工位, {deviceNo}号车");
}
catch (Exception ex)
{
_logHelper.Error("数值转换发生错误", ex);
}
}
} }
} }

@ -57,6 +57,7 @@
<Compile Include="Business\RecipeSendBusiness.cs" /> <Compile Include="Business\RecipeSendBusiness.cs" />
<Compile Include="Business\RoleBusiness.cs" /> <Compile Include="Business\RoleBusiness.cs" />
<Compile Include="Business\SqlLogHelper.cs" /> <Compile Include="Business\SqlLogHelper.cs" />
<Compile Include="Business\TCPClientFactory.cs" />
<Compile Include="Business\WorkStationBusiness.cs" /> <Compile Include="Business\WorkStationBusiness.cs" />
<Compile Include="Business\XmlUtil.cs" /> <Compile Include="Business\XmlUtil.cs" />
<Compile Include="MainForm\BaseForm.cs"> <Compile Include="MainForm\BaseForm.cs">

@ -166,7 +166,7 @@ namespace HighWayIot.Winform.MainForm
UserPanelSwitch(typeof(DailyReportPage), button.Text); UserPanelSwitch(typeof(DailyReportPage), button.Text);
break; break;
case "机台物料信息绑定": case "机台物料信息绑定":
UserPanelSwitch(typeof(EquipMaterialBindingPage), button.Text); UserPanelSwitch(typeof(EquipParamSettingPage), button.Text);
break; break;
case "硫化机配方参数配置": case "硫化机配方参数配置":
UserPanelSwitch(typeof(ProductionScheduling), button.Text); UserPanelSwitch(typeof(ProductionScheduling), button.Text);

@ -33,12 +33,6 @@ namespace HighWayIot.Winform.UserControlPages
{ {
this.SelectRole = new System.Windows.Forms.Button(); this.SelectRole = new System.Windows.Forms.Button();
this.ButtonPanel = new System.Windows.Forms.Panel(); this.ButtonPanel = new System.Windows.Forms.Panel();
this.P3TextBox = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.P2TextBox = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.P1TextBox = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label();
this.SelectLogEndTime = new System.Windows.Forms.DateTimePicker(); this.SelectLogEndTime = new System.Windows.Forms.DateTimePicker();
this.SelectLogBeginTime = new System.Windows.Forms.DateTimePicker(); this.SelectLogBeginTime = new System.Windows.Forms.DateTimePicker();
@ -53,9 +47,6 @@ namespace HighWayIot.Winform.UserControlPages
this.Text = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Text = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.LogTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.LogTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Operator = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Operator = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.P1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.P2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.P3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ButtonPanel.SuspendLayout(); this.ButtonPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.LogDataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.LogDataGridView)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
@ -75,12 +66,6 @@ namespace HighWayIot.Winform.UserControlPages
// //
this.ButtonPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.ButtonPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.ButtonPanel.Controls.Add(this.P3TextBox);
this.ButtonPanel.Controls.Add(this.label7);
this.ButtonPanel.Controls.Add(this.P2TextBox);
this.ButtonPanel.Controls.Add(this.label6);
this.ButtonPanel.Controls.Add(this.P1TextBox);
this.ButtonPanel.Controls.Add(this.label5);
this.ButtonPanel.Controls.Add(this.label4); this.ButtonPanel.Controls.Add(this.label4);
this.ButtonPanel.Controls.Add(this.SelectLogEndTime); this.ButtonPanel.Controls.Add(this.SelectLogEndTime);
this.ButtonPanel.Controls.Add(this.SelectLogBeginTime); this.ButtonPanel.Controls.Add(this.SelectLogBeginTime);
@ -97,54 +82,6 @@ namespace HighWayIot.Winform.UserControlPages
this.ButtonPanel.Size = new System.Drawing.Size(1162, 61); this.ButtonPanel.Size = new System.Drawing.Size(1162, 61);
this.ButtonPanel.TabIndex = 4; this.ButtonPanel.TabIndex = 4;
// //
// P3TextBox
//
this.P3TextBox.Location = new System.Drawing.Point(943, 32);
this.P3TextBox.Name = "P3TextBox";
this.P3TextBox.Size = new System.Drawing.Size(53, 21);
this.P3TextBox.TabIndex = 26;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(902, 36);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(35, 12);
this.label7.TabIndex = 25;
this.label7.Text = "字段3";
//
// P2TextBox
//
this.P2TextBox.Location = new System.Drawing.Point(843, 32);
this.P2TextBox.Name = "P2TextBox";
this.P2TextBox.Size = new System.Drawing.Size(53, 21);
this.P2TextBox.TabIndex = 24;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(802, 36);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(35, 12);
this.label6.TabIndex = 23;
this.label6.Text = "字段2";
//
// P1TextBox
//
this.P1TextBox.Location = new System.Drawing.Point(743, 32);
this.P1TextBox.Name = "P1TextBox";
this.P1TextBox.Size = new System.Drawing.Size(53, 21);
this.P1TextBox.TabIndex = 22;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(702, 36);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(35, 12);
this.label5.TabIndex = 21;
this.label5.Text = "字段1";
//
// label4 // label4
// //
this.label4.AutoSize = true; this.label4.AutoSize = true;
@ -236,10 +173,7 @@ namespace HighWayIot.Winform.UserControlPages
this.Id, this.Id,
this.Text, this.Text,
this.LogTime, this.LogTime,
this.Operator, this.Operator});
this.P1,
this.P2,
this.P3});
this.LogDataGridView.Location = new System.Drawing.Point(0, 65); this.LogDataGridView.Location = new System.Drawing.Point(0, 65);
this.LogDataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.LogDataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.LogDataGridView.Name = "LogDataGridView"; this.LogDataGridView.Name = "LogDataGridView";
@ -280,27 +214,6 @@ namespace HighWayIot.Winform.UserControlPages
this.Operator.Name = "Operator"; this.Operator.Name = "Operator";
this.Operator.ReadOnly = true; this.Operator.ReadOnly = true;
// //
// P1
//
this.P1.DataPropertyName = "P1";
this.P1.HeaderText = "字段1";
this.P1.Name = "P1";
this.P1.ReadOnly = true;
//
// P2
//
this.P2.DataPropertyName = "P2";
this.P2.HeaderText = "字段2";
this.P2.Name = "P2";
this.P2.ReadOnly = true;
//
// P3
//
this.P3.DataPropertyName = "P3";
this.P3.HeaderText = "字段3";
this.P3.Name = "P3";
this.P3.ReadOnly = true;
//
// OperateConfigPage // OperateConfigPage
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@ -330,19 +243,10 @@ namespace HighWayIot.Winform.UserControlPages
private DateTimePicker SelectLogBeginTime; private DateTimePicker SelectLogBeginTime;
private CheckBox IsCheckByLogTime; private CheckBox IsCheckByLogTime;
private Label label3; private Label label3;
private TextBox P3TextBox;
private Label label7;
private TextBox P2TextBox;
private Label label6;
private TextBox P1TextBox;
private Label label5;
private DataGridView LogDataGridView; private DataGridView LogDataGridView;
private DataGridViewTextBoxColumn Id; private DataGridViewTextBoxColumn Id;
private DataGridViewTextBoxColumn Text; private DataGridViewTextBoxColumn Text;
private DataGridViewTextBoxColumn LogTime; private DataGridViewTextBoxColumn LogTime;
private DataGridViewTextBoxColumn Operator; private DataGridViewTextBoxColumn Operator;
private DataGridViewTextBoxColumn P1;
private DataGridViewTextBoxColumn P2;
private DataGridViewTextBoxColumn P3;
} }
} }

@ -37,11 +37,7 @@ namespace HighWayIot.Winform.UserControlPages
private void SelectRole_Click(object sender, EventArgs e) private void SelectRole_Click(object sender, EventArgs e)
{ {
List<SysLogEntity> list = sysLogService.GetLogInfos(); List<SysLogEntity> list = sysLogService.GetLogInfos();
int? p1 = GeneralUtils.StringNullOrToInt(P1TextBox.Text);
int? p2 = GeneralUtils.StringNullOrToInt(P2TextBox.Text);
int? p3 = GeneralUtils.StringNullOrToInt(P3TextBox.Text);
string logText = LogTextTextBox.Text.Trim(); string logText = LogTextTextBox.Text.Trim();
string operatorName = OperatorNameTextBox.Text.Trim(); string operatorName = OperatorNameTextBox.Text.Trim();
bool logTimeChecked = IsCheckByLogTime.Checked; bool logTimeChecked = IsCheckByLogTime.Checked;
@ -51,9 +47,6 @@ namespace HighWayIot.Winform.UserControlPages
Lists = list.Where(x => Lists = list.Where(x =>
(string.IsNullOrEmpty(logText) || x.Text.Contains(logText)) && (string.IsNullOrEmpty(logText) || x.Text.Contains(logText)) &&
(string.IsNullOrEmpty(operatorName) || x.Operator == operatorName) && (string.IsNullOrEmpty(operatorName) || x.Operator == operatorName) &&
(!p1.HasValue || x.P1 == p1.Value) &&
(!p2.HasValue || x.P2 == p2.Value) &&
(!p3.HasValue || x.P3 == p3.Value) &&
(!logTimeChecked || (x.LogTime >= logBeginTime && x.LogTime <= logEndTime)) (!logTimeChecked || (x.LogTime >= logBeginTime && x.LogTime <= logEndTime))
).ToList(); ).ToList();

@ -129,13 +129,4 @@
<metadata name="Operator.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="Operator.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="P1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="P2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="P3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root> </root>

@ -101,7 +101,7 @@ namespace HighWayIot.Winform.UserControlPages
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show("物料更新ID转换发生错误"); MessageBox.Show("物料更新ID转换发生错误" + ex.Message);
} }
entity.MaterialCode = MaterialDataGridView.Rows[a].Cells["MaterialCode"].Value.ToString(); entity.MaterialCode = MaterialDataGridView.Rows[a].Cells["MaterialCode"].Value.ToString();
entity.MaterialName = MaterialDataGridView.Rows[a].Cells["MaterialName"].Value.ToString(); entity.MaterialName = MaterialDataGridView.Rows[a].Cells["MaterialName"].Value.ToString();

@ -60,5 +60,10 @@ namespace HighWayIot.Winform.UserControlPages
NowDateProductNumLabel.Text = DateTime.Now.ToString("MM 月 dd 日 产量"); NowDateProductNumLabel.Text = DateTime.Now.ToString("MM 月 dd 日 产量");
} }
private void BindData()
{
}
} }
} }

@ -153,4 +153,7 @@
<metadata name="DataRefresh.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="DataRefresh.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>44</value>
</metadata>
</root> </root>

@ -233,7 +233,7 @@ namespace HighWayIot.Winform.UserControlPages
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show("ID转换发生错误"); MessageBox.Show("ID转换发生错误" + ex.Message);
return; return;
} }
@ -303,7 +303,7 @@ namespace HighWayIot.Winform.UserControlPages
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show("数据格式错误!"); MessageBox.Show("数据格式错误!" + ex.Message);
return; return;
} }
@ -377,7 +377,7 @@ namespace HighWayIot.Winform.UserControlPages
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show("ID转换发生错误"); MessageBox.Show("ID转换发生错误" + ex.Message);
return; return;
} }
@ -439,7 +439,7 @@ namespace HighWayIot.Winform.UserControlPages
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show("数据格式错误!"); MessageBox.Show("数据格式错误!" + ex.Message);
return; return;
} }

@ -32,7 +32,7 @@ namespace HighWayIot.Winform.UserControlPages
/// <summary> /// <summary>
/// RFID数据分析 /// RFID数据分析
/// </summary> /// </summary>
private RfidDataAnalyse _rfidDataAnalyse = new RfidDataAnalyse(); private RfidDataAnalyse _RfidDataAnalyse = new RfidDataAnalyse();
XmlUtil xmlUtil = new XmlUtil(); XmlUtil xmlUtil = new XmlUtil();
@ -63,7 +63,7 @@ namespace HighWayIot.Winform.UserControlPages
/// <param name="e"></param> /// <param name="e"></param>
private void button1_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)
{ {
OperateResult<byte[]> PlcResult = PlcConnect.MelsecInstance1.Read("B230", 2); OperateResult<byte[]> PlcResult = PlcConnect.MelsecInstance2.Read("B230", 2);
if (PlcResult.IsSuccess) if (PlcResult.IsSuccess)
{ {
@ -96,7 +96,7 @@ namespace HighWayIot.Winform.UserControlPages
/// <param name="e"></param> /// <param name="e"></param>
private async void button2_Click(object sender, EventArgs e) private async void button2_Click(object sender, EventArgs e)
{ {
var a = await _touchSocketTcpClient.Send($"10.20.48.{RFIDtext.Text}", _rfidDataAnalyse.Send02H(1000)); var a = await _touchSocketTcpClient.Send($"10.20.48.{RFIDtext.Text}", _RfidDataAnalyse.Send02H(1000));
LogHelper.Instance.Info($"10.20.48.{RFIDtext.Text} 发送" + (a ? "成功" : "失败")); LogHelper.Instance.Info($"10.20.48.{RFIDtext.Text} 发送" + (a ? "成功" : "失败"));
} }

Loading…
Cancel
Save