1
0
Fork 0

feat - 添加RFIDClientSocket 解析RFID数据

master
SoulStar 4 days ago
parent 1085112ebf
commit a55ed808bb

@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Common
{
/// <summary>
/// 通用工具类
/// </summary>
public class GeneralUtils
{
/// <summary>
/// 获取枚举类值的description元数据(没有Des返回名字)
/// </summary>
/// <returns></returns>
public static string GetEnumStringDescription(Enum enumValue)
{
string value = enumValue.ToString();
FieldInfo field = enumValue.GetType().GetField(value);
object[] objs = field.GetCustomAttributes(typeof(DescriptionAttribute), false); //获取描述属性
if (objs.Length == 0) //当描述属性没有时,直接返回名称
return value;
DescriptionAttribute descriptionAttribute = (DescriptionAttribute)objs[0];
return descriptionAttribute.Description;
}
/// <summary>
/// 获取枚举类的键值对
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static IEnumerable<KeyValuePair<string, int>> GetEnumKeyValuePairs<T>() where T : Enum
{
var enumType = typeof(T);
var fields = enumType.GetFields();
foreach (var fi in fields)
{
if (fi.FieldType != enumType || !fi.IsLiteral)
continue;
var name = fi.Name;
var value = (int)enumType.GetField(name).GetValue(null);
yield return new KeyValuePair<string, int>(name, value);
}
}
}
}

@ -47,6 +47,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="GeneralUtils.cs" />
<Compile Include="JsonChange.cs" />
<Compile Include="MsgUtil.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

@ -48,6 +48,10 @@
<ItemGroup>
<Compile Include="DataTypeEnum.cs" />
<Compile Include="PlcConnect.cs" />
<Compile Include="PlcEntity\RgvStationEnum.cs" />
<Compile Include="PlcHelper\BasePlcHelper.cs" />
<Compile Include="PlcHelper\RfidResult.cs" />
<Compile Include="PlcHelper\WorkStationWrite.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Plc.PlcEntity
{
public enum RgvStationEnum
{
RgvRingInstallStation = 1,
Rgv1Station,
Rgv2Station,
Rgv3Station,
Rgv4Station,
Rgv5Station,
RgvTireUnloadingStation,
RgvBendWaitStation,
Rgv3WeighCalibrationStation,
Rgv4WeighCalibrationStation,
Rgv5WeighCalibrationStation,
RgvMainLineEntranceStation,
RgvMainLineExitStation,
RgvAuxline1Station,
RgvAuxline2Station,
RgvAuxline3Station,
RgvAuxline4Station,
}
}

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Plc.PlcHelper
{
public class BasePlcHelper
{
}
}

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Plc.PlcHelper
{
public class RfidResult
{
}
}

@ -0,0 +1,22 @@
using HighWayIot.Plc.PlcEntity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Plc.PlcHelper
{
public class WorkStationWrite
{
/// <summary>
/// RFID工位识别
/// </summary>
/// <param name="rgvStation"></param>
/// <returns></returns>
public bool WriteStationSingal(RgvStationEnum rgvStation)
{
}
}
}

@ -0,0 +1,103 @@
using HighWayIot.Log4net;
using HighWayIot.Rfid.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Rfid
{
/// <summary>
/// RFID基础数据分析
/// </summary>
public class BaseRFIDDataAnalyse
{
private static LogHelper _logHelper = LogHelper.Instance;
/// <summary>
/// 基础接收数据解析
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public BaseReciveDataEntity BaseAnalyse(byte[] data)
{
BaseReciveDataEntity result = new BaseReciveDataEntity();
int index = 0;
index += 2;
//取Length
result.DataLength = data[index];
index++;
//取Code
result.Code = data[index];
index++;
//取Status
result.Status = data[index];
index++;
//取Data
Array.Copy(data, 5, result.Data, 0, result.DataLength);
index += result.DataLength;
//算Xor
result.Xor = data[index];
int xor = 0;
for (int i = 0; i < 3 + result.DataLength; i++)
{
xor ^= data[i];
}
if(xor != data[data.Length - 1])
{
_logHelper.Error("数据校验和未通过");
return new BaseReciveDataEntity();
}
return result;
}
/// <summary>
/// 发送数据封装
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public byte[] BaseSendDataAnalyse(BaseSendDataEntity entity)
{
byte[] result = new byte[entity.Data.Length + 6];
int index = 2;
//指令头
result[0] = 0xBB;
result[1] = 0xDD;
//数据长度
result[index] = (byte)entity.Data.Length;
index++;
//指令编号
result[index] = entity.Code;
//数据
Array.Copy(entity.Data, 0, result, 4, entity.Data.Length);
index += entity.Data.Length;
//校验和
int xor = 0;
for (int i = 2; i < 2 + entity.Data.Length; i++)
{
xor ^= result[i];
}
result[index] = (byte)xor;
index++;
//帧尾
result[index] = 0x0D;
return result;
}
}
}

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Rfid.Dto
{
public class MessagePack
{
//public byte m_beginChar1 = 0xBB; //开始包
public byte[] m_pData = null; //发送数据
//public byte m_EndChar1 = 0x0D; //结束包
}
}

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Rfid.Entity
{
/// <summary>
/// 接收数据基础类
/// </summary>
public class BaseReciveDataEntity
{
/// <summary>
/// 数据长度2
/// </summary>
public byte DataLength { get; set; }
/// <summary>
/// 指令编号
/// </summary>
public byte Code { get; set; }
/// <summary>
/// 状态码
/// </summary>
public byte Status { get; set; }
/// <summary>
/// 数据
/// </summary>
public byte[] Data { get; set; }
/// <summary>
/// 校验位
/// </summary>
public byte Xor { get; set; }
}
}

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Rfid.Entity
{
/// <summary>
/// 发送数据基础类
/// </summary>
public class BaseSendDataEntity
{
/// <summary>
/// 指令编号
/// </summary>
public byte Code { get; set; }
/// <summary>
/// 数据
/// </summary>
public byte[] Data { get; set; }
}
}

