From 9d1660270272180cd71147d6ddd53d1382643d2e Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 02 十一月 2026 18:00:14 +0800
Subject: [PATCH] merge: 并入远程 Initial commit 作为历史根节点

---
 Plugin.TestResult/Util/ModelCodeParser.cs |  100 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 100 insertions(+), 0 deletions(-)

diff --git a/Plugin.TestResult/Util/ModelCodeParser.cs b/Plugin.TestResult/Util/ModelCodeParser.cs
new file mode 100644
index 0000000..6d69852
--- /dev/null
+++ b/Plugin.TestResult/Util/ModelCodeParser.cs
@@ -0,0 +1,100 @@
+锘縰sing HMI.Core.Entity;
+using HMI.Core.Manager;
+using Plugin.TestResult.Util;
+using Plugin.TestResult_WPF.Model;
+using System;
+using System.Linq;
+
+namespace Plugin.TestResult_WPF.Util
+{
+    public class ModelCodeParser : ICodeParser
+    {
+        public CellInfo GetCellInfoByCode(string code)
+        {
+            string[] arr = code.Split('-');
+            if (arr == null || arr.Length != 3)
+            {
+                throw new Exception("鎵爜鏍煎紡寮傚父");
+            }
+            return new CellInfo()
+            {
+                OriginCode = code,
+                MachineName = arr[0],
+                OvenName = arr[1],
+                Index = int.Parse(arr[2]) - 1,
+            };
+        }
+
+        public CellInfo GetCellInfoByCode(string model, int columns, int rows, string code)
+        {
+            var list = ProductManager.GetParametersByProductName(model);
+            ParameterData config = null;
+            if (list != null && list.Count > 0)
+            {
+                config = list.Where(e => e.Name == "PositionCodeConfig").FirstOrDefault();
+            }
+            if (string.IsNullOrEmpty(config?.Value))
+            {
+                // 浜у搧娌℃湁灏辨寜榛樿鐨勫幓閰�
+                config = ParameterManager.GetCommonParameterByName("PositionCodeConfig");
+                if (string.IsNullOrEmpty(config?.Value))
+                {
+                    throw new Exception($"褰撳墠鍨嬪彿[{model}]鏈厤缃┐浣嶈鍒�");
+                }
+            }
+            string value = config.Value;
+            string[] arr = value?.Split(';');
+            try
+            {
+                if (arr.Length == 2)
+                {
+                    string[] v1s = arr[0].Split(',');
+                    string[] v2s = arr[1].Split(',');
+
+                    return new CellInfo
+                    {
+                        OriginCode = code,
+                        OvenName = code.Substring(int.Parse(v1s[0]), int.Parse(v1s[1])),
+                        Index = int.Parse(code.Substring(int.Parse(v2s[0]), int.Parse(v2s[1]))) - 1
+                    };
+                }
+                else if (arr.Length == 3)
+                {
+                    string[] v1s = arr[0].Split(',');
+                    string[] v2s = arr[1].Split(',');
+                    string[] v3s = arr[2].Split(',');
+
+                    int row = int.Parse(code.Substring(int.Parse(v2s[0]), int.Parse(v2s[1])));
+                    int index = int.Parse(code.Substring(int.Parse(v3s[0]), int.Parse(v3s[1])));
+
+                    return new CellInfo()
+                    {
+                        OriginCode = code,
+                        OvenName = code.Substring(int.Parse(v1s[0]), int.Parse(v1s[1])),
+                        Index = (row - 1) * columns + (index - 1),
+                    };
+                }
+                else if (arr.Length >= 4)
+                {
+                    string[] v1s = arr[0].Split(',');
+                    string[] v2s = arr[1].Split(',');
+                    string[] v3s = arr[2].Split(',');
+                    columns = int.Parse(arr[3]);
+                    int row = int.Parse(code.Substring(int.Parse(v2s[0]), int.Parse(v2s[1])));
+                    int index = int.Parse(code.Substring(int.Parse(v3s[0]), int.Parse(v3s[1])));
+                    return new CellInfo()
+                    {
+                        OriginCode = code,
+                        OvenName = code.Substring(int.Parse(v1s[0]), int.Parse(v1s[1])),
+                        Index = (row - 1) * columns + (index - 1),
+                    };
+                }
+                throw new Exception($"褰撳墠鍨嬪彿[{model}]绌翠綅瑙勫垯閰嶇疆寮傚父");
+            }
+            catch (Exception ex)
+            {
+                throw new Exception($"褰撳墠鍨嬪彿[{model}]瑙f瀽寮傚父:{ex.Message}", ex);
+            }
+        }
+    }
+}

--
Gitblit v1.9.1