新增设置功率

master
CaesarBao 3 months ago
parent e6502707c3
commit d93dd2bf5f

@ -95,6 +95,12 @@ namespace Mesnac.DeviceAdapter
/// <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></returns>
bool GetOnlineStatus();
/// <summary>
/// 连接设备
@ -215,6 +221,15 @@ namespace Mesnac.DeviceAdapter
/// <param name="Antenna">天线号0为本机255为读取所有天线</param>
UInt16 Device_GetIdentifyData(ref Byte[] pReadData, Byte Antenna);
/// <summary>
/// 获取天线收发功率
/// </summary>
/// <param name="iDbi"></param>
/// <param name="Antenna"></param>
/// <param name="RorW"></param>
/// <returns></returns>
int Device_GetRf(byte Antenna, WriteOrRead RorW);
/// <summary>
/// 设置天线收发功率
/// </summary>

@ -182,6 +182,14 @@
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="TouchSocket.Core" publicKeyToken="d6c415a2f58eda72" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.18.0" newVersion="3.1.18.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="TouchSocket" publicKeyToken="5f39d7da98dac6a9" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.18.0" newVersion="3.1.18.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

@ -38,13 +38,21 @@
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.label_Version = new System.Windows.Forms.Label();
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.退ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.label_CollectID = new System.Windows.Forms.Label();
this.adapter_list = new HighWayAssemble.DoubleBufferListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.equip_list = new HighWayAssemble.DoubleBufferListView();
this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
@ -53,7 +61,6 @@
this.columnHeader10 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader16 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader17 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.sensor_list = new HighWayAssemble.DoubleBufferListView();
this.columnHeader11 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader12 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
@ -63,13 +70,9 @@
this.columnHeader19 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader20 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader21 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.label_Version = new System.Windows.Forms.Label();
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.退ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.label_CollectID = new System.Windows.Forms.Label();
this.contextMenuStrip2 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
@ -84,6 +87,7 @@
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.contextMenuStrip1.SuspendLayout();
this.contextMenuStrip2.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
@ -103,7 +107,7 @@
// 菜单ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "菜单ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(62, 28);
this.ToolStripMenuItem.Size = new System.Drawing.Size(62, 32);
this.ToolStripMenuItem.Text = "菜单";
//
// 关于ToolStripMenuItem
@ -111,7 +115,7 @@
this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.v20230913ToolStripMenuItem});
this.ToolStripMenuItem.Name = "关于ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(62, 28);
this.ToolStripMenuItem.Size = new System.Drawing.Size(62, 32);
this.ToolStripMenuItem.Text = "关于";
//
// v20230913ToolStripMenuItem
@ -182,52 +186,6 @@
this.groupBox1.TabStop = false;
this.groupBox1.Text = "MES软件";
//
// adapter_list
//
this.adapter_list.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2,
this.columnHeader3,
this.columnHeader4,
this.columnHeader5});
this.adapter_list.Dock = System.Windows.Forms.DockStyle.Fill;
this.adapter_list.HideSelection = false;
this.adapter_list.Location = new System.Drawing.Point(4, 26);
this.adapter_list.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.adapter_list.Name = "adapter_list";
this.adapter_list.Size = new System.Drawing.Size(263, 261);
this.adapter_list.TabIndex = 0;
this.adapter_list.UseCompatibleStateImageBehavior = false;
this.adapter_list.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "编号";
this.columnHeader1.Width = 40;
//
// columnHeader2
//
this.columnHeader2.Text = "名称";
this.columnHeader2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader2.Width = 80;
//
// columnHeader3
//
this.columnHeader3.Text = "IP地址";
this.columnHeader3.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader3.Width = 100;
//
// columnHeader4
//
this.columnHeader4.Text = "端口号";
this.columnHeader4.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// columnHeader5
//
this.columnHeader5.Text = "连接状态";
this.columnHeader5.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader5.Width = 97;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.equip_list);
@ -241,63 +199,6 @@
this.groupBox2.TabStop = false;
this.groupBox2.Text = "设备信息";
//
// equip_list
//
this.equip_list.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader6,
this.columnHeader7,
this.columnHeader8,
this.columnHeader9,
this.columnHeader10,
this.columnHeader16,
this.columnHeader17});
this.equip_list.Dock = System.Windows.Forms.DockStyle.Fill;
this.equip_list.HideSelection = false;
this.equip_list.Location = new System.Drawing.Point(4, 26);
this.equip_list.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.equip_list.Name = "equip_list";
this.equip_list.Size = new System.Drawing.Size(1140, 261);
this.equip_list.TabIndex = 1;
this.equip_list.UseCompatibleStateImageBehavior = false;
this.equip_list.View = System.Windows.Forms.View.Details;
//
// columnHeader6
//
this.columnHeader6.Text = "编号";
this.columnHeader6.Width = 50;
//
// columnHeader7
//
this.columnHeader7.Text = "名称";
this.columnHeader7.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader7.Width = 120;
//
// columnHeader8
//
this.columnHeader8.Text = "连接串";
this.columnHeader8.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader8.Width = 120;
//
// columnHeader9
//
this.columnHeader9.Text = "连接方式";
this.columnHeader9.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// columnHeader10
//
this.columnHeader10.Text = "设备类型";
this.columnHeader10.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// columnHeader16
//
this.columnHeader16.Text = "所属汇集";
this.columnHeader16.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// columnHeader17
//
this.columnHeader17.Text = "连接状态";
this.columnHeader17.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.sensor_list);
@ -311,72 +212,6 @@
this.groupBox3.TabStop = false;
this.groupBox3.Text = "传感器信息";
//
// sensor_list
//
this.sensor_list.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader11,
this.columnHeader12,
this.columnHeader13,
this.columnHeader14,
this.columnHeader15,
this.columnHeader19,
this.columnHeader20,
this.columnHeader21});
this.sensor_list.Dock = System.Windows.Forms.DockStyle.Fill;
this.sensor_list.HideSelection = false;
this.sensor_list.Location = new System.Drawing.Point(4, 26);
this.sensor_list.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.sensor_list.Name = "sensor_list";
this.sensor_list.Size = new System.Drawing.Size(1417, 616);
this.sensor_list.TabIndex = 1;
this.sensor_list.UseCompatibleStateImageBehavior = false;
this.sensor_list.View = System.Windows.Forms.View.Details;
//
// columnHeader11
//
this.columnHeader11.Text = "编号";
this.columnHeader11.Width = 80;
//
// columnHeader12
//
this.columnHeader12.Text = "名称";
this.columnHeader12.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader12.Width = 120;
//
// columnHeader13
//
this.columnHeader13.Text = "序号";
this.columnHeader13.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader13.Width = 40;
//
// columnHeader14
//
this.columnHeader14.Text = "类型";
this.columnHeader14.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// columnHeader15
//
this.columnHeader15.Text = "设备编号";
this.columnHeader15.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// columnHeader19
//
this.columnHeader19.Text = "时间";
this.columnHeader19.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader19.Width = 130;
//
// columnHeader20
//
this.columnHeader20.Text = "数据";
this.columnHeader20.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader20.Width = 140;
//
// columnHeader21
//
this.columnHeader21.Text = "时间间隔ms";
this.columnHeader21.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader21.Width = 100;
//
// timer1
//
this.timer1.Enabled = true;
@ -440,6 +275,200 @@
this.label_CollectID.TextAlign = System.Drawing.ContentAlignment.TopRight;
this.label_CollectID.Click += new System.EventHandler(this.Label_CollectID_Click);
//
// adapter_list
//
this.adapter_list.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2,
this.columnHeader3,
this.columnHeader4,
this.columnHeader5});
this.adapter_list.Dock = System.Windows.Forms.DockStyle.Fill;
this.adapter_list.HideSelection = false;
this.adapter_list.Location = new System.Drawing.Point(4, 26);
this.adapter_list.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.adapter_list.Name = "adapter_list";
this.adapter_list.Size = new System.Drawing.Size(263, 261);
this.adapter_list.TabIndex = 0;
this.adapter_list.UseCompatibleStateImageBehavior = false;
this.adapter_list.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "编号";
this.columnHeader1.Width = 40;
//
// columnHeader2
//
this.columnHeader2.Text = "名称";
this.columnHeader2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader2.Width = 80;
//
// columnHeader3
//
this.columnHeader3.Text = "IP地址";
this.columnHeader3.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader3.Width = 100;
//
// columnHeader4
//
this.columnHeader4.Text = "端口号";
this.columnHeader4.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// columnHeader5
//
this.columnHeader5.Text = "连接状态";
this.columnHeader5.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader5.Width = 97;
//
// equip_list
//
this.equip_list.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader6,
this.columnHeader7,
this.columnHeader8,
this.columnHeader9,
this.columnHeader10,
this.columnHeader16,
this.columnHeader17});
this.equip_list.Dock = System.Windows.Forms.DockStyle.Fill;
this.equip_list.HideSelection = false;
this.equip_list.Location = new System.Drawing.Point(4, 26);
this.equip_list.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.equip_list.Name = "equip_list";
this.equip_list.Size = new System.Drawing.Size(1140, 261);
this.equip_list.TabIndex = 1;
this.equip_list.UseCompatibleStateImageBehavior = false;
this.equip_list.View = System.Windows.Forms.View.Details;
//
// columnHeader6
//
this.columnHeader6.Text = "编号";
this.columnHeader6.Width = 50;
//
// columnHeader7
//
this.columnHeader7.Text = "名称";
this.columnHeader7.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader7.Width = 120;
//
// columnHeader8
//
this.columnHeader8.Text = "连接串";
this.columnHeader8.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader8.Width = 120;
//
// columnHeader9
//
this.columnHeader9.Text = "连接方式";
this.columnHeader9.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// columnHeader10
//
this.columnHeader10.Text = "设备类型";
this.columnHeader10.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// columnHeader16
//
this.columnHeader16.Text = "所属汇集";
this.columnHeader16.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// columnHeader17
//
this.columnHeader17.Text = "连接状态";
this.columnHeader17.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// sensor_list
//
this.sensor_list.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader11,
this.columnHeader12,
this.columnHeader13,
this.columnHeader14,
this.columnHeader15,
this.columnHeader19,
this.columnHeader20,
this.columnHeader21});
this.sensor_list.Dock = System.Windows.Forms.DockStyle.Fill;
this.sensor_list.FullRowSelect = true;
this.sensor_list.HideSelection = false;
this.sensor_list.Location = new System.Drawing.Point(4, 26);
this.sensor_list.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.sensor_list.Name = "sensor_list";
this.sensor_list.Size = new System.Drawing.Size(1417, 616);
this.sensor_list.TabIndex = 1;
this.sensor_list.UseCompatibleStateImageBehavior = false;
this.sensor_list.View = System.Windows.Forms.View.Details;
this.sensor_list.MouseClick += new System.Windows.Forms.MouseEventHandler(this.sensor_list_MouseClick);
//
// columnHeader11
//
this.columnHeader11.Text = "编号";
this.columnHeader11.Width = 80;
//
// columnHeader12
//
this.columnHeader12.Text = "名称";
this.columnHeader12.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader12.Width = 120;
//
// columnHeader13
//
this.columnHeader13.Text = "序号";
this.columnHeader13.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader13.Width = 40;
//
// columnHeader14
//
this.columnHeader14.Text = "类型";
this.columnHeader14.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// columnHeader15
//
this.columnHeader15.Text = "设备编号";
this.columnHeader15.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// columnHeader19
//
this.columnHeader19.Text = "时间";
this.columnHeader19.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader19.Width = 130;
//
// columnHeader20
//
this.columnHeader20.Text = "数据";
this.columnHeader20.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader20.Width = 140;
//
// columnHeader21
//
this.columnHeader21.Text = "时间间隔ms";
this.columnHeader21.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader21.Width = 100;
//
// contextMenuStrip2
//
this.contextMenuStrip2.ImageScalingSize = new System.Drawing.Size(20, 20);
this.contextMenuStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem1,
this.toolStripMenuItem2});
this.contextMenuStrip2.Name = "contextMenuStrip1";
this.contextMenuStrip2.Size = new System.Drawing.Size(241, 97);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(240, 30);
this.toolStripMenuItem1.Text = "修改";
this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click);
//
// toolStripMenuItem2
//
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
this.toolStripMenuItem2.Size = new System.Drawing.Size(240, 30);
this.toolStripMenuItem2.Text = "读取";
this.toolStripMenuItem2.Click += new System.EventHandler(this.toolStripMenuItem2_Click);
//
// FrmDisplayView
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
@ -473,6 +502,7 @@
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.contextMenuStrip1.ResumeLayout(false);
this.contextMenuStrip2.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@ -519,6 +549,9 @@
private System.Windows.Forms.ColumnHeader columnHeader16;
private System.Windows.Forms.ColumnHeader columnHeader17;
private System.Windows.Forms.ToolStripMenuItem v20230913ToolStripMenuItem;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip2;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
}
}