@ -1,22 +0,0 @@
using HighWayIot.Rfid.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Rfid
{
public interface ICommunicateService
{
void Init(string strIp, int iPort, object objetcter);
bool SendMessage(MessagePack pMessagePack);
bool Connect();
bool GetState();
bool DisConnect();
}
}

@ -1,216 +0,0 @@
using GRreader;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Rfid
{
public delegate void RecvIdentifyData(ushort iLen, byte[] pData, byte Antenna, UInt16 iDeviceId, string strId);
public enum G2MemBank
{
RESERVED = 0, //保留区
EPC = 1,
TID = 2,
USER = 3,
};
public enum CommType
{
RJ45 = 1, //网口
RS232 = 2, //com口
RS485 = 3, //485接口
};
public enum DeviceType
{
Mesnac_PKRK = 1, //软控物联网读写器一体机_GRUI160
Alien_9650 = 2, //Alien9650
ThingMagic_Vega = 3, //ThingMagic车载读写器
Mesnac_LD = 4, //软控磊德
Mesnac_GRUV100 = 5, //软控物联网车载读写器_GRUV100
Mesnac_GRUR445 = 6, //软控物联网四端口读写器
GzgDevice = 7, //干燥柜
ZlanIO_101 = 101, //卓岚IO
Moxa_E1212 = 102, //摩砂E1212
HwIo8 = 103, //海威
RFU620 = 620, //SICK 读写器
RFly_I160 = 160,//金瑞铭RFly-I160读写器
HWKC_81600 = 81600,//海威IO设备
Fuchs = 104
};
public enum WriteOrRead
{
Write = 1, //写
Read = 2, //读
};
/// <summary>
/// 设备适配层接口
/// </summary>
public interface IDeviceAdapter
{
event RecvIdentifyData RecvIdentifyDataEvent;
/// <summary>
/// 设备初始化
/// </summary>
/// <returns>true成功false失败</returns>
/// <param name="iCommType">通讯类型 1RJ45 2串口。</param>
/// <param name="pUrl">连接字符串 当iCommType为1时pUrl格式“192.168.1.100:23”为2时pUrl格式为“Com1:9600“</param>
/// <param name="iDeviceType">详见DeviceType</param>
bool Device_Init(CommType iCommType, string pUrl, DeviceType iDeviceType);
/// <summary>
/// 设备初始化
/// </summary>
/// <returns>true成功false失败</returns>
/// <param name="iCommType">通讯类型 1RJ45 2串口。</param>
/// <param name="pUrl">连接字符串 当iCommType为1时pUrl格式“192.168.1.100:23”为2时pUrl格式为“Com1:9600“</param>
/// <param name="iDeviceType">详见DeviceType</param>
bool Device_Init_Id(CommType iCommType, string pUrl, UInt16 iDeviceId);
/// <summary>
/// 连接设备
/// </summary>
/// <returns>true成功false失败</returns>
bool Device_Connect();
/// <summary>
/// 重新连接设备
/// </summary>
/// <returns>true成功false失败</returns>
bool Device_ReConnect();
/// <summary>
/// 设备销毁
/// </summary>
void Device_Destroy();
/// <summary>
/// 设备状态
/// </summary>
/// <returns>true正常false异常</returns>
bool Device_GetState();
/// <summary>
/// 根据天线号读取单个标签数据,只返回一条
/// //只有在天线号为0的时候可以读写其他区的数据
/// </summary>
/// <returns>实际读取到的长度0为读取失败</returns>
/// <param name="filterMembank">过滤数据区域 1保留区 2TID区 3EPC区 4USER区</param>
/// <param name="filterWordPtr">过滤写入起始偏移地址单位byte</param>
/// <param name="filterWordCnt">过滤长度单位byte</param>
/// <param name="filterData">过滤数据</param>
/// <param name="Membank">数据区哉 1保留区 2TID区 3EPC区 4USER区</param>
/// <param name="WordPtr">读取起始偏移地址单位byte必须为偶数。</param>
/// <param name="WordCnt">读取长度单位byte必须为偶数。</param>
/// <param name="pReadData">读取数据存放区。</param>
/// <param name="Antenna">天线号0为本机255为所有天线</param>
UInt16 Device_Read(G2MemBank filterMembank, UInt16 filterWordPtr, UInt16 filterWordCnt, Byte[] filterData, G2MemBank Membank, UInt16 WordPtr, UInt16 WordCnt, ref Byte[] pReadData, byte Antenna);
/// <summary>
/// 根据天线号写单个标签数据
/// //只有在天线号为0的时候可以写其他区的数据
/// </summary>
/// <returns>0写失败 1写入成功 2写入和读取的不一致</returns>
/// <param name="filterMembank">过滤数据区哉 1保留区 2TID区 3EPC区 4USER区</param>
/// <param name="filterWordPtr">过滤写入起始偏移地址单位byte</param>
/// <param name="filterWordCnt">过滤写入长度单位byte</param>
/// <param name="filterData">过滤数据</param>
/// <param name="Membank">数据区哉 1保留区 2TID区 3EPC区 4USER区</param>
/// <param name="WordPtr">写入起始偏移地址单位byte必须为偶数。</param>
/// <param name="WordCnt">写入长度单位byte必须为偶数。</param>
/// <param name="pWriteData">待写入的数据</param>
/// <param name="Antenna">天线号0为本机255为所有天线</param>
UInt16 Device_Write(G2MemBank filterMembank, UInt16 filterWordPtr, UInt16 filterWordCnt, Byte[] filterData,
G2MemBank Membank, UInt16 WordPtr, UInt16 WordCnt, Byte[] pWriteData, byte Antenna);
/// <summary>
/// 根据天线号识别单个标签EPC数据只返回一条
/// </summary>
/// <returns>识别的标签EPC长度0为识别失败</returns>
/// <param name="pReadData">识别到的数据缓存区</param>
/// <param name="Antenna">天线号0为本机255为所有天线</param>
/// <param name="Timedout">超时时间,单位毫秒,识别到立即返回,未识别到等待超时返回</param>
Byte Device_GetOneIdentifyData(ref Byte[] pReadData, Byte Antenna, UInt16 Timedout);
/// <summary>
/// 根据天线号识别单个标签EPC数据只返回一条
/// </summary>
/// <returns>识别的标签EPC长度0为识别失败</returns>
/// <param name="pReadData">识别到的数据缓存区</param>
/// <param name="Antenna">天线号0为本机255为所有天线</param>
/// <param name="Timedout">超时时间,单位毫秒,统计时间内读到的次数,返回次数最多的一条</param>
Byte Device_GetOneIdentifyData_Finish(ref Byte[] pReadData, Byte Antenna, UInt16 Timedout);
/// <summary>
/// 根据天线号识别单个标签EPC数据只返回一条
/// </summary>
/// <returns>EPC数据例"4A474730303130323332",为""时失败</returns>
/// <param name="Antenna">天线号0为本机255为所有天线</param>
/// <param name="Timedout">超时时间,单位毫秒,识别到立即返回,未识别到等待超时返回</param>
string Device_GetOneIdentifyData(Byte Antenna, UInt16 Timedout);
/// <summary>
/// 根据天线号识别单个标签EPC数据只返回一条
/// </summary>
/// <returns>EPC数据例"4A474730303130323332",为""时失败</returns>
/// <param name="Antenna">天线号0为本机255为所有天线</param>
/// <param name="Timedout">超时时间,单位毫秒,统计时间内读到的次数,返回次数最多的一条</param>
string Device_GetOneIdentifyData_Finish(Byte Antenna, UInt16 Timedout);
/// <summary>
/// 开始工作,读写器为开始识别,其他设备待定义
/// </summary>
/// <returns>true正常false异常</returns>
/// <param name="AutoReport">是否自动上报1自动0不自动默认0</param>
/// <param name="Filter">过滤规则默认为0无规则, 后续待定</param>
bool Device_BeginIdentify();
/// <summary>
/// 停止识别,读写器为停止识别,其他设备待定义
/// </summary>
/// <returns>true正常false异常</returns>
bool Device_StopIdentify();
/// <summary>
/// 获取工作期间的所有数据
/// </summary>
/// <returns>实际读取到数据的总长度包括每组数据所占的字节0为读取失败</returns>
/// <param name="pReadData">数据存放区,多组数据时格式为:1字节长度+天线号+每组数据...</param>
/// <param name="Antenna">天线号0为本机255为读取所有天线</param>
UInt16 Device_GetIdentifyData(ref Byte[] pReadData, Byte Antenna);
/// <summary>
/// 设置天线收发功率
/// </summary>
/// <returns>true为设置成功false为设置失败</returns>
/// <param name="iDbi">识别到的数据缓存区</param>
/// <param name="Antenna">天线号0为本机255为所有天线</param>
/// <param name="RorW">Write为写Read为读</param>
bool Device_SetRf(int iDbi, Byte Antenna, WriteOrRead RorW);
/// <summary>
/// 发送心跳报文
/// </summary>
/// <returns>1成功2为通讯成功设备未返回3为发送失败</returns>
byte Device_SendHeartPack();
/// <summary>
/// 获取自报数据
/// </summary>
/// <returns>总长度0为失败</returns>
/// <param name="pReadData">获得的自报数据,格式为长度,数据,。。。。。。长度,数据,其中长度占一个字节</param>
UInt16 Device_GetReportData(ref byte[] pReadData, Byte Antenna, UInt32 Timedout);
/// <summary>
/// 四通道读写器按时间段读取数据
/// </summary>
/// <param name="DeviceType"></param>
/// <returns></returns>
List<TagInfo> Device_GetTagInfoList(DeviceType DeviceType,int time);
}
}

