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; }
///
/// 所有的库区
///
public static List Areas { get; set; }
///
/// 所有产线信息列表
///
public static List ProductionLines { get; set; }
///
/// 所有称重设备信息列表
///
public static List WeightDevices { get; set; }
///
/// Agv读卡器信息列表
///
public static List AgvScanDevices { get; set; }
///
/// 所有安全门设置
///
public static List 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>(keyValue.Value.ToString());
}
if (keyValue.Name == "ProductionLine")
{
ProductionLines = JsonConvert.DeserializeObject>(keyValue.Value.ToString());
}
if (keyValue.Name == "WeightDevices")
{
WeightDevices = JsonConvert.DeserializeObject>(keyValue.Value.ToString());
}
if (keyValue.Name == "AgvScanDevice")
{
AgvScanDevices = JsonConvert.DeserializeObject>(keyValue.Value.ToString());
}
if (keyValue.Name == "SafeDoorDevices")
{
SafeDoorDevices = JsonConvert.DeserializeObject>(keyValue.Value.ToString());
}
}
}
}
LogHelper.Info("加载配置文件信息 完成");
}
catch (Exception ex)
{
LogHelper.Error("加载配置文件失败!" + ex.Message, ex);
}
}
///
/// 产线信息
///
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 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; }//称重设备的点位
}
///
/// 读卡器设备
///
public class AgvScanDevice
{
public string AgvCode { get; set; }//agv编号
public string ScanAddress { get; set; }//agv读卡器地址
public string ScanState { get; set; }//agv状态
}
///
/// 安全门设备
///
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; }
}
}
}