Compare commits

..

6 Commits
master ... Test

Author SHA1 Message Date
杨威 5f2eefec5e demo 2 months ago
杨威 954bac5bc8 test 2 months ago
杨威 d649cbbd8a test 2 months ago
杨威 aeddacaedd 更新dll 2 months ago
杨威 eab733f0ad demo 3 months ago
杨威 45605775c5 w 3 months ago

@ -36,14 +36,14 @@
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="Chloe, Version=5.27.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Chloe.5.27.0\lib\net46\Chloe.dll</HintPath>
<Reference Include="Chloe, Version=5.30.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Chloe.5.30.0\lib\net46\Chloe.dll</HintPath>
</Reference>
<Reference Include="Chloe.Extension, Version=5.25.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Chloe.Extension.5.25.0\lib\net46\Chloe.Extension.dll</HintPath>
</Reference>
<Reference Include="Chloe.SQLite, Version=5.27.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Chloe.SQLite.5.27.0\lib\net46\Chloe.SQLite.dll</HintPath>
<Reference Include="Chloe.SQLite, Version=5.30.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Chloe.SQLite.5.30.0\lib\net46\Chloe.SQLite.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />

@ -6,12 +6,5 @@ using System.Threading.Tasks;
namespace DNSD_DB.Entity
{
public class LightsEntity
{
public int Green { get; set; }
public int Yellow { get; set; }
public int Red { get; set; }
}
}

@ -18,6 +18,24 @@ namespace DNSD_DB.Entity
/// 行编号
/// </summary>
public int RowIndex { get; set; }
/// <summary>
/// RFID值
/// </summary>
public string RFIDValue { get; set; }
/// <summary>
/// 状态指示 0未操作 1正在操作 2准备操作 3已完成 4超时报警
/// </summary>
public int RFIDState { get; set; } = 0;
public int Green { get; set; }
public int Yellow { get; set; }
public int Red { get; set; }
}
public class RowEntity

@ -6,16 +6,5 @@ using System.Threading.Tasks;
namespace DNSD_DB.Entity
{
public class RFIDStatesEntity
{
/// <summary>
/// RFID值
/// </summary>
public string RFIDValue { get; set; }
/// <summary>
/// 状态指示 0未操作 1正在操作 2准备操作 3已完成 4超时报警
/// </summary>
public int RFIDState { get; set; } = 0;
}
}

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Chloe" version="5.27.0" targetFramework="net48" />
<package id="Chloe.SQLite" version="5.27.0" targetFramework="net48" />
<package id="Chloe" version="5.30.0" targetFramework="net48" />
<package id="Chloe.SQLite" version="5.30.0" targetFramework="net48" />
</packages>

@ -6,12 +6,12 @@ using System.Threading.Tasks;
namespace NDSD_Screwdriver
{
internal class DOperateEntity
public class DOperateEntity
{
public int port { get; set; }
/// <summary>
/// -1 DClose > 0 DTimeOpen =0 Dopen
/// -1 DClose > 1 DTimeOpen = 0 Dopen
/// </summary>
public int delay { get; set; }

@ -38,9 +38,6 @@
this.TestButton = new System.Windows.Forms.Button();
this.InitButton = new System.Windows.Forms.Button();
this.SettingButton = new System.Windows.Forms.Button();
this.ServerRestartButton = new System.Windows.Forms.Button();
this.StartServerButton = new System.Windows.Forms.Button();
this.ServerStopButton = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
((System.ComponentModel.ISupportInitialize)(this.LogDataGridView)).BeginInit();
@ -52,7 +49,7 @@
// DOTest
//
this.DOTest.Location = new System.Drawing.Point(15, 15);
this.DOTest.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.DOTest.Margin = new System.Windows.Forms.Padding(2);
this.DOTest.Name = "DOTest";
this.DOTest.Size = new System.Drawing.Size(63, 35);
this.DOTest.TabIndex = 0;
@ -69,12 +66,12 @@
this.RFIDValue});
this.LogDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.LogDataGridView.Location = new System.Drawing.Point(2, 16);
this.LogDataGridView.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.LogDataGridView.Margin = new System.Windows.Forms.Padding(2);
this.LogDataGridView.Name = "LogDataGridView";
this.LogDataGridView.RowHeadersVisible = false;
this.LogDataGridView.RowHeadersWidth = 51;
this.LogDataGridView.RowTemplate.Height = 27;
this.LogDataGridView.Size = new System.Drawing.Size(441, 1251);
this.LogDataGridView.Size = new System.Drawing.Size(441, 1043);
this.LogDataGridView.TabIndex = 1;
//
// logTime
@ -107,10 +104,10 @@
this.groupBox1.Controls.Add(this.LogDataGridView);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right;
this.groupBox1.Location = new System.Drawing.Point(713, 0);
this.groupBox1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.groupBox1.Margin = new System.Windows.Forms.Padding(2);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.groupBox1.Size = new System.Drawing.Size(445, 1269);
this.groupBox1.Padding = new System.Windows.Forms.Padding(2);
this.groupBox1.Size = new System.Drawing.Size(445, 1061);
this.groupBox1.TabIndex = 2;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "日志";
@ -134,10 +131,10 @@
this.ScrewdriverMonitor.ForeColor = System.Drawing.Color.Black;
this.ScrewdriverMonitor.HeaderColor = System.Drawing.Color.Black;
this.ScrewdriverMonitor.Location = new System.Drawing.Point(0, 0);
this.ScrewdriverMonitor.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.ScrewdriverMonitor.Margin = new System.Windows.Forms.Padding(2);
this.ScrewdriverMonitor.Name = "ScrewdriverMonitor";
this.ScrewdriverMonitor.RowsTotalCount = 13;
this.ScrewdriverMonitor.Size = new System.Drawing.Size(622, 1269);
this.ScrewdriverMonitor.Size = new System.Drawing.Size(622, 1061);
this.ScrewdriverMonitor.TabIndex = 3;
this.ScrewdriverMonitor.Text = "hslTable1";
this.ScrewdriverMonitor.TopHeaderColor = System.Drawing.Color.Black;
@ -149,7 +146,7 @@
// TestButton
//
this.TestButton.Location = new System.Drawing.Point(15, 113);
this.TestButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.TestButton.Margin = new System.Windows.Forms.Padding(2);
this.TestButton.Name = "TestButton";
this.TestButton.Size = new System.Drawing.Size(63, 36);
this.TestButton.TabIndex = 4;
@ -160,7 +157,7 @@
// InitButton
//
this.InitButton.Location = new System.Drawing.Point(15, 70);
this.InitButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.InitButton.Margin = new System.Windows.Forms.Padding(2);
this.InitButton.Name = "InitButton";
this.InitButton.Size = new System.Drawing.Size(63, 30);
this.InitButton.TabIndex = 7;
@ -170,8 +167,8 @@
//
// SettingButton
//
this.SettingButton.Location = new System.Drawing.Point(15, 400);
this.SettingButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.SettingButton.Location = new System.Drawing.Point(15, 179);
this.SettingButton.Margin = new System.Windows.Forms.Padding(2);
this.SettingButton.Name = "SettingButton";
this.SettingButton.Size = new System.Drawing.Size(63, 62);
this.SettingButton.TabIndex = 8;
@ -179,52 +176,16 @@
this.SettingButton.UseVisualStyleBackColor = true;
this.SettingButton.Click += new System.EventHandler(this.SettingButton_Click);
//
// ServerRestartButton
//
this.ServerRestartButton.Location = new System.Drawing.Point(15, 327);
this.ServerRestartButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.ServerRestartButton.Name = "ServerRestartButton";
this.ServerRestartButton.Size = new System.Drawing.Size(63, 54);
this.ServerRestartButton.TabIndex = 9;
this.ServerRestartButton.Text = "重启服务器";
this.ServerRestartButton.UseVisualStyleBackColor = true;
this.ServerRestartButton.Click += new System.EventHandler(this.ServerRestartButton_Click);
//
// StartServerButton
//
this.StartServerButton.Location = new System.Drawing.Point(15, 169);
this.StartServerButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.StartServerButton.Name = "StartServerButton";
this.StartServerButton.Size = new System.Drawing.Size(63, 55);
this.StartServerButton.TabIndex = 10;
this.StartServerButton.Text = "手动启动服务器";
this.StartServerButton.UseVisualStyleBackColor = true;
this.StartServerButton.Click += new System.EventHandler(this.StartServerButton_Click);
//
// ServerStopButton
//
this.ServerStopButton.Location = new System.Drawing.Point(15, 250);
this.ServerStopButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.ServerStopButton.Name = "ServerStopButton";
this.ServerStopButton.Size = new System.Drawing.Size(63, 58);
this.ServerStopButton.TabIndex = 11;
this.ServerStopButton.Text = "手动关闭服务器";
this.ServerStopButton.UseVisualStyleBackColor = true;
this.ServerStopButton.Click += new System.EventHandler(this.ServerStopButton_Click);
//
// panel1
//
this.panel1.Controls.Add(this.DOTest);
this.panel1.Controls.Add(this.SettingButton);
this.panel1.Controls.Add(this.ServerRestartButton);
this.panel1.Controls.Add(this.ServerStopButton);
this.panel1.Controls.Add(this.InitButton);
this.panel1.Controls.Add(this.StartServerButton);
this.panel1.Controls.Add(this.TestButton);
this.panel1.Dock = System.Windows.Forms.DockStyle.Right;
this.panel1.Location = new System.Drawing.Point(622, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(91, 1269);
this.panel1.Size = new System.Drawing.Size(91, 1061);
this.panel1.TabIndex = 12;
//
// panel2
@ -233,18 +194,18 @@
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 0);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(622, 1269);
this.panel2.Size = new System.Drawing.Size(622, 1061);
this.panel2.TabIndex = 13;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1158, 1269);
this.ClientSize = new System.Drawing.Size(1158, 1061);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Controls.Add(this.groupBox1);
this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.Margin = new System.Windows.Forms.Padding(2);
this.Name = "MainForm";
this.Text = "拧紧枪监控主界面";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed);
@ -265,9 +226,6 @@
private System.Windows.Forms.Button TestButton;
private System.Windows.Forms.Button InitButton;
private System.Windows.Forms.Button SettingButton;
private System.Windows.Forms.Button ServerRestartButton;
private System.Windows.Forms.Button StartServerButton;
private System.Windows.Forms.Button ServerStopButton;
private System.Windows.Forms.DataGridViewTextBoxColumn logTime;
private System.Windows.Forms.DataGridViewTextBoxColumn LogValue;
private System.Windows.Forms.DataGridViewTextBoxColumn RFIDValue;

File diff suppressed because it is too large Load Diff

@ -40,6 +40,9 @@ namespace NDSD_Screwdriver
public String Com { get; set; }
public String ServiceIp { get; set; } = "tcp://127.0.0.1:7789";
}

@ -33,16 +33,16 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Chloe, Version=5.27.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Chloe.5.27.0\lib\net46\Chloe.dll</HintPath>
<Reference Include="Chloe, Version=5.30.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Chloe.5.30.0\lib\net46\Chloe.dll</HintPath>
</Reference>
<Reference Include="Chloe.SQLite, Version=5.27.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Chloe.SQLite.5.27.0\lib\net46\Chloe.SQLite.dll</HintPath>
<Reference Include="Chloe.SQLite, Version=5.30.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Chloe.SQLite.5.30.0\lib\net46\Chloe.SQLite.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="mscorlib" />
<Reference Include="NewLife.Core, Version=10.10.2024.803, Culture=neutral, PublicKeyToken=8343210f0b524456, processorArchitecture=MSIL">
<HintPath>..\packages\NewLife.Core.10.10.2024.803\lib\net461\NewLife.Core.dll</HintPath>
<Reference Include="NewLife.Core, Version=11.0.2024.827, Culture=neutral, PublicKeyToken=8343210f0b524456, processorArchitecture=MSIL">
<HintPath>..\packages\NewLife.Core.11.0.2024.827-beta1512\lib\net461\NewLife.Core.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>
@ -57,8 +57,8 @@
<HintPath>..\Dll\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Ports, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Ports.8.0.0\lib\net462\System.IO.Ports.dll</HintPath>
<Reference Include="System.IO.Ports, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Ports.9.0.0-preview.7.24405.7\lib\net462\System.IO.Ports.dll</HintPath>
</Reference>
<Reference Include="System.Management" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
@ -88,13 +88,13 @@
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="TouchSocket, Version=2.1.0.0, Culture=neutral, PublicKeyToken=5f39d7da98dac6a9, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.2.1.0-rc.11\lib\net472\TouchSocket.dll</HintPath>
<HintPath>..\packages\TouchSocket.2.1.0-rc.17\lib\net472\TouchSocket.dll</HintPath>
</Reference>
<Reference Include="TouchSocket.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=d6c415a2f58eda72, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.Core.2.1.0-rc.11\lib\net472\TouchSocket.Core.dll</HintPath>
<HintPath>..\packages\TouchSocket.Core.2.1.0-rc.17\lib\net472\TouchSocket.Core.dll</HintPath>
</Reference>
<Reference Include="TouchSocket.SerialPorts, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b0dfdf1c6b51c716, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.SerialPorts.2.1.0-rc.11\lib\net472\TouchSocket.SerialPorts.dll</HintPath>
<HintPath>..\packages\TouchSocket.SerialPorts.2.1.0-rc.17\lib\net472\TouchSocket.SerialPorts.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@ -122,8 +122,12 @@
</Compile>
<Compile Include="FormUtils.cs" />
<Compile Include="TestDataFactory.cs" />
<Compile Include="Tool\ClientFactory.cs" />
<Compile Include="Tool\DengTool.cs" />
<Compile Include="Tool\MyFixedHeaderRequestInfo.cs" />
<Compile Include="Tool\QingTcpClient2.cs" />
<Compile Include="Tool\SerialPortFactory1.cs" />
<Compile Include="Tool\TighteningResult.cs" />
<EmbeddedResource Include="FrmSetting.resx">
<DependentUpon>FrmSetting.cs</DependentUpon>
</EmbeddedResource>
@ -181,7 +185,7 @@
</Content>
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\TouchSocket.Core.2.1.0-rc.11\analyzers\dotnet\cs\TouchSocket.Core.SourceGenerator.dll" />
<Analyzer Include="..\packages\TouchSocket.Core.2.1.0-rc.17\analyzers\dotnet\cs\TouchSocket.Core.SourceGenerator.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -33,6 +33,7 @@ namespace NDSD_Screwdriver
private ICache cache = Cache.Default;
public ScrewdriverTest()
{
DOperate = new DOperate();
InitializeComponent();
cache.Set("Test", DateTime.Now);
@ -97,15 +98,11 @@ namespace NDSD_Screwdriver
MessageBox.Show("属性值无效!");
return;
}
Thread thread = new Thread(() =>
for (int i = 0; i <= 16; i++)
{
for (int i = 0; i <= 16; i++)
{
DOperate.DOpen(i);
Thread.Sleep(span);
}
});
thread.Start();
DOperate.DOpen(i);
Thread.Sleep(200);
}
}
private void ScrewdriverTest_FormClosed(object sender, FormClosedEventArgs e)

@ -15,9 +15,9 @@ namespace NDSD_Screwdriver
List<string> ls = new List<string>
{
"E0040150B8C12108",
"E0040150B8C170F6",
"E0040150B8C1393A",
"E0040150B8C0512F",
"E0040150B8C170F6",
"E0040150B8C12100"
};

@ -0,0 +1,46 @@
using System;
using System.Text;
using TouchSocket.Sockets;
namespace NDSD_Screwdriver.Tool
{
public class ClientFactory
{
TcpClient client = new TcpClient();
private IWaitingClient<ITcpClient, IReceiverResult> waitClient;
public ClientFactory(string ip)
{
client.ConnectAsync(ip).ConfigureAwait(false).GetAwaiter().GetResult();
//调用CreateWaitingClient获取到IWaitingClient的对象。
waitClient = client.CreateWaitingClient(new WaitingOptions()
{
FilterFunc = response => //设置用于筛选的fun委托当返回为true时才会响应返回
true
});
}
public byte[] Send(string str)
{
//然后使用SendThenReturn。
byte[] returnData = waitClient.SendThenReturn(Encoding.UTF8.GetBytes(str));
Console.WriteLine($"收到回应消息:{Encoding.UTF8.GetString(returnData)}");
return returnData;
//同时如果适配器收到数据后返回的并不是字节而是IRequestInfo对象时可以使用SendThenResponse.
//ResponsedData responsedData = await waitClient.SendThenResponse(Encoding.UTF8.GetBytes("RRQM"));
//IRequestInfo requestInfo = responsedData.RequestInfo;//同步收到的RequestInfo
}
}
}

@ -0,0 +1,102 @@
using NDSD_TouchSocket;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace NDSD_Screwdriver.Tool
{
public class DengTool
{
private Queue<DOperateEntity> _methodQueue;
private CancellationTokenSource sendCancellationTokenSource;
/// <summary>
/// 输出端口操作
/// </summary>
private DOperate DOperateInfo;
public DengTool()
{
DOperateInfo = new DOperate();
_methodQueue =new Queue<DOperateEntity>();
}
/// <summary>
/// RFID刷新任务
/// </summary>
// private void SendRunningTask()
// {
// sendCancellationTokenSource = new CancellationTokenSource();
// Task.Run(() =>
// {
// while (!sendCancellationTokenSource.Token.IsCancellationRequested)
// {
// while (_methodQueue.Count > 0)
// {
// var q = _methodQueue.Dequeue();
// // -1 DClose > 0 DTimeOpen =0 Dopen
// //-1 DClose > 0 DTimeOpen =0 Dopen
// if (q.delay == -1)
// {
// DOperateInfo.DClose(q.port);
// }
//
// if (q.delay == 0)
// {
// DOperateInfo.DClose(q.port);
// Thread.Sleep(100); // 模拟一些长时间的工作
// DOperateInfo.DOpen(q.port);
// }
//
// if (q.delay ==1)
// {
//
// DOperateInfo.DTimeOpen(q.port, q.delay);
// }
//
// Thread.Sleep(100); // 模拟一些长时间的工作
// }
//
// Thread.Sleep(10); // 模拟一些长时间的工作
// }
// }, sendCancellationTokenSource.Token);
// }
public void AddMq(DOperateEntity entity)
{
_methodQueue.Enqueue(entity);
}
public void Stop()
{
_methodQueue.Clear();
sendCancellationTokenSource.Cancel();
}
public void Start()
{
// SendRunningTask();
}
public void Restart()
{
Stop();
Thread.Sleep(200);
Start();
}
}
}

@ -0,0 +1,163 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using NewLife.Log;
using TouchSocket.Core;
using TouchSocket.Sockets;
using Timer = System.Timers.Timer;
namespace NDSD_Screwdriver.Tool
{
public class QingTcpClient2
{
public TighteningResult gitResult { get; }
public int TighteningStatus => gitResult.TighteningStatus;
public int IsOk { get; set; } = -1;
public string updateTime { get; set; }
private int eable = -1;
TcpClient tcpClient = new TcpClient();
private Timer timer1 = null;
public QingTcpClient2(string str = "192.168.5.212:4545")
{
gitResult = new TighteningResult();
tcpClient.Connecting = (client, e) => EasyTask.CompletedTask;//即将连接到服务器此时已经创建socket但是还未建立tcp
tcpClient.Connected = (client, e) => EasyTask.CompletedTask;//成功连接到服务器
tcpClient.Setup(new TouchSocketConfig()
.SetRemoteIPHost(str)
.ConfigureContainer(a =>
{
a.AddConsoleLogger();//添加一个日志注入
}));
tcpClient.Received = (client, e) =>
{
//从服务器收到信息。但是一般byteBlock和requestInfo会根据适配器呈现不同的值。
var mes = e.ByteBlock.Span.ToString(Encoding.ASCII);
var sb = Sub(mes);
XTrace.WriteLine("控制器返回:"+mes);
switch (sb)
{
case "0061":
gitResult.msg = mes;
XTrace.WriteLine(gitResult.Timestamp.ToFullString());
XTrace.WriteLine(gitResult.TighteningStatus.ToString());
client.Send("00200062001 \0");
break;
}
// switch (sb)
// {
// case "0002":
// switch (eable)
// {
// case 1:
// client.Send("00200043 \0");
// break;
// case 0:
// client.Send("00200042 \0");
// break;
// }
// eable = -1;
// break;
// case "0043":
// client.Send("00300064001 0000000000\0");
// break;
//
// case "0065":
// IsOk = mes.Substring(96, 19).ToInt();
// updateTime = mes.Substring(95, 1);
// break;
// }
// XTrace.WriteLine($"客户端接收到信息:{mes}");
return EasyTask.CompletedTask;
};
tcpClient.Connect();
Begin();
Thread.Sleep(100);
Satus();
timer1 = new Timer();
timer1.Enabled = true;
timer1.Elapsed += timer1_Tick;
timer1.Interval = 500; //设置时间间隔毫秒为单位单位Ms
timer1.Start();
}
private string Sub(string str)
{
string mes = "";
var length = str.TrimStart().Length;
if (length >= 9)
{
mes = str.Substring(4, 4);
}
if (mes == "0005" && length >= 24)
{
mes = str.Substring(20, 4);
}
return mes;
}
private void timer1_Tick(object sender, EventArgs e)
{
tcpClient.Send("00209999 \0");
}
public void Begin()
{
tcpClient.Send("00200001 \0");
}
public void Enable()
{
// XTrace.WriteLine("枪发送使能");
tcpClient.Send("00200043 \0");
}
public void Close()
{
// XTrace.WriteLine("枪发送关闭");
tcpClient.Send("00200042 \0");
}
public void Satus()
{
tcpClient.Send("00200060001 \0");
}
public void OK()
{
tcpClient.Send("00200062001 \0");
}
}
}

@ -3,7 +3,8 @@ using NewLife.Log;
using NewLife;
using System.IO.Ports;
using System.Net.Http;
using NewLife.Http;
using TouchSocket.Core;
using TouchSocket.SerialPorts;
using TouchSocket.Sockets;
@ -18,7 +19,7 @@ namespace NDSD_Screwdriver.Tool
public SerialPortFactory(string portName)
{
clientSerialPortClient.Connecting = (client, e) => EasyTask.CompletedTask;//即将连接到端口
clientSerialPortClient.Connected = (client, e) => { return EasyTask.CompletedTask; };//成功连接到端口
clientSerialPortClient.Connected = (client, e) => EasyTask.CompletedTask;//成功连接到端口
clientSerialPortClient.Setup(new TouchSocket.Core.TouchSocketConfig()
.SetSerialPortOption(new SerialPortOption()
{
@ -29,7 +30,7 @@ namespace NDSD_Screwdriver.Tool
StopBits = System.IO.Ports.StopBits.One //停止位
}).SetSerialDataHandlingAdapter(() => new MyFixedHeaderCustomDataHandlingAdapter()));
//clientSerialPortClient.Connect();
clientSerialPortClient.Connect();
waitClient = clientSerialPortClient.CreateWaitingClient(new WaitingOptions()
{
@ -47,7 +48,8 @@ namespace NDSD_Screwdriver.Tool
try
{
ResponsedData responsedData = waitClient.SendThenResponse(new byte[] { 0x00, 0x03, 0x00, 0x50, 0x00, 0x04, 0x45, 0xC9 });
ResponsedData responsedData = waitClient.SendThenResponse(new byte[]
{ 0x00, 0x03, 0x00, 0x50, 0x00, 0x04, 0x45, 0xC9 },500);
IRequestInfo requestInfo = responsedData.RequestInfo;
var myFixedHeaderRequestInfo = requestInfo as MyFixedHeaderRequestInfo;
return myFixedHeaderRequestInfo?.GetBody();

@ -0,0 +1,41 @@
using System;
namespace NDSD_Screwdriver.Tool
{
public class TighteningResult
{
public string msg { set; get; } = "";
public bool IsOk => msg.Length > 0;
public int CellID => int.Parse(msg.Substring(22, 4));
public int ChannelID => int.Parse(msg.Substring(28, 2));
public string ControllerName => msg.Substring(32, 25).Trim();
public string VINNumber => msg.Substring(59, 25).Trim();
public int JobID => int.Parse(msg.Substring(86, 2));
public int ParametersetID => int.Parse(msg.Substring(90, 3));
public int Batchsize => int.Parse(msg.Substring(95, 4));
public int Batchcounter => int.Parse(msg.Substring(101, 4));
// 0=tightening NG, 1=tightening OK
public int TighteningStatus => int.Parse(msg.Substring(107, 1));
//0=Low, 1=OK, 2=High
public int Torquestatus => int.Parse(msg.Substring(110, 1));
public int Anglestatus => int.Parse(msg.Substring(113, 1));
public double TorqueMinlimit => double.Parse(msg.Substring(116, 6)) / 100.0;
public double TorqueMaxlimit => double.Parse(msg.Substring(124, 6)) / 100.0;
public double Torquefinaltarget => double.Parse(msg.Substring(132, 6)) / 100.0;
public string strVal => msg.Substring(140, 6);
public double Torque => double.Parse(strVal) / 100.0;
public int AngleMin => int.Parse(msg.Substring(148, 5));
public int AngleMax => int.Parse(msg.Substring(155, 5));
public int FinalAngleTarget => int.Parse(msg.Substring(162, 5));
public int Angle => int.Parse(strVal);
public DateTime Timestamp => DateTime.Parse($"{msg.Substring(176, 10)} {msg.Substring(187, 8)}");
}
}

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Chloe" version="5.27.0" targetFramework="net48" />
<package id="Chloe.SQLite" version="5.27.0" targetFramework="net48" />
<package id="NewLife.Core" version="10.10.2024.803" targetFramework="net48" />
<package id="Chloe" version="5.30.0" targetFramework="net48" />
<package id="Chloe.SQLite" version="5.30.0" targetFramework="net48" />
<package id="NewLife.Core" version="11.0.2024.827-beta1512" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.IO.Ports" version="8.0.0" targetFramework="net48" />
<package id="System.IO.Ports" version="9.0.0-preview.7.24405.7" 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="6.0.0" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
<package id="TouchSocket" version="2.1.0-rc.11" targetFramework="net48" />
<package id="TouchSocket.Core" version="2.1.0-rc.11" targetFramework="net48" />
<package id="TouchSocket.SerialPorts" version="2.1.0-rc.11" targetFramework="net48" />
<package id="TouchSocket" version="2.1.0-rc.17" targetFramework="net48" />
<package id="TouchSocket.Core" version="2.1.0-rc.17" targetFramework="net48" />
<package id="TouchSocket.SerialPorts" version="2.1.0-rc.17" targetFramework="net48" />
</packages>

@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NewLife;
using NewLife.Log;
namespace NDSD_TouchSocket
{
@ -37,6 +38,7 @@ namespace NDSD_TouchSocket
/// <param name="delay">延迟1代表0.1s/100ms</param>
public void DTimeOpen(int port, int delay)
{
XTrace.WriteLine("发送延迟开灯指令:"+(int)port);
DTimeOpen((Port)(port + 4), delay);
}
@ -55,6 +57,7 @@ namespace NDSD_TouchSocket
/// <param name="port">int1-16</param>
public void DOpen(int port)
{
XTrace.WriteLine("发送开灯指令:"+(int)port);
DOpen((Port)(port + 4));
}
@ -67,12 +70,15 @@ namespace NDSD_TouchSocket
Server.SendMessage(sendAnalysis.DCloseDataAnlysis((byte)port));
}
/// <summary>
/// int控制接口关
/// </summary>
/// <param name="port">int1-16</param>
public void DClose(int port)
{
XTrace.WriteLine("发送关灯指令:"+(int)port);
DClose((Port)(port + 4));
}
}

@ -33,8 +33,8 @@
<ItemGroup>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="mscorlib" />
<Reference Include="NewLife.Core, Version=10.10.2024.803, Culture=neutral, PublicKeyToken=8343210f0b524456, processorArchitecture=MSIL">
<HintPath>..\packages\NewLife.Core.10.10.2024.803\lib\net461\NewLife.Core.dll</HintPath>
<Reference Include="NewLife.Core, Version=11.0.2024.827, Culture=neutral, PublicKeyToken=8343210f0b524456, processorArchitecture=MSIL">
<HintPath>..\packages\NewLife.Core.11.0.2024.827-beta1512\lib\net461\NewLife.Core.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\NDSD-Screwdriver\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
@ -45,8 +45,8 @@
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Ports, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Ports.8.0.0\lib\net462\System.IO.Ports.dll</HintPath>
<Reference Include="System.IO.Ports, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Ports.9.0.0-preview.7.24405.7\lib\net462\System.IO.Ports.dll</HintPath>
</Reference>
<Reference Include="System.Management" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
@ -74,13 +74,13 @@
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="TouchSocket, Version=2.1.0.0, Culture=neutral, PublicKeyToken=5f39d7da98dac6a9, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.2.1.0-rc.11\lib\net472\TouchSocket.dll</HintPath>
<HintPath>..\packages\TouchSocket.2.1.0-rc.17\lib\net472\TouchSocket.dll</HintPath>
</Reference>
<Reference Include="TouchSocket.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=d6c415a2f58eda72, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.Core.2.1.0-rc.11\lib\net472\TouchSocket.Core.dll</HintPath>
<HintPath>..\packages\TouchSocket.Core.2.1.0-rc.17\lib\net472\TouchSocket.Core.dll</HintPath>
</Reference>
<Reference Include="TouchSocket.SerialPorts, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b0dfdf1c6b51c716, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.SerialPorts.2.1.0-rc.11\lib\net472\TouchSocket.SerialPorts.dll</HintPath>
<HintPath>..\packages\TouchSocket.SerialPorts.2.1.0-rc.17\lib\net472\TouchSocket.SerialPorts.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@ -96,7 +96,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\TouchSocket.Core.2.1.0-rc.11\analyzers\dotnet\cs\TouchSocket.Core.SourceGenerator.dll" />
<Analyzer Include="..\packages\TouchSocket.Core.2.1.0-rc.17\analyzers\dotnet\cs\TouchSocket.Core.SourceGenerator.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NewLife;
using NewLife.Log;
using TouchSocket.Core;
namespace NDSD_TouchSocket
@ -50,6 +52,8 @@ namespace NDSD_TouchSocket
public byte[] DOpenDataAnalysis(byte port)
{
string CrcData = DOperateHead + port.ToString("X2") + DOpenData; //结合
XTrace.WriteLine("deng:"+CrcData);
return CrcCombine(CrcData);
}
@ -61,7 +65,11 @@ namespace NDSD_TouchSocket
public byte[] DCloseDataAnlysis(byte port)
{
string CrcData = DOperateHead + port.ToString("X2") + DCloseData; //结合
return CrcCombine(CrcData);
var by= CrcCombine(CrcData);
return by;
}
/// <summary>

@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NewLife;
using NewLife.Log;
using TouchSocket.Core;
using TouchSocket.Sockets;
@ -28,12 +30,12 @@ namespace NDSD_TouchSocket
{
service.Connecting = (client, e) =>
{
Console.WriteLine(client.IP + " 正在连接");
XTrace.WriteLine(client.IP + " 正在连接");
return EasyTask.CompletedTask;
};//有客户端正在连接
service.Connected = (client, e) =>
{
Console.WriteLine(client.IP + " 成功连接");
XTrace.WriteLine(client.IP + " 成功连接");
service.ResetIdAsync(client.Id, client.IP);
this.ClientIP = client.IP;
this.ClientPort = client.Port.ToString();
@ -41,12 +43,12 @@ namespace NDSD_TouchSocket
};//有客户端成功连接
service.Closing = (client, e) =>
{
Console.WriteLine(client.IP + " 正在断开连接");
XTrace.WriteLine(client.IP + " 正在断开连接");
return EasyTask.CompletedTask;
};//有客户端正在断开连接,只有当主动断开时才有效。
service.Closed = (client, e) =>
{
Console.WriteLine(client.IP + " 断开连接");
XTrace.WriteLine(client.IP + " 断开连接");
return EasyTask.CompletedTask;
};//有客户端断开连接
service.Received = (client, e) =>
@ -56,7 +58,8 @@ namespace NDSD_TouchSocket
//logHelper.Info($"已从{client.IP}:{client.Port}接收到信息:{mes}");
//BufferMemory(BufferAnalysis.SplitByteArray(e.ByteBlock.Span.ToArray(), 0, e.ByteBlock.Length));
var byte2 = BufferAnalysis.SplitByteArray(e.ByteBlock.Span.ToArray(), 0, e.ByteBlock.Length);
XTrace.WriteLine(byte2.ToHex(" "));
return EasyTask.CompletedTask;
};
@ -178,17 +181,6 @@ namespace NDSD_TouchSocket
}
}
//private void BufferMemory(byte[] bytes)
//{
// if (bytes[4] == 0x00 && bytes[5] == 0xB9)
// {
// BufferAnalysis.JudgeSingle(false);
// }
// else if (bytes[4] == 0xFF && bytes[5] == 0xF9)
// {
// BufferAnalysis.JudgeSingle(true);
// }
//}
}
}

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NewLife.Core" version="10.10.2024.803" targetFramework="net48" />
<package id="NewLife.Core" version="11.0.2024.827-beta1512" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.IO.Ports" version="8.0.0" targetFramework="net48" />
<package id="System.IO.Ports" version="9.0.0-preview.7.24405.7" 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="6.0.0" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
<package id="TouchSocket" version="2.1.0-rc.11" targetFramework="net48" />
<package id="TouchSocket.Core" version="2.1.0-rc.11" targetFramework="net48" />
<package id="TouchSocket.SerialPorts" version="2.1.0-rc.11" targetFramework="net48" />
<package id="TouchSocket" version="2.1.0-rc.17" targetFramework="net48" />
<package id="TouchSocket.Core" version="2.1.0-rc.17" targetFramework="net48" />
<package id="TouchSocket.SerialPorts" version="2.1.0-rc.17" targetFramework="net48" />
</packages>
Loading…
Cancel
Save