@ -1,831 +0,0 @@
using HighWayIot.Common;
using HighWayIot.Log4net;
using HighWayIot.Rfid.Dto;
using HighWayIot.Rfid.Impl;
using MaterialTraceability.Rfid.Impl;
using System;
using System.Collections;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace HighWayIot.Rfid.Impl
{
public enum RecvState
{
//RFly-I160 返回数据 BB DD 00 01 40 41 0D
WaitingBeginChar1_State = 1, //等待接收帧同步字符1 0xBB
WaitingBeginChar2_State = 2, //等待接收帧同步字符2 0xDD
WaitingForBarcodeLength_State = 3, //等待条码长度不固定
WaitingForCode_State = 4, //等待指令编号Code 0x02
WaitingForStus_State = 5, //等待接受状态码 0x00
WaitingForTagCount_State = 6, //等待接受标签组数不固定
WaitingForCount_State = 7, //等待接收第一组标签读取次数 0x01
WaitingForRSSI_State = 8, //等待接收读取信号强度 0xCB
WaitingForAnt_State = 9, //等待接收天线端口 0x01
WaitingForPC1_State = 10, //等待接收EPC区域 0x00
WaitingForPC2_State = 11, //等待接收EPC区域 0x00
WaitingForData_State = 12, //等待接收数据字符
WaitingForXor_State = 13, //等待比对校验位
WaitingForEndChar_State = 14, //等待接收尾字符 0x0D
};
class BgTcpClient : ICommunicateService
{
private LogHelper log = LogHelper.Instance;
private StringChange stringChange = StringChange.Instance;
RecvState enumRecvState = RecvState.WaitingBeginChar1_State;
int m_iPosition = 0;
UInt16 m_iFullMessageLength = 0;
byte m_iVerify = 0;
byte[] m_szFullMessage = new byte[1024]; //此数组用于状态机
int iBarcodeGroupCount = 0; //读取的组数
int iBarcodeLength = 0;//条码长度
int iBarcodeGroupCountFlag = 0;//组数标记
RFly_I160Adapter m_RFly_I160Adapter = null;
private BackgroundWorker m_bgwReceive = new BackgroundWorker();
private BackgroundWorker m_bgwDeal = new BackgroundWorker();
private string m_FsIP = "";
private Int32 m_FnPort = 0;
private Socket m_ClientSock = null;
private ArrayList m_FrecvData = new ArrayList();
private Semaphore m_Fsem = new Semaphore(0, 100000);
private ManualResetEvent Exitevent = new ManualResetEvent(false);
/// <summary>
/// 接收线程
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void bgwReceive_DoWork(object sender, DoWorkEventArgs e)
{
//LogService.Instance.Debug("RFly-I160 进入 bgwReceive_DoWork 线程函数:");
int nPackLen = 1024;
byte[] buff = new byte[nPackLen];
while (true)
{
try
{
if (m_ClientSock != null && m_ClientSock.Connected)
{
int nCount = m_ClientSock.Receive(buff, nPackLen, 0);
if (nCount > 0)
{
log.RfidLog(m_FsIP + ":" + m_FnPort + " RFly-I160接收原始报文:" + bytesToHexStr(buff, nCount));
PareReceiveBufferData(buff, nCount); //调用状态机函数
continue;
}
else //接收错误
{
if (m_ClientSock != null)
{
m_ClientSock.Close();
m_ClientSock = null;
}
e.Cancel = true;
m_Fsem.Release();
}
}
else
{
e.Cancel = true;
if (m_ClientSock != null)
{
m_ClientSock.Close();
m_ClientSock = null;
}
m_Fsem.Release();
return;
}
}
catch (Exception ex)
{
e.Cancel = true;
if (m_ClientSock != null)
{
m_ClientSock.Close();
m_ClientSock = null;
}
log.Error("Socket接收数据线程退出",ex);
m_Fsem.Release();
return;
}
if (this.m_bgwReceive.CancellationPending)
{
e.Cancel = true;
if (m_ClientSock != null)
{
m_ClientSock.Close();
m_ClientSock = null;
}
m_Fsem.Release();
return;
}
}
}
/// <summary>
/// 发送线程(包括接收后的处理)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void bgwDeal_DoWork(object sender, DoWorkEventArgs e)
{
log.RfidLog("RFly-I160 进入 bgwDeal_DoWork 线程:");
while (true)
{
try
{
m_Fsem.WaitOne();
lock (m_FrecvData)
{
if (m_FrecvData.Count > 0)
{
byte[] buff = (byte[])m_FrecvData[0];
if (m_RFly_I160Adapter != null)
{
m_RFly_I160Adapter.Device_DealValidPack(buff); //处理函数
}
m_FrecvData.RemoveAt(0);
}
}
if (Exitevent.WaitOne(0, false))
{
e.Cancel = true;
log.RfidLog("Socket处理数据线程正常退出");
Exitevent.Reset();
return;
}
}
catch (Exception ex)
{
e.Cancel = true;
log.Error("Socket处理数据异常",ex);
return;
}
if (this.m_bgwDeal.CancellationPending)
{
log.RfidLog("Socket处理数据线程异常退出");
e.Cancel = true;
return;
}
}
}
/// <summary>
/// 发送函数
/// </summary>
/// <param name="pMessagePack"></param>
/// <returns></returns>
public bool SendMessage(MessagePack pMessagePack)
{
UInt16 iPos = 0;
byte[] u16byte = new byte[2];
try
{
byte[] SendBuffer = new byte[pMessagePack.m_pData.Length]; //起始字符1
Array.Copy(pMessagePack.m_pData, 0, SendBuffer, iPos, pMessagePack.m_pData.Length); //数据域
log.RfidLog(m_FsIP + ":" + m_FnPort + " RFly-I160发送原始报文:" + bytesToHexStr(SendBuffer, pMessagePack.m_pData.Length));
int nCount = m_ClientSock.Send(SendBuffer, pMessagePack.m_pData.Length, SocketFlags.None);
if (nCount > 0) //发送成功
{
//LogInfo.Fatal("m_ClientSock.Send函数发送成功");
return true;
}
else
{
log.RfidLog("连接已断开,数据发送失败");
return false;
}
}
catch (Exception ex)
{
log.Error("发送报文异常", ex);
return false;
}
}
#region 初始化一套函数
public bool Connect()
{
//连接
try
{
Exitevent.Reset();
if (m_FsIP == "" || m_FnPort == 0)
{
log.RfidLog("IP和端口号不能为空连接失败");
return false;
}
if (m_ClientSock != null && GetState())
{
log.RfidLog("已经连接了");
return true;
}
m_ClientSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint iep = new IPEndPoint(IPAddress.Parse(m_FsIP), m_FnPort);
m_ClientSock.Connect(iep);
if (m_ClientSock.Connected)
{
try
{
if (!m_bgwReceive.IsBusy)
{
//启动接收线程
m_bgwReceive.DoWork += new DoWorkEventHandler(bgwReceive_DoWork);
m_bgwReceive.RunWorkerAsync();
}
else
{
log.RfidLog("接收线程正在运行");
}
//启动处理线程
if (!m_bgwDeal.IsBusy)
{
m_bgwDeal.DoWork += new DoWorkEventHandler(bgwDeal_DoWork);
m_bgwDeal.RunWorkerAsync();
}
else
{
log.RfidLog("处理线程正在运行");
}
return true;
}
catch (Exception ex)
{
log.Error("创建后台线程异常 ",ex);
return true;
}
}
else
{
return false;
}
}
catch (Exception ex)
{
log.Error("Socket连接异常 ",ex);
return false;
}
}
public bool DisConnect()
{
try
{
Exitevent.Set();
Thread.Sleep(100);
m_Fsem.Release();
if (m_ClientSock != null)
{
log.Info("关闭Socket连接 ");
m_ClientSock.Disconnect(false);
m_ClientSock.Close();
m_ClientSock = null;
}
return true;
}
catch (Exception ex)
{
log.Error("Socket连接异常 ",ex);
return false;
}
}
public bool GetState()
{
bool bResult = false;
bool blockingState = false;
try
{
if (m_ClientSock != null)
{
blockingState = m_ClientSock.Blocking;
byte[] tmp = new byte[1];
m_ClientSock.Blocking = false;
m_ClientSock.Send(tmp, 0, 0);
bResult = true;
Console.WriteLine("Connected!");
}
else
{
bResult = false;
}
}
catch (SocketException e)
{
// 10035 == WSAEWOULDBLOCK
if (e.NativeErrorCode.Equals(10035))
{
bResult = true;
Console.WriteLine("Still Connected, but the Send would block");
}
else
{
bResult = false;
Console.WriteLine("Disconnected: error code {0}!", e.NativeErrorCode);
}
}
finally
{
if (m_ClientSock != null)
{
m_ClientSock.Blocking = blockingState;
}
}
return bResult;
}
public void Init(string strIp, int iPort, object objetcter)
{
Exitevent.Reset();
m_FsIP = strIp;
m_FnPort = iPort;
m_RFly_I160Adapter = objetcter as RFly_I160Adapter;
}
#endregion
/// <summary>
/// 状态机函数
/// </summary>
/// <param name="buffer"></param>
/// <param name="iLen"></param>
public void PareReceiveData(byte[] buffer, int iLen)
{
//LogService.Instance.Debug("RFly-I160进入状态机");
m_szFullMessage = new byte[iLen];
for (int i = 0; i < iLen; i++)
{
switch (enumRecvState)
{
case RecvState.WaitingBeginChar1_State: //开始接受数据帧1 0xBB
//LogService.Instance.Debug("RFly-I160等待接收帧同步字符WaitingBeginChar1_State:0XBB");
Array.Clear(m_szFullMessage, 0, iLen);//清空为0
if (buffer[i] == 0xBB)
{
//LogService.Instance.Debug("Buffer数据为: " + StringChange.bytesToHexStr(buffer, buffer.Length));
m_szFullMessage[m_iPosition] = buffer[i];
m_iPosition++;
enumRecvState = RecvState.WaitingBeginChar2_State;
}
else
{
m_iFullMessageLength = 0;
m_iPosition = 0;
enumRecvState = RecvState.WaitingBeginChar1_State;
}
break;
case RecvState.WaitingBeginChar2_State: //开始接受数据帧1 0xDD
if (buffer[i] == 0xDD)
{
m_szFullMessage[m_iPosition] = buffer[i];
m_iPosition++;
enumRecvState = RecvState.WaitingForBarcodeLength_State;
}
else
{
m_iFullMessageLength = 0;
m_iPosition = 0;
enumRecvState = RecvState.WaitingBeginChar1_State;
}
break;
case RecvState.WaitingForBarcodeLength_State: //开始接受数据长度(TagCount - EPC)
m_szFullMessage[m_iPosition] = buffer[i];
iBarcodeLength = buffer[i]; //单组标签18两组标签35
m_iPosition++;
enumRecvState = RecvState.WaitingForCode_State;
break;
case RecvState.WaitingForCode_State: //开始接受指令编号
if (buffer[i] == 0x02)
{
m_szFullMessage[m_iPosition] = buffer[i];
m_iPosition++;
enumRecvState = RecvState.WaitingForStus_State;
}
else if (buffer[i] == 0x90) // 如果是心跳BB DD 01 90 00 1F 8E 0D
{
//LogService.Instance.Debug("RFly-I160等待接受WaitingForEndChar_State:温度");
m_szFullMessage[m_iPosition] = buffer[i];
m_iPosition++;
enumRecvState = RecvState.WaitingForEndChar_State;
}
else if (buffer[i] == 0xBF) // 如果是心跳BB DD 04 BF 00 00 00 F9 0B 49 0D
{
//LogService.Instance.Debug("RFly-I160等待接受WaitingForEndChar_State:心跳");
m_szFullMessage[m_iPosition] = buffer[i];
m_iPosition++;
enumRecvState = RecvState.WaitingForEndChar_State;
}
else
{
m_iFullMessageLength = 0;
m_iPosition = 0;
enumRecvState = RecvState.WaitingBeginChar1_State;
}
break;
case RecvState.WaitingForStus_State: //开始接受状态码
if (buffer[i] == 0x00)
{
m_szFullMessage[m_iPosition] = buffer[i];
m_iPosition++;
enumRecvState = RecvState.WaitingForTagCount_State;
}
else if (buffer[i] == 0x40)
{
m_szFullMessage[m_iPosition] = buffer[i];
//LogService.Instance.Debug("RFU620等待接受WaitingForEndChar_State:Noread");
lock (m_FrecvData)
{
m_FrecvData.Add(m_szFullMessage);
}
m_Fsem.Release();
m_iPosition = 0;
i = iLen;
enumRecvState = RecvState.WaitingBeginChar1_State;
//LogService.Instance.Debug("RFly-I160状态机结束。");
}
break;
case RecvState.WaitingForTagCount_State: //开始接受标签组数
Array.Copy(buffer, i, m_szFullMessage, m_iPosition, iBarcodeLength);//m_iPosition = 5
byte[] tempData = new byte[iBarcodeLength];
Array.Clear(tempData, 0, iBarcodeLength);
Array.Copy(buffer, i, tempData, 0, iBarcodeLength);
//LogService.Instance.Debug("解析的数据为: " + StringChange.bytesToHexStr(tempData, iBarcodeLength));
//m_szFullMessage[m_iPosition] = buffer[i]; //单组标签01两组标签02
m_iPosition = m_iPosition + iBarcodeLength; //m_iPosition = 39
i = i + iBarcodeLength - 1; //i = 39
enumRecvState = RecvState.WaitingForXor_State;
break;
case RecvState.WaitingForXor_State: //开始比对校验位 Rfly160
byte[] m_CRCVerify = new byte[1024]; //此数组用于校验位计算
Array.Clear(m_CRCVerify, 0, m_CRCVerify.Length);
Array.Copy(m_szFullMessage, 2, m_CRCVerify, 0, iBarcodeLength + 3); //校验位计算是从Length - EPC 结束
m_szFullMessage[m_iPosition] = buffer[i];
m_iVerify = m_szFullMessage[m_iPosition];
if (m_iVerify == CalculateVerify(m_CRCVerify, m_CRCVerify.Length))
{
m_iPosition++;
enumRecvState = RecvState.WaitingForEndChar_State;
}
else //如果校验不成功
{
m_iFullMessageLength = 0;
m_iPosition = 0;
enumRecvState = RecvState.WaitingBeginChar1_State;
}
break;
case RecvState.WaitingForEndChar_State:
if (buffer[0] == 0xBB && buffer[1] == 0xDD && buffer[2] == 0x00 && buffer[3] != 0x90) //此处为Noread数据显示
{
//LogService.Instance.Debug("RFly-I160等待接受WaitingForEndChar_State:Noread");
m_szFullMessage[0] = 0xBB;
m_szFullMessage[1] = 0xDD;
m_szFullMessage[2] = 0x00;
lock (m_FrecvData)
{
m_FrecvData.Add(m_szFullMessage);
}
m_Fsem.Release();
m_iPosition = 0;
i = iLen;
enumRecvState = RecvState.WaitingBeginChar1_State;
}
//else if (buffer[i] == 0x00) //获取温度
//{
// m_szFullMessage[3] = 0x00;
// m_iPosition++;
// lock (m_FrecvData)
// {
// m_FrecvData.Add(m_szFullMessage);
// }
// m_Fsem.Release();
//}
else if (buffer[i] == 0x00) //获取温度
{
//m_szFullMessage[3] = 0x90;
//m_iPosition++;
Array.Copy(buffer, 0, m_szFullMessage, 0, 8);
i = 8;
lock (m_FrecvData)
{
m_FrecvData.Add(m_szFullMessage);
}
m_Fsem.Release();
//add by wenjy 2022-09-03
//m_iPosition = 0;
//i = iLen;
//enumRecvState = RecvState.WaitingBeginChar1_State;
}
else if (buffer[i] == 0x11)
{
//m_szFullMessage[3] = 0x00;
Array.Copy(buffer, 0, m_szFullMessage, 0, 7);
i = 7;
lock (m_FrecvData)
{
m_FrecvData.Add(m_szFullMessage);
}
m_Fsem.Release();
}
else if (buffer[i] == 0x01)
{
//m_szFullMessage[3] = 0x00;
Array.Copy(buffer, 0, m_szFullMessage, 0, 8);
i = 8;
lock (m_FrecvData)
{
m_FrecvData.Add(m_szFullMessage);
}
m_Fsem.Release();
}
else if (buffer[0] == 0xBB && buffer[1] == 0xDD && buffer[2] == 0x04 && buffer[3] == 0xBF)
{
m_szFullMessage[3] = 0xBF;
m_iPosition++;
lock (m_FrecvData)
{
m_FrecvData.Add(m_szFullMessage);
}
m_Fsem.Release();
}
else
{
m_szFullMessage[m_iPosition] = buffer[i];
m_iPosition++;
if (buffer[i] == 0x0D)
{
//LogService.Instance.Debug("RFly-I160准备发送");
lock (m_FrecvData)
{
m_FrecvData.Add(m_szFullMessage);
}
m_Fsem.Release();
}
}
m_iPosition = 0;
enumRecvState = RecvState.WaitingBeginChar1_State;
//LogService.Instance.Debug("RFly-I160状态机结束。");
break;
}
}
}
/// <summary>
/// 状态机函数 Add By WenJy 2022-09-26
/// </summary>
/// <param name="buffer"></param>
/// <param name="iLen"></param>
public void PareReceiveBufferData(byte[] buffer, int iLen)
{
var bufferStr = stringChange.bytesToHexStr(buffer, iLen);
log.RfidLog(String.Format("进入状态机函数:{0}", bufferStr));
m_szFullMessage = new byte[iLen];
for (int i = 0; i < iLen; i++)
{
switch (enumRecvState)
{
case RecvState.WaitingBeginChar1_State: //开始接受数据帧1 0xBB
Array.Clear(m_szFullMessage, 0, iLen);//清空为0
if (buffer[i] == 0xBB)
{
m_szFullMessage[m_iPosition] = buffer[i];
m_iPosition++;
enumRecvState = RecvState.WaitingBeginChar2_State;
}
else
{
m_iFullMessageLength = 0;
m_iPosition = 0;
enumRecvState = RecvState.WaitingBeginChar1_State;
}
break;
case RecvState.WaitingBeginChar2_State: //开始接受数据帧1 0xDD
if (buffer[i] == 0xDD)
{
m_szFullMessage[m_iPosition] = buffer[i];
m_iPosition++;
enumRecvState = RecvState.WaitingForBarcodeLength_State;
}
else
{
m_iFullMessageLength = 0;
m_iPosition = 0;
enumRecvState = RecvState.WaitingBeginChar1_State;
}
break;
case RecvState.WaitingForBarcodeLength_State: //开始接受数据长度(TagCount - EPC)
m_szFullMessage[m_iPosition] = buffer[i];
iBarcodeLength = buffer[i]; //单组标签18两组标签35
m_iPosition++;
enumRecvState = RecvState.WaitingForCode_State;
break;
case RecvState.WaitingForCode_State: //开始接受指令编号
if (buffer[i] == 0x02)
{
m_szFullMessage[m_iPosition] = buffer[i];
m_iPosition++;
enumRecvState = RecvState.WaitingForStus_State;
}
else if (buffer[i] == 0x90) // 如果是心跳BB DD 01 90 00 1F 8E 0D
{
//LogService.Instance.Debug("RFly-I160等待接受WaitingForEndChar_State:温度");
m_szFullMessage[m_iPosition] = buffer[i];
m_iPosition++;
enumRecvState = RecvState.WaitingForEndChar_State;
}
else if (buffer[i] == 0xBF) // 如果是心跳BB DD 04 BF 00 00 00 F9 0B 49 0D
{
//LogService.Instance.Debug("RFly-I160等待接受WaitingForEndChar_State:心跳");
m_szFullMessage[m_iPosition] = buffer[i];
m_iPosition++;
enumRecvState = RecvState.WaitingForEndChar_State;
}
else
{
m_iFullMessageLength = 0;
m_iPosition = 0;
enumRecvState = RecvState.WaitingBeginChar1_State;
}
break;
case RecvState.WaitingForStus_State: //开始接受状态码
if (buffer[i] == 0x00)
{
m_szFullMessage[m_iPosition] = buffer[i];
m_iPosition++;
enumRecvState = RecvState.WaitingForTagCount_State;
}
else if (buffer[i] == 0x40)
{
m_szFullMessage[m_iPosition] = buffer[i];
//LogService.Instance.Debug("RFU620等待接受WaitingForEndChar_State:Noread");
lock (m_FrecvData)
{
m_FrecvData.Add(m_szFullMessage);
}
m_Fsem.Release();
m_iPosition = 0;
i = iLen;
enumRecvState = RecvState.WaitingBeginChar1_State;
//LogService.Instance.Debug("RFly-I160状态机结束。");
}
break;
case RecvState.WaitingForTagCount_State: //开始接受标签组数
Array.Copy(buffer, i, m_szFullMessage, m_iPosition, iBarcodeLength);//m_iPosition = 5
byte[] tempData = new byte[iBarcodeLength];
Array.Clear(tempData, 0, iBarcodeLength);
Array.Copy(buffer, i, tempData, 0, iBarcodeLength);
m_iPosition = m_iPosition + iBarcodeLength; //m_iPosition = 39
i = i + iBarcodeLength - 1; //i = 39
enumRecvState = RecvState.WaitingForXor_State;
break;
case RecvState.WaitingForXor_State: //开始比对校验位 Rfly160
byte[] m_CRCVerify = new byte[1024]; //此数组用于校验位计算
Array.Clear(m_CRCVerify, 0, m_CRCVerify.Length);
Array.Copy(m_szFullMessage, 2, m_CRCVerify, 0, iBarcodeLength + 3); //校验位计算是从Length - EPC 结束
m_szFullMessage[m_iPosition] = buffer[i];
m_iVerify = m_szFullMessage[m_iPosition];
if (m_iVerify == CalculateVerify(m_CRCVerify, m_CRCVerify.Length))
{
m_iPosition++;
enumRecvState = RecvState.WaitingForEndChar_State;
}
else //如果校验不成功
{
m_iFullMessageLength = 0;
m_iPosition = 0;
enumRecvState = RecvState.WaitingBeginChar1_State;
}
break;
case RecvState.WaitingForEndChar_State:
if (buffer[0] == 0xBB && buffer[1] == 0xDD && buffer[2] == 0x00 && buffer[3] != 0x90) //此处为Noread数据显示
{
m_szFullMessage[0] = 0xBB;
m_szFullMessage[1] = 0xDD;
m_szFullMessage[2] = 0x00;
lock (m_FrecvData)
{
m_FrecvData.Add(m_szFullMessage);
}
m_Fsem.Release();
m_iPosition = 0;
i = iLen;
enumRecvState = RecvState.WaitingBeginChar1_State;
}
else if (buffer[0] == 0xBB && buffer[1] == 0xDD && buffer[2] == 0x04 && buffer[3] == 0xBF)
{
Array.Copy(buffer, 0, m_szFullMessage, 0, 11);
i = 11;
lock (m_FrecvData)
{
m_FrecvData.Add(m_szFullMessage);
}
m_Fsem.Release();
i = iLen;
}
else if (buffer[i] == 0x00) //获取温度
{
Array.Copy(buffer, 0, m_szFullMessage, 0, 8);
i = 8;
lock (m_FrecvData)
{
m_FrecvData.Add(m_szFullMessage);
}
m_Fsem.Release();
i = iLen;
}
else if (buffer[i] == 0x11)
{
Array.Copy(buffer, 0, m_szFullMessage, 0, 7);
i = 7;
lock (m_FrecvData)
{
m_FrecvData.Add(m_szFullMessage);
}
m_Fsem.Release();
}
else if (buffer[i] == 0x01)
{
Array.Copy(buffer, 0, m_szFullMessage, 0, 8);
i = 8;
lock (m_FrecvData)
{
m_FrecvData.Add(m_szFullMessage);
}
m_Fsem.Release();
}
else
{
m_szFullMessage[m_iPosition] = buffer[i];
m_iPosition++;
if (buffer[i] == 0x0D)
{
lock (m_FrecvData)
{
m_FrecvData.Add(m_szFullMessage);
}
m_Fsem.Release();
}
}
m_iPosition = 0;
enumRecvState = RecvState.WaitingBeginChar1_State;
break;
}
}
}
//CRC异或校验
public byte CalculateVerify(byte[] pMessage, int iLength)
{
UInt16 i;
byte iVerify = 0;
iVerify = pMessage[0];
for (i = 1; i < iLength; i++)
{
iVerify = (byte)(iVerify ^ pMessage[i]);
}
return iVerify;
}
private byte[] Swap16Bytes(byte[] OldU16)
{
byte[] ReturnBytes = new byte[2];
ReturnBytes[1] = OldU16[0];
ReturnBytes[0] = OldU16[1];
return ReturnBytes;
}
private string bytesToHexStr(byte[] bytes, int iLen)//e.g. { 0x01, 0x01} ---> " 01 01"
{
string returnStr = "";
if (bytes != null)
{
for (int i = 0; i < iLen; i++)
{
returnStr += bytes[i].ToString("X2");
}
}
return returnStr;
}
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,87 @@
using HighWayIot.Log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using TouchSocket.Core;
using TouchSocket.Sockets;
using TcpClient = TouchSocket.Sockets.TcpClient;
namespace HighWayIot.TouchSocket
{
public class TouchSocketTcpClient
{
private static LogHelper _logHelper = LogHelper.Instance;
private static readonly Lazy<TouchSocketTcpClient> lazy = new Lazy<TouchSocketTcpClient>(() => new TouchSocketTcpClient());
public static TouchSocketTcpClient Instance => lazy.Value;
TcpClient client = new TcpClient();
public async void TcpClient(string ip, string port)
{
client.Connecting = (client, e) =>
{
return EasyTask.CompletedTask;
};//有客户端正在连接
client.Connected = (client, e) =>
{
return EasyTask.CompletedTask;
};//有客户端成功连接
client.Closing = (client, e) =>
{
return EasyTask.CompletedTask;
};//有客户端正在断开连接,只有当主动断开时才有效。
client.Closed = (client, e) =>
{
return EasyTask.CompletedTask;
};//有客户端断开连接
client.Received = async (client, e) =>
{
//从客户端收到信息
var mes = e.ByteBlock.Span.ToString(Encoding.UTF8);
client.Logger.Info($"已从{client.IP}接收到信息:{mes}");
};
await client.SetupAsync(new TouchSocketConfig()
.SetRemoteIPHost($"{ip}:{port}")
.ConfigureContainer(a =>
{
a.AddConsoleLogger();//添加一个日志注入
}));
Result result = Result.Default; //不断尝试重连
do
{
result = await client.TryConnectAsync();
}
while (!result.IsSuccess);
return;
}
/// <summary>
/// 信息发送
/// </summary>
/// <param name="message">Bytes</param>
/// <returns></returns>
public async Task<bool> Send(byte[] message)
{
try
{
await client.SendAsync(message);
return true;
}
catch (Exception e)
{
_logHelper.Error("发送数据发生错误" + e);
return false;
}
}
}
}

@ -1,58 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TouchSocket.Core;
using TouchSocket.Sockets;
namespace HighWayIot.TouchSocket
{
public class TouchSocketTcpServer
{
private static readonly Lazy<TouchSocketTcpServer> lazy = new Lazy<TouchSocketTcpServer>(() => new TouchSocketTcpServer());
public static TouchSocketTcpServer Instance => lazy.Value;
TcpService service = new TcpService();
public async void TcpServer()
{
service.Connecting = (client, e) =>
{
return EasyTask.CompletedTask;
};//有客户端正在连接
service.Connected = (client, e) =>
{
return EasyTask.CompletedTask;
};//有客户端成功连接
service.Closing = (client, e) =>
{
return EasyTask.CompletedTask;
};//有客户端正在断开连接,只有当主动断开时才有效。
service.Closed = (client, e) =>
{
return EasyTask.CompletedTask;
};//有客户端断开连接
service.Received = async (client, e) =>
{
//从客户端收到信息
var mes = e.ByteBlock.Span.ToString(Encoding.UTF8);
client.Logger.Info($"已从{client.Id}接收到信息:{mes}");
};
await service.SetupAsync(new TouchSocketConfig()//载入配置
.SetListenIPHosts("tcp://127.0.0.1:7789", 7790)//可以同时监听两个地址
.ConfigureContainer(a =>//容器的配置顺序应该在最前面
{
a.AddConsoleLogger();//添加一个控制台日志注入注意在maui中控制台日志不可用
})
.ConfigurePlugins(a =>
{
//a.Add();//此处可以添加插件
}));
await service.StartAsync();//启动
}
}
}

@ -45,27 +45,6 @@ namespace HighWayIot.Winform.Business
}
}
/// <summary>
/// 获取枚举类的键值对
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static IEnumerable<KeyValuePair<string, int>> GetEnumKeyValuePairs<T>() where T : Enum
{
var enumType = typeof(T);
var fields = enumType.GetFields();
foreach (var fi in fields)
{
if (fi.FieldType != enumType || !fi.IsLiteral)
continue;
var name = fi.Name;
var value = (int)enumType.GetField(name).GetValue(null);
yield return new KeyValuePair<string, int>(name, value);
}
}
/// <summary>
/// 返回对应的枚举类Type类型
/// </summary>

