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 int LineSorting { get; set; } = 0;
|
|
/// <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; }//产线的满托下线位
|
public int Sorting { 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; }
|
}
|
}
|
}
|