diff --git a/.vs/LargeSquareOne/CopilotIndices/17.14.1431.25910/CodeChunks.db b/.vs/LargeSquareOne/CopilotIndices/17.14.1431.25910/CodeChunks.db
index 16b885f..a4c9113 100644
Binary files a/.vs/LargeSquareOne/CopilotIndices/17.14.1431.25910/CodeChunks.db and b/.vs/LargeSquareOne/CopilotIndices/17.14.1431.25910/CodeChunks.db differ
diff --git a/.vs/LargeSquareOne/CopilotIndices/17.14.1431.25910/CodeChunks.db-wal b/.vs/LargeSquareOne/CopilotIndices/17.14.1431.25910/CodeChunks.db-wal
index 1065cec..0feccb1 100644
Binary files a/.vs/LargeSquareOne/CopilotIndices/17.14.1431.25910/CodeChunks.db-wal and b/.vs/LargeSquareOne/CopilotIndices/17.14.1431.25910/CodeChunks.db-wal differ
diff --git a/.vs/LargeSquareOne/CopilotIndices/17.14.1431.25910/SemanticSymbols.db b/.vs/LargeSquareOne/CopilotIndices/17.14.1431.25910/SemanticSymbols.db
index 3e2cb9f..61a487e 100644
Binary files a/.vs/LargeSquareOne/CopilotIndices/17.14.1431.25910/SemanticSymbols.db and b/.vs/LargeSquareOne/CopilotIndices/17.14.1431.25910/SemanticSymbols.db differ
diff --git a/.vs/LargeSquareOne/CopilotIndices/17.14.1431.25910/SemanticSymbols.db-wal b/.vs/LargeSquareOne/CopilotIndices/17.14.1431.25910/SemanticSymbols.db-wal
index a55e72d..18f50e8 100644
Binary files a/.vs/LargeSquareOne/CopilotIndices/17.14.1431.25910/SemanticSymbols.db-wal and b/.vs/LargeSquareOne/CopilotIndices/17.14.1431.25910/SemanticSymbols.db-wal differ
diff --git a/JinYuan.ControlCenter/ControlCenter_Plc.cs b/JinYuan.ControlCenter/ControlCenter_Plc.cs
index 87225fd..e66345c 100644
--- a/JinYuan.ControlCenter/ControlCenter_Plc.cs
+++ b/JinYuan.ControlCenter/ControlCenter_Plc.cs
@@ -1955,6 +1955,7 @@ namespace JinYuan.ControlCenters
CommonMethods.mesConfig.equipNum,
CommonMethods.mesConfig.MaterialCode);//分档查询
+ var channels = CommonMethods.mesConfig.ChannelConfig.Channels;
try
{
@@ -1964,44 +1965,59 @@ namespace JinYuan.ControlCenters
list[i].Mes_sorting_scheme = mesResFangAnType[0];
if (success && mesResType[0] != "NULL")
{
+ #region 注释代码
+ //if (mesResType[0].Equals(CommonMethods.mesConfig.Grading1))
+ //{
+ // listGradeResult[i] = (short)(CommonMethods.MESGradingSet[0]);
+ // list[i].Remark = $"出站条码[{list[i].BarCode}],MES反馈档位:{mesResType[0]},{listGradeResult[i]}";
+ //}
+ //else if (mesResType[0].Equals(CommonMethods.mesConfig.Grading2))
+ //{
+ // listGradeResult[i] = (short)(CommonMethods.MESGradingSet[1]);
+ // list[i].Remark = $"出站条码[{list[i].BarCode}],MES反馈档位:{mesResType[0]},{listGradeResult[i]}";
+ //}
+ //else if (mesResType[0].Equals(CommonMethods.mesConfig.Grading3))
+ //{
+ // listGradeResult[i] = (short)(CommonMethods.MESGradingSet[2]);
+ // list[i].Remark = $"出站条码[{list[i].BarCode}],MES反馈档位:{mesResType[0]},{listGradeResult[i]}";
+ //}
+ //else if (mesResType[0].Equals(CommonMethods.mesConfig.Grading4))
+ //{
+ // listGradeResult[i] = (short)(CommonMethods.MESGradingSet[3]);
+ // list[i].Remark = $"出站条码[{list[i].BarCode}],MES反馈档位:{mesResType[0]},{listGradeResult[i]}";
+ //}
+ //else if (mesResType[0].Equals(CommonMethods.mesConfig.Grading5))
+ //{
+ // listGradeResult[i] = (short)(CommonMethods.MESGradingSet[4]);
+ // list[i].Remark = $"出站条码[{list[i].BarCode}],MES反馈档位:{mesResType[0]},{listGradeResult[i]}";
+ //}
+ //else if (mesResType[0].Equals(CommonMethods.mesConfig.Grading6))
+ //{
+ // listGradeResult[i] = (short)(CommonMethods.MESGradingSet[5]);
+ // list[i].Remark = $"出站条码[{list[i].BarCode}],MES反馈档位:{mesResType[0]},{listGradeResult[i]}";
+ //}
+ //else
+ //{
+ // listGradeResult[i] = (short)(97);// 走分档NG
+ // list[i].Remark = $"出站条码[{list[i].BarCode}],MES反馈档位:{mesResType[0]},MES未反馈正确档位";
+ // throw new Exception("MES未反馈正确档位");
+ //}
+ #endregion
- if (mesResType[0].Equals(CommonMethods.mesConfig.Grading1))
+ // MES分档查询
+ var channel = channels.FirstOrDefault(it => it.Gears.Contains(mesResType[0]));
+
+ if (channel != null)
{
- listGradeResult[i] = (short)(CommonMethods.MESGradingSet[0] );
+ listGradeResult[i] = (short)channel.DefaultValue;
list[i].Remark = $"出站条码[{list[i].BarCode}],MES反馈档位:{mesResType[0]},{listGradeResult[i]}";
}
- else if (mesResType[0].Equals(CommonMethods.mesConfig.Grading2))
- {
- listGradeResult[i] = (short)(CommonMethods.MESGradingSet[1]);
- list[i].Remark = $"出站条码[{list[i].BarCode}],MES反馈档位:{mesResType[0]},{listGradeResult[i]}";
- }
- else if (mesResType[0].Equals(CommonMethods.mesConfig.Grading3))
- {
- listGradeResult[i] = (short)(CommonMethods.MESGradingSet[2]);
- list[i].Remark = $"出站条码[{list[i].BarCode}],MES反馈档位:{mesResType[0]},{listGradeResult[i]}";
- }
- else if (mesResType[0].Equals(CommonMethods.mesConfig.Grading4))
- {
- listGradeResult[i] = (short)(CommonMethods.MESGradingSet[3]);
- list[i].Remark = $"出站条码[{list[i].BarCode}],MES反馈档位:{mesResType[0]},{listGradeResult[i]}";
- }
- else if (mesResType[0].Equals(CommonMethods.mesConfig.Grading5))
- {
- listGradeResult[i] = (short)(CommonMethods.MESGradingSet[4]);
- list[i].Remark = $"出站条码[{list[i].BarCode}],MES反馈档位:{mesResType[0]},{listGradeResult[i]}";
- }
- else if (mesResType[0].Equals(CommonMethods.mesConfig.Grading6))
- {
- listGradeResult[i] = (short)(CommonMethods.MESGradingSet[5]);
- list[i].Remark = $"出站条码[{list[i].BarCode}],MES反馈档位:{mesResType[0]},{listGradeResult[i]}";
- }
else
{
listGradeResult[i] = (short)(97);// 走分档NG
list[i].Remark = $"出站条码[{list[i].BarCode}],MES反馈档位:{mesResType[0]},MES未反馈正确档位";
throw new Exception("MES未反馈正确档位");
}
-
}
else
{
diff --git a/JinYuan.Models/JinYuan.Models.csproj b/JinYuan.Models/JinYuan.Models.csproj
index 2fc0010..044f08f 100644
--- a/JinYuan.Models/JinYuan.Models.csproj
+++ b/JinYuan.Models/JinYuan.Models.csproj
@@ -94,6 +94,7 @@
+
diff --git a/JinYuan.Models/SysConfig/ChannelConfig.cs b/JinYuan.Models/SysConfig/ChannelConfig.cs
new file mode 100644
index 0000000..7a46ddc
--- /dev/null
+++ b/JinYuan.Models/SysConfig/ChannelConfig.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JinYuan.Models.SysConfig
+{
+ public class ChannelConfig
+ {
+ public List Channels { get; set; } = new List();
+ }
+
+ public class Channel
+ {
+ public int ChannelId { get; set; }
+ public int DefaultValue { get; set; }
+ public List Gears { get; set; } = new List();
+ }
+}
diff --git a/JinYuan.Models/SysConfig/SysConfig.cs b/JinYuan.Models/SysConfig/SysConfig.cs
index 94da9e1..fa68ba4 100644
--- a/JinYuan.Models/SysConfig/SysConfig.cs
+++ b/JinYuan.Models/SysConfig/SysConfig.cs
@@ -1,4 +1,4 @@
-namespace JinYuan.Models
+namespace JinYuan.Models.SysConfig
{
public class SysConfig
{
diff --git a/JinYuan.VirtualDataLibrary/CommonMethods.cs b/JinYuan.VirtualDataLibrary/CommonMethods.cs
index a3890e0..18c4abe 100644
--- a/JinYuan.VirtualDataLibrary/CommonMethods.cs
+++ b/JinYuan.VirtualDataLibrary/CommonMethods.cs
@@ -5,6 +5,8 @@ using JinYuan.DAL;
using JinYuan.Helper;
using JinYuan.MES;
using JinYuan.Models;
+using JinYuan.Models.SysConfig;
+using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
@@ -311,83 +313,96 @@ namespace JinYuan.VirtualDataLibrary
{
DateTime Date = DateTime.Now;
- #region 档位写入
MESGradingSet = new short[6];
- var gradingMap = new Dictionary();
- var gGradingMap = new Dictionary();
- short normalStart = 21;
- short gStart = 31;
- string[] specialGrading = new string[] { "NG", "扫码NG" };
- var gradings = new[] {
- mesConfig.Grading1.Trim(),
- mesConfig.Grading2.Trim(),
- mesConfig.Grading3.Trim(),
- mesConfig.Grading4.Trim(),
- mesConfig.Grading5.Trim(),
- mesConfig.Grading6.Trim()
- };
+ #region 档位写入
+ //var gradingMap = new Dictionary();
+ //var gGradingMap = new Dictionary();
+ //short normalStart = 21;
+ //short gStart = 31;
+ //string[] specialGrading = new string[] { "NG", "扫码NG" };
- for (int i = 0; i < gradings.Length; i++)
- {
- string grading = gradings[i];
- if (!specialGrading.Contains(grading) && grading.EndsWith("G"))
- {
- if (gGradingMap.TryGetValue(grading, out short value))
- MESGradingSet[i] = value;
- else
- {
- MESGradingSet[i] = gStart;
- gGradingMap.Add(grading, gStart);
- gStart++;
- }
- }
- else
- {
- if (gradingMap.TryGetValue(grading, out short value))
- MESGradingSet[i] = value;
- else
- {
- MESGradingSet[i] = normalStart;
- gradingMap.Add(grading, normalStart);
- normalStart++;
- }
- }
- }
+ //var gradings = new[] {
+ // mesConfig.Grading1.Trim(),
+ // mesConfig.Grading2.Trim(),
+ // mesConfig.Grading3.Trim(),
+ // mesConfig.Grading4.Trim(),
+ // mesConfig.Grading5.Trim(),
+ // mesConfig.Grading6.Trim()
+ //};
- #region 更新默认档位
- for (int i = 0; i < gradings.Length; i++)
- {
- switch (gradings[i])
- {
- /* 性能NG */
- case "NG":
- MESGradingSet[i] = 98;
- break;
- /* 外观检NG
- case "E63yG":
- MESGradingSet[i] = 31;
- break;
- case "F63yG":
- MESGradingSet[i] = 32;
- break;
- */
- /* 其它NG */
- case "拦截":
- case "扫码NG":
- case "其它":
- MESGradingSet[i] = 97;
- break;
- /* 性能NG */
- case "不设置":
- MESGradingSet[i] = 0;
- break;
- }
- }
- #endregion
+ //for (int i = 0; i < gradings.Length; i++)
+ //{
+ // string grading = gradings[i];
+ // if (!specialGrading.Contains(grading) && grading.EndsWith("G"))
+ // {
+ // if (gGradingMap.TryGetValue(grading, out short value))
+ // MESGradingSet[i] = value;
+ // else
+ // {
+ // MESGradingSet[i] = gStart;
+ // gGradingMap.Add(grading, gStart);
+ // gStart++;
+ // }
+ // }
+ // else
+ // {
+ // if (gradingMap.TryGetValue(grading, out short value))
+ // MESGradingSet[i] = value;
+ // else
+ // {
+ // MESGradingSet[i] = normalStart;
+ // gradingMap.Add(grading, normalStart);
+ // normalStart++;
+ // }
+ // }
+ //}
+
+ //#region 更新默认档位
+ //for (int i = 0; i < gradings.Length; i++)
+ //{
+ // switch (gradings[i])
+ // {
+ // /* 性能NG */
+ // case "NG":
+ // MESGradingSet[i] = 98;
+ // break;
+ // /* 外观检NG
+ // case "E63yG":
+ // MESGradingSet[i] = 31;
+ // break;
+ // case "F63yG":
+ // MESGradingSet[i] = 32;
+ // break;
+ // */
+ // /* 其它NG */
+ // case "拦截":
+ // case "扫码NG":
+ // case "其它":
+ // MESGradingSet[i] = 97;
+ // break;
+ // /* 性能NG */
+ // case "不设置":
+ // MESGradingSet[i] = 0;
+ // break;
+ // }
+ //}
+ //#endregion
#endregion
+ // 读取Chanel列表的默认值写入PLC
+ if (mesConfig.ChannelConfig?.Channels == null || mesConfig.ChannelConfig.Channels.Count != 6)
+ {
+ throw new ArgumentOutOfRangeException("Channel.json 不满足要求,文件不存在或没有6个通道");
+ }
+
+ var channels = mesConfig.ChannelConfig.Channels;
+ for (int i = 0; i < channels.Count; i++)
+ {
+ MESGradingSet[i] = (short)channels[i].DefaultValue;
+ }
+
var isWrite1 = PlcLink.WriteValue("D2600", MESGradingSet[0], Data_Type.Short);
var isWrite2 = PlcLink.WriteValue("D2601", MESGradingSet[1], Data_Type.Short);
var isWrite3 = PlcLink.WriteValue("D2602", MESGradingSet[2], Data_Type.Short);
@@ -519,6 +534,23 @@ namespace JinYuan.VirtualDataLibrary
public static string iniFilePath = Path.Combine(System.Windows.Forms.Application.StartupPath, "ini\\Configure.ini");
+ public static string ChannelPath = Path.Combine(System.Windows.Forms.Application.StartupPath, "Config\\settings.json");
+
+ #region 读取json配置
+ public static Models.SysConfig.ChannelConfig LoadFromJson(string filePath)
+ {
+ var json = File.ReadAllText(filePath);
+ return JsonConvert.DeserializeObject(json);
+ }
+
+ // 保存
+ public static void SaveToJson(string filePath, ChannelConfig config)
+ {
+ var json = JsonConvert.SerializeObject(config, Newtonsoft.Json.Formatting.Indented);
+ File.WriteAllText(filePath, json);
+ }
+ #endregion
+
#region 读取配置文件
///
@@ -549,7 +581,7 @@ namespace JinYuan.VirtualDataLibrary
mesConfig.Grading4 = IniConfigHelper.ReadIniData("MES配置", "Grading4", "false");
mesConfig.Grading5 = IniConfigHelper.ReadIniData("MES配置", "Grading5", "false");
mesConfig.Grading6 = IniConfigHelper.ReadIniData("MES配置", "Grading6", "false");
-
+ mesConfig.ChannelConfig = LoadFromJson(ChannelPath);
}
catch (Exception)
{
diff --git a/JinYuan.VirtualDataLibrary/JinYuan.VirtualDataLibrary.csproj b/JinYuan.VirtualDataLibrary/JinYuan.VirtualDataLibrary.csproj
index 29749b6..3698ba3 100644
--- a/JinYuan.VirtualDataLibrary/JinYuan.VirtualDataLibrary.csproj
+++ b/JinYuan.VirtualDataLibrary/JinYuan.VirtualDataLibrary.csproj
@@ -40,6 +40,9 @@
False
..\LargeSquareOne\Lib\JinYuan.CommunicationLib.dll
+
+ ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll
+
False
..\HBG_NegativeElectrodeWeld\Lib\PLCCommunication.dll
@@ -104,6 +107,7 @@
+
diff --git a/JinYuan.VirtualDataLibrary/MesConfig.cs b/JinYuan.VirtualDataLibrary/MesConfig.cs
index 5286fb4..4c8cec0 100644
--- a/JinYuan.VirtualDataLibrary/MesConfig.cs
+++ b/JinYuan.VirtualDataLibrary/MesConfig.cs
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using JinYuan.Models.SysConfig;
+using System.Collections.Generic;
namespace JinYuan.VirtualDataLibrary
{
@@ -139,6 +140,11 @@ namespace JinYuan.VirtualDataLibrary
///
public string Grading6 = "拦截";
+ ///
+ /// 通道档位设置
+ ///
+ public Models.SysConfig.ChannelConfig ChannelConfig = new ChannelConfig();
+
///
/// 设备状态
///
diff --git a/JinYuan.VirtualDataLibrary/packages.config b/JinYuan.VirtualDataLibrary/packages.config
new file mode 100644
index 0000000..e46d5a8
--- /dev/null
+++ b/JinYuan.VirtualDataLibrary/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/LargeSquareOne/Config/Channel.json b/LargeSquareOne/Config/Channel.json
new file mode 100644
index 0000000..7c11277
--- /dev/null
+++ b/LargeSquareOne/Config/Channel.json
@@ -0,0 +1,34 @@
+{
+ "channels": [
+ {
+ "channelId": 1,
+ "default": 21,
+ "gears": [ "E63y", "F63y" ]
+ },
+ {
+ "channelId": 2,
+ "default": 31,
+ "gears": [ "E63yG", "F63yG" ]
+ },
+ {
+ "channelId": 3,
+ "default": 98,
+ "gears": [ "NG" ]
+ },
+ {
+ "channelId": 4,
+ "default": 97,
+ "gears": [ "拦截" ]
+ },
+ {
+ "channelId": 5,
+ "default": 97,
+ "gears": [ "拦截" ]
+ },
+ {
+ "channelId": 6,
+ "default": 97,
+ "gears": [ "拦截" ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/LargeSquareOne/LargeSquareOne.csproj b/LargeSquareOne/LargeSquareOne.csproj
index 4c21d9c..cad0381 100644
--- a/LargeSquareOne/LargeSquareOne.csproj
+++ b/LargeSquareOne/LargeSquareOne.csproj
@@ -417,6 +417,9 @@
Always
+
+ PreserveNewest
+
Always