@ -53,6 +53,7 @@ namespace HighWayIot.Winform.MainForm
this.RecipeConfigStripItem = new System.Windows.Forms.ToolStripMenuItem();
this.EquipMaterialBindingStripItem = new System.Windows.Forms.ToolStripMenuItem();
this.TestMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.DeviceDataManageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.UserControlTabs = new System.Windows.Forms.TabControl();
this.ClosePageButton = new System.Windows.Forms.Button();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
@ -64,7 +65,7 @@ namespace HighWayIot.Winform.MainForm
this.StripLabel2 = new System.Windows.Forms.ToolStripStatusLabel();
this.TimeStripLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.TimeDisplayTimer = new System.Windows.Forms.Timer(this.components);
this.DeviceDataManageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.DataRefreshTimer = new System.Windows.Forms.Timer(this.components);
this.MainMenu.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
@ -224,6 +225,13 @@ namespace HighWayIot.Winform.MainForm
this.TestMenuItem.Text = "PLC测试页面";
this.TestMenuItem.Click += new System.EventHandler(this.StripMenuItemClick);
//
// DeviceDataManageToolStripMenuItem
//
this.DeviceDataManageToolStripMenuItem.Name = "DeviceDataManageToolStripMenuItem";
this.DeviceDataManageToolStripMenuItem.Size = new System.Drawing.Size(92, 22);
this.DeviceDataManageToolStripMenuItem.Text = "设备数据管理";
this.DeviceDataManageToolStripMenuItem.Click += new System.EventHandler(this.StripMenuItemClick);
//
// UserControlTabs
//
this.UserControlTabs.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -316,12 +324,9 @@ namespace HighWayIot.Winform.MainForm
this.TimeDisplayTimer.Interval = 1000;
this.TimeDisplayTimer.Tick += new System.EventHandler(this.TimeDisplayTimer_Tick);
//
// DeviceDataManageToolStripMenuItem
// DataRefreshTimer
//
this.DeviceDataManageToolStripMenuItem.Name = "DeviceDataManageToolStripMenuItem";
this.DeviceDataManageToolStripMenuItem.Size = new System.Drawing.Size(92, 22);
this.DeviceDataManageToolStripMenuItem.Text = "设备数据管理";
this.DeviceDataManageToolStripMenuItem.Click += new System.EventHandler(this.StripMenuItemClick);
this.DataRefreshTimer.Tick += new System.EventHandler(this.DataRefreshTimer_Tick);
//
// BaseForm
//
@ -379,5 +384,6 @@ namespace HighWayIot.Winform.MainForm
private ToolStripMenuItem MaterialConfigStripItem;
private ToolStripMenuItem MaterialTypeConfigStripItem;
private ToolStripMenuItem DeviceDataManageToolStripMenuItem;
private Timer DataRefreshTimer;
}
}

@ -270,5 +270,15 @@ namespace HighWayIot.Winform.MainForm
{
}
private void DataRefreshTimer_Tick(object sender, EventArgs e)
{
//一读
//判断结果
//哪个工位读到了哪个工位写
}
}
}

@ -126,6 +126,9 @@
<metadata name="TimeDisplayTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>257, 17</value>
</metadata>
<metadata name="DataRefreshTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>415, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>

Loading…
Cancel
Save