kazelee
2025-05-26 53d582ad41d8450b21045b2d862a532ecc57a9ba
util/Settings.cs
@@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.IO;
using HH.WCS.Mobox3.DSZSH.util;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -13,10 +15,10 @@
        public static string SqlServer { get; set; }
        public static string TcpServerIp { get; set; }
        public static int TcpServerPort { get; set; }
        public static List<Config.Area> Areas { get; set; }
        public static List<Config.Task> Tasks { get; set; }
        public static List<Config.ProductionLine> ProductionLines { get; set; }
        public static List<Config.Area> Areas { get; set; } = new List<Config.Area>();
        public static List<Config.Task> Tasks { get; set; } = new List<Config.Task>();
        public static List<Config.ProductionLine> ProductionLines { get; set; } = new List<Config.ProductionLine>();
        public static List<Config.ProdAgvSite> ProdAgvSites { get; set; } = new List<Config.ProdAgvSite>();
        /// <summary>
        /// 库区字典(加载后就不变)
        /// </summary>
@@ -26,6 +28,8 @@
        /// 任务字典(加载后就不变)
        /// </summary>
        public static Dictionary<string, Config.Task> TaskMap { get; set; } = new Dictionary<string, Config.Task>();
        public static Dictionary<string, int> AgvSite_ProdLineCodeMap { get; set; } = new Dictionary<string, int>();
        public static void Init() {
            // 加载配置文件
@@ -59,6 +63,11 @@
                Tasks = root.Tasks;
                ProductionLines = root.ProductionLines;
                ProdAgvSites = root.ProdAgvSite;
                foreach (var item in ProdAgvSites) {
                    AgvSite_ProdLineCodeMap.Add(item.Code, item.ProdId);
                }
            }   
            catch (FileNotFoundException) {
                LogHelper.Info("JSON 文件未找到");
@@ -83,7 +92,18 @@
                TaskMap.Add(task.Name, task);
            }
        }
        private static void LoadProdLines() {
            //var db = new SqlHelper<object>().GetInstance();
            //for (int  i = 0;  i < ProductionLines.Count;  i++) {
            //    var line = ProductionLines[i];
            //    // 通过OnLoc OffLoc找到AGVsite然后写入字典
            //}
        }
    }
    // [Convert JSON to C# Classes Online - Json2CSharp Toolkit](https://json2csharp.com/)
    public class Config {
@@ -91,6 +111,11 @@
        public class Area {
            public string Name { get; set; }
            public List<string> Codes { get; set; }
        }
        public class ProdAgvSite {
            public string Code { get; set; }
            public int ProdId { get; set; }
        }
        public class ProductionLine {
@@ -112,6 +137,7 @@
            public List<Area> Areas { get; set; }
            public List<Task> Tasks { get; set; }
            public List<ProductionLine> ProductionLines { get; set; }
            public List<ProdAgvSite> ProdAgvSite { get; set; }
        }
        public class Task {
@@ -119,6 +145,8 @@
            public List<string> StartAreas { get; set; }
            public List<string> EndAreas { get; set; }
        }
    }
    public class AreaName {