@ -1,4 +1,5 @@
using Highway.Assemble.common;
using HighWayAssemble.Main;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@ -17,6 +18,7 @@ namespace HighWayAssemble
public FrmDisplayView()
{
InitializeComponent();
this.StartPosition = FormStartPosition.CenterScreen;
controller = new FrmDisplayControl(this);
}
@ -426,5 +428,56 @@ namespace HighWayAssemble
}
}
private void sensor_list_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Right) return;
// 获取点击的列表项
var hitTestInfo = sensor_list.HitTest(e.X, e.Y);
if (hitTestInfo.Item == null) return; // 点击空白处不触发
// 选中点击项(可选)
hitTestInfo.Item.Selected = true;
// 显示上下文菜单
contextMenuStrip2.Show(sensor_list, e.Location);
}
/// <summary>
/// 修改功率设置
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
try
{
WriteData writeData = new WriteData(controller, sensor_list.SelectedItems[0].Text.ToString());
writeData.StartPosition = FormStartPosition.Manual;
int x = this.Left + (this.Width - writeData.Width) / 2;
int y = this.Top + (this.Height - writeData.Height) / 2;
// 设置子窗口位置
writeData.Location = new Point(x, y);
writeData.Show(this); // 关联父窗口(可选,视需求)
}
catch (Exception ex)
{
}
}
/// <summary>
/// 测试读取
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripMenuItem2_Click(object sender, EventArgs e)
{
try
{
controller.ReadEPC(sensor_list.SelectedItems[0].Text.ToString());
}
catch (Exception ex)
{
}
}
}
}

