using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using static HH.WCS.ZhongCeJinTan.util.Settings;
|
|
namespace HH.WCS.ZhongCeJinTan.util
|
{
|
public class Settings
|
{
|
|
|
public static string SqlServer { get; set; }
|
|
public static string TmDeviceIp { get; set; }
|
|
|
|
//hosttoagv鉴权
|
//public static string AppKey { get; set; }
|
//public static string AppSecret { get; set; }
|
|
|
public static int TmDevicePort { get; set; }
|
|
public static List<safetyLocation> safetyLocations { get; set; }
|
public static string WcsApiAddres { get; set; }
|
|
public static string MesApiAddres { get; set; }
|
|
/// <summary>
|
/// 空托缓存区
|
/// </summary>
|
public static string EmptyPalletBufferArea { get; set; }
|
|
/// <summary>
|
/// Mes获取物料信息接口地址
|
/// </summary>
|
public static string MesGetItemApi { get; set; }
|
|
/// <summary>
|
/// 配置
|
/// </summary>
|
public static List<deviceInfo> deviceInfos { get; set; }
|
|
/// <summary>
|
/// 胎面设备配置
|
/// </summary>
|
public static List<TmDeviceInfo> TmDeviceInfos { get; set; }
|
|
public static List<areaInfo> areaInfos { get; set; }
|
|
/// <summary>
|
/// 优先级配置
|
/// </summary>
|
//public static OutMinutePriority outMinutePriority { get; set; }
|
|
|
|
/// <summary>
|
/// NDC地址
|
/// </summary>
|
public static string NDCApiUrl { 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 == "TableName") {
|
var list = JsonConvert.DeserializeObject<List<TableName>>(keyValue.Value.ToString());
|
list.ForEach(a => STAttribute.attributes.Add(a.name, a.code));
|
}
|
if (keyValue.Name == "SqlServer") {
|
SqlServer = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "WcsApiAddres")
|
{
|
WcsApiAddres = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "MesApiAddres")
|
{
|
MesApiAddres = keyValue.Value.ToString();
|
}
|
|
if (keyValue.Name == "MesGetItemApi")
|
{
|
MesGetItemApi = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "NDCApiUrl")
|
{
|
NDCApiUrl = keyValue.Value.ToString();
|
}
|
|
if (keyValue.Name == "TmDeviceIp")
|
{
|
TmDeviceIp = keyValue.Value.ToString();
|
}
|
|
if (keyValue.Name == "TmDevicePort")
|
{
|
TmDevicePort = (int)keyValue.Value;
|
}
|
if (keyValue.Name == "EmptyPalletBufferArea")
|
{
|
EmptyPalletBufferArea = keyValue.Value.ToString();
|
}
|
|
//hosttoagv鉴权
|
//if (keyValue.Name == "AppKey")
|
//{
|
// AppKey = keyValue.Value.ToString();
|
//}
|
//if (keyValue.Name == "AppSecret")
|
//{
|
// AppSecret = keyValue.Value.ToString();
|
//}
|
|
if (keyValue.Name == "SafetyLocation")
|
{
|
safetyLocations = JsonConvert.DeserializeObject<List<safetyLocation>>(keyValue.Value.ToString());
|
}
|
|
if (keyValue.Name == "TmDevice")
|
{
|
TmDeviceInfos = JsonConvert.DeserializeObject<List<TmDeviceInfo>>(keyValue.Value.ToString());
|
}
|
|
//if (keyValue.Name == "OutMinutePriority")
|
//{
|
// outMinutePriority = JsonConvert.DeserializeObject<OutMinutePriority> (keyValue.Value.ToString());
|
//}
|
//if (keyValue.Name == "DeviceInfo")
|
//{
|
// deviceInfos = JsonConvert.DeserializeObject<List<deviceInfo>>(keyValue.Value.ToString());
|
//}
|
//if (keyValue.Name == "AreaInfo")
|
//{
|
// areaInfos = JsonConvert.DeserializeObject<List<areaInfo>>(keyValue.Value.ToString());
|
//}
|
}
|
}
|
}
|
LogHelper.Info("加载配置文件信息 完成");
|
}
|
catch (Exception ex) {
|
LogHelper.Error("加载配置文件失败!" + ex.Message, ex);
|
}
|
|
}
|
|
|
// "OutMinutePriority": {
|
// "Minute": 10,
|
// "Priority": 1
|
//},
|
|
|
public class OutMinutePriority
|
{
|
public int Minute { get; set; }
|
public int Priority { get; set; }
|
}
|
|
public class TmDeviceInfo
|
{
|
public string deviceName { get; set; }
|
public string locCode { get; set; }
|
public int deviceType { get; set; }
|
public int enable { get; set; }
|
public int beginAddr { get; set; }
|
public int writeSafetyAddr { get; set; }
|
public int writeSafetyAddr1 { get; set; }
|
public int readSafetyAddr { get; set; }
|
public int readSafetyAddr1 { get; set; }
|
public int endAddr { get; set; }
|
}
|
|
public class deviceInfo
|
{
|
public string address { get; set; }
|
public string deviceName { get; set; }
|
public string[] deviceNo { get; set; }
|
public string[] location { get; set; }
|
|
public int deviceType { get; set; }
|
public int enable { get; set; }
|
}
|
|
public class areaInfo
|
{
|
|
public string[] startArea { get; set; }
|
public string[] endArea { get; set; }
|
|
public string carType { get; set; }
|
|
}
|
|
|
|
|
public class safetyLocation
|
{
|
public string name { get; set; }
|
public List<string> Area { get; set; }
|
|
public int type{ get; set; }
|
}
|
|
public class TableName
|
{
|
public string name { get; set; }
|
public string code { get; set; }
|
}
|
|
public class EndLoc
|
{
|
public string[] location;
|
}
|
|
public class zoneInfo
|
{
|
public string zone { get; set; }
|
public string deviceName { get; set; }
|
/// <summary>
|
/// </summary>
|
public int zoneType { get; set; }
|
public int[] rows { get; set; }
|
|
public int bits { get; set; }
|
}
|
public class zoneInfo1
|
{
|
public string deviceName { get; set; }
|
/// <summary>
|
/// 库区列表,按数组下标顺序选择
|
/// </summary>
|
public string[] zone { get; set; }
|
|
public int zoneType { get; set; }
|
}
|
|
|
public class tpZone
|
{
|
public string zone { get; set; }
|
public string deviceName { get; set; }
|
/// <summary>
|
/// </summary>
|
public int zoneType { get; set; }
|
public int bits { get; set; }
|
|
public string address { get; set; }
|
}
|
|
}
|
}
|