1
0
Fork 0

feat - 重写plc读取类 - 引入touchsocket - 新建设备参数实体和服务类

master
SoulStar 3 weeks ago
parent f30e997935
commit 1085112ebf

@ -336,7 +336,5 @@ namespace HighWayIot.Plc
}
return result.Content;
}
}
}

@ -58,6 +58,7 @@
<Compile Include="domain\SysErrorLogEntity.cs" />
<Compile Include="domain\SysLogEntity.cs" />
<Compile Include="domain\WeightDataSourceEntity.cs" />
<Compile Include="domain\ZxCarParaEntity.cs" />
<Compile Include="domain\ZxMaterialTypeEntity.cs" />
<Compile Include="domain\ZxMaterialChildTypeEntity.cs" />
<Compile Include="domain\ZxMaterialEntity.cs" />
@ -68,6 +69,7 @@
<Compile Include="Repository.cs" />
<Compile Include="service\SysLogService.cs" />
<Compile Include="service\SysErrorLogService.cs" />
<Compile Include="service\ZxCarParaService.cs" />
<Compile Include="service\ZxMaterialChildTypeService.cs" />
<Compile Include="service\ZxMaterialTypeService.cs" />
<Compile Include="service\ZxRecipeParaService.cs" />

@ -0,0 +1,256 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Repository.domain
{
/// <summary>
/// 小车参数
///</summary>
[SugarTable("zx_car_para")]
internal class ZxCarParaEntity
{
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
/// <summary>
/// 备 注:
/// 默认值: 设备编号
///</summary>
[SugarColumn(ColumnName = "device_no")]
public int Device_no { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p01")]
public bool? P01 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p02")]
public bool? P02 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p03")]
public bool? P03 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p04")]
public bool? P04 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p05")]
public bool? P05 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p06")]
public bool? P06 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p07")]
public bool? P07 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p08")]
public bool? P08 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p09")]
public bool? P09 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p10")]
public bool? P10 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p11")]
public bool? P11 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p12")]
public bool? P12 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p13")]
public bool? P13 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p14")]
public bool? P14 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p15")]
public bool? P15 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p16")]
public bool? P16 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p17")]
public bool? P17 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p18")]
public bool? P18 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p19")]
public bool? P19 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p20")]
public bool? P20 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p21")]
public bool? P21 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p22")]
public bool? P22 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p23")]
public bool? P23 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p24")]
public bool? P24 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p25")]
public bool? P25 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p26")]
public bool? P26 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p27")]
public bool? P27 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p28")]
public bool? P28 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p29")]
public bool? P29 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p30")]
public bool? P30 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p31")]
public bool? P31 { get; set; }
/// <summary>
/// 备 注:
/// 默认值:
///</summary>
[SugarColumn(ColumnName = "p32")]
public bool? P32 { get; set; }
}
}

@ -0,0 +1,63 @@
using HighWayIot.Log4net;
using HighWayIot.Repository.domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Repository.service
{
internal class ZxCarParaService
{
private static readonly Lazy<ZxCarParaService> lazy = new Lazy<ZxCarParaService>(() => new ZxCarParaService());
public static ZxCarParaService Instance
{
get
{
return lazy.Value;
}
}
private LogHelper log = LogHelper.Instance;
Repository<ZxCarParaEntity> _repository => new Repository<ZxCarParaEntity>("sqlserver");
/// <summary>
/// 查询所有小车参数信息
/// </summary>
/// <returns></returns>
public List<ZxCarParaEntity> GetCarParaInfos()
{
try
{
List<ZxCarParaEntity> entity = _repository.GetList();
return entity;
}
catch (Exception ex)
{
log.Error("用户信息获取异常", ex);
return null;
}
}
/// <summary>
/// 更新小车参数信息
/// </summary>
/// <returns></returns>
public bool UpDateCarParaInfos(ZxCarParaEntity entity)
{
try
{
return _repository.Update(entity);
}
catch (Exception ex)
{
log.Error("用户信息获取异常", ex);
return false;
}
}
}
}

@ -46,11 +46,11 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Dto\MessagePack.cs" />
<Compile Include="ICommunicateService.cs" />
<Compile Include="IDeviceAdapter.cs" />
<Compile Include="Impl\BgTcpClient.cs" />
<Compile Include="Impl\RFLY_I160ADAPTER.CS" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RecvState.cs" />
<Compile Include="RfidAbsractFactory.cs" />
<Compile Include="RflyFactory.cs" />
<Compile Include="TagInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HighWayIot.Common\HighWayIot.Common.csproj">
@ -62,13 +62,5 @@
<Name>HighWayIot.Log4net</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="TouchSocket">
<Version>3.0.6</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Impl\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -10,9 +10,13 @@ namespace HighWayIot.Rfid
public interface ICommunicateService
{
void Init(string strIp, int iPort, object objetcter);
bool SendMessage(MessagePack pMessagePack);
bool Connect();
bool GetState();
bool DisConnect();
}
}