@ -1262,6 +1262,9 @@
//////////////////////////////////8=
</value>
</data>
<metadata name="contextMenuStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>556, 16</value>
</metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

@ -124,11 +124,11 @@
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="TouchSocket, Version=3.1.4.0, Culture=neutral, PublicKeyToken=5f39d7da98dac6a9, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.3.1.4\lib\net45\TouchSocket.dll</HintPath>
<Reference Include="TouchSocket, Version=3.1.18.0, Culture=neutral, PublicKeyToken=5f39d7da98dac6a9, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.3.1.18\lib\net45\TouchSocket.dll</HintPath>
</Reference>
<Reference Include="TouchSocket.Core, Version=3.1.4.0, Culture=neutral, PublicKeyToken=d6c415a2f58eda72, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.Core.3.1.4\lib\net45\TouchSocket.Core.dll</HintPath>
<Reference Include="TouchSocket.Core, Version=3.1.18.0, Culture=neutral, PublicKeyToken=d6c415a2f58eda72, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.Core.3.1.18\lib\net45\TouchSocket.Core.dll</HintPath>
</Reference>
<Reference Include="TouchSocket.Http, Version=3.1.4.0, Culture=neutral, PublicKeyToken=ecea290704fb8ddd, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.Http.3.1.4\lib\net45\TouchSocket.Http.dll</HintPath>
@ -154,6 +154,12 @@
</Compile>
<Compile Include="Main\Main.cs" />
<Compile Include="Main\FrmDisplayModel.cs" />
<Compile Include="Main\WriteData.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Main\WriteData.Designer.cs">
<DependentUpon>WriteData.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Protocol\ApiServer.cs" />
@ -168,6 +174,9 @@
<EmbeddedResource Include="FrmDisplayView.resx">
<DependentUpon>FrmDisplayView.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Main\WriteData.resx">
<DependentUpon>WriteData.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@ -234,7 +243,7 @@
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\TouchSocket.Core.3.1.4\analyzers\dotnet\cs\TouchSocket.Core.SourceGenerator.dll" />
<Analyzer Include="..\packages\TouchSocket.Core.3.1.18\analyzers\dotnet\cs\TouchSocket.Core.SourceGenerator.dll" />
<Analyzer Include="..\packages\TouchSocket.Rpc.3.1.4\analyzers\dotnet\cs\TouchSocket.Rpc.SourceGenerator.dll" />
<Analyzer Include="..\packages\TouchSocket.WebApi.3.1.4\analyzers\dotnet\cs\TouchSocket.WebApi.SourceGenerator.dll" />
</ItemGroup>

@ -12,6 +12,7 @@ namespace HighWayAssemble
{
FrmDisplayView view;
ISoftInfo m_softInfo;
FrmDisplayModel frmDisplayModel;
/// <summary>
/// 注册视图层插件
/// </summary>
@ -21,7 +22,7 @@ namespace HighWayAssemble
this.view = view;
OnRegister();//绑定
/* m_model =*/
new FrmDisplayModel();
frmDisplayModel = new FrmDisplayModel();
// m_ConfigInfo = App.Make<IConfigInfo>();
m_softInfo = App.Make<ISoftInfo>();
@ -189,5 +190,17 @@ namespace HighWayAssemble
//});
App.On(EventSystem.LoadCollectID, LoadCollectID);
}
public void ReadEPC(string CombineID)
{
frmDisplayModel.ReadEPC(CombineID);
}
public int GetRf(string CombineID)
{
return frmDisplayModel.GetRf(CombineID);
}
public void SetRf(string CombineID,int idb)
{
frmDisplayModel.SetRf(CombineID, idb * 100);
}
}
}

@ -66,6 +66,7 @@ namespace HighWayAssemble
{
try
{
FrmDisplayView.LogInfo.Info("创建SockteSvr成功");
SoftInfo = App.Make<ISoftInfo>();
SoftInfo.CollectInfo = new Collect();
// configInfo = App.Make<IConfigInfo>();
@ -80,7 +81,7 @@ namespace HighWayAssemble
var t = Task.Run(async delegate
{
await Task.Delay(10);
CreateTcp();
//CreateTcp();
MesHttpClient = new MesHttpClient();
MesHttpClient.init();
var service = new HttpService();
@ -117,8 +118,21 @@ namespace HighWayAssemble
a.UseDefaultHttpServicePlugin();
}
));
await service.StartAsync();
await m_service.StartAsync();//启动
try
{
await service.StartAsync();
//await m_service.StartAsync();//启动
FrmDisplayView.LogInfo.Info("创建SockteSvr成功");
}
catch (Exception ex)
{
FrmDisplayView.LogInfo.Fatal("读取配置文件异常!空间名:" + ex.Source + "" + '\n' +
"方法名:" + ex.TargetSite + '\n' +
"故障点:" + ex.StackTrace.Substring(ex.StackTrace.LastIndexOf("\\") + 1, ex.StackTrace.Length - ex.StackTrace.LastIndexOf("\\") - 1) + '\n' +
"错误提示:" + ex.Message);
}
//CreatSocketServer();
@ -152,7 +166,10 @@ namespace HighWayAssemble
}
catch (Exception ex)
{
FrmDisplayView.LogInfo.Fatal("读取配置文件异常!空间名:" + ex.Source + "" + '\n' +
"方法名:" + ex.TargetSite + '\n' +
"故障点:" + ex.StackTrace.Substring(ex.StackTrace.LastIndexOf("\\") + 1, ex.StackTrace.Length - ex.StackTrace.LastIndexOf("\\") - 1) + '\n' +
"错误提示:" + ex.Message);
}
}
@ -332,8 +349,7 @@ namespace HighWayAssemble
m_EquipClient.RecEquipStateasyc(async (state) =>
{
App.TriggerHalt(EventSystem.updateEquipListInfoasyc, state);
await InsertDeviceState(state.m_iDeviceId, state.m_ConnectState);
});
//设备状态回调
m_EquipClient.RecEquipState(async (state) =>
@ -1557,5 +1573,43 @@ namespace HighWayAssemble
}
}
public void ReadEPC(string CombineID)
{
try
{
List<TagInfo> rfid = m_EquipClient.ReadRFID(CombineID);
}
catch (Exception ex)
{
throw;
}
}
public int GetRf(string CombineID)
{
int flag = 0;
try
{
flag = m_EquipClient.GetRf(CombineID);
return flag;
}
catch (Exception ex)
{
return flag;
}
}
public void SetRf(string CombineID,int db)
{
bool iflag = false;
try
{
iflag = m_EquipClient.SetRf(CombineID, db);
}
catch (Exception ex)
{
}
}
}
}

