From fe2aa4880d5c9fd88088ad0ed81ebaca05629f5f Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 02 十一月 2026 17:59:45 +0800
Subject: [PATCH] feat: 集成CAN驱动/模拟器 + 仪器仪表注册/硬件调试模块
---
HMI.Core/Manager/ProductManager.cs | 31 +++++++++++++++++++++++++++++--
1 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/HMI.Core/Manager/ProductManager.cs b/HMI.Core/Manager/ProductManager.cs
index 5d02c09..96e10d6 100644
--- a/HMI.Core/Manager/ProductManager.cs
+++ b/HMI.Core/Manager/ProductManager.cs
@@ -1,7 +1,9 @@
锘縰sing HMI.Core.Entity;
+using HMI.Core.Setting;
using HMI.Core.Util;
using System.Collections.Generic;
using System.IO;
+using System.Linq;
namespace HMI.Core.Manager
{
@@ -10,13 +12,32 @@
/// </summary>
public class ProductManager
{
+ public static string GetFolder()
+ {
+ if (ParamSetting.ShareConfig != null)
+ {
+ return Path.Combine(ParamSetting.ShareConfig, "Product");
+ }
+ return Path.Combine(PathHelper.ConfigFolder, "Product");
+ }
+
+ public static string GetDataFilePath()
+ {
+ return Path.Combine(GetFolder(), "Product.data");
+ }
+
+ public static string GetParamFolderByProductName(string productName)
+ {
+ return Path.Combine(GetFolder(), "Parameter", $"Parameter_{productName}.data");
+ }
+
/// <summary>
/// 鑾峰彇淇濆瓨鐨勪骇鍝�
/// </summary>
/// <returns></returns>
public static T GetProducts<T>() where T : IList<ProductData>
{
- string path = PathHelper.ProductDataFile;
+ string path = GetDataFilePath();
if (!File.Exists(path)) return default(T);
T datas = XmlHelper.DeserializeFromXml<T>(path);
return datas;
@@ -28,7 +49,7 @@
/// <returns></returns>
public static T GetParametersByProductName<T>(string productName) where T : IList<ParameterData>
{
- string path = Path.Combine(PathHelper.ProductParameterFolder, $"Parameter_{productName}.data");
+ string path = GetParamFolderByProductName(productName);
if (!File.Exists(path)) return default(T);
T datas = XmlHelper.DeserializeFromXml<T>(path);
return datas;
@@ -51,5 +72,11 @@
List<ParameterData> datas = GetParametersByProductName<List<ParameterData>>(productName);
return datas ?? new List<ParameterData>();
}
+
+ public static ParameterData GetParameterByProductAndName(string product, string name)
+ {
+ List<ParameterData> datas = GetParametersByProductName<List<ParameterData>>(product);
+ return datas?.FirstOrDefault(e => e.Name == name);
+ }
}
}
--
Gitblit v1.9.1