@ -60,7 +60,11 @@ namespace HighWayIot.Rfid.Impl
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 线程函数:");
@ -129,7 +133,11 @@ namespace HighWayIot.Rfid.Impl
}
}
//发送线程(包括接收后的处理)
/// <summary>
/// 发送线程(包括接收后的处理)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void bgwDeal_DoWork(object sender, DoWorkEventArgs e)
{
log.RfidLog("RFly-I160 进入 bgwDeal_DoWork 线程:");
@ -174,7 +182,11 @@ namespace HighWayIot.Rfid.Impl
}
}
//发送函数
/// <summary>
/// 发送函数
/// </summary>
/// <param name="pMessagePack"></param>
/// <returns></returns>
public bool SendMessage(MessagePack pMessagePack)
{
UInt16 iPos = 0;
@ -780,6 +792,7 @@ namespace HighWayIot.Rfid.Impl
}
}
//CRC异或校验
public byte CalculateVerify(byte[] pMessage, int iLength)
{
UInt16 i;
@ -792,6 +805,7 @@ namespace HighWayIot.Rfid.Impl
}
return iVerify;
}
private byte[] Swap16Bytes(byte[] OldU16)
{
byte[] ReturnBytes = new byte[2];

@ -9,7 +9,6 @@ using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using TagInfo = HighWayIot.Rfid.TagInfo;
namespace MaterialTraceability.Rfid.Impl
{
@ -343,6 +342,7 @@ namespace MaterialTraceability.Rfid.Impl
}
return iResult;
}
public ushort Device_GetReportData(ref byte[] pReadData, Byte Antenna, UInt32 Timedout)
{
byte[] pTemp = null;
@ -639,6 +639,7 @@ namespace MaterialTraceability.Rfid.Impl
}
return iResult;
}
/// <summary>
/// 返回读写器获取的条码中最好的一条 1:按照读取次数最多返回条码2按照功率最大返回条码
/// </summary>
@ -851,7 +852,6 @@ namespace MaterialTraceability.Rfid.Impl
}
#region 处理自动上传的函数
private Mutex mutauto = new Mutex();
@ -1158,7 +1158,6 @@ namespace MaterialTraceability.Rfid.Impl
}
#endregion
#region 该函数不实现了
public bool Device_SetRf(int iDbi, byte Antenna, WriteOrRead RorW)
{

@ -1,21 +0,0 @@
namespace HighWayIot.Rfid
{
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
}
}

@ -1,28 +0,0 @@
using System.Collections.Generic;
namespace HighWayIot.Rfid
{
/// <summary>
/// RFID抽象工厂
/// </summary>
public abstract class RfidAbsractFactory
{
public string ConfigKey { get; set; }
/// <summary>
/// 建立连接
/// </summary>
/// <param name="ip"></param>
/// <param name="port"></param>
/// <returns></returns>
public abstract bool Connect(string ip, int port);
/// <summary>
/// 按时间段盘点
/// </summary>
/// <param name="timeout"></param>
/// <returns></returns>
public abstract List<TagInfo> TimePeriodRead(int timeout = 5000);
}
}