@ -0,0 +1,100 @@
namespace HighWayAssemble.Main
{
partial class WriteData
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.read = new System.Windows.Forms.Button();
this.write = new System.Windows.Forms.Button();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Font = new System.Drawing.Font("宋体", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.textBox1.Location = new System.Drawing.Point(164, 74);
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.Size = new System.Drawing.Size(100, 39);
this.textBox1.TabIndex = 0;
//
// read
//
this.read.Location = new System.Drawing.Point(328, 74);
this.read.Name = "read";
this.read.Size = new System.Drawing.Size(108, 40);
this.read.TabIndex = 2;
this.read.Text = "读取";
this.read.UseVisualStyleBackColor = true;
this.read.Click += new System.EventHandler(this.read_Click);
//
// write
//
this.write.Location = new System.Drawing.Point(328, 152);
this.write.Name = "write";
this.write.Size = new System.Drawing.Size(108, 40);
this.write.TabIndex = 3;
this.write.Text = "写入";
this.write.UseVisualStyleBackColor = true;
this.write.Click += new System.EventHandler(this.write_Click);
//
// numericUpDown1
//
this.numericUpDown1.Font = new System.Drawing.Font("宋体", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.numericUpDown1.Location = new System.Drawing.Point(164, 152);
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(100, 39);
this.numericUpDown1.TabIndex = 4;
//
// WriteData
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(602, 296);
this.Controls.Add(this.numericUpDown1);
this.Controls.Add(this.write);
this.Controls.Add(this.read);
this.Controls.Add(this.textBox1);
this.Name = "WriteData";
this.Text = "功率设置";
this.Load += new System.EventHandler(this.WriteData_Load);
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button read;
private System.Windows.Forms.Button write;
private System.Windows.Forms.NumericUpDown numericUpDown1;
}
}

@ -0,0 +1,58 @@
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 HighWayAssemble.Main
{
public partial class WriteData : Form
{
public string Combineid = "";
FrmDisplayControl _controller;
public WriteData(FrmDisplayControl controller, string combineid)
{
InitializeComponent();
_controller = controller;
Combineid = combineid;
}
private void WriteData_Load(object sender, EventArgs e)
{
textBox1.ReadOnly = true;
textBox1.Enabled = false;
SetRf();
}
private void read_Click(object sender, EventArgs e)
{
SetRf();
}
/// <summary>
/// 设置功率
/// </summary>
private void SetRf()
{
try
{
int idb = _controller.GetRf(Combineid);
textBox1.Text = idb.ToString();
numericUpDown1.Value = idb;
}
catch (Exception ex)
{
}
}
private void write_Click(object sender, EventArgs e)
{
_controller.SetRf(Combineid, int.Parse(numericUpDown1.Text));
SetRf();
}
}
}

@ -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>

@ -87,7 +87,8 @@ namespace HighWayAssemble.Protocol
{
if (rfid != null && rfid.Any())
{
mesReadRespon.EPCID = string.Join(",", rfid.Select(item => item.EPCstring));
//mesReadRespon.EPCID = string.Join(",", rfid.Select(item => item.EPCstring));
mesReadRespon.EPCID = "MORE";
Msg = "multiple EPC";
}
}

@ -10,8 +10,8 @@
<package id="System.Text.Json" version="8.0.5" targetFramework="net461" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net452" requireReinstallation="true" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net452" requireReinstallation="true" />
<package id="TouchSocket" version="3.1.4" targetFramework="net461" />
<package id="TouchSocket.Core" version="3.1.4" targetFramework="net461" />
<package id="TouchSocket" version="3.1.18" targetFramework="net461" />
<package id="TouchSocket.Core" version="3.1.18" targetFramework="net461" />
<package id="TouchSocket.Http" version="3.1.4" targetFramework="net461" />
<package id="TouchSocket.Rpc" version="3.1.4" targetFramework="net461" />
<package id="TouchSocket.WebApi" version="3.1.4" targetFramework="net461" />

@ -1,4 +1,5 @@
using Highway.Assemble.common;
using CatLib;
using Highway.Assemble.common;
using log4net;
using Mesnac.DeviceAdapter;
using Mesnac.DeviceAdapterNet;
@ -290,23 +291,20 @@ namespace Highway.Assemble.EquipClient
{
item.m_ConnectState = 0;
return;
}
if (item.m_iDeviceId == 10001)
{
}
switch (item.m_ConnectState)
{
case 0: // 未连接状态
if (await RunOnThreadPool(() => pDeviceAdapter.Device_Init_Id((CommType)item.m_iConnectMode, item.m_strConnectStr, item.m_iDeviceId)))
{
{
if (await RunOnThreadPool(() => pDeviceAdapter.Device_Connect()))
{
// 管理事件订阅,避免重复订阅
pDeviceAdapter.RecvIdentifyDataEvent -= RecvIdentifyData_Instance;
pDeviceAdapter.RecvIdentifyDataEvent += RecvIdentifyData_Instance;
item.m_ConnectState = await GetConnectionStateFromHeartbeat(pDeviceAdapter);
//item.m_ConnectState = await GetConnectionStateFromHeartbeat(pDeviceAdapter);
item.m_ConnectState = pDeviceAdapter.GetOnlineStatus()==true?(byte)1:(byte)0;
}
else
{
@ -320,26 +318,27 @@ namespace Highway.Assemble.EquipClient
break;
case 1: // 已连接状态
item.m_ConnectState = await GetConnectionStateFromHeartbeat(pDeviceAdapter);
//item.m_ConnectState = await GetConnectionStateFromHeartbeat(pDeviceAdapter);
item.m_ConnectState = pDeviceAdapter.GetOnlineStatus() == true ? (byte)1 : (byte)0;
break;
case 2: // 连接异常状态
int heartbeatResult = await GetConnectionStateFromHeartbeat(pDeviceAdapter);
if (heartbeatResult == 2)
{
item.m_ConnectState = 0;
await RunOnThreadPool(() => item.m_IDeviceAdapter.Device_Destroy());
}
else if (heartbeatResult == 1)
{
item.m_ConnectState = 1;
}
else
{
item.m_ConnectState = 0;
await RunOnThreadPool(() => item.m_IDeviceAdapter.Device_Destroy());
}
break;
//case 2: // 连接异常状态
// int heartbeatResult = await GetConnectionStateFromHeartbeat(pDeviceAdapter);
// if (heartbeatResult == 2)
// {
// item.m_ConnectState = 0;
// await RunOnThreadPool(() => item.m_IDeviceAdapter.Device_Destroy());
// }
// else if (heartbeatResult == 1)
// {
// item.m_ConnectState = 1;
// }
// else
// {
// item.m_ConnectState = 0;
// await RunOnThreadPool(() => item.m_IDeviceAdapter.Device_Destroy());
// }
// break;
}
}
@ -852,7 +851,7 @@ namespace Highway.Assemble.EquipClient
//LogInfo.Info("合并编号:" + id + ",识别单次标签命令自报");
FilterData = m_SensorInfoList.Find(x=>x.combineid == id).FilterData;
tags = GetOneEpcByCombineId(id);
if (tags != null)
if (tags != null && tags.Count > 0)
{
//有过滤
LogInfo.Info("-------------------------------------------------------------------------------------------------------------");
@ -1265,6 +1264,52 @@ namespace Highway.Assemble.EquipClient
}
}
public bool SetRf(string id,int idb)
{
bool flag = false;
try
{
DeviceInfo deviceInfo = null;
deviceInfo = GetIDeviceInfoByCombineId(id.ToString());
if (deviceInfo.m_IDeviceAdapter != null)
{
if (deviceInfo.m_IDeviceAdapter.GetOnlineStatus())
{
flag = deviceInfo.m_IDeviceAdapter.Device_SetRf(idb, 1, WriteOrRead.Write);
}
return flag;
}
return flag;
}
catch (Exception ex)
{
return false;
}
}
public int GetRf(string id)
{
int flag = 0;
try
{
DeviceInfo deviceInfo = null;
deviceInfo = GetIDeviceInfoByCombineId(id.ToString());
if (deviceInfo.m_IDeviceAdapter != null)
{
if (deviceInfo.m_IDeviceAdapter.GetOnlineStatus())
{
flag = deviceInfo.m_IDeviceAdapter.Device_GetRf(1, WriteOrRead.Read);
}
return flag;
}
return flag;
}
catch (Exception ex)
{
return flag;
}
}
}
}

