fix: 修复PLC字符串解析和任务处理逻辑
修复DeviceCommand中字符串解析逻辑,处理长度不一致情况
调整ConveyorLine任务处理逻辑,优化条件判断
添加Siemens通信中对byte数组类型的支持
更新.gitignore文件合并Visual Studio相关配置
修改LocationInfoService中库位编码生成规则
| | |
| | | [*.cs] |
| | | |
| | | # CS8618: å¨éåºæé 彿°æ¶ï¼ä¸å¯ä¸º null çåæ®µå¿
é¡»å
å«é null å¼ã请èè声æä¸ºå¯ä»¥ä¸º nullã |
| | | dotnet_diagnostic.CS8618.severity = none |
| | | # CS8600: å° null åé¢éæå¯è½ä¸º null çå¼è½¬æ¢ä¸ºé null ç±»åã |
| | | dotnet_diagnostic.CS8600.severity = silent |
| | |
| | | [Ll]og/ |
| | | [Ll]ogs/ |
| | | |
| | | # Visual Studio |
| | | # Visual Studio and User-specific files |
| | | .vs/ |
| | | *.user |
| | | *.suo |
| | | *.userosscache |
| | | *.sln.docstates |
| | | |
| | | # User-specific files |
| | | *.rsuser |
| | | *.suo |
| | | *.user |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | { |
| | | "version": "0.2.0", |
| | | "configurations": [ |
| | | { |
| | | // ä½¿ç¨ IntelliSense æ¾åº C# è°è¯åå¨åªäºå±æ§ |
| | | // å°æ¬åç¨äºç°æå±æ§ç说æ |
| | | // æå
³è¯¦ç»ä¿¡æ¯ï¼è¯·è®¿é® https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.mdã |
| | | "name": ".NET Core Launch (web)", |
| | | "type": "coreclr", |
| | | "request": "launch", |
| | | "preLaunchTask": "build", |
| | | // å¦æå·²æ´æ¹ç®æ æ¡æ¶ï¼è¯·ç¡®ä¿æ´æ°ç¨åºè·¯å¾ã |
| | | "program": "${workspaceFolder}/WIDESEAWCS_Server/bin/Debug/net8.0/WIDESEAWCS_Server.dll", |
| | | "args": [], |
| | | "cwd": "${workspaceFolder}/WIDESEAWCS_Server", |
| | | "stopAtEntry": false, |
| | | // å¯ç¨å¨å¯å¨ ASP.NET Core æ¶å¯å¨ Web æµè§å¨ãæå
³è¯¦ç»ä¿¡æ¯: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser |
| | | "serverReadyAction": { |
| | | "action": "openExternally", |
| | | "pattern": "\\bNow listening on:\\s+(https?://\\S+)" |
| | | }, |
| | | "env": { |
| | | "ASPNETCORE_ENVIRONMENT": "Development" |
| | | }, |
| | | "sourceFileMap": { |
| | | "/Views": "${workspaceFolder}/Views" |
| | | } |
| | | }, |
| | | { |
| | | "name": ".NET Core Attach", |
| | | "type": "coreclr", |
| | | "request": "attach" |
| | | } |
| | | ] |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | { |
| | | "version": "2.0.0", |
| | | "tasks": [ |
| | | { |
| | | "label": "build", |
| | | "command": "dotnet", |
| | | "type": "process", |
| | | "args": [ |
| | | "build", |
| | | "${workspaceFolder}/WIDESEAWCS_Server/WIDESEAWCS_Server.csproj", |
| | | "/property:GenerateFullPaths=true", |
| | | "/consoleloggerparameters:NoSummary;ForceNoAlign" |
| | | ], |
| | | "problemMatcher": "$msCompile" |
| | | }, |
| | | { |
| | | "label": "publish", |
| | | "command": "dotnet", |
| | | "type": "process", |
| | | "args": [ |
| | | "publish", |
| | | "${workspaceFolder}/WIDESEAWCS_Server/WIDESEAWCS_Server.csproj", |
| | | "/property:GenerateFullPaths=true", |
| | | "/consoleloggerparameters:NoSummary;ForceNoAlign" |
| | | ], |
| | | "problemMatcher": "$msCompile" |
| | | }, |
| | | { |
| | | "label": "watch", |
| | | "command": "dotnet", |
| | | "type": "process", |
| | | "args": [ |
| | | "watch", |
| | | "run", |
| | | "--project", |
| | | "${workspaceFolder}/WIDESEAWCS_Server/WIDESEAWCS_Server.csproj" |
| | | ], |
| | | "problemMatcher": "$msCompile" |
| | | } |
| | | ] |
| | | } |
| | |
| | | /// 32使 ç¬¦å·æ´å |
| | | /// </summary> |
| | | public const string DataType_UDInt = "udint"; |
| | | |
| | | /// <summary> |
| | | /// åèæ°ç» |
| | | /// </summary> |
| | | public const string DataType_ByteArray = "byte[]"; |
| | | #endregion <Const> |
| | | |
| | | /// <summary> |
| | |
| | | return plc.Write(address, Convert.ToString(value)); |
| | | case TypeCode.Char: |
| | | return plc.Write(address, Convert.ToChar(value)); |
| | | //case TypeCode.arr: |
| | | // return plc.Write(address, Convert.ToChar(value)); |
| | | default: |
| | | if (value is int[]) |
| | | { |
| | |
| | | case SiemensDBDataType.DataType_Char: |
| | | |
| | | break; |
| | | |
| | | case SiemensDBDataType.DataType_ByteArray: |
| | | { |
| | | byte[] writeVal; |
| | | try |
| | | { |
| | | writeVal = Encoding.UTF8.GetBytes(value.ToString()); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new CommunicationException(string.Format(CommunicationExceptionMessage.TypeConvertError, dataType, address, value, ex.Message), CommunicationErrorType.TypeError, innerException: ex); |
| | | } |
| | | obj = GetResult(Write(address, writeVal), address, writeVal); |
| | | } |
| | | break; |
| | | default: |
| | | throw new CommunicationException(string.Format(CommunicationExceptionMessage.DataTypeErrorException, dataType, address), CommunicationErrorType.TypeError); |
| | | } |
| | |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Core.LogHelper; |
| | | |
| | | namespace WIDESEAWCS_QuartzJob.DeviceBase |
| | | { |
| | |
| | | case TypeCode.String: |
| | | ushort dataLength = CheckStringAttribute(propertyInfo); |
| | | |
| | | //if (dataLength - 2 != Content[index]) |
| | | //{ |
| | | // throw new Exception($"读åPLCå符串å®ä¹é¿åº¦ã{Content[index]}ãä¸å¯¹è±¡ã{GetType().Name}ã屿§ã{propertyInfo.Name}ãç¹æ§å®ä¹å符串é¿åº¦ã{dataLength}ãä¸ä¸è´"); |
| | | //} |
| | | if (dataLength - 2 != Content[index]) |
| | | { |
| | | //throw new Exception($"读åPLCå符串å®ä¹é¿åº¦ã{Content[index]}ãä¸å¯¹è±¡ã{GetType().Name}ã屿§ã{propertyInfo.Name}ãç¹æ§å®ä¹å符串é¿åº¦ã{dataLength}ãä¸ä¸è´"); |
| | | //QuartzLogger.Debug($"读åPLCå符串å®ä¹é¿åº¦ã{Content[index]}ãä¸å¯¹è±¡ã{GetType().Name}ã屿§ã{propertyInfo.Name}ãç¹æ§å®ä¹å符串é¿åº¦ã{dataLength}ãä¸ä¸è´"); |
| | | |
| | | //if (Content[index + 1] > Content.Length - index - 2) |
| | | //{ |
| | | // throw new Exception($"读åPLCå符串å®é
é¿åº¦ã{Content[index + 1]}ãè¶
åºå½åbyteæ°ç»é¿åº¦ï¼ç´¢å¼ï¼ã{index}ãï¼å符串起å§ç´¢å¼ï¼ã{index + 2}ãï¼æ°ç»é¿åº¦ï¼ã{Content.Length}ãï¼è§£æé¿åº¦ï¼ã{Content.Length - index - 2}ã"); |
| | | //} |
| | | propertyInfo.SetValue(this, Encoding.Default.GetString(Content, index, dataLength).Trim().Replace("\0", "").Replace("\\u000","").Trim()); |
| | | index += dataLength; |
| | | break; |
| | | } |
| | | |
| | | // propertyInfo.SetValue(this, Encoding.Default.GetString(Content, index + 2, Content[index + 1] > 0 ? Content[index + 1] : dataLength - 2)); |
| | | propertyInfo.SetValue(this, Encoding.Default.GetString(Content, index, dataLength - 2)); |
| | | if (Content[index + 1] > Content.Length - index - 2) |
| | | { |
| | | throw new Exception($"读åPLCå符串å®é
é¿åº¦ã{Content[index + 1]}ãè¶
åºå½åbyteæ°ç»é¿åº¦ï¼ç´¢å¼ï¼ã{index}ãï¼å符串起å§ç´¢å¼ï¼ã{index + 2}ãï¼æ°ç»é¿åº¦ï¼ã{Content.Length}ãï¼è§£æé¿åº¦ï¼ã{Content.Length - index - 2}ã"); |
| | | } |
| | | |
| | | propertyInfo.SetValue(this, Encoding.Default.GetString(Content, index + 2, Content[index + 1] > 0 ? Content[index + 1] : dataLength - 2)); |
| | | //propertyInfo.SetValue(this, Encoding.Default.GetString(Content, index, dataLength - 2)); |
| | | index += dataLength; |
| | | break; |
| | | default: |
| | |
| | | using Newtonsoft.Json; |
| | | using Quartz; |
| | | using SqlSugar; |
| | | using System.Text; |
| | | using System.Text.Json; |
| | | using WIDESEA_Core; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | |
| | | { |
| | | _logger.LogDebug("Executeï¼åè®¾å¤ {ChildDeviceCode} å½ä»¤ä¸ºç©ºï¼è·³è¿", childDeviceCode); |
| | | QuartzLogger.Debug($"åè®¾å¤ {childDeviceCode} å½ä»¤ä¸ºç©ºï¼è·³è¿", conveyorLine.DeviceCode); |
| | | return Task.CompletedTask; |
| | | continue; |
| | | } |
| | | |
| | | // 妿 WCS_ACK 为 1ï¼å
æ¸
é¤ï¼è¡¨ç¤ºå¤çè¿ä¸ä¸æ¬¡è¯·æ±ï¼ |
| | |
| | | if (checkPalletPositions.Any(x => x.Code == childDeviceCode)) |
| | | { |
| | | // æ£æ¥è¾éçº¿ç¶æï¼æ¯å¦ææçï¼ |
| | | if (command.CV_State == 1) |
| | | if (command.CV_State == 2) |
| | | { |
| | | // æ£æ¥è¯¥ä½ç½®æ¯å¦å·²æä»»å¡ |
| | | var existingTask = _taskService.Db.Queryable<Dt_Task>().First(x => x.TargetAddress == childDeviceCode); |
| | |
| | | // åªæå½ PLC_STB 为 1 æ¶æå¤çä»»å¡ |
| | | if (command.PLC_STB != 1) |
| | | { |
| | | //_logger.LogDebug("Executeï¼åè®¾å¤ {ChildDeviceCode} PLC_STB ä¸ä¸º1ï¼è·³è¿", childDeviceCode); |
| | | //QuartzLogger.Debug($"åè®¾å¤ {childDeviceCode} PLC_STB ä¸ä¸º1ï¼è·³è¿", conveyorLine.DeviceCode); |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | // ========== å¤çå·²æä»»å¡å·çæ
åµ ========== |
| | | if (command.TaskNo > 0) |
| | | if (command.TaskNo > 0 && !command.Barcode.IsNullOrEmpty()) |
| | | { |
| | | // æ¥è¯¢æ£å¨æ§è¡çä»»å¡ |
| | | Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNo, childDeviceCode); |
| | |
| | | public byte Last_pallet { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æçæ¡ç ï¼22个åç¬¦ï¼ |
| | | /// æçæ¡ç ï¼20个åç¬¦ï¼ |
| | | /// </summary> |
| | | /// <remarks> |
| | | /// å卿ççæ¡ç ä¿¡æ¯ï¼ç¨äºè´§ç©è¿½è¸ªååºä½ç®¡çã |
| | | /// </remarks> |
| | | [DataLength(22)] |
| | | [DataLength(20)] |
| | | public string Barcode { get; set; } |
| | | } |
| | | } |
| | |
| | | EnableStatus = EnableStatusEnum.Normal.GetHashCode(), |
| | | LocationStatus = LocationStatusEnum.Free.GetHashCode(), |
| | | LocationType = LocationTypeEnum.Undefined.GetHashCode(), |
| | | LocationCode = $"{roadwayNo}-{row:D3}-{col:D3}-{layer:D3}", |
| | | //LocationCode = $"{roadwayNo}-{row:D3}-{col:D3}-{layer:D3}", |
| | | LocationCode = $"{row:D3}-{col:D3}-{layer:D3}", |
| | | LocationName = $"{roadwayNo}å··é{row:D3}è¡{col:D3}å{layer:D3}å±{depth:D2}æ·±" |
| | | }; |
| | | } |