@ -1,459 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using HighWayIot.Common;
using HighWayIot.Log4net;
using HighWayIot.Rfid.Dto;
using TouchSocket.Core;
using TouchSocket.Sockets;
namespace HighWayIot.Rfid
{
public class RflyFactory:RfidAbsractFactory
{
private LogHelper log = LogHelper.Instance;
private readonly TcpClient _tcpClient = new TcpClient();
private readonly StringChange _stringChange;
public RflyFactory(StringChange stringChange)
{
_stringChange = stringChange;
}
/// <summary>
/// 建立连接
/// </summary>
/// <param name="ip"></param>
/// <param name="port"></param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
public override bool Connect(string ip, int port)
{
try
{
_tcpClient.Connect(ip,port);
return true;
}
catch (Exception e)
{
throw new InvalidOperationException($"设备连接异常:{e.Message}");
}
}
/// <summary>
/// 按时间段盘点
/// </summary>
/// <param name="timeout"></param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
public override List<TagInfo> TimePeriodRead(int timeout = 5000)
{
byte[] u16byte = new byte[2];
byte[] bCRC = new byte[4];
try
{
#region 指令封装
MessagePack pMessagePack = new MessagePack();
pMessagePack.m_pData = new byte[8];
pMessagePack.m_pData[0] = 0xAA;
pMessagePack.m_pData[1] = 0x55;
pMessagePack.m_pData[2] = 0x02;
pMessagePack.m_pData[3] = 0x02;
u16byte = BitConverter.GetBytes(timeout); //超时时间
u16byte = _stringChange.Swap16Bytes(u16byte); //协议里为大端在前
Array.Copy(u16byte, 0, pMessagePack.m_pData, 4, 2);
Array.Copy(pMessagePack.m_pData, 2, bCRC, 0, 4);
pMessagePack.m_pData[6] = _stringChange.CalculateVerify(bCRC, bCRC.Length);
pMessagePack.m_pData[7] = 0x0D;
#endregion
var waitClient = _tcpClient.CreateWaitingClient(new WaitingOptions()
{
FilterFunc = response =>
{
return true;
}
});
byte[] reciveBuffer = waitClient.SendThenReturn(pMessagePack.m_pData, timeout);
log.Info($"接收原始报文:{_stringChange.bytesToHexStr(reciveBuffer,reciveBuffer.Length)}");
byte[] resultBuffer = PareReceiveBufferData(reciveBuffer,reciveBuffer.Length);
List<TagInfo> tagInfoList = Device_DealTagInfoList(resultBuffer);
return tagInfoList;
}
catch (Exception e)
{
throw new InvalidOperationException($"按时间段盘点异常:{e.Message}");
}
}
#region 标签解析
/// <summary>
/// 状态机函数
/// </summary>
/// <param name="buffer"></param>
/// <param name="iLen"></param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
private byte[] PareReceiveBufferData(byte[] buffer, int iLen)
{
RecvState enumRecvState = RecvState.WaitingBeginChar1_State;
int m_iPosition = 0;
UInt16 m_iFullMessageLength = 0;
int iBarcodeLength = 0;//条码长度
ArrayList m_FrecvData = new ArrayList();
byte m_iVerify = 0;
try
{
var bufferStr = _stringChange.bytesToHexStr(buffer, iLen);
byte[] 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
{
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
{
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_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 == _stringChange.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_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);
}
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);
}
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);
}
}
else if (buffer[i] == 0x01)
{
Array.Copy(buffer, 0, m_szFullMessage, 0, 8);
i = 8;
lock (m_FrecvData)
{
m_FrecvData.Add(m_szFullMessage);
}
}
else
{
m_szFullMessage[m_iPosition] = buffer[i];
m_iPosition++;
if (buffer[i] == 0x0D)
{
lock (m_FrecvData)
{
m_FrecvData.Add(m_szFullMessage);
}
}
}
m_iPosition = 0;
enumRecvState = RecvState.WaitingBeginChar1_State;
break;
}
}
return m_szFullMessage;
}
catch (Exception e)
{
throw new InvalidOperationException($"状态机逻辑处理异常:{e.Message}");
}
}
private Mutex mutauto = new Mutex();
/// <summary>
/// 解析函数
/// </summary>
/// <param name="AutoDealReportData"></param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
public List<TagInfo> Device_DealTagInfoList(byte[] AutoDealReportData)
{
List<TagInfo> tagInfoList = new List<TagInfo>();
byte[] bResultEPC_Data = new byte[14];
byte[] m_AutoReadEPC = null;
int m_readEPCDataLen = 0;
try
{
mutauto.WaitOne();
int iFirstCountPos = 6; //第一次读取标签次数位置
int iFirstRSSIPos = 7; //第一次读取标签强度位置
int iFirstAnt = 8;
int iFirstPC = 9; //第一次读取标签天线位置
int iFirstLeftBarcketPos = 11;//EPC数据起始位置
UInt16 tempDataCount = 0;
int tempDataRSSI = 0;
UInt16 tempDataANT = 0;
int iBarcodeGroupCount = Convert.ToInt32(AutoDealReportData[5].ToString()); //标签组数
int iBarcodeLength = 16; //标签长度
int iCommonSecondFlag = 0;
for (int j = 0; j < iBarcodeGroupCount; j++)
{
TagInfo tag = new TagInfo();
byte[] tempPCByte = new byte[2]; //取出PC
Array.Clear(tempPCByte, 0, 2);
Array.Copy(AutoDealReportData, iFirstPC, tempPCByte, 0, 2);
int pc = Convert.ToInt32(tempPCByte[0].ToString("X"));
int epcLength = EPCLengthByPC(pc);
iBarcodeLength = epcLength;
byte[] tempDataByte = new byte[epcLength];
Array.Clear(tempDataByte, 0, iBarcodeLength);
Array.Copy(AutoDealReportData, iFirstLeftBarcketPos, tempDataByte, 0, iBarcodeLength);
byte[] tempCountByte = new byte[1]; //取出标签次数
Array.Clear(tempCountByte, 0, 1);
Array.Copy(AutoDealReportData, iFirstCountPos, tempCountByte, 0, 1);
tempDataCount = tempCountByte[0];
byte[] tempRSSIByte = new byte[1]; //取出标签强度
Array.Clear(tempRSSIByte, 0, 1);
Array.Copy(AutoDealReportData, iFirstRSSIPos, tempRSSIByte, 0, 1);
tempDataRSSI = _stringChange.HexStringToNegative(_stringChange.bytesToHexStr(tempRSSIByte, 1));
#region add by wenjy 20220829 取出天线号
byte[] tempAntByte = new byte[1]; //取出天线号
Array.Clear(tempAntByte, 0, 1);
Array.Copy(AutoDealReportData, iFirstAnt, tempAntByte, 0, 1);
tempDataANT = tempAntByte[0];
#endregion
tag.Count = tempDataCount;
tag.RSSI = tempDataRSSI;
tag.EPC = tempDataByte;
if (pc == 24)
{
tag.EPCstring = _stringChange.bytesToHexStr(tempDataByte, tempDataByte.Length).Substring(0, 7);
}
else
{
tag.EPCstring = Encoding.ASCII.GetString(tempDataByte);
}
tag.PC = tempPCByte;
tag.Antana = tempDataANT;
tagInfoList.Add(tag);
int iBarcodeListLen = tagInfoList.Count; //特别注意,必须这样,要不然会多一条数据
iFirstCountPos = iFirstCountPos + iBarcodeLength + 5; //次数
iFirstRSSIPos = iFirstCountPos + 1; //强度
iFirstAnt = iFirstRSSIPos + 1; //天线
iFirstPC = iFirstAnt + 1;
iFirstLeftBarcketPos = iFirstLeftBarcketPos + iBarcodeLength + 5;
log.Info("----函数调用:Device_DealTagInfoList 第[" + (iCommonSecondFlag + 1) + "]次数据解析为:" + tag.EPCstring + ",读取标签次数:[" + tempDataCount + "],标签信号强度:[" + tempDataRSSI + "],天线号:[" + tempDataANT + "]");
iCommonSecondFlag++;
if (iCommonSecondFlag == iBarcodeGroupCount)
{
mutauto.ReleaseMutex();
log.Info("《《《返回标签数据!");
return tagInfoList;
}
}
return tagInfoList;
}
catch (Exception ex)
{
mutauto.ReleaseMutex();
throw new InvalidOperationException($"Device_AutoDealContent 自动处理函数异常:{ex.Message}");
}
}
/// <summary>
/// 根据PC获取EPC长度
/// </summary>
/// <param name="pcValue"></param>
/// <returns></returns>
private int EPCLengthByPC(int pcValue)
{
int epcLength = 0;
if (pcValue >= 10 && pcValue < 20)
{
epcLength = 4;
}
else if (pcValue >= 20 && pcValue < 30)
{
epcLength = 8;
}
else if (pcValue >= 30 && pcValue < 40)
{
epcLength = 12;
}
else if (pcValue >= 40 && pcValue < 50)
{
epcLength = 16;
}
else if (pcValue >= 50 && pcValue < 60)
{
epcLength = 20;
}
else if (pcValue >= 60 && pcValue < 70)
{
epcLength = 24;
}
else if (pcValue >= 70 && pcValue < 80)
{
epcLength = 28;
}
else if (pcValue >= 80 && pcValue < 90)
{
epcLength = 30;
}
return epcLength;
}
#endregion
}
}