@ -69,5 +69,8 @@
<Name>Mesnac.DeviceAdapter.RFly_I160</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -21,6 +21,10 @@ namespace Highway.Assemble.EquipClient
List<TagInfo> ReadRFID(string id);
bool SetRf(string id,int iDB);
int GetRf(string id);
void RecSendData(Action<string, List<TagInfo>> action);
void RecAutoData(Action<int, byte[]> action);

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

@ -1514,6 +1514,16 @@ namespace Mesnac.DeviceAdapter.Fuchs
throw new NotImplementedException();
}
public bool GetOnlineStatus()
{
throw new NotImplementedException();
}
public int Device_GetRf(byte Antenna, WriteOrRead RorW)
{
throw new NotImplementedException();
}
//public List<TagInfo> TagInventoryTimePeriod(byte Antenna, int time)
//{
// List<TagInfo> t = new List<TagInfo> { };

@ -790,6 +790,16 @@ namespace Mesnac.DeviceAdapter.HWKC_81600
{
throw new NotImplementedException();
}
public bool GetOnlineStatus()
{
throw new NotImplementedException();
}
public int Device_GetRf(byte Antenna, WriteOrRead RorW)
{
throw new NotImplementedException();
}
#endregion
}
}

@ -37,13 +37,41 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dll\log4net.dll</HintPath>
</Reference>
<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.configuration" />
<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.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="TouchSocket, Version=3.1.18.0, Culture=neutral, PublicKeyToken=5f39d7da98dac6a9, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.3.1.18\lib\net45\TouchSocket.dll</HintPath>
</Reference>
<Reference Include="TouchSocket.Core, Version=3.1.18.0, Culture=neutral, PublicKeyToken=d6c415a2f58eda72, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.Core.3.1.18\lib\net45\TouchSocket.Core.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="BgTcpClient.cs" />
@ -59,6 +87,12 @@
<Name>Mesnac.IDeviceAdapter</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\TouchSocket.Core.3.1.18\analyzers\dotnet\cs\TouchSocket.Core.SourceGenerator.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

@ -3,11 +3,15 @@ using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net.Sockets;
//using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using TouchSocket.Core;
using TouchSocket.Sockets;
namespace Mesnac.DeviceAdapter.RFly_I160
{
@ -62,8 +66,9 @@ namespace Mesnac.DeviceAdapter.RFly_I160
private byte m_OneEpcAntenna = 254;
private byte[] m_OneEpcData = null;
private bool m_GetReadNoDataSuccessful;
public readonly TouchSocket.Sockets.TcpClient _tcpClient = new TouchSocket.Sockets.TcpClient();
List<TagInfo> tagInfos = null;
#endregion
public int AutoReport
@ -98,7 +103,7 @@ namespace Mesnac.DeviceAdapter.RFly_I160
m_strIp = split[0];
string strTemp = split[1];
m_iPort = Convert.ToInt32(strTemp);
m_ICommunicateService.Init(m_strIp, m_iPort, this, m_iDeviceId);
//m_ICommunicateService.Init(m_strIp, m_iPort, this, m_iDeviceId);
// LogInfo.Info("设备初始化成功IP" + m_strIp + "端口号:" + m_iPort);
}
else //串口,代用串口号和波特率
@ -112,7 +117,7 @@ namespace Mesnac.DeviceAdapter.RFly_I160
m_strIp = split[0];
string strTemp = split[1];
m_iPort = Convert.ToInt32(strTemp);
m_ICommunicateService.Init(m_strIp, m_iPort, this, m_iDeviceId);
//m_ICommunicateService.Init(m_strIp, m_iPort, this, m_iDeviceId);
LogInfo.Info("设备初始化成功,串口号:" + m_strIp + "波特率:" + m_iPort);
}
}
@ -131,11 +136,105 @@ namespace Mesnac.DeviceAdapter.RFly_I160
Device_Init(iCommType, pUrl, (DeviceType)1);
return true;
}
public bool Device_Connect()
/// <summary>
/// 获取设备在线状态
/// </summary>
/// <param name="ip"></param>
/// <param name="port"></param>
/// <returns></returns>
public bool GetOnlineStatus()
{
try
{
return _tcpClient.Online;
}
catch (Exception e)
{
return false;
}
}
public bool Device_Connect()
{
byte bAntana = 0; //读写器天线号 默认0x04
UInt16 iReadCount = 0; //标签读取次数
UInt16 iRSSI = 0; //标签信号强度
byte[] bResultEPC_Data = new byte[12];
byte[] bNoData = new byte[12];
try
{
_tcpClient.Setup(new TouchSocketConfig().SetRemoteIPHost($"{m_strIp}:{m_iPort}"));
_tcpClient.Connect();
_tcpClient.Received = (client, e) =>
{
//从服务器收到信息。但是一般byteBlock和requestInfo会根据适配器呈现不同的值。
var mes = e.ByteBlock.Span.ToArray();
LogInfo.Warn("》》》RFly-I160设备" + m_iDeviceId + ",IP:" + m_strIp + ",接收原始报文:" + bytesToHexStr(mes, mes.Length));
byte[] ValidData = PareReceiveData(mes, mes.Length);
switch (ValidData[3])
{
//GPIO
case 0x51:
m_WriteAlarmSemSuccessful = true;
m_WriteAlarmSem.Release();
break;
}
if (ValidData[0] == 0XBB && ValidData[1] == 0XDD && ValidData[2] == 0X00 && ValidData[3] == 0x02) //超时 02 4E 6F 52 65 61 64 03
{
// LogInfo.Info("----函数调用:Device_DealValidPackNoRead!");
m_BarcodeGroupCount = 0;
m_GetReadNoDataSuccessful = true;
if (m_GetReadNoDataSuccessful && m_ReadDataSuccessful == false)
{
bAntana = 1;
m_AutoReadEPC = null;
m_GetReadNoDataSuccessful = false;
this.RecvIdentifyDataEvent(0, null, bAntana, m_iDeviceId, m_strIp, "1");
}
}
if (ValidData[0] == 0XBB && ValidData[1] == 0XDD && ValidData[2] != 0X00 && ValidData[3] != 0XBF) //正常有数据
{
m_BarcodeGroupCount = Convert.ToInt32(ValidData[5].ToString("X2")); //标签组数TagCount
m_MulAllData = new byte[ValidData.Length];
Array.Clear(m_MulAllData, 0, ValidData.Length);
Array.Copy(ValidData, 0, m_MulAllData, 0, ValidData.Length);
Array.Copy(m_MulAllData, 11, bResultEPC_Data, 0, 12);
bAntana = ValidData[8];
m_OneEpcAntenna = ValidData[8];
iReadCount = ValidData[6];
iRSSI = ValidData[7];
//Device_AutoDealContent(m_MulAllData);
tagInfos = GetTagInfos(m_MulAllData);
m_ReadDataLen = (byte)tagInfos.Count;
m_OneEpcDataLen = (byte)tagInfos.Count;
//m_OneEpcData = new byte[m_OneEpcDataLen];
if (RecvIdentifyDataEvent != null)
{
if (m_ReadDataSuccessful == false)
{
this.RecvIdentifyDataEvent.Invoke(Convert.ToUInt16(Convert.ToUInt16(tagInfos.Count)), tagInfos, bAntana, m_iDeviceId, m_strIp, "1");
}
else
{
m_OneEpcSem.Release();
m_ReadSem.Release();
}
}
}
return EasyTask.CompletedTask;
};
return true;
if (m_ICommunicateService != null)
{
if (m_ICommunicateService.Connect())
@ -157,7 +256,8 @@ namespace Mesnac.DeviceAdapter.RFly_I160
}
catch (Exception ex)
{
LogInfo.Info("Device_Connect异常" + ex.Message);
LogInfo.Fatal("IP" + m_strIp + "端口号: " + m_iPort + ",Device_Connect:连接失败,"+ex.Message);
//LogInfo.Info("Device_Connect异常" + ex.Message);
return false;
}
}
@ -295,7 +395,19 @@ namespace Mesnac.DeviceAdapter.RFly_I160
{
m_pData = new byte[9] { 0xAA, 0x55, 0x00, 0x90, 0x90, 0x0D, 0x00, 0x00, 0x0D }
};
var waitClient = _tcpClient.CreateWaitingClient(new WaitingOptions()
{
FilterFunc = response =>
{
return true;
}
});
byte[] reciveBuffer = waitClient.SendThenReturn(messagePack.m_pData, 2000);
LogInfo.Warn("》》》RFly-I160设备" + m_iDeviceId + ",IP:" + m_strIp + ",接收原始报文:" + bytesToHexStr(reciveBuffer, reciveBuffer.Length));
byte[] message = PareReceiveData(reciveBuffer, reciveBuffer.Length);
return 1;
// 检查通信服务
if (m_ICommunicateService == null)
{
@ -336,7 +448,7 @@ namespace Mesnac.DeviceAdapter.RFly_I160
{
// 处理超时的情况
LogInfo.Warn("Heartbeat response timed out after 2000ms.");
return 0; // 或者抛出异常,取决于你的需求
return 2; // 或者抛出异常,取决于你的需求
}
@ -358,7 +470,7 @@ namespace Mesnac.DeviceAdapter.RFly_I160
{
m_GlobalSem.Release();
}
catch (ApplicationException)
catch (ApplicationException ex)
{
LogInfo.Error("Global semaphore was already released.");
}
@ -600,6 +712,38 @@ namespace Mesnac.DeviceAdapter.RFly_I160
//int i = m_OneEpcSem.Release(1);
m_OneEpcSem.WaitOne(1, false);
m_OneEpcDataLen = 0;
m_ReadDataSuccessful = true;
LogInfo.Warn("》》》RFly-I160设备" + m_iDeviceId + ",IP:" + m_strIp + ",发送原始报文:" + bytesToHexStr(pMessagePack.m_pData, pMessagePack.m_pData.Length));
var waitClient = _tcpClient.CreateWaitingClient(new WaitingOptions()
{
FilterFunc = response =>
{
// 检查响应数据是否符合预期
if (response.ByteBlock != null && response.ByteBlock.Length > 0)
{
// 可以根据实际情况添加更多的检查逻辑
LogInfo.Warn("》》》RFly-I160设备" + m_iDeviceId + ",IP:" + m_strIp + ",接收原始报文:" + bytesToHexStr(response.ByteBlock.ToArray(0, response.ByteBlock.Length), response.ByteBlock.Length));
return true;
}
return false;
}
});
byte[] reciveBuffer = waitClient.SendThenReturn(pMessagePack.m_pData, 1000 * 2);//设置10秒超时
//Console.WriteLine($"收到回应消息:{bytesToHexStr(reciveBuffer, reciveBuffer.Length)}");
byte[] message = PareReceiveData(reciveBuffer, reciveBuffer.Length);
List<TagInfo> tags = GetTagInfos(message);
if (tags != null && tags.Count > 0)
{
return tags;
}
else
{
return new List<TagInfo>();
}
//_tcpClient.Send(pMessagePack.m_pData);
if (m_ICommunicateService.SendMessage(pMessagePack)) //发送报文成功
{
m_ReadDataSuccessful = true;
@ -645,12 +789,13 @@ namespace Mesnac.DeviceAdapter.RFly_I160
}
catch (Exception ex)
{
LogInfo.Info("Device_GetOneIdentifyData识别单条EPC数据异常" + ex.Message);
LogInfo.Info("Device_GetOneIdentifyData识别单条EPC数据异常" + m_iDeviceId + ",IP:" + m_strIp +","+ ex.Message);
iResult = 0;
m_ReadDataSuccessful = false;
}
finally
{
m_ReadDataSuccessful = false;
m_GlobalSem.Release();
}
return tagInfo;
@ -755,8 +900,6 @@ namespace Mesnac.DeviceAdapter.RFly_I160
pMessagePack.m_pData[3] = 0x51;
pMessagePack.m_pData[4] = (byte)port;
pMessagePack.m_pData[5] = 0x00;
//pMessagePack.m_pData[6] = 0x00;
//pMessagePack.m_pData[7] = 0x00;
u16byte = BitConverter.GetBytes(Timedout); //超时时间
u16byte = StringChange.Swap16Bytes(u16byte); //协议里为大端在前
// LogInfo.Info("u16byte" + u16byte);
@ -765,29 +908,43 @@ namespace Mesnac.DeviceAdapter.RFly_I160
pMessagePack.m_pData[8] = StringChange.CalculateVerify(bCRC, bCRC.Length);
pMessagePack.m_pData[9] = 0x0D;
m_WriteAlarmSem.WaitOne(1, false);
if (m_ICommunicateService.SendMessage(pMessagePack)) //发送报文成功
LogInfo.Warn("》》》RFly-I160设备" + m_iDeviceId + ",IP:" + m_strIp + ",发送原始报文:" + bytesToHexStr(pMessagePack.m_pData, pMessagePack.m_pData.Length));
var waitClient = _tcpClient.CreateWaitingClient(new WaitingOptions()
{
if (m_WriteAlarmSem.WaitOne(500, false)) //等待结果,并取结果返回。
FilterFunc = response =>
{
if (m_WriteAlarmSemSuccessful)
// 检查响应数据是否符合预期
if (response.ByteBlock != null && response.ByteBlock.Length > 0)
{
iflag = true;
LogInfo.Warn("》》》RFly-I160设备" + m_iDeviceId + ",IP:" + m_strIp + ",接收原始报文:" + bytesToHexStr(response.ByteBlock.ToArray(0, response.ByteBlock.Length), response.ByteBlock.Length));
// 可以根据实际情况添加更多的检查逻辑
return true;
}
return false;
}
else //超时
});
byte[] bytes = waitClient.SendThenReturn(pMessagePack.m_pData, 1000 * 10);//设置10秒超时
//Console.WriteLine($"收到回应消息:{bytesToHexStr(bytes, bytes.Length)}");
if (bytes[2] == 0X00)
{
return true;
}
//_tcpClient.Send(pMessagePack.m_pData);
if (m_WriteAlarmSem.WaitOne(500, false)) //等待结果,并取结果返回。
{
if (m_WriteAlarmSemSuccessful)
{
LogInfo.Info("超时");
iflag = true;
}
}
else
else //超时
{
LogInfo.Info("发送识别命令失败:");
m_WriteAlarmSemSuccessful = false;
LogInfo.Info("超时");
}
}
catch (Exception ex)
{
LogInfo.Info("识别数据异常:" + ex.Message);
LogInfo.Info(m_iDeviceId + ",IP:" + m_strIp + "数据异常:" + ex.Message);
m_WriteAlarmSemSuccessful = false;
}
finally
@ -1014,7 +1171,7 @@ namespace Mesnac.DeviceAdapter.RFly_I160
List<TagInfo> tagInfoList = new List<TagInfo>();
try
{
mutauto.WaitOne();
//mutauto.WaitOne();
int iFirstCountPos = 6; //第一次读取标签次数位置
int iFirstRSSIPos = 7; //第一次读取标签强度位置
int iFirstAnt = 8;
@ -1094,7 +1251,7 @@ namespace Mesnac.DeviceAdapter.RFly_I160
iCommonSecondFlag++;
if (iCommonSecondFlag == iBarcodeGroupCount)
{
mutauto.ReleaseMutex();
//mutauto.ReleaseMutex();
return tagInfoList;
}
}
@ -1102,7 +1259,7 @@ namespace Mesnac.DeviceAdapter.RFly_I160
catch (Exception ex)
{
LogInfo.Info("----函数调用:Device_AutoDealContent 自动处理函数异常:" + ex.ToString());
mutauto.ReleaseMutex();
//mutauto.ReleaseMutex();
}
return tagInfoList;
@ -1194,11 +1351,136 @@ namespace Mesnac.DeviceAdapter.RFly_I160
#region 该函数不实现了
public int Device_GetRf(byte Antenna, WriteOrRead RorW)
{
int bResult = 0;
try
{
byte[] u16byte = new byte[2];
byte[] bCRC = new byte[2];
//获取功率AA 55 00 72 72 0D
MessagePack pMessagePack = new MessagePack();
if (RorW == WriteOrRead.Read)
{
pMessagePack.m_pData = new byte[6];
pMessagePack.m_pData[0] = 0xAA;
pMessagePack.m_pData[1] = 0x55;
pMessagePack.m_pData[2] = 0x00;
pMessagePack.m_pData[3] = 0x72;
Array.Copy(pMessagePack.m_pData, 2, bCRC, 0, 2);
pMessagePack.m_pData[4] = StringChange.CalculateVerify(bCRC, bCRC.Length);
pMessagePack.m_pData[5] = 0x0D;
LogInfo.Warn("》》》RFly-I160设备" + m_iDeviceId + ",IP:" + m_strIp + ",发送原始报文:" + bytesToHexStr(pMessagePack.m_pData, pMessagePack.m_pData.Length));
var waitClient = _tcpClient.CreateWaitingClient(new WaitingOptions()
{
FilterFunc = response =>
{
// 检查响应数据是否符合预期
if (response.ByteBlock != null && response.ByteBlock.Length > 0)
{
// 可以根据实际情况添加更多的检查逻辑
LogInfo.Warn("》》》RFly-I160设备" + m_iDeviceId + ",IP:" + m_strIp + ",接收原始报文:" + bytesToHexStr(response.ByteBlock.ToArray(0, response.ByteBlock.Length), response.ByteBlock.Length));
return true;
}
return false;
}
});
byte[] reciveBuffer = waitClient.SendThenReturn(pMessagePack.m_pData, 1000 * 2);//设置10秒超时
//byte[] message = PareReceiveData(reciveBuffer, reciveBuffer.Length);
if (reciveBuffer != null)
{
byte[] bDB = new byte[2];
bDB[0] = reciveBuffer[6];
bDB[1] = reciveBuffer[7];
int iDB = Convert.ToInt32(StringChange.bytesToHexStr(bDB, 2), 16)/100;
return iDB;
}
}
return bResult;
}
catch (Exception ex)
{
return bResult;
}
}
public bool Device_SetRf(int iDbi, byte Antenna, WriteOrRead RorW)
{
bool bResult = false;
try
{
byte[] u16byte = new byte[2];
byte[] bCRC = new byte[22];
//获取功率AA 55 00 72 72 0D
MessagePack pMessagePack = new MessagePack();
if (RorW == WriteOrRead.Write)
{
pMessagePack.m_pData = new byte[28];
pMessagePack.m_pData[0] = 0xAA;
pMessagePack.m_pData[1] = 0x55;
pMessagePack.m_pData[2] = 0x14;
pMessagePack.m_pData[3] = 0x42;
pMessagePack.m_pData[4] = 0x01;
u16byte = BitConverter.GetBytes(iDbi); //功率
u16byte = StringChange.Swap16Bytes(u16byte); //协议里为大端在前
Array.Copy(u16byte, 0, pMessagePack.m_pData, 5, 2);
u16byte = BitConverter.GetBytes(iDbi); //功率
u16byte = StringChange.Swap16Bytes(u16byte); //协议里为大端在前
Array.Copy(u16byte, 0, pMessagePack.m_pData, 7, 2);
pMessagePack.m_pData[9] = 0x02;
u16byte = BitConverter.GetBytes(iDbi); //功率
u16byte = StringChange.Swap16Bytes(u16byte); //协议里为大端在前
Array.Copy(u16byte, 0, pMessagePack.m_pData, 10, 2);
u16byte = BitConverter.GetBytes(iDbi); //功率
u16byte = StringChange.Swap16Bytes(u16byte); //协议里为大端在前
Array.Copy(u16byte, 0, pMessagePack.m_pData, 12, 2);
pMessagePack.m_pData[14] = 0x03;
u16byte = BitConverter.GetBytes(iDbi); //功率
u16byte = StringChange.Swap16Bytes(u16byte); //协议里为大端在前
Array.Copy(u16byte, 0, pMessagePack.m_pData, 15, 2);
u16byte = BitConverter.GetBytes(iDbi); //功率
u16byte = StringChange.Swap16Bytes(u16byte); //协议里为大端在前
Array.Copy(u16byte, 0, pMessagePack.m_pData, 17, 2);
pMessagePack.m_pData[19] = 0x04;
u16byte = BitConverter.GetBytes(iDbi); //功率
u16byte = StringChange.Swap16Bytes(u16byte); //协议里为大端在前
Array.Copy(u16byte, 0, pMessagePack.m_pData, 20, 2);
u16byte = BitConverter.GetBytes(iDbi); //功率
u16byte = StringChange.Swap16Bytes(u16byte); //协议里为大端在前
Array.Copy(u16byte, 0, pMessagePack.m_pData, 22, 2);
Array.Copy(pMessagePack.m_pData, 2, bCRC, 0, 22);
pMessagePack.m_pData[24] = StringChange.CalculateVerify(bCRC, bCRC.Length);
pMessagePack.m_pData[25] = 0x0D;
}
LogInfo.Warn("》》》RFly-I160设备" + m_iDeviceId + ",IP:" + m_strIp + ",发送原始报文:" + bytesToHexStr(pMessagePack.m_pData, pMessagePack.m_pData.Length));
var waitClient = _tcpClient.CreateWaitingClient(new WaitingOptions()
{
FilterFunc = response =>
{
// 检查响应数据是否符合预期
if (response.ByteBlock != null && response.ByteBlock.Length > 0)
{
// 可以根据实际情况添加更多的检查逻辑
LogInfo.Warn("》》》RFly-I160设备" + m_iDeviceId + ",IP:" + m_strIp + ",接收原始报文:" + bytesToHexStr(response.ByteBlock.ToArray(0, response.ByteBlock.Length), response.ByteBlock.Length));
return true;
}
return false;
}
});
byte[] reciveBuffer = waitClient.SendThenReturn(pMessagePack.m_pData, 1000 * 2);//设置10秒超时
//Console.WriteLine($"收到回应消息:{bytesToHexStr(reciveBuffer, reciveBuffer.Length)}");
//byte[] message = PareReceiveData(reciveBuffer, reciveBuffer.Length);
if (RorW == WriteOrRead.Write)
{
if (reciveBuffer[3] == 0x42 && reciveBuffer[4] == 0x00)
{
return true;
}
}
//bool Set_OK;
//if (RorW == WriteOrRead.Read)
//{
@ -1414,6 +1696,232 @@ namespace Mesnac.DeviceAdapter.RFly_I160
{
throw new NotImplementedException();
}
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;
}
public byte[] PareReceiveData(byte[] buffer, int iLen)
{
RecvState enumRecvState = RecvState.WaitingBeginChar1_State;
byte[] m_szFullMessage = new byte[buffer.Length]; //此数组用于状态机
int m_iPosition = 0;
byte m_iVerify = 0;
int iBarcodeLength = 0;//条码长度
ArrayList m_FrecvData = new ArrayList();
//m_RFly_I160Adapter.LogInfo.Warn("RFly-I160进入状态机");
try
{
for (int i = 0; i < iLen; i++)
{
switch (enumRecvState)
{
case RecvState.WaitingBeginChar1_State: //开始接受数据帧1 0xBB
//m_RFly_I160Adapter.LogInfo.Warn("RFly-I160等待接收帧同步字符WaitingBeginChar1_State:0XBB");
Array.Clear(m_szFullMessage, 0, buffer.Length);//清空为0
if (buffer[i] == 0xBB)
{
//m_RFly_I160Adapter.LogInfo.Warn("Buffer数据为: " + StringChange.bytesToHexStr(buffer, buffer.Length));
m_szFullMessage[m_iPosition] = buffer[i];
m_iPosition++;
enumRecvState = RecvState.WaitingBeginChar2_State;
}
else
{
m_iPosition = 0;
enumRecvState = RecvState.WaitingBeginChar1_State;
}
break;
case RecvState.WaitingBeginChar2_State: //开始接受数据帧1 0xDD
//m_RFly_I160Adapter.LogInfo.Warn("RFly-I160等待接收帧同步字符WaitingBeginChar2_State:0XDD");
if (buffer[i] == 0xDD)
{
m_szFullMessage[m_iPosition] = buffer[i];
m_iPosition++;
enumRecvState = RecvState.WaitingForBarcodeLength_State;
}
else
{
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_RFly_I160Adapter.LogInfo.Warn("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
{
//m_RFly_I160Adapter.LogInfo.Warn("RFly-I160等待接受WaitingForEndChar_State:心跳");
m_szFullMessage[m_iPosition] = buffer[i];
m_iPosition++;
enumRecvState = RecvState.WaitingForEndChar_State;
}
else if (buffer[i] == 0x51)
{
m_szFullMessage[m_iPosition] = buffer[i];
m_iPosition++;
enumRecvState = RecvState.WaitingForStus_State;
}
else
{
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];
//m_RFly_I160Adapter.LogInfo.Warn("RFU620等待接受WaitingForEndChar_State:Noread");
lock (m_FrecvData)
{
m_FrecvData.Add(m_szFullMessage);
}
m_iPosition = 0;
i = iLen;
enumRecvState = RecvState.WaitingBeginChar1_State;
//m_RFly_I160Adapter.LogInfo.Warn("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_RFly_I160Adapter.LogInfo.Warn("解析的数据为: " + 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_iPosition = 0;
enumRecvState = RecvState.WaitingBeginChar1_State;
}
break;
case RecvState.WaitingForEndChar_State:
if (buffer[0] == 0xBB && buffer[1] == 0xDD && buffer[2] == 0x00) //此处为Noread数据显示
{
//m_RFly_I160Adapter.LogInfo.Warn("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_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);
}
}
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);
}
}
else
{
m_szFullMessage[m_iPosition] = buffer[i];
m_iPosition++;
if (buffer[i] == 0x0D)
{
//m_RFly_I160Adapter.LogInfo.Warn("RFly-I160准备发送");
lock (m_FrecvData)
{
m_FrecvData.Add(m_szFullMessage);
}
}
}
m_iPosition = 0;
enumRecvState = RecvState.WaitingBeginChar1_State;
//m_RFly_I160Adapter.LogInfo.Warn("RFly-I160状态机结束。");
break;
}
}
return m_szFullMessage;
}
catch (Exception ex)
{
LogInfo.Error(ex.Message);
return null;
}
}
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;
}
#endregion
}
}

@ -230,6 +230,7 @@ namespace Mesnac.DeviceAdapter.RFly_I160
}
return iNegate;
}
}
}

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net461" />
<package id="System.Buffers" version="4.5.1" targetFramework="net461" />
<package id="System.Memory" version="4.5.5" targetFramework="net461" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net461" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net461" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net461" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net461" />
<package id="TouchSocket" version="3.1.18" targetFramework="net461" />
<package id="TouchSocket.Core" version="3.1.18" targetFramework="net461" />
</packages>
Loading…
Cancel
Save