diff --git a/Tools/SocketTool/SocketClient.cs b/Tools/SocketTool/SocketClient.cs index b8ddb55..c325dbc 100644 --- a/Tools/SocketTool/SocketClient.cs +++ b/Tools/SocketTool/SocketClient.cs @@ -131,8 +131,6 @@ public class SocketClient reConnectSocket.Start(); //Task.Factory.StartNew(ReConnectSocket); } - - /// /// 连接 socket /// @@ -163,15 +161,11 @@ public class SocketClient try { int bytes = socket.Receive(recvBytes, recvBytes.Length, SocketFlags.None); - if (bytes <= 0) - { - continue; - } + if (bytes <= 0) continue; + GetTcpData?.BeginInvoke(recvBytes, socketInfo.SocketIp ?? "", null, null); + if (GetTcpData != null) continue; string? recvStr = Encod?.GetString(recvBytes, 0, bytes); //此处编码方式请根据服务端发送的编码方式修改对应,否则可能造成部分字符乱码 - if (string.IsNullOrEmpty(recvStr)) - { - continue; - } + if (string.IsNullOrEmpty(recvStr)) continue; if (recvStr.Trim().Length > 0) { GetSocketMessage?.Invoke(recvStr, socketInfo.SocketIp ?? ""); @@ -325,6 +319,13 @@ public class SocketClient public event GetMessage? GetSocketMessage; + public delegate void GetData(byte[] data, string IPAddress); + /// + /// 字节返回事件 + /// + public event GetData? GetTcpData; + + public delegate void OffLine(string IPAddress); /// /// 当有地址掉线时触发 diff --git a/WcsMain/ApiServe/Controllers/Dto/WcsDto/ElTag/ShowNumRequest.cs b/WcsMain/ApiServe/Controllers/Dto/WcsDto/ElTag/ShowNumRequest.cs new file mode 100644 index 0000000..f4e23b5 --- /dev/null +++ b/WcsMain/ApiServe/Controllers/Dto/WcsDto/ElTag/ShowNumRequest.cs @@ -0,0 +1,20 @@ +using System.Text.Json.Serialization; + +namespace WcsMain.ApiServe.Controllers.Dto.WcsDto.ElTag; + +public class ShowNumRequest +{ + /// + /// 标签名称 + /// + [JsonPropertyName("tagName")] + public int? TagName { get; set; } + + /// + /// 标签显示的数字 + /// + [JsonPropertyName("value")] + public int? Num { get; set; } + + +} diff --git a/WcsMain/ApiServe/Controllers/WcsController/ElTagController.cs b/WcsMain/ApiServe/Controllers/WcsController/ElTagController.cs new file mode 100644 index 0000000..e61066d --- /dev/null +++ b/WcsMain/ApiServe/Controllers/WcsController/ElTagController.cs @@ -0,0 +1,36 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using WcsMain.ApiServe.ControllerFilter.ExceptionFilter; +using WcsMain.ApiServe.Controllers.Dto; +using WcsMain.ApiServe.Controllers.Dto.WcsDto.ElTag; +using WcsMain.ApiServe.Service.WcsService; + +namespace WcsMain.ApiServe.Controllers.WcsController; + + + +/// +/// 电子标签控制器的控制类 +/// +[Route("api/wcs/elTag")] +[ApiController] +[WcsExceptionFilter] +public class ElTagController(ElTagService elTagService) : ControllerBase +{ + + private readonly ElTagService _elTagService = elTagService; + + /// + /// 向标签发送显示数字 + /// + /// + /// + [HttpPost("showNum")] + public WcsApiResponse ShowNum([FromBody] ShowNumRequest request) + { + return _elTagService.ShowNum(request); + } + + + +} diff --git a/WcsMain/ApiServe/Service/WcsService/ElTagService.cs b/WcsMain/ApiServe/Service/WcsService/ElTagService.cs new file mode 100644 index 0000000..e9187c1 --- /dev/null +++ b/WcsMain/ApiServe/Service/WcsService/ElTagService.cs @@ -0,0 +1,20 @@ +using WcsMain.ApiServe.Controllers.Dto; +using WcsMain.ApiServe.Controllers.Dto.WcsDto.ElTag; +using WcsMain.ApiServe.Factory; +using WcsMain.WcsAttribute.AutoFacAttribute; + +namespace WcsMain.ApiServe.Service.WcsService; + +[Service] +public class ElTagService +{ + /// + /// 展示电子标签的数字 + /// + /// + /// + public WcsApiResponse ShowNum(ShowNumRequest request) + { + return WcsApiResponseFactory.Fail(); + } +} diff --git a/WcsMain/AppEntity/SystemData/AppConfigEntity.cs b/WcsMain/AppEntity/SystemData/AppConfigEntity.cs index 0b38d76..0a7a4d0 100644 --- a/WcsMain/AppEntity/SystemData/AppConfigEntity.cs +++ b/WcsMain/AppEntity/SystemData/AppConfigEntity.cs @@ -83,6 +83,16 @@ public class AppConfigEntity [ConfigKey("UseSocket")] public string? UseSocket { get; set; } + /// + /// 表示是否开启 Opr 连接 电子标签 + /// + /// + /// 0 - 关闭 + /// 1 - 开启 + /// + [ConfigKey("UseOpr")] + public string? UseOpr { get; set; } + /// /// 表示过账确认的方法 diff --git a/WcsMain/Common/CommonTool.cs b/WcsMain/Common/CommonTool.cs index 3fa1e78..0898011 100644 --- a/WcsMain/Common/CommonTool.cs +++ b/WcsMain/Common/CommonTool.cs @@ -3,6 +3,7 @@ using PlcTool.Siemens; using SqlSugar; using System.Diagnostics.CodeAnalysis; using WcsMain.Business.CommonAction; +using WcsMain.ElTag.Atop; using WcsMain.Tcp.Client; namespace WcsMain.Common; @@ -46,6 +47,19 @@ public class CommonTool #endregion + + #region 电子标签的 TCP 连接 + + /// + /// 电子标签的 TCP 连接 + /// + [NotNull] + public static OprTcpClient? OprTcpClient { get; set; } + + #endregion + + + #region WMS 接口 // 请查看 Plugins 文件夹 WmsWebApiPost diff --git a/WcsMain/DataBase/TableEntity/AppElTagBase.cs b/WcsMain/DataBase/TableEntity/AppElTagBase.cs new file mode 100644 index 0000000..7ec7f11 --- /dev/null +++ b/WcsMain/DataBase/TableEntity/AppElTagBase.cs @@ -0,0 +1,58 @@ +using SqlSugar; + +namespace WcsMain.DataBase.TableEntity; + + +[SugarTable("tbl_app_eltag_base")] +public class AppElTagBase +{ + /// + /// 点位 + /// + [SugarColumn(ColumnName = "location", IsPrimaryKey = true)] + public string? Location { get; set; } + + /// + /// 标签的名称 + /// + [SugarColumn(ColumnName = "tag_name")] + public string? TagName { get; set; } + + /// + /// 标签的ID + /// + [SugarColumn(ColumnName = "tag_id")] + public int? TagId { get; set; } + + /// + /// 标签类型 + /// + [SugarColumn(ColumnName = "tag_type")] + public int? TagType { get; set; } + + /// + /// 控制器的别称 + /// + [SugarColumn(ColumnName = "controller_diaplay_name")] + public string? ControllerDisplayName { get; set;} + + /// + /// 所属区域 + /// + [SugarColumn(ColumnName = "area")] + public string? Area { get; set; } + + /// + /// LED灯的默认状态 + /// + [SugarColumn(ColumnName = "led_status")] + public int? LedStatus { get; set; } + + /// + /// 备注 + /// + [SugarColumn(ColumnName = "remark")] + public string? Remark { get; set; } + + +} diff --git a/WcsMain/ElTag/Atop/AtopEnum/BuzzerType.cs b/WcsMain/ElTag/Atop/AtopEnum/BuzzerType.cs new file mode 100644 index 0000000..c8db8e1 --- /dev/null +++ b/WcsMain/ElTag/Atop/AtopEnum/BuzzerType.cs @@ -0,0 +1,14 @@ +namespace WcsMain.ElTag.Atop.AtopEnum; + +/// +/// 蜂鸣器类型 +/// +public enum BuzzerType +{ + OFF = 0, + ON = 1, + _2sec = 2, + _1sec = 3, + _0_5_sec = 4, + _0_25_sec = 5 +} diff --git a/WcsMain/ElTag/Atop/AtopEnum/LedColor.cs b/WcsMain/ElTag/Atop/AtopEnum/LedColor.cs new file mode 100644 index 0000000..b01e1ce --- /dev/null +++ b/WcsMain/ElTag/Atop/AtopEnum/LedColor.cs @@ -0,0 +1,14 @@ +namespace WcsMain.ElTag.Atop.AtopEnum; + +/// +/// 电子标签灯的颜色 +/// +public enum LedColor +{ + Red = 0, + Green = 1, + Orange = 2, + Blue = 3, + Pink = 4, + Cyan = 5, +} diff --git a/WcsMain/ElTag/Atop/AtopEnum/LedStatus.cs b/WcsMain/ElTag/Atop/AtopEnum/LedStatus.cs new file mode 100644 index 0000000..41a7155 --- /dev/null +++ b/WcsMain/ElTag/Atop/AtopEnum/LedStatus.cs @@ -0,0 +1,14 @@ +namespace WcsMain.ElTag.Atop.AtopEnum; + +/// +/// 灯的状态 +/// +public enum LedStatus +{ + LEDOff = 0, + LEDOn = 1, + _2secblinking = 2, + _1secblinking = 3, + _0_5secblinking = 4, + _0_25secblinking = 5 +} diff --git a/WcsMain/ElTag/Atop/AtopEnum/TagButtons.cs b/WcsMain/ElTag/Atop/AtopEnum/TagButtons.cs new file mode 100644 index 0000000..f300859 --- /dev/null +++ b/WcsMain/ElTag/Atop/AtopEnum/TagButtons.cs @@ -0,0 +1,11 @@ +namespace WcsMain.ElTag.Atop.AtopEnum; + +/// +/// 标签按钮 +/// +public enum TagButtons +{ + ConfirmKey = 1, + ShortageKey = 2, + AllKey = 3 +} diff --git a/WcsMain/ElTag/Atop/AtopEnum/TagMode.cs b/WcsMain/ElTag/Atop/AtopEnum/TagMode.cs new file mode 100644 index 0000000..121f122 --- /dev/null +++ b/WcsMain/ElTag/Atop/AtopEnum/TagMode.cs @@ -0,0 +1,10 @@ +namespace WcsMain.ElTag.Atop.AtopEnum; + +/// +/// 标签的模式 +/// +public enum TagMode +{ + Picking = 0, + Stock = 1 +} diff --git a/WcsMain/ElTag/Atop/BaseOprDataHandler.cs b/WcsMain/ElTag/Atop/BaseOprDataHandler.cs new file mode 100644 index 0000000..2dfc80c --- /dev/null +++ b/WcsMain/ElTag/Atop/BaseOprDataHandler.cs @@ -0,0 +1,18 @@ +using WcsMain.Common; +using WcsMain.Tcp.Client; +using WcsMain.Tcp.Entity; +using WcsMain.WcsAttribute.AutoFacAttribute; +using static SocketTool.SocketClient; + +namespace WcsMain.ElTag.Atop; + +/// +/// 电子标签收到数据的数据处理类 +/// +[Component] +public class BaseOprDataHandler +{ + + + +} diff --git a/WcsMain/ElTag/Atop/ConnectOprServe.cs b/WcsMain/ElTag/Atop/ConnectOprServe.cs new file mode 100644 index 0000000..d0f4acc --- /dev/null +++ b/WcsMain/ElTag/Atop/ConnectOprServe.cs @@ -0,0 +1,74 @@ +using WcsMain.Common; +using WcsMain.DataBase.Dao; +using WcsMain.DataBase.TableEntity; +using WcsMain.Enum.General; +using WcsMain.Enum.Tcp; +using WcsMain.Tcp.Entity; +using WcsMain.WcsAttribute.AutoFacAttribute; + +namespace WcsMain.ElTag.Atop; + +/// +/// 连接并接收电子标签信息 +/// +/// +[Component] +public class ConnectOprServe(AppTcpDao tcpDao, BaseOprDataHandler baseOprDataHandler) +{ + private readonly AppTcpDao _tcpDao = tcpDao; + private readonly BaseOprDataHandler _baseOprDataHandler = baseOprDataHandler; + + /// + /// 设置基本参数 + /// + public void SetBaseAction() + { + CommonTool.OprTcpClient = new OprTcpClient(); + CommonTool.OprTcpClient.SetConnecting((tcpData) => ConsoleLog.Info($"电子标签:{tcpData} 正在连接")); + CommonTool.OprTcpClient.SetConnectFailAction((tcpData, ex) => ConsoleLog.Warning($"电子标签:{tcpData} 连接失败,参考信息:{ex.Message}")); + CommonTool.OprTcpClient.SetConnectSuccess((tcpData) => ConsoleLog.Success($"电子标签:{tcpData} 连接成功")); + CommonTool.OprTcpClient.SetConnectOffline((tcpData) => ConsoleLog.Warning($"电子标签:{tcpData} 失去连接")); + CommonTool.OprTcpClient.SetGetData(GetData); + } + + /// + /// 连接电子标签 + /// + public void Connect() + { + Task.Factory.StartNew(() => + { + List? tcps = default; + while (true) + { + tcps = _tcpDao.Query(new AppTcp { TcpStatus = (int)TrueFalseEnum.TRUE, TcpType = (int)TcpType.Opr }); + if (tcps != default) break; + Thread.Sleep(5000); + continue; + } + if (tcps.Count == 0) return; + CommonTool.OprTcpClient.SetBaseTcpServe(tcps); + CommonTool.OprTcpClient.Connect(); + }, TaskCreationOptions.LongRunning); + } + + + + + /// + /// 收到数据处理方法 + /// + /// + /// + public void GetData(TcpServeConnectionData tcpServe, byte[] datas) + { + + } + + + + + + + +} diff --git a/WcsMain/ElTag/Atop/Entity/TagReturnInfo.cs b/WcsMain/ElTag/Atop/Entity/TagReturnInfo.cs new file mode 100644 index 0000000..95b315d --- /dev/null +++ b/WcsMain/ElTag/Atop/Entity/TagReturnInfo.cs @@ -0,0 +1,51 @@ +namespace WcsMain.ElTag.Atop.Entity; + +public class TagReturnInfo +{ + + /// + /// 按下的按键类型 + /// + /// + /// Data(1)= 16H “confirmatin key “ pressed + /// 43H “shotage button/down-count button” pressed + /// 25H “function button/up-count button” pressed. + /// + public int KeyType { get; set; } + + /// + /// 消息类型 + /// + /// + /// 01H:Tag busy,04H 功能键 + /// + public int MsgType { get; set; } + + /// + /// 提交信息 + /// + /// + /// 13卡键 + /// 10通讯超时 + /// + public int SubCommand { get; set; } + + /// + /// IP 地址 + /// + public string? Ip { get; set; } + + + + public int Abbr { get; set; } + + /// + /// 传回消息的端口 ---- 注意不是控制器端口 + /// + public int Port { get; set; } + + /// + /// 返回的数据 + /// + public string? Data { get; set; } +} diff --git a/WcsMain/ElTag/Atop/Entity/TagSendInfo.cs b/WcsMain/ElTag/Atop/Entity/TagSendInfo.cs new file mode 100644 index 0000000..2187093 --- /dev/null +++ b/WcsMain/ElTag/Atop/Entity/TagSendInfo.cs @@ -0,0 +1,98 @@ +using System.Drawing; +using WcsMain.ElTag.Atop.AtopEnum; + +namespace WcsMain.ElTag.Atop.Entity; + +/// +/// 发送到电子标签的信息 +/// +public class TagSendInfo +{ + /// + /// 展示标签的ID + /// + /// + /// + public static byte[] ShowTagId(byte tagId) + { + byte[] data = new byte[8]; + data[0] = 8; + data[1] = 0; + data[2] = 0x60; + data[6] = 0x13; + data[7] = tagId; + return data; + } + + /// + /// 标签重启 + /// + /// + /// + public static byte[] RestartTag(byte tagId) + { + byte[] data = new byte[8]; + data[0] = 8; + data[1] = 0; + data[2] = 0x60; + data[6] = 0x14; + data[7] = tagId; + return data; + } + + /// + /// 关闭标签 + /// + /// + /// + public static byte[] TurnOffTag(byte tagId) + { + byte[] data = new byte[8]; + data[0] = 8; + data[1] = 0; + data[2] = 0x60; + data[6] = 1; + data[7] = tagId; + return data; + } + + + + /// + /// 返回一个设置标签按钮灯颜色的报文 + /// + /// 标签的ID + /// 颜色枚举值 + /// + public static byte[] LedColor(byte tagId, LedColor ledColor = AtopEnum.LedColor.Green) + { + byte[] data = new byte[10]; + data[0] = 0x0A; + data[1] = 0; + data[2] = 0x60; + data[6] = 0x1F; + data[7] = tagId; + data[8] = 0; + data[9] = (byte)ledColor; + return data; + } + + /// + /// 返回一个设置按钮灯闪烁频率的报文 + /// + /// 标签的编号 + /// 闪烁频率 + /// + public static byte[] LedStatus(byte tagId, LedStatus ledStatus = AtopEnum.LedStatus._0_5secblinking) + { + byte[] data = new byte[10]; + data[0] = 0x0A; + data[1] = 0; + data[2] = 0x60; + data[6] = 0x1F; + data[7] = tagId; + data[8] = 4; + data[9] = (byte)ledStatus; + return data; + } +} diff --git a/WcsMain/ElTag/Atop/OprTcpClient.cs b/WcsMain/ElTag/Atop/OprTcpClient.cs new file mode 100644 index 0000000..663bf24 --- /dev/null +++ b/WcsMain/ElTag/Atop/OprTcpClient.cs @@ -0,0 +1,27 @@ +using SocketTool; +using System.Text; +using WcsMain.ElTag.Atop.Entity; +using WcsMain.Tcp.Client; +using WcsMain.WcsAttribute.AutoFacAttribute; + +namespace WcsMain.ElTag.Atop; + +/// +/// 电子标签主控制类 +/// +public class OprTcpClient : BaseTcpClient +{ + + + + /// + /// 连接电子标签客户端 + /// + public void Send() + { + + + + } + +} diff --git a/WcsMain/Enum/Tcp/TcpType.cs b/WcsMain/Enum/Tcp/TcpType.cs index af97bcd..8bd203d 100644 --- a/WcsMain/Enum/Tcp/TcpType.cs +++ b/WcsMain/Enum/Tcp/TcpType.cs @@ -5,8 +5,8 @@ /// public enum TcpType { - PLC = 0, - SCAN = 1, - + PLC = 0, // PLC + SCAN = 1, // 扫码器 + Opr = 2, // 电子标签 } diff --git a/WcsMain/StartAction/ServiceStart.cs b/WcsMain/StartAction/ServiceStart.cs index 669a394..5b646ab 100644 --- a/WcsMain/StartAction/ServiceStart.cs +++ b/WcsMain/StartAction/ServiceStart.cs @@ -9,6 +9,7 @@ using WcsMain.DataBase.Dao; using WcsMain.DataBase.TableEntity; using WcsMain.WcsAttribute.AppConfig; using WcsMain.Business.Convey; +using WcsMain.ElTag.Atop; namespace WcsMain.StartAction; @@ -17,7 +18,8 @@ namespace WcsMain.StartAction; /// [Component] public class ServiceStart(WcsCirculation wcsCirculation, ConnectPLCs connectPLCs, SocketOperation socketOperation, - AppStackerDao appStackerDao, AppLocationDao appLocationDao, AppConfigDao appConfigDao, ConnectPlcServe connectPlcServe) + AppStackerDao appStackerDao, AppLocationDao appLocationDao, AppConfigDao appConfigDao, ConnectPlcServe connectPlcServe, + ConnectOprServe connectOprServe) { private readonly AppConfigDao _appconfigDao = appConfigDao; private readonly AppLocationDao _applocationDao = appLocationDao; @@ -26,6 +28,7 @@ public class ServiceStart(WcsCirculation wcsCirculation, ConnectPLCs connectPLCs private readonly ConnectPLCs _connectPlcs = connectPLCs; private readonly WcsCirculation _wcsCirculation = wcsCirculation; private readonly ConnectPlcServe _connectPlcServe = connectPlcServe; + private readonly ConnectOprServe _connectOprServe = connectOprServe; private static string _errMsg = string.Empty; @@ -52,10 +55,10 @@ public class ServiceStart(WcsCirculation wcsCirculation, ConnectPLCs connectPLCs { /* 指定线程池规格 */ ThreadPool.SetMinThreads(30, 10); - CreatePlcClient(); // 连接 PLC 客户端 CreateSocketClient(); // Socket客户端 + ConnectOprServe(); // 连接 Opr 电子标签客户端 CreateCieculateTask();// 创建并启用定时器 } @@ -71,7 +74,7 @@ public class ServiceStart(WcsCirculation wcsCirculation, ConnectPLCs connectPLCs } /// - /// 创建并运行 Socket 客户端 + /// 创建并运行 Socket 客户端 ---- 待更新 /// public void CreateSocketClient() { @@ -81,6 +84,19 @@ public class ServiceStart(WcsCirculation wcsCirculation, ConnectPLCs connectPLCs } } + /// + /// 连接Opr电子标签客户端 + /// + public void ConnectOprServe() + { + if (CommonData.AppConfig.UseOpr == "1") // 1 表示允许连接电子标签 + { + _connectOprServe.SetBaseAction(); + _connectOprServe.Connect(); + } + } + + public void CreateTcpClient() { @@ -179,6 +195,4 @@ public class ServiceStart(WcsCirculation wcsCirculation, ConnectPLCs connectPLCs CommonData.AppLocations = appLocations; } - - } \ No newline at end of file diff --git a/WcsMain/Tcp/Client/BaseTcpClient.cs b/WcsMain/Tcp/Client/BaseTcpClient.cs index c03c22c..0692908 100644 --- a/WcsMain/Tcp/Client/BaseTcpClient.cs +++ b/WcsMain/Tcp/Client/BaseTcpClient.cs @@ -9,7 +9,6 @@ namespace WcsMain.Tcp.Client; /// /// Wcs 的Tcp 客户端 /// -[Component] public class BaseTcpClient { /// @@ -37,12 +36,18 @@ public class BaseTcpClient /// private Action? _getMessage; + /// + /// 获取数据事件 + /// + private Action? _getData; + public void SetConnecting(Action action) => _connecting = action; public void SetConnectFailAction(Action action) => _connectFail = action; public void SetConnectSuccess(Action action) => _connectSuccess = action; public void SetConnectOffline(Action action) => _connectOffline = action; public void GetMessage(Action action) => _getMessage = action; + public void SetGetData(Action action) => _getData = action; /// /// 当前需要连接的服务端数量 @@ -104,6 +109,7 @@ public class BaseTcpClient if (readLength > 0) { serveData.RecvMsgTime = DateTime.Now; + _getData?.BeginInvoke(serveData, bytes, null, null); _getMessage?.BeginInvoke(serveData, Encoding.ASCII.GetString(bytes), null, null); continue; } @@ -185,6 +191,45 @@ public class BaseTcpClient } } + /// + /// 向指定别称的客户端发送消息 + /// + /// + /// + /// + public TcpClientSendResult Send(byte[] value, params string[] displayNames) + { + TcpClientSendResult tcpClientSendResult = new() { Success = true }; + // 指定发送 + List sendTasks = []; + foreach (var tcpServe in tcpServeConnectionDatas) + { + if (displayNames.Length > 0 && !displayNames.Contains(tcpServe.DisplayName)) { continue; } + if (tcpServe.TcpClient == default || tcpServe.IsConnected != Enum.General.TrueFalseEnum.TRUE) + { + tcpClientSendResult = new() { Success = false, Exception = new Exception($"别称:{tcpServe.DisplayName} 的Tcp连接不可用") }; + } + else + { + sendTasks.Add(Task.Factory.StartNew(() => + { + var sendNetworkStream = tcpServe.TcpClient.GetStream(); + try + { + sendNetworkStream.Write(value); + } + catch (Exception ex) + { + tcpClientSendResult = new() { Success = false, Exception = ex }; + } + })); + } + } + if (sendTasks.Count == 0) return new() { Success = false, Exception = new Exception("没有要发送的客户端") }; + Task.WaitAll([.. sendTasks]); + return tcpClientSendResult; + } + /// /// 向指定别称的客户端发送消息 /// diff --git a/WcsMain/Tcp/Client/PlcTcpClient.cs b/WcsMain/Tcp/Client/PlcTcpClient.cs index 7c978b3..766a0e6 100644 --- a/WcsMain/Tcp/Client/PlcTcpClient.cs +++ b/WcsMain/Tcp/Client/PlcTcpClient.cs @@ -9,8 +9,7 @@ namespace WcsMain.Tcp.Client; /// /// 专用与连接 PLC 的Tcp客户端 /// -[Component] -public partial class PlcTcpClient : BaseTcpClient +public class PlcTcpClient : BaseTcpClient { /// @@ -86,7 +85,7 @@ public partial class PlcTcpClient : BaseTcpClient public MsgHeader? GetMsgHeader(string? value) { if (string.IsNullOrEmpty(value)) return default; - if (!RegexMsgFormat().IsMatch(value)) return default; + if (!Regex.IsMatch(value, "^<.+\\>$")) return default; string[] msgDatas = value.Split(';'); if(msgDatas.Length < 4 ) return default; var msgHeader = new MsgHeader() @@ -99,19 +98,4 @@ public partial class PlcTcpClient : BaseTcpClient return msgHeader; } - - - - - - - - - - - - - - [GeneratedRegex("^<.+\\>$")] - private static partial Regex RegexMsgFormat(); } diff --git a/WcsMain/WcsMain.csproj.user b/WcsMain/WcsMain.csproj.user index 0ab25a4..2add57c 100644 --- a/WcsMain/WcsMain.csproj.user +++ b/WcsMain/WcsMain.csproj.user @@ -2,5 +2,7 @@ FolderProfile + ApiControllerEmptyScaffolder + root/Common/Api \ No newline at end of file diff --git a/WcsMain/appsettings.json b/WcsMain/appsettings.json index 33113d0..2f6a46a 100644 --- a/WcsMain/appsettings.json +++ b/WcsMain/appsettings.json @@ -14,7 +14,7 @@ "DBMssqlLocal": "Data Source=192.168.142.131;Initial Catalog=wcs_stacker;User Id=sa;Password=Sa123;", "ApplicationConfig": { - "ApiOnly": true, + "ApiOnly": false, "Language": "zh-CN" }, "UseUrls": [ "http://*:890" ]