@ -1,17 +0,0 @@
using System;
namespace HighWayIot.Rfid
{
public class TagInfo
{
public byte[] PC = new byte[2];
public int Count { get; set; }
public int RSSI{ get; set; }
public int Antana{ get; set; }
public byte[] EPC{ get; set; }
public byte[] Data{ get; set; }
public string PCstring = (string) null;
public string EPCstring = (string) null;
public DateTime Time{ get; set; }
}
}

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DD18A634-1F9C-409A-8C32-C3C81B1B55B5}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>HighWayIot.TouchSocket</RootNamespace>
<AssemblyName>HighWayIot.TouchSocket</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<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>
<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>
<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>
<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>
<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>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<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>
<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>
</ItemGroup>
<ItemGroup>
<Compile Include="TouchSocketTcpServer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\TouchSocket.Core.3.0.9\analyzers\dotnet\cs\TouchSocket.Core.SourceGenerator.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("HighWayIot.TouchSocket")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HighWayIot.TouchSocket")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("dd18a634-1f9c-409a-8c32-c3c81b1b55b5")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -0,0 +1,58 @@
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();//启动
}
}
}

@ -0,0 +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" />
</packages>

@ -70,6 +70,12 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UserControlPages\DeviceDataManage.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UserControlPages\DeviceDataManage.Designer.cs">
<DependentUpon>DeviceDataManage.cs</DependentUpon>
</Compile>
<Compile Include="UserControlPages\LogPages\AlarmLogPage.cs">
<SubType>UserControl</SubType>
</Compile>
@ -212,6 +218,9 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="UserControlPages\DeviceDataManage.resx">
<DependentUpon>DeviceDataManage.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UserControlPages\LogPages\AlarmLogPage.resx">
<DependentUpon>AlarmLogPage.cs</DependentUpon>
</EmbeddedResource>
@ -304,10 +313,6 @@
<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>
</ItemGroup>
<ItemGroup>
<Content Include="Static\海威.ico" />

@ -64,6 +64,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.MainMenu.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
@ -78,7 +79,8 @@ namespace HighWayIot.Winform.MainForm
this.MaterialMenuStripItem,
this.RecipeConfigStripItem,
this.EquipMaterialBindingStripItem,
this.TestMenuItem});
this.TestMenuItem,
this.DeviceDataManageToolStripMenuItem});
this.MainMenu.Location = new System.Drawing.Point(0, 0);
this.MainMenu.Name = "MainMenu";
this.MainMenu.Padding = new System.Windows.Forms.Padding(5, 1, 0, 1);
@ -101,35 +103,35 @@ namespace HighWayIot.Winform.MainForm
// UserStripMenuItem
//
this.UserStripMenuItem.Name = "UserStripMenuItem";
this.UserStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.UserStripMenuItem.Size = new System.Drawing.Size(136, 22);
this.UserStripMenuItem.Text = "用户管理";
this.UserStripMenuItem.Click += new System.EventHandler(this.StripMenuItemClick);
//
// RoleStripMenuItem
//
this.RoleStripMenuItem.Name = "RoleStripMenuItem";
this.RoleStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.RoleStripMenuItem.Size = new System.Drawing.Size(136, 22);
this.RoleStripMenuItem.Text = "角色管理";
this.RoleStripMenuItem.Click += new System.EventHandler(this.StripMenuItemClick);
//
// ShiftTimeConfigStripItem
//
this.ShiftTimeConfigStripItem.Name = "ShiftTimeConfigStripItem";
this.ShiftTimeConfigStripItem.Size = new System.Drawing.Size(180, 22);
this.ShiftTimeConfigStripItem.Size = new System.Drawing.Size(136, 22);
this.ShiftTimeConfigStripItem.Text = "班时间维护";
this.ShiftTimeConfigStripItem.Click += new System.EventHandler(this.StripMenuItemClick);
//
// LogoutStripMenuItem
//
this.LogoutStripMenuItem.Name = "LogoutStripMenuItem";
this.LogoutStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.LogoutStripMenuItem.Size = new System.Drawing.Size(136, 22);
this.LogoutStripMenuItem.Text = "注销";
this.LogoutStripMenuItem.Click += new System.EventHandler(this.LogoutStripMenuItem_Click);
//
// SysQuitStripMenuItem
//
this.SysQuitStripMenuItem.Name = "SysQuitStripMenuItem";
this.SysQuitStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.SysQuitStripMenuItem.Size = new System.Drawing.Size(136, 22);
this.SysQuitStripMenuItem.Text = "退出系统";
this.SysQuitStripMenuItem.Click += new System.EventHandler(this.SysQuitStripMenuItem_Click);
//
@ -146,21 +148,21 @@ namespace HighWayIot.Winform.MainForm
// DaliyReportStripItem
//
this.DaliyReportStripItem.Name = "DaliyReportStripItem";
this.DaliyReportStripItem.Size = new System.Drawing.Size(180, 22);
this.DaliyReportStripItem.Size = new System.Drawing.Size(124, 22);
this.DaliyReportStripItem.Text = "日报表";
this.DaliyReportStripItem.Click += new System.EventHandler(this.StripMenuItemClick);
//
// OperateLogStripMenuItem
//
this.OperateLogStripMenuItem.Name = "OperateLogStripMenuItem";
this.OperateLogStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.OperateLogStripMenuItem.Size = new System.Drawing.Size(124, 22);
this.OperateLogStripMenuItem.Text = "操作日志";
this.OperateLogStripMenuItem.Click += new System.EventHandler(this.StripMenuItemClick);
//
// AlarmLogStripMenuItem
//
this.AlarmLogStripMenuItem.Name = "AlarmLogStripMenuItem";
this.AlarmLogStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.AlarmLogStripMenuItem.Size = new System.Drawing.Size(124, 22);
this.AlarmLogStripMenuItem.Text = "报警日志";
this.AlarmLogStripMenuItem.Click += new System.EventHandler(this.StripMenuItemClick);
//
@ -190,14 +192,14 @@ namespace HighWayIot.Winform.MainForm
// MaterialConfigStripItem
//
this.MaterialConfigStripItem.Name = "MaterialConfigStripItem";
this.MaterialConfigStripItem.Size = new System.Drawing.Size(180, 22);
this.MaterialConfigStripItem.Size = new System.Drawing.Size(148, 22);
this.MaterialConfigStripItem.Text = "物料管理";
this.MaterialConfigStripItem.Click += new System.EventHandler(this.StripMenuItemClick);
//
// MaterialTypeConfigStripItem
//
this.MaterialTypeConfigStripItem.Name = "MaterialTypeConfigStripItem";
this.MaterialTypeConfigStripItem.Size = new System.Drawing.Size(180, 22);
this.MaterialTypeConfigStripItem.Size = new System.Drawing.Size(148, 22);
this.MaterialTypeConfigStripItem.Text = "物料类型管理";
this.MaterialTypeConfigStripItem.Click += new System.EventHandler(this.StripMenuItemClick);
//
@ -218,8 +220,8 @@ namespace HighWayIot.Winform.MainForm
// TestMenuItem
//
this.TestMenuItem.Name = "TestMenuItem";
this.TestMenuItem.Size = new System.Drawing.Size(68, 22);
this.TestMenuItem.Text = "测试页面";
this.TestMenuItem.Size = new System.Drawing.Size(89, 22);
this.TestMenuItem.Text = "PLC测试页面";
this.TestMenuItem.Click += new System.EventHandler(this.StripMenuItemClick);
//
// UserControlTabs
@ -269,8 +271,8 @@ namespace HighWayIot.Winform.MainForm
// HighWayLogo
//
this.HighWayLogo.Name = "HighWayLogo";
this.HighWayLogo.Size = new System.Drawing.Size(214, 17);
this.HighWayLogo.Text = "Design by 青岛海威物联科技有限公司";
this.HighWayLogo.Size = new System.Drawing.Size(143, 17);
this.HighWayLogo.Text = "Design by HighWayIOT";
//
// SplitLabel1
//
@ -294,7 +296,7 @@ namespace HighWayIot.Winform.MainForm
//
this.toolStripStatusLabel1.BorderSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Right)));
this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
this.toolStripStatusLabel1.Size = new System.Drawing.Size(1461, 17);
this.toolStripStatusLabel1.Size = new System.Drawing.Size(1532, 17);
this.toolStripStatusLabel1.Spring = true;
//
// StripLabel2
@ -314,6 +316,13 @@ namespace HighWayIot.Winform.MainForm
this.TimeDisplayTimer.Interval = 1000;
this.TimeDisplayTimer.Tick += new System.EventHandler(this.TimeDisplayTimer_Tick);
//
// 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);
//
// BaseForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@ -369,5 +378,6 @@ namespace HighWayIot.Winform.MainForm
private ToolStripMenuItem EquipMaterialBindingStripItem;
private ToolStripMenuItem MaterialConfigStripItem;
private ToolStripMenuItem MaterialTypeConfigStripItem;
private ToolStripMenuItem DeviceDataManageToolStripMenuItem;
}
}

@ -98,7 +98,7 @@ namespace HighWayIot.Winform.MainForm
case "监控主页面":
UserPanelSwitch(typeof(MonitorMainPage), button.Text);
break;
case "测试页面":
case "PLC测试页面":
UserPanelSwitch(typeof(TestPage), button.Text);
break;
case "班时间维护":
@ -122,6 +122,9 @@ namespace HighWayIot.Winform.MainForm
case "生产排程":
UserPanelSwitch(typeof(ProductionScheduling), button.Text);
break;
case "设备数据管理":
UserPanelSwitch(typeof(ProductionScheduling), button.Text);
break;
case "":
break;
default:
@ -262,5 +265,10 @@ namespace HighWayIot.Winform.MainForm
TraverseMenuitem(i);
}
}
private void DeviceDataManageToolStripMenuItem_Click(object sender, EventArgs e)
{
}
}
}

@ -47,7 +47,7 @@ namespace HighWayIot.Winform.MainForm
//
// Login
//
this.Login.Location = new System.Drawing.Point(92, 127);
this.Login.Location = new System.Drawing.Point(92, 118);
this.Login.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Login.Name = "Login";
this.Login.Size = new System.Drawing.Size(82, 28);
@ -73,6 +73,7 @@ namespace HighWayIot.Winform.MainForm
this.PassText.PasswordChar = '●';
this.PassText.Size = new System.Drawing.Size(146, 21);
this.PassText.TabIndex = 2;
this.PassText.Text = "123";
//
// label1
//
@ -144,6 +145,7 @@ namespace HighWayIot.Winform.MainForm
this.Name = "LoginForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "大连软控开炼机成型机数据管理系统 - 登录界面";
this.Load += new System.EventHandler(this.LoginForm_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();

@ -8,6 +8,7 @@ using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
@ -20,8 +21,11 @@ namespace HighWayIot.Winform.MainForm
public LoginForm()
{
InitializeComponent();
}
/// <summary>
/// 登陆验证
/// </summary>
@ -47,5 +51,15 @@ namespace HighWayIot.Winform.MainForm
return;
}
}
/// <summary>
/// 自动登录
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LoginForm_Load(object sender, EventArgs e)
{
Login_Click(sender, e);
}
}
}

@ -0,0 +1,111 @@
namespace HighWayIot.Winform.UserControlPages
{
partial class DeviceDataManage
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// comboBox1
//
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(94, 30);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(110, 20);
this.comboBox1.TabIndex = 0;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.button2);
this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.comboBox1);
this.groupBox1.Location = new System.Drawing.Point(3, 3);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(355, 179);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "小车参数设置";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(23, 34);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(65, 12);
this.label1.TabIndex = 1;
this.label1.Text = "设备号选择";
//
// button1
//
this.button1.Font = new System.Drawing.Font("宋体", 12F);
this.button1.Location = new System.Drawing.Point(25, 70);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(126, 41);
this.button1.TabIndex = 2;
this.button1.Text = "从PLC上传";
this.button1.UseVisualStyleBackColor = true;
//
// button2
//
this.button2.Font = new System.Drawing.Font("宋体", 12F);
this.button2.Location = new System.Drawing.Point(195, 70);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(126, 41);
this.button2.TabIndex = 3;
this.button2.Text = "下传到PLC";
this.button2.UseVisualStyleBackColor = true;
//
// DeviceDataManage
//
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.groupBox1);
this.Name = "DeviceDataManage";
this.Size = new System.Drawing.Size(1293, 884);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button2;
}
}

@ -0,0 +1,20 @@
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
{
public partial class DeviceDataManage : UserControl
{
public DeviceDataManage()
{
InitializeComponent();
}
}
}

@ -0,0 +1,120 @@
<?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>

@ -5,7 +5,9 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows.Forms;
using TouchSocket.Core;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
@ -59,7 +61,45 @@ namespace HighWayIot.Winform.UserControlPages
/// <param name="e"></param>
private void ReadButton_Click(object sender, EventArgs e)
{
DataTypeEnum en = (DataTypeEnum)Convert.ToInt32(PlcType.SelectedValue);
string res = string.Empty;
switch (en)
{
case DataTypeEnum.Bool:
res = PlcConnect.ReadBool(PlcAddress.Text).ToString();
break;
case DataTypeEnum.Int16:
res = PlcConnect.ReadInt16(PlcAddress.Text).ToString();
break;
case DataTypeEnum.UInt16:
res = PlcConnect.ReadUInt16(PlcAddress.Text).ToString();
break;
case DataTypeEnum.Int32:
res = PlcConnect.ReadInt32(PlcAddress.Text).ToString();
break;
case DataTypeEnum.UInt32:
res = PlcConnect.ReadUInt32(PlcAddress.Text).ToString();
break;
case DataTypeEnum.Int64:
res = PlcConnect.ReadInt64(PlcAddress.Text).ToString();
break;
case DataTypeEnum.UInt64:
res = PlcConnect.ReadUInt64(PlcAddress.Text).ToString();
break;
case DataTypeEnum.Float:
res = PlcConnect.ReadFloat(PlcAddress.Text).ToString();
break;
case DataTypeEnum.Double:
res = PlcConnect.ReadDouble(PlcAddress.Text).ToString();
break;
default:
res = "不对劲儿奥";
break;
}
PlcShowValue.Text = res;
}
/// <summary>

@ -13,10 +13,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HighWayIot.Repository", "Hi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HighWayIot.Plc", "HighWayIot.Plc\HighWayIot.Plc.csproj", "{4EE4C3E2-AC45-4275-8017-E99D70FC1F52}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HighWayIot.Rfid", "HighWayIot.Rfid\HighWayIot.Rfid.csproj", "{29813574-49C0-4979-A5A6-47EB7C4288A0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HighWayIot.Winform", "HighWayIot.Winform\HighWayIot.Winform.csproj", "{E36F832C-5F90-491C-B3B7-E94C734FD292}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HighWayIot.TouchSocket", "HighWayIot.TouchSocket\HighWayIot.TouchSocket.csproj", "{DD18A634-1F9C-409A-8C32-C3C81B1B55B5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HighWayIot.Rfid", "HighWayIot.Rfid\HighWayIot.Rfid.csproj", "{29813574-49C0-4979-A5A6-47EB7C4288A0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -43,14 +45,18 @@ Global
{4EE4C3E2-AC45-4275-8017-E99D70FC1F52}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4EE4C3E2-AC45-4275-8017-E99D70FC1F52}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4EE4C3E2-AC45-4275-8017-E99D70FC1F52}.Release|Any CPU.Build.0 = Release|Any CPU
{29813574-49C0-4979-A5A6-47EB7C4288A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{29813574-49C0-4979-A5A6-47EB7C4288A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{29813574-49C0-4979-A5A6-47EB7C4288A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{29813574-49C0-4979-A5A6-47EB7C4288A0}.Release|Any CPU.Build.0 = Release|Any CPU
{E36F832C-5F90-491C-B3B7-E94C734FD292}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E36F832C-5F90-491C-B3B7-E94C734FD292}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E36F832C-5F90-491C-B3B7-E94C734FD292}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E36F832C-5F90-491C-B3B7-E94C734FD292}.Release|Any CPU.Build.0 = Release|Any CPU
{DD18A634-1F9C-409A-8C32-C3C81B1B55B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD18A634-1F9C-409A-8C32-C3C81B1B55B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD18A634-1F9C-409A-8C32-C3C81B1B55B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD18A634-1F9C-409A-8C32-C3C81B1B55B5}.Release|Any CPU.Build.0 = Release|Any CPU
{29813574-49C0-4979-A5A6-47EB7C4288A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{29813574-49C0-4979-A5A6-47EB7C4288A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{29813574-49C0-4979-A5A6-47EB7C4288A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{29813574-49C0-4979-A5A6-47EB7C4288A0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Loading…
Cancel
Save