杨张扬
2025-06-12 52adedb218549cde2bdc60c3b338e360e72d94a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
 
 
namespace HH.WCS.Mobox3.DoubleCoin.util
{
    public class Settings
    {
        public static string HostToAgvServerUrl { get; set; }
        public static string NDCApiUrl { get; set; }
        public static string SqlServer { get; set; }
        public static string WebApiUrl { get; set; }
        public static string TCPServerIP { get; set; }
        public static int TCPServerPort { get; set; }
        public static bool S7TestMoni { get; set; }
        public static bool IsOpenScanCode { get; set; }
 
        /// <summary>
        /// 所有的库区
        /// </summary>
        public static List<string> Areas { get; set; }
 
        /// <summary>
        /// 所有产线信息列表
        /// </summary>
        public static List<ProductionLine> ProductionLines { get; set; }
 
        /// <summary>
        /// 所有称重设备信息列表
        /// </summary>
        public static List<WeightDevice> WeightDevices { get; set; }
 
        /// <summary>
        /// Agv读卡器信息列表
        /// </summary>
        public static List<AgvScanDevice> AgvScanDevices { get; set; }
 
        /// <summary>
        /// 所有安全门设置
        /// </summary>
        public static List<SafeDoorDevice> SafeDoorDevices { get; set; }
 
        public static void Init()
        {
            LogHelper.Info("加载配置文件信息 开始");
            try
            {
                var jsonFile = System.AppDomain.CurrentDomain.BaseDirectory + "/config/config.json";
                using (System.IO.StreamReader file = System.IO.File.OpenText(jsonFile))
                {
                    using (JsonTextReader reader = new JsonTextReader(file))
                    {
                        JObject o = (JObject)JToken.ReadFrom(reader);
                        foreach (Newtonsoft.Json.Linq.JProperty keyValue in o.Properties())
                        {
                            Console.WriteLine(keyValue.Name);
                            if (keyValue.Name == "SqlServer")
                            {
                                SqlServer = keyValue.Value.ToString();
                            }
                            if (keyValue.Name == "NDCApiUrl")
                            {
                                NDCApiUrl = keyValue.Value.ToString();
                            }
                            if (keyValue.Name == "WebApiUrl")
                            {
                                WebApiUrl = keyValue.Value.ToString();
                            }
                            if (keyValue.Name == "TCPServerIP")
                            {
                                TCPServerIP = keyValue.Value.ToString();
                            }
                            if (keyValue.Name == "TCPServerPort")
                            {
                                TCPServerPort = Convert.ToInt32(keyValue.Value);
                            }
                            if (keyValue.Name == "S7TestMoni")
                            {
                                S7TestMoni = (bool)(keyValue.Value);
                            }
                            if (keyValue.Name == "IsOpenScanCode")
                            {
                                IsOpenScanCode = (bool)(keyValue.Value);
                            }
                            if (keyValue.Name == "Areas")
                            {
                                Areas = JsonConvert.DeserializeObject<List<string>>(keyValue.Value.ToString());
                            }
                            if (keyValue.Name == "ProductionLine")
                            {
                                ProductionLines = JsonConvert.DeserializeObject<List<ProductionLine>>(keyValue.Value.ToString());
                            }
                            if (keyValue.Name == "WeightDevices")
                            {
                                WeightDevices = JsonConvert.DeserializeObject<List<WeightDevice>>(keyValue.Value.ToString());
                            }
                            if (keyValue.Name == "AgvScanDevice")
                            {
                                AgvScanDevices = JsonConvert.DeserializeObject<List<AgvScanDevice>>(keyValue.Value.ToString());
                            }
                            if (keyValue.Name == "SafeDoorDevices")
                            {
                                SafeDoorDevices = JsonConvert.DeserializeObject<List<SafeDoorDevice>>(keyValue.Value.ToString());
                            }
                        }
                    }
                }
                LogHelper.Info("加载配置文件信息 完成");
            }
            catch (Exception ex)
            {
                LogHelper.Error("加载配置文件失败!" + ex.Message, ex);
            }
 
        }
      
        /// <summary>
        /// 产线信息
        /// </summary>
        public class ProductionLine
        {
            public string ProductionLine_IP { get; set; }//产线IP地址
            public string ProductionLine_Name { get; set; }//产线的名称
            public int ProductionLine_Rack { get; set; }//产线的架子号
            public int ProductionLine_Slot { get; set; }//产线的插槽号
            public string PointIn { get; set; }//产线的空托上线位
            public string PointOut { get; set; }//产线的满托下线位
        }
 
        /// <summary>
        /// 称重设备信息
        /// </summary>
        public class WeightDevice
        {
            public string WeightDevice_IP { get; set; }//称重设备IP地址
            public string WeightDevice_Name { get; set; }//称重设备的名称
            public int WeightDevice_Rack { get; set; }//称重设备的架子号
            public int WeightDevice_Slot { get; set; }//称重设备的插槽号
            public string Point { get; set; }//称重设备的点位
        }
 
        /// <summary>
        /// 读卡器设备
        /// </summary>
        public class AgvScanDevice
        {
            public string AgvCode { get; set; }//agv编号
            public string ScanAddress { get; set; }//agv读卡器地址
            public string ScanState { get; set; }//agv状态
        }
        
        /// <summary>
        /// 安全门设备
        /// </summary>
        public class SafeDoorDevice
        {
            public string DeviceCode { get; set; }//设备代号
            public string DeviceName { get; set; }//设备名称
            public string IPAddress { get; set; }//地址
        }
 
        public class SpeAndTime
        {
            public string Spe { get; set; }
            public int Minute { get; set; }
        }
    }
}