change - 解决问题

master
SoulStar 1 month ago
parent 11a501e7fb
commit 821cf907f6

@ -5,7 +5,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace NDSD_Screwdriver namespace NDSD_Screwdriver.Entity
{ {
public class MonitorEntity public class MonitorEntity
{ {

@ -1,9 +1,12 @@
using NDSD_TouchSocket; using DNSD_DB;
using NDSD_Screwdriver.Entity;
using NDSD_TouchSocket;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing; using System.Drawing;
using System.Drawing.Text;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -43,7 +46,7 @@ namespace NDSD_Screwdriver
/// <summary> /// <summary>
/// RFID列表 /// RFID列表
/// </summary> /// </summary>
string[] RFIDs = new string[] public string[] RFIDs = new string[]
{ {
"1111222233334444", "1111222233334444",
"2222222233334444", "2222222233334444",
@ -60,6 +63,7 @@ namespace NDSD_Screwdriver
{ {
MessageBox.Show("服务端打开失败!"); MessageBox.Show("服务端打开失败!");
} }
} }
/// <summary> /// <summary>
@ -122,7 +126,13 @@ namespace NDSD_Screwdriver
/// <param name="e"></param> /// <param name="e"></param>
private void TestButton1_Click(object sender, EventArgs e) private void TestButton1_Click(object sender, EventArgs e)
{ {
if(RFIDs.Length == 0)
{
MessageBox.Show("没有值,请先设置。");
}
SetNowRowsLightState(FormUtils.TestRamColor()); SetNowRowsLightState(FormUtils.TestRamColor());
RefreshRoll(); RefreshRoll();
if (++NowRowIndex >= RFIDs.Length) if (++NowRowIndex >= RFIDs.Length)
{ {
@ -132,6 +142,7 @@ namespace NDSD_Screwdriver
private void InitButton_Click(object sender, EventArgs e) private void InitButton_Click(object sender, EventArgs e)
{ {
NowRowIndex = 0;
InitMonitirIntity(); InitMonitirIntity();
SetRFIDValue(RFIDs); SetRFIDValue(RFIDs);
} }
@ -205,6 +216,7 @@ namespace NDSD_Screwdriver
private void SetNowRowsLightState(LightState lightState) private void SetNowRowsLightState(LightState lightState)
{ {
monitorEntities[NowRowIndex].RowEntitys[2].Color = FormUtils.EnumColorToBrush(lightState); monitorEntities[NowRowIndex].RowEntitys[2].Color = FormUtils.EnumColorToBrush(lightState);
for (int i = 0; i < RFIDs.Length; i++) for (int i = 0; i < RFIDs.Length; i++)
{ {
monitorEntities[NowRowIndex].RowEntitys[0].Value = i == NowRowIndex ? "=>" : ""; monitorEntities[NowRowIndex].RowEntitys[0].Value = i == NowRowIndex ? "=>" : "";
@ -219,5 +231,7 @@ namespace NDSD_Screwdriver
monitorEntities[i].RowEntitys[0].Value = i == NowRowIndex ? "=>" : ""; monitorEntities[i].RowEntitys[0].Value = i == NowRowIndex ? "=>" : "";
} }
} }
} }
} }

@ -81,7 +81,7 @@
<Compile Include="MainForm.Designer.cs"> <Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon> <DependentUpon>MainForm.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="MonitorEntity.cs" /> <Compile Include="Entity\MonitorEntity.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ScrewdriverTest.cs"> <Compile Include="ScrewdriverTest.cs">

@ -10,7 +10,7 @@ namespace NDSD_TouchSocket
{ {
SendAnalysis sendAnalysis; SendAnalysis sendAnalysis;
private static TcpServer Server = TcpServer.Instance; TcpServer Server = TcpServer.Instance;
public DOperate() public DOperate()
{ {

@ -14,6 +14,8 @@ namespace NDSD_TouchSocket
public static TcpServer Instance => lazy.Value; public static TcpServer Instance => lazy.Value;
string ClientIP;
string ClientPort;
TcpService service = new TcpService(); TcpService service = new TcpService();
@ -30,6 +32,8 @@ namespace NDSD_TouchSocket
{ {
Console.WriteLine(client.IP + " 成功连接"); Console.WriteLine(client.IP + " 成功连接");
service.ResetIdAsync(client.Id, client.IP); service.ResetIdAsync(client.Id, client.IP);
this.ClientIP = client.IP;
this.ClientPort = client.Port.ToString();
return EasyTask.CompletedTask; return EasyTask.CompletedTask;
};//有客户端成功连接 };//有客户端成功连接
service.Closing = (client, e) => service.Closing = (client, e) =>
@ -89,12 +93,12 @@ namespace NDSD_TouchSocket
} }
} }
public async void SendMessage(byte[] bytes) public void SendMessage(byte[] bytes)
{ {
//尝试性获取 //尝试性获取
if (service.TryGetClient("192.168.0.178", out var sessionClient)) if (service.TryGetClient(ClientIP, out var sessionClient))
{ {
await sessionClient.SendAsync(bytes); sessionClient.SendAsync(bytes);
} }
return; return;
} }

Loading…
Cancel
Save