2 Commits

Author SHA1 Message Date
c88a8122cc 修改串口 2025-03-21 18:55:17 +08:00
9562d86449 金川部署需要修改Logo、文字提示
本分支在2014/11/11已经部署至金川现场
之后部署一次 合并提交一次
2024-11-11 17:43:16 +08:00
10 changed files with 68 additions and 59 deletions

View File

@ -21,8 +21,8 @@
<!--字体--> <!--字体-->
<FontFamily x:Key="IconFont">pack://application,,,/智能仓储WCS管理系统;component/Fonts/#iconfont</FontFamily> <FontFamily x:Key="IconFont">pack://application,,,/智能仓储WCS管理系统;component/Fonts/#iconfont</FontFamily>
<!--字符串--> <!--字符串-->
<sys:String x:Key="AboutInfo1">卓越盟讯</sys:String> <!--<sys:String x:Key="AboutInfo1">卓越盟讯</sys:String>-->
<!--<sys:String x:Key="AboutInfo1">金川数智</sys:String>--> <sys:String x:Key="AboutInfo1">金川数智</sys:String>
<sys:String x:Key="AboutInfo2">智造未来</sys:String> <sys:String x:Key="AboutInfo2">智造未来</sys:String>
</ResourceDictionary> </ResourceDictionary>
</Application.Resources> </Application.Resources>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 264 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 264 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -4,9 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using TouchSocket.Core; using System.IO.Ports;
using TouchSocket.SerialPorts;
using TouchSocket.Sockets;
using WCS管理系统.Views.Controls; using WCS管理系统.Views.Controls;
namespace WCS管理系统 namespace WCS管理系统
@ -24,33 +22,29 @@ namespace 智能仓储WCS管理系统
{ {
try try
{ {
var client = new SerialPortClient(); var _serialPort = new SerialPort();
//成功连接到端口
client.Connected = (client, e) => // 初始化串口配置
_serialPort = new SerialPort
{ {
Logs.Write($"扫码枪{client.MainSerialPort.PortName},已成功连接!", LogsType.Scanner); PortName = COM,
//初始化扫码枪对象 BaudRate = 9600,
Parity = Parity.None,
DataBits = 8,
StopBits = StopBits.One,
Handshake = Handshake.None,
Encoding = Encoding.UTF8 // 根据设备要求选择编码
};
_serialPort.Open();
var Scanner = new Scanner() var Scanner = new Scanner()
{ {
SerialPortClient = (SerialPortClient)client, SerialPort = _serialPort,
//ScannerDisplayControl = new ScannerDisplayControl(client.MainSerialPort.PortName), //ScannerDisplayControl = new ScannerDisplayControl(client.MainSerialPort.PortName),
COM = client.MainSerialPort.PortName, COM = COM,
TempCode = string.Empty, TempCode = string.Empty,
}; };
Scanners.Add(Scanner); Scanners.Add(Scanner);
return EasyTask.CompletedTask;
};
client.Setup(new TouchSocket.Core.TouchSocketConfig()
.SetSerialPortOption(new SerialPortOption()
{
BaudRate = 9600,//波特率
DataBits = 8,//数据位
Parity = System.IO.Ports.Parity.None,//校验位
PortName = COM,
StopBits = System.IO.Ports.StopBits.One//停止位
}));
client.Connect(LocalFile.Config.ScannerTimeOut, new CancellationToken());
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -63,7 +57,7 @@ namespace 智能仓储WCS管理系统
public class Scanner public class Scanner
{ {
public SerialPortClient SerialPortClient { get; set; } public SerialPort SerialPort { get; set; }
public ScannerDisplayControl ScannerDisplayControl { get; set; } public ScannerDisplayControl ScannerDisplayControl { get; set; }

View File

@ -30,6 +30,7 @@ using WCS.Model.ApiModel.MatBaseInfo;
using System.Security.Cryptography; using System.Security.Cryptography;
using Ping9719.WpfEx; using Ping9719.WpfEx;
using System.Diagnostics.Eventing.Reader; using System.Diagnostics.Eventing.Reader;
using System.IO.Ports;
namespace WCS管理系统.ViewModel namespace WCS管理系统.ViewModel
{ {
@ -41,28 +42,42 @@ namespace 智能仓储WCS管理系统.ViewModel
var scanners = ScannerManager.Scanners; var scanners = ScannerManager.Scanners;
foreach (var scanner in scanners) foreach (var scanner in scanners)
{ {
scanner.SerialPortClient.Received = (client, e) => scanner.SerialPort.DataReceived += SerialPort_DataReceived;
}
RevertScannerStatus();
}
public void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{ {
try
{
var _serialPort = sender as SerialPort;
if (_serialPort == null)
return;
//// 读取所有可用数据
string receivedData = _serialPort.ReadExisting();
//获取串口号 //获取串口号
var COM = client.MainSerialPort.PortName; var COM = _serialPort.PortName;
//获取扫码枪对象 //获取扫码枪对象
var scanner = ScannerManager.Scanners.Where(t => t.COM == COM).FirstOrDefault(); var scanner = ScannerManager.Scanners.Where(t => t.COM == COM).FirstOrDefault();
if (scanner == null) if (scanner == null)
return EasyTask.CompletedTask; return;
int newBytes = e.ByteBlock.Len; //int newBytes = e.ByteBlock.Len;
if (newBytes > 0) if (receivedData.Length > 0)
{ {
var currentScanedCode = Encoding.UTF8.GetString(e.ByteBlock, 0, e.ByteBlock.Len); var currentScanedCode = receivedData;
Logs.Write($"接收到扫码枪[{scanner.COM}]扫码数据{currentScanedCode}", LogsType.Scanner); Logs.Write($"接收到扫码枪[{scanner.COM}]扫码数据{currentScanedCode}", LogsType.Scanner);
scanner.TempCode += currentScanedCode; scanner.TempCode += currentScanedCode;
//校验末尾码 //校验末尾码
CheckDataCompleteness(scanner); CheckDataCompleteness(scanner);
scanner.ScannerDisplayControl.RefreshValues(scanner.ShelfCode, scanner.MatSn, scanner.InstoreUser); scanner.ScannerDisplayControl.RefreshValues(scanner.ShelfCode, scanner.MatSn, scanner.InstoreUser);
} }
return EasyTask.CompletedTask;
};
} }
RevertScannerStatus(); catch (Exception ex)
{
Console.WriteLine($"接收数据错误: {ex.Message}");
}
} }
#region Property #region Property

View File

@ -60,8 +60,8 @@
<PackageReference Include="SqlSugar" Version="5.1.4.149" /> <PackageReference Include="SqlSugar" Version="5.1.4.149" />
<PackageReference Include="SqlSugar.MySqlConnector" Version="5.1.3.42" /> <PackageReference Include="SqlSugar.MySqlConnector" Version="5.1.3.42" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.118" /> <PackageReference Include="System.Data.SQLite.Core" Version="1.0.118" />
<PackageReference Include="System.IO.Ports" Version="9.0.0" />
<PackageReference Include="TouchSocket.Http" Version="2.0.3" /> <PackageReference Include="TouchSocket.Http" Version="2.0.3" />
<PackageReference Include="TouchSocket.SerialPorts" Version="2.0.2" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -84,12 +84,12 @@
<Resource Include="Resources\Logo.ico" /> <Resource Include="Resources\Logo.ico" />
<Resource Include="Resources\Logo.png" /> <Resource Include="Resources\Logo.png" />
<Resource Include="Resources\主页.png" /> <Resource Include="Resources\主页.png" />
<Resource Include="Resources\入库.png"/> <Resource Include="Resources\入库.png" />
<Resource Include="Resources\出库.png"/> <Resource Include="Resources\出库.png" />
<Resource Include="Resources\盘点.png"/> <Resource Include="Resources\盘点.png" />
<Resource Include="Resources\查询.png"/> <Resource Include="Resources\查询.png" />
<Resource Include="Resources\货架.png"/> <Resource Include="Resources\货架.png" />
<Resource Include="Resources\物料.png"/> <Resource Include="Resources\物料.png" />
<Resource Include="Resources\权限.png" /> <Resource Include="Resources\权限.png" />
<Resource Include="Resources\调试.png" /> <Resource Include="Resources\调试.png" />
</ItemGroup> </ItemGroup>