diff --git a/JinYuan.ControlCenter/ControlCenter_Plc.cs b/JinYuan.ControlCenter/ControlCenter_Plc.cs
index 352097d..f945b48 100644
--- a/JinYuan.ControlCenter/ControlCenter_Plc.cs
+++ b/JinYuan.ControlCenter/ControlCenter_Plc.cs
@@ -256,6 +256,23 @@ namespace JinYuan.ControlCenters
}
return Result;
}
+ private int JudgmentWGJResult(int A, int[,] B, int C)
+ {
+ int Result = 1;
+ OK_NG = "OK";
+ for (int i = 0; i < 28; i++)
+ {
+ if (B[C,i] ==1)
+ {
+ //1OK,2扫码NG,3MES反馈NG,4其他NG
+ Result = 4;
+ OK_NG = "NG";
+ NG_Type += $"外观检测NG{i + 1}";
+ }
+ }
+
+ return Result;
+ }
#region 上料工位(数据处理)
///
/// 上料工位
@@ -1801,38 +1818,39 @@ namespace JinYuan.ControlCenters
//不良代码判定
List NGcodeList = new List();
- NGcodeList = NGcode(m.list_Data1[i, 10], m.list_Data1[i, 11], m.list_Data1[i, 12], m.list_Data1[i, 15], m.list_Data1[i, 26], m.list_Data1[i, 16]
- , m.list_Data1[i, 17], m.list_Data1[i, 18], m.list_Data1[i, 19], m.list_Data1[i, 23], m.list_Data1[i, 24], m.list_Data1[i, 25], m.list_Data1[i, 27]);
+ //NGcodeList = NGcode(m.list_Data1[i, 10], m.list_Data1[i, 11], m.list_Data1[i, 12], m.list_Data1[i, 15], m.list_Data1[i, 26], m.list_Data1[i, 16]
+ // , m.list_Data1[i, 17], m.list_Data1[i, 18], m.list_Data1[i, 19], m.list_Data1[i, 23], m.list_Data1[i, 24], m.list_Data1[i, 25], m.list_Data1[i, 27]);
+ NGcodeList = NGWGJcode(m.list_Data1,i);
//电芯CCD判定结果
- #region //电芯CCD判定结果
- m.CCDResult1 = m.CCD_Data[i, 0] == 0 ? "OK" : (m.CCD_Data[i, 0] == 1 ? "NG" : "缺图");
- m.CCDResult2 = m.CCD_Data[i, 1] == 0 ? "OK" : (m.CCD_Data[i, 1] == 1 ? "NG" : "缺图");
- m.CCDResult3 = m.CCD_Data[i, 2] == 0 ? "OK" : (m.CCD_Data[i, 2] == 1 ? "NG" : "缺图");
- m.CCDResult4 = m.CCD_Data[i, 3] == 0 ? "OK" : (m.CCD_Data[i, 3] == 1 ? "NG" : "缺图");
- m.CCDResult5 = m.CCD_Data[i, 4] == 0 ? "OK" : (m.CCD_Data[i, 4] == 1 ? "NG" : "缺图");
- m.CCDResult6 = m.CCD_Data[i, 5] == 0 ? "OK" : (m.CCD_Data[i, 5] == 1 ? "NG" : "缺图");
- m.CCDResult7 = m.CCD_Data[i, 6] == 0 ? "OK" : (m.CCD_Data[i, 6] == 1 ? "NG" : "缺图");
- m.CCDResult8 = m.CCD_Data[i, 7] == 0 ? "OK" : (m.CCD_Data[i, 7] == 1 ? "NG" : "缺图");
- m.CCDResult9 = m.CCD_Data[i, 8] == 0 ? "OK" : (m.CCD_Data[i, 8] == 1 ? "NG" : "缺图");
- m.CCDResult10 = m.CCD_Data[i, 9] == 0 ? "OK" : (m.CCD_Data[i, 9] == 1 ? "NG" : "缺图");
- m.CCDResult11 = m.CCD_Data[i, 10] == 0 ? "OK" : (m.CCD_Data[i, 10] == 1 ? "NG" : "缺图");
- m.CCDResult12 = m.CCD_Data[i, 11] == 0 ? "OK" : (m.CCD_Data[i, 11] == 1 ? "NG" : "缺图");
- m.CCDResult13 = m.CCD_Data[i, 12] == 0 ? "OK" : (m.CCD_Data[i, 12] == 1 ? "NG" : "缺图");
- m.CCDResult14 = m.CCD_Data[i, 13] == 0 ? "OK" : (m.CCD_Data[i, 13] == 1 ? "NG" : "缺图");
- m.CCDResult15 = m.CCD_Data[i, 14] == 0 ? "OK" : (m.CCD_Data[i, 14] == 1 ? "NG" : "缺图");
- m.CCDResult16 = m.CCD_Data[i, 15] == 0 ? "OK" : (m.CCD_Data[i, 15] == 1 ? "NG" : "缺图");
- m.CCDResult17 = m.CCD_Data[i, 16] == 0 ? "OK" : (m.CCD_Data[i, 16] == 1 ? "NG" : "缺图");
- m.CCDResult18 = m.CCD_Data[i, 17] == 0 ? "OK" : (m.CCD_Data[i, 17] == 1 ? "NG" : "缺图");
- m.CCDResult19 = m.CCD_Data[i, 18] == 0 ? "OK" : (m.CCD_Data[i, 18] == 1 ? "NG" : "缺图");
- m.CCDResult20 = m.CCD_Data[i, 19] == 0 ? "OK" : (m.CCD_Data[i, 19] == 1 ? "NG" : "缺图");
- m.CCDResult21 = m.CCD_Data[i, 20] == 0 ? "OK" : (m.CCD_Data[i, 20] == 1 ? "NG" : "缺图");
- m.CCDResult22 = m.CCD_Data[i, 21] == 0 ? "OK" : (m.CCD_Data[i, 21] == 1 ? "NG" : "缺图");
- m.CCDResult23 = m.CCD_Data[i, 22] == 0 ? "OK" : (m.CCD_Data[i, 22] == 1 ? "NG" : "缺图");
- m.CCDResult24 = m.CCD_Data[i, 23] == 0 ? "OK" : (m.CCD_Data[i, 23] == 1 ? "NG" : "缺图");
- m.CCDResult25 = m.CCD_Data[i, 24] == 0 ? "OK" : (m.CCD_Data[i, 24] == 1 ? "NG" : "缺图");
- m.CCDResult26 = m.CCD_Data[i, 25] == 0 ? "OK" : (m.CCD_Data[i, 25] == 1 ? "NG" : "缺图");
- m.CCDResult27 = m.CCD_Data[i, 26] == 0 ? "OK" : (m.CCD_Data[i, 26] == 1 ? "NG" : "缺图");
+ #region //电芯CCD判定结果 1 0K 0NG 2缺图
+ m.CCDResult1 = m.CCD_Data[i, 0] == 1 ? "OK" : (m.CCD_Data[i, 0] == 0 ? "NG" : "缺图");
+ m.CCDResult2 = m.CCD_Data[i, 1] == 1 ? "OK" : (m.CCD_Data[i, 1] == 0 ? "NG" : "缺图");
+ m.CCDResult3 = m.CCD_Data[i, 2] == 1 ? "OK" : (m.CCD_Data[i, 2] == 0 ? "NG" : "缺图");
+ m.CCDResult4 = m.CCD_Data[i, 3] == 1 ? "OK" : (m.CCD_Data[i, 3] == 0 ? "NG" : "缺图");
+ m.CCDResult5 = m.CCD_Data[i, 4] == 1 ? "OK" : (m.CCD_Data[i, 4] == 0 ? "NG" : "缺图");
+ m.CCDResult6 = m.CCD_Data[i, 5] == 1 ? "OK" : (m.CCD_Data[i, 5] == 0 ? "NG" : "缺图");
+ m.CCDResult7 = m.CCD_Data[i, 6] == 1 ? "OK" : (m.CCD_Data[i, 6] == 0 ? "NG" : "缺图");
+ m.CCDResult8 = m.CCD_Data[i, 7] == 1 ? "OK" : (m.CCD_Data[i, 7] == 0 ? "NG" : "缺图");
+ m.CCDResult9 = m.CCD_Data[i, 8] == 1 ? "OK" : (m.CCD_Data[i, 8] == 0 ? "NG" : "缺图");
+ m.CCDResult10 = m.CCD_Data[i, 9] == 1 ? "OK" : (m.CCD_Data[i, 9] == 0 ? "NG" : "缺图");
+ m.CCDResult11 = m.CCD_Data[i, 10] == 1 ? "OK" : (m.CCD_Data[i, 10] == 0 ? "NG" : "缺图");
+ m.CCDResult12 = m.CCD_Data[i, 11] == 1 ? "OK" : (m.CCD_Data[i, 11] == 0 ? "NG" : "缺图");
+ m.CCDResult13 = m.CCD_Data[i, 12] == 1 ? "OK" : (m.CCD_Data[i, 12] == 0 ? "NG" : "缺图");
+ m.CCDResult14 = m.CCD_Data[i, 13] == 1 ? "OK" : (m.CCD_Data[i, 13] == 0 ? "NG" : "缺图");
+ m.CCDResult15 = m.CCD_Data[i, 14] == 1 ? "OK" : (m.CCD_Data[i, 14] == 0 ? "NG" : "缺图");
+ m.CCDResult16 = m.CCD_Data[i, 15] == 1 ? "OK" : (m.CCD_Data[i, 15] == 0 ? "NG" : "缺图");
+ m.CCDResult17 = m.CCD_Data[i, 16] == 1 ? "OK" : (m.CCD_Data[i, 16] == 0 ? "NG" : "缺图");
+ m.CCDResult18 = m.CCD_Data[i, 17] == 1 ? "OK" : (m.CCD_Data[i, 17] == 0 ? "NG" : "缺图");
+ m.CCDResult19 = m.CCD_Data[i, 18] == 1 ? "OK" : (m.CCD_Data[i, 18] == 0 ? "NG" : "缺图");
+ m.CCDResult20 = m.CCD_Data[i, 19] == 1 ? "OK" : (m.CCD_Data[i, 19] == 0 ? "NG" : "缺图");
+ m.CCDResult21 = m.CCD_Data[i, 20] == 1 ? "OK" : (m.CCD_Data[i, 20] == 0 ? "NG" : "缺图");
+ m.CCDResult22 = m.CCD_Data[i, 21] == 1 ? "OK" : (m.CCD_Data[i, 21] == 0 ? "NG" : "缺图");
+ m.CCDResult23 = m.CCD_Data[i, 22] == 1 ? "OK" : (m.CCD_Data[i, 22] == 0 ? "NG" : "缺图");
+ m.CCDResult24 = m.CCD_Data[i, 23] == 1 ? "OK" : (m.CCD_Data[i, 23] == 0 ? "NG" : "缺图");
+ m.CCDResult25 = m.CCD_Data[i, 24] == 1 ? "OK" : (m.CCD_Data[i, 24] == 0 ? "NG" : "缺图");
+ m.CCDResult26 = m.CCD_Data[i, 25] == 1 ? "OK" : (m.CCD_Data[i, 25] == 0 ? "NG" : "缺图");
+ m.CCDResult27 = m.CCD_Data[i, 26] == 1 ? "OK" : (m.CCD_Data[i, 26] == 0 ? "NG" : "缺图");
#endregion
m.CSBYHASCANNINGTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
@@ -1851,9 +1869,10 @@ namespace JinYuan.ControlCenters
{
for (int ii = 0; ii < 27; ii++)
{
- if (m.CCD_Data[i, ii] != 0)
+ if (m.CCD_Data[i, ii] != 1)
{
- MyRes[i] = m.CCD_Data[i, ii];
+ //1OK,2扫码NG,3MES反馈NG,4其他NG
+ MyRes[i] = 4;
break;
}
@@ -1861,7 +1880,7 @@ namespace JinYuan.ControlCenters
}
else
MyRes[i] = 1;
- //MyRes[i] = JudgmentResult(Code_NG, m.CCD_Data);
+ MyRes[i] = JudgmentWGJResult(Code_NG, m.CCD_Data,i);
m.Result = MyRes[i];
@@ -2008,11 +2027,12 @@ namespace JinYuan.ControlCenters
#endregion
JYResult result1 = null;
JYResult result2 = null;
+ JYResult result3 = null;
if (pf.IsFeedbackPlc)
{
//result1 = CommonMethods.PlcLink.WriteValue(pf.VarList[2].VarAddress, MyRes[0], Data_Type.Short);//判断结果写入PLC
//result2 = CommonMethods.PlcLink.WriteValue(pf.VarList[3].VarAddress, MyRes[1], Data_Type.Short);//判断结果写入PLC
- //if (CommonMethods.sysConfig.OKSwitching)
+ // if (CommonMethods.sysConfig.OKSwitching)
{
//调试发OK
//MyRes[0] = 1;
@@ -2020,7 +2040,7 @@ namespace JinYuan.ControlCenters
Thread.Sleep(500);
result1 = CommonMethods.PlcLink.WriteValue(pf.VarList[2].VarAddress, MyRes[0], Data_Type.Short);//判断结果写入PLC
result2 = CommonMethods.PlcLink.WriteValue(pf.VarList[3].VarAddress, MyRes[1], Data_Type.Short);//判断结果写入PLC
- result2 = CommonMethods.PlcLink.WriteValue(pf.VarList[4].VarAddress, MyRes[2], Data_Type.Short);//判断结果写入PLC
+ result3 = CommonMethods.PlcLink.WriteValue(pf.VarList[4].VarAddress, MyRes[2], Data_Type.Short);//判断结果写入PLC
}
//else
//{
@@ -2030,7 +2050,7 @@ namespace JinYuan.ControlCenters
// result2 = CommonMethods.PlcLink.WriteValue(pf.VarList[3].VarAddress, MyRes[1], Data_Type.Short);//判断结果写入PLC
//}
}
- JYResult result3 = CommonMethods.PlcLink.WriteValue(pf.VarList[0].VarAddress, 0);//置位0
+ JYResult result4 = CommonMethods.PlcLink.WriteValue(pf.VarList[0].VarAddress, 0);//置位0
CommonMethods.AddDataMonitorLog(0, $"发送信息给PLC:{result1.IsSuccess},{MyRes[0]},{MyRes[1]},{MyRes[2]}");
LoggerHelp.WriteLog($"发送信息给PLC:{result1.IsSuccess},{MyRes[0]},{MyRes[1]},{MyRes[2]}");
@@ -2212,6 +2232,20 @@ namespace JinYuan.ControlCenters
return NGcodelist;
}
+ //下料不良代码 外观检
+ public List NGWGJcode(short[ ,] lstResult,int index)
+ {
+ List NGcodelist = new List();
+ for (int i = 0; i < 28; i++)
+ {
+ if(lstResult[index,i] == 2)
+ {
+ NGcodelist.Add("WGJA00"+(i+1));
+ }
+ }
+
+ return NGcodelist;
+ }
#endregion
#region NG下料不良代码
diff --git a/JinYuan.MES/MesDataProcess.cs b/JinYuan.MES/MesDataProcess.cs
index b09aaf2..7c5de03 100644
--- a/JinYuan.MES/MesDataProcess.cs
+++ b/JinYuan.MES/MesDataProcess.cs
@@ -783,14 +783,14 @@ namespace JinYuan.MES
long outTime = sw.ElapsedMilliseconds;
if (outTime > 1000)
{
- LoggerHelp.WriteLog($"预焊出站PC<=>MES上传耗时:{outTime}ms,电芯码:{listBar.CSBYHCODEA}", "MESTime");
+ LoggerHelp.WriteLog($"外观检出站PC<=>MES上传耗时:{outTime}ms,电芯码:{listBar.CSBYHCODEA}", "MESTime");
}
if (string.IsNullOrEmpty(result))
{
string resData = result == "" ? "" : result;
- resJson = $"{nowDate.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用产品出站信息(组装)接口:{url},请求数据为:{postcontent},\n{nowDate.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{resData}";
- TxtHelper.WriteTxt($@"D:\APILog\Logs\MesLogs\{nowDate.ToString("yyyyMMdd")}\产品出站信息(组装)\{nowDate.ToString("HH")}.txt", resJson);
+ resJson = $"{nowDate.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用产品出站信息(包装)接口:{url},请求数据为:{postcontent},\n{nowDate.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{resData}";
+ TxtHelper.WriteTxt($@"D:\APILog\Logs\MesLogs\{nowDate.ToString("yyyyMMdd")}\产品出站信息(包装)\{nowDate.ToString("HH")}.txt", resJson);
return res;
}
@@ -799,22 +799,22 @@ namespace JinYuan.MES
{
res = true;
GetOutMesResType(res1, listBar.CSBYHCODEA, ref MesMessage, ref mesResType);
- resJson = $"{nowDate.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用产品出站信息(组装)接口:{url},请求数据为:{postcontent},\n{nowDate.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{result}";
- TxtHelper.WriteTxt($@"D:\APILog\Logs\MesLogs\{nowDate.ToString("yyyyMMdd")}\产品出站信息(组装)\{nowDate.ToString("HH")}.txt", resJson);
+ resJson = $"{nowDate.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用产品出站信息(包装)接口:{url},请求数据为:{postcontent},\n{nowDate.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{result}";
+ TxtHelper.WriteTxt($@"D:\APILog\Logs\MesLogs\{nowDate.ToString("yyyyMMdd")}\产品出站信息(包装)\{nowDate.ToString("HH")}.txt", resJson);
}
else
{
GetOutMesResType(res1, listBar.CSBYHCODEA, ref MesMessage, ref mesResType);
var resData = res1 == null ? "" : result;
- resJson = $"{nowDate.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用产品出站信息(组装)接口:{url},请求数据为:{postcontent},\n{nowDate.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{resData}";
- TxtHelper.WriteTxt($@"D:\APILog\Logs\MesLogs\{nowDate.ToString("yyyyMMdd")}\产品出站信息(组装)\{nowDate.ToString("HH")}.txt", resJson);
+ resJson = $"{nowDate.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用产品出站信息(包装)接口:{url},请求数据为:{postcontent},\n{nowDate.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{resData}";
+ TxtHelper.WriteTxt($@"D:\APILog\Logs\MesLogs\{nowDate.ToString("yyyyMMdd")}\产品出站信息(包装)\{nowDate.ToString("HH")}.txt", resJson);
}
}
catch (Exception ex)
{
- resJson = $"产品出站信息(组装)接口发生异常:{ex.Message}";
- LoggerHelp.WriteEX("产品出站信息(组装)接口", ex);
+ resJson = $"产品出站信息(包装)接口发生异常:{ex.Message}";
+ LoggerHelp.WriteEX("产品出站信息(包装)接口", ex);
}
return res;
diff --git a/JinYuan.Models/FDConfig.cs b/JinYuan.Models/FDConfig.cs
new file mode 100644
index 0000000..a340e8d
--- /dev/null
+++ b/JinYuan.Models/FDConfig.cs
@@ -0,0 +1,52 @@
+using SqlSugar;
+
+namespace JinYuan.Models
+{
+ public class FDConfig
+ {
+ ///
+ /// 编号
+ ///
+
+ public int FdNum { get; set; }
+ ///
+ /// OK拉带类型1
+ ///
+ public string OKLD1Type { get; set; }
+ ///
+ /// OK拉带类型2
+ ///
+ public string OKLD2Type { get; set; }
+ ///
+ /// OK拉带类型3
+ ///
+ public string OKLD3Type { get; set; }
+ ///
+ /// OK拉带类型4
+ ///
+ public string OKLD4Type { get; set; }
+ ///
+ /// NG拉带类型5
+ ///
+ public string NGLD5Type { get; set; }
+ ///
+ /// NG拉带类型6
+ ///
+ public string NGLD6Type { get; set; }
+ ///
+ /// NG拉带类型7
+ ///
+ public string NGLD7Type { get; set; }
+ ///
+ /// 是否开启分档
+ ///
+ public bool IsFDActive { get; set; }
+ ///
+ ///是否激活NG电池不分类排出
+ ///
+
+ public bool IsNGActive { get; set; }
+
+
+ }
+}
diff --git a/JinYuan.Models/JinYuan.Models.csproj b/JinYuan.Models/JinYuan.Models.csproj
index 2e2a31e..89adaba 100644
--- a/JinYuan.Models/JinYuan.Models.csproj
+++ b/JinYuan.Models/JinYuan.Models.csproj
@@ -84,6 +84,7 @@
+
diff --git a/JinYuan.VirtualDataLibrary/MesConfig.cs b/JinYuan.VirtualDataLibrary/MesConfig.cs
index 2294e38..50553f4 100644
--- a/JinYuan.VirtualDataLibrary/MesConfig.cs
+++ b/JinYuan.VirtualDataLibrary/MesConfig.cs
@@ -184,6 +184,10 @@ namespace JinYuan.VirtualDataLibrary
/// 设备风速接口
///
public string CollectData = "http://10.1.3.66:3000/mock/15/eve_api/ems/iot/upload_device_collect_data";
+ ///
+ /// 设备风速接口
+ ///
+ public string OkNgParamMesUrl = "http://10.17.128.206/core/api/public/eve/pm/eqm/new/grading";
}
}
diff --git a/LargeSquareOne/App.config b/LargeSquareOne/App.config
index 71dfbd6..04900ab 100644
--- a/LargeSquareOne/App.config
+++ b/LargeSquareOne/App.config
@@ -5,7 +5,7 @@
-
+
diff --git a/LargeSquareOne/Config/Configure.ini b/LargeSquareOne/Config/Configure.ini
index b982b35..e6ff45d 100644
--- a/LargeSquareOne/Config/Configure.ini
+++ b/LargeSquareOne/Config/Configure.ini
@@ -34,6 +34,8 @@ MES
É豸״̬=http://10.22.160.141/core/api/public/eve/pm/eqm/run/status/operation
ÄܺÄ=http://10.22.160.141/core/api/public/eve/pm/energy/consumption/collection/submit
·çËÙÒÇ=https://iot.eveportal.com:9470/eve_api/ems/iot/upload_device_collect_data
+·çËÙÒÇ=https://iot.eveportal.com:9470/eve_api/ems/iot/upload_device_collect_data
+·ֵµ²ÎÊý=http://10.22.160.141/core/api/public/eve/pm/eqm/new/grading
guid=a270c7d2-9cbd-4739-9a0b-0709b5813332
DeviceState=1
run_AlarmMark=0
diff --git a/LargeSquareOne/Config/Device.xlsx b/LargeSquareOne/Config/Device.xlsx
new file mode 100644
index 0000000..c5d26eb
Binary files /dev/null and b/LargeSquareOne/Config/Device.xlsx differ
diff --git a/LargeSquareOne/Config/FdConfig.xlsx b/LargeSquareOne/Config/FdConfig.xlsx
new file mode 100644
index 0000000..17a4569
Binary files /dev/null and b/LargeSquareOne/Config/FdConfig.xlsx differ
diff --git a/LargeSquareOne/FrmMain.cs b/LargeSquareOne/FrmMain.cs
index cecac8b..5f95ae1 100644
--- a/LargeSquareOne/FrmMain.cs
+++ b/LargeSquareOne/FrmMain.cs
@@ -198,6 +198,7 @@ namespace LargeSquareOne
CommonMethods.mesConfig.InPutStationMesUrl = IniConfigHelper.ReadIniData("MES配置", "产品进站", "0");
CommonMethods.mesConfig.EquProcessProcessParamMesUrl = IniConfigHelper.ReadIniData("MES配置", "产品过程加工参数", "0");
CommonMethods.mesConfig.ResultProcessParamMesUrl = IniConfigHelper.ReadIniData("MES配置", "产品结果加工参数", "0");
+ CommonMethods.mesConfig.OkNgParamMesUrl = IniConfigHelper.ReadIniData("MES配置", "分档参数", "0");
CommonMethods.mesConfig.OutStationMesUrl = IniConfigHelper.ReadIniData("MES配置", "产品出站", "0");
CommonMethods.mesConfig.AlarmCurrencyMesUrl = IniConfigHelper.ReadIniData("MES配置", "设备报警", "0");
CommonMethods.mesConfig.StatusMesUrl = IniConfigHelper.ReadIniData("MES配置", "设备状态", "0");
diff --git a/LargeSquareOne/FrmParamSet.Designer.cs b/LargeSquareOne/FrmParamSet.Designer.cs
index b83aa9c..de3ef9c 100644
--- a/LargeSquareOne/FrmParamSet.Designer.cs
+++ b/LargeSquareOne/FrmParamSet.Designer.cs
@@ -29,6 +29,9 @@
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmSystemSet));
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
this.up_QieHuanPeriod = new JinYuan.ControlLib.UpDownLabel();
this.tog_AutoQieHuanM = new JinYuan.ControlLib.Toggle();
this.label16 = new System.Windows.Forms.Label();
@@ -73,6 +76,9 @@
this.title1 = new JinYuan.ControlLib.Title();
this.label18 = new System.Windows.Forms.Label();
this.tog_OKSwitching = new JinYuan.ControlLib.Toggle();
+ this.title5 = new JinYuan.ControlLib.Title();
+ this.dgvFdConfigs = new System.Windows.Forms.DataGridView();
+ ((System.ComponentModel.ISupportInitialize)(this.dgvFdConfigs)).BeginInit();
this.SuspendLayout();
//
// up_QieHuanPeriod
@@ -647,12 +653,73 @@
this.tog_OKSwitching.TrueText = "";
this.tog_OKSwitching.CheckedChanged += new System.EventHandler(this.tog_OKSwitching_CheckedChanged);
//
+ // title5
+ //
+ this.title5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(5)))), ((int)(((byte)(28)))), ((int)(((byte)(68)))));
+ this.title5.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("title5.BackgroundImage")));
+ this.title5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.title5.Font = new System.Drawing.Font("微软雅黑", 14.25F, System.Drawing.FontStyle.Bold);
+ this.title5.Location = new System.Drawing.Point(22, 424);
+ this.title5.Margin = new System.Windows.Forms.Padding(5, 8, 5, 8);
+ this.title5.Name = "title5";
+ this.title5.Size = new System.Drawing.Size(117, 37);
+ this.title5.TabIndex = 49;
+ this.title5.TitleName = "分档设置";
+ //
+ // dgvFdConfigs
+ //
+ this.dgvFdConfigs.AllowUserToAddRows = false;
+ this.dgvFdConfigs.AllowUserToDeleteRows = false;
+ this.dgvFdConfigs.AllowUserToResizeRows = false;
+ this.dgvFdConfigs.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(14)))), ((int)(((byte)(23)))), ((int)(((byte)(38)))));
+ this.dgvFdConfigs.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
+ this.dgvFdConfigs.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
+ dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
+ dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(14)))), ((int)(((byte)(23)))), ((int)(((byte)(38)))));
+ dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 10.5F);
+ dataGridViewCellStyle1.ForeColor = System.Drawing.Color.White;
+ dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(14)))), ((int)(((byte)(23)))), ((int)(((byte)(38)))));
+ dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+ dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+ this.dgvFdConfigs.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
+ this.dgvFdConfigs.ColumnHeadersHeight = 40;
+ this.dgvFdConfigs.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
+ dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+ dataGridViewCellStyle2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(6)))), ((int)(((byte)(40)))), ((int)(((byte)(86)))));
+ dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 10.5F);
+ dataGridViewCellStyle2.ForeColor = System.Drawing.Color.White;
+ dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+ dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+ dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
+ this.dgvFdConfigs.DefaultCellStyle = dataGridViewCellStyle2;
+ this.dgvFdConfigs.EnableHeadersVisualStyles = false;
+ this.dgvFdConfigs.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(21)))), ((int)(((byte)(77)))), ((int)(((byte)(147)))));
+ this.dgvFdConfigs.Location = new System.Drawing.Point(44, 486);
+ this.dgvFdConfigs.Name = "dgvFdConfigs";
+ this.dgvFdConfigs.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
+ dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+ dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(6)))), ((int)(((byte)(40)))), ((int)(((byte)(86)))));
+ dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 10.5F);
+ dataGridViewCellStyle3.ForeColor = System.Drawing.Color.White;
+ dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+ dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+ dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+ this.dgvFdConfigs.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
+ this.dgvFdConfigs.RowHeadersWidth = 55;
+ this.dgvFdConfigs.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
+ this.dgvFdConfigs.RowTemplate.Height = 40;
+ this.dgvFdConfigs.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.False;
+ this.dgvFdConfigs.Size = new System.Drawing.Size(1757, 69);
+ this.dgvFdConfigs.TabIndex = 78;
+ //
// FrmSystemSet
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(14)))), ((int)(((byte)(23)))), ((int)(((byte)(38)))));
this.ClientSize = new System.Drawing.Size(1370, 651);
+ this.Controls.Add(this.dgvFdConfigs);
+ this.Controls.Add(this.title5);
this.Controls.Add(this.tog_OKSwitching);
this.Controls.Add(this.label18);
this.Controls.Add(this.up_QieHuanPeriod);
@@ -702,6 +769,7 @@
this.Margin = new System.Windows.Forms.Padding(5);
this.Name = "FrmSystemSet";
this.Text = "系统设置";
+ ((System.ComponentModel.ISupportInitialize)(this.dgvFdConfigs)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -752,5 +820,7 @@
private System.Windows.Forms.Label label17;
private System.Windows.Forms.Label label18;
private JinYuan.ControlLib.Toggle tog_OKSwitching;
+ private JinYuan.ControlLib.Title title5;
+ private System.Windows.Forms.DataGridView dgvFdConfigs;
}
}
\ No newline at end of file
diff --git a/LargeSquareOne/FrmParamSet.cs b/LargeSquareOne/FrmParamSet.cs
index 8d2e651..ab3756d 100644
--- a/LargeSquareOne/FrmParamSet.cs
+++ b/LargeSquareOne/FrmParamSet.cs
@@ -1,15 +1,32 @@
-using JinYuan.ControlLib;
+using JinYuan.CommunicationLib.Enum;
+using JinYuan.ControlLib;
using JinYuan.Helper;
+using JinYuan.Models;
using JinYuan.VirtualDataLibrary;
using Microsoft.Win32;
+using MiniExcelLibs;
using System;
+using System.Collections.Generic;
+using System.ComponentModel;
using System.IO;
using System.Windows.Forms;
+using System.Linq;
+using static Org.BouncyCastle.Math.EC.ECCurve;
+using System.Drawing;
namespace LargeSquareOne
{
public partial class FrmSystemSet : Form
{
+ private string FdConfigFilePath = "fd_config.xlsx";
+ private List fdConfigs;
+ private List PLCTypes = new List();
+ private List NGLDTypes1 = new List();//NG拉带类型
+ private List NGLDTypes2 = new List();//NG拉带类型
+ private List NGLDTypes3 = new List();//NG拉带类型
+ private bool isFDEditing = false;
+ private int editingFDRowIndex = -1;
+ private readonly string configFolderPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config");
///
/// 打印日志方法
///
@@ -49,6 +66,14 @@ namespace LargeSquareOne
this.cmb_PLCType.Items.Add("Mitsubishi");
this.cmb_PLCType.Items.Add("Inovance");
+ FdConfigFilePath = Path.Combine(configFolderPath, "FdConfig.xlsx");
+ PLCTypes.AddRange(new string[] { "OmronFinsTCP", "OmronCipNet" });
+ NGLDTypes1.AddRange(new string[] { "面1", "面2", "面3" });
+ NGLDTypes2.AddRange(new string[] { "面1", "面2", "面3" });
+ NGLDTypes3.AddRange(new string[] { "面1", "面2", "面3" });
+ SetupFDDataGridView();
+ LoadFDConfig();
+
this.tog_AutoStart.IsChecked = CommonMethods.sysConfig.AutoStart;
this.tog_AutoLogin.IsChecked = CommonMethods.sysConfig.AutoLogin;
this.tog_AutoLock.IsChecked = CommonMethods.sysConfig.AutoLock;
@@ -73,7 +98,7 @@ namespace LargeSquareOne
this.up_ShowSeriesCount.ValueChanged += new System.EventHandler(this.up_ShowSeriesCount_ValueChanged);
this.devPath = devPath;
-
+
InitParam();
}
@@ -417,5 +442,424 @@ namespace LargeSquareOne
LogMessage(OKMessage, "强制结果OK日志");
}
}
+
+ #region 分档设置
+ private void LoadFDConfig()
+ {
+
+ try
+ {
+ if (File.Exists(FdConfigFilePath))
+ {
+ using (var stream = File.OpenRead(FdConfigFilePath))
+ {
+ var devices = MiniExcel.Query(stream).ToList();
+ fdConfigs = devices.Select(device => new FDConfig
+ {
+ FdNum = device.FdNum,
+ OKLD1Type = device.OKLD1Type,
+ OKLD2Type = device.OKLD2Type,
+ OKLD3Type = device.OKLD3Type,
+ OKLD4Type = device.OKLD4Type,
+ NGLD5Type = device.NGLD5Type,
+ NGLD6Type = device.NGLD6Type,
+ NGLD7Type = device.NGLD7Type,
+ IsFDActive = device.IsFDActive,
+ IsNGActive = device.IsNGActive
+ }).ToList();
+ }
+
+ }
+ else
+ {
+ fdConfigs = new List();
+ }
+
+ RefreshFDDataGridView();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"加载配置文件失败:{ex.Message}", "错误",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ fdConfigs = new List();
+ }
+
+
+ }
+ private void SetColumnsFDReadOnly(bool readOnly)
+ {
+ foreach (DataGridViewColumn col in dgvFdConfigs.Columns)
+ {
+ // PlcNum 列始终保持只读
+ if (col.Name == "FdNum")
+ {
+ col.ReadOnly = true;
+ continue;
+ }
+
+ // 按钮列不需要设置 ReadOnly 属性
+ if (col is DataGridViewButtonColumn)
+ continue;
+
+ // 其他列根据参数设置
+ col.ReadOnly = readOnly;
+ }
+ }
+
+ ///
+ /// 初始化分档DataGrid
+ ///
+ private void SetupFDDataGridView()
+ {
+ // 设置基本属性
+ dgvFdConfigs.AutoGenerateColumns = false;
+ dgvFdConfigs.MultiSelect = false;
+
+ // 添加数据列
+ dgvFdConfigs.Columns.AddRange(new DataGridViewColumn[]
+ {
+ new DataGridViewTextBoxColumn
+ {
+ Name = "FdNum",
+ HeaderText = "分档编号",
+ DataPropertyName = "FdNum",
+ ReadOnly = true,
+ Width = 80,
+ ValueType = typeof(int)
+ },
+ #region 分档类型
+ new DataGridViewTextBoxColumn
+ {
+ Name = "OKLD1Type",
+ HeaderText = "OK拉带类型1",
+ DataPropertyName = "OKLD1Type",
+ Width = 120,
+ ValueType = typeof(string)
+ },
+ new DataGridViewTextBoxColumn
+ {
+ Name = "OKLD2Type",
+ HeaderText = "OK拉带类型2",
+ DataPropertyName = "OKLD2Type",
+ Width = 120,
+ ValueType = typeof(string)
+ },
+ new DataGridViewTextBoxColumn
+ {
+ Name = "OKLD3Type",
+ HeaderText = "OK拉带类型3",
+ DataPropertyName = "OKLD3Type",
+ Width = 120,
+ ValueType = typeof(string)
+ },
+ new DataGridViewTextBoxColumn
+ {
+ Name = "OKLD4Type",
+ HeaderText = "OK拉带类型4",
+ DataPropertyName = "OKLD4Type",
+ Width = 120,
+ ValueType = typeof(string)
+ },
+ #endregion
+ #region NG拉带类型
+ new DataGridViewComboBoxColumn
+ {
+ Name = "NGLD5Type",
+ HeaderText = "NG拉带类型5",
+ DataPropertyName = "NGLD5Type",//NG拉带
+ DataSource = new List(NGLDTypes1), // 使用新列表避免引用问题
+ Width = 160,
+ ValueType = typeof(string),
+ FlatStyle = FlatStyle.Flat,
+ DefaultCellStyle = new DataGridViewCellStyle
+ {
+ BackColor = Color.FromArgb(14, 23, 38), // 深色背景
+ ForeColor = Color.White, // 白色文字
+ SelectionBackColor = Color.FromArgb(0, 122, 204), // 选中时的背景色
+ SelectionForeColor = Color.White, // 选中时的文字颜色
+ Font = new Font("微软雅黑", 9F) // 字体设置
+ }
+ },
+ new DataGridViewComboBoxColumn
+ {
+ Name = "NGLD6Type",
+ HeaderText = "NG拉带类型6",
+ DataPropertyName = "NGLD6Type",//NG拉带
+ DataSource = new List(NGLDTypes2), // 使用新列表避免引用问题
+ Width = 160,
+ ValueType = typeof(string),
+ FlatStyle = FlatStyle.Flat,
+ DefaultCellStyle = new DataGridViewCellStyle
+ {
+ BackColor = Color.FromArgb(14, 23, 38), // 深色背景
+ ForeColor = Color.White, // 白色文字
+ SelectionBackColor = Color.FromArgb(0, 122, 204), // 选中时的背景色
+ SelectionForeColor = Color.White, // 选中时的文字颜色
+ Font = new Font("微软雅黑", 9F) // 字体设置
+ }
+ },
+ new DataGridViewComboBoxColumn
+ {
+ Name = "NGLD7Type",
+ HeaderText = "NG拉带类型7",
+ DataPropertyName = "NGLD7Type",//NG拉带
+ DataSource = new List(NGLDTypes3), // 使用新列表避免引用问题
+ Width = 160,
+ ValueType = typeof(string),
+ FlatStyle = FlatStyle.Flat,
+ DefaultCellStyle = new DataGridViewCellStyle
+ {
+ BackColor = Color.FromArgb(14, 23, 38), // 深色背景
+ ForeColor = Color.White, // 白色文字
+ SelectionBackColor = Color.FromArgb(0, 122, 204), // 选中时的背景色
+ SelectionForeColor = Color.White, // 选中时的文字颜色
+ Font = new Font("微软雅黑", 9F) // 字体设置
+ }
+ },
+ #endregion
+ #region 开启分档
+ new DataGridViewCheckBoxColumn
+ {
+ Name = "IsFDActive",
+ HeaderText = "开启分档",
+ DataPropertyName = "IsFDActive",
+ Width = 80,
+ ValueType = typeof(bool),
+ TrueValue = true,
+ FalseValue = false
+ },
+ new DataGridViewCheckBoxColumn
+ {
+ Name = "IsNGActive",
+ HeaderText = "NG电池不分类排出",
+ DataPropertyName = "IsNGActive",
+ Width = 80,
+ ValueType = typeof(bool),
+ TrueValue = true,
+ FalseValue = false
+ },
+ #endregion
+
+ new DataGridViewButtonColumn
+ {
+ Name = "Edit",
+ HeaderText = "操作",
+ Text = "修改",
+ UseColumnTextForButtonValue = true,
+ Width = 80
+ }
+
+
+ });
+
+
+ // 设置列为只读
+ SetColumnsFDReadOnly(false);
+
+ // 绑定事件
+ dgvFdConfigs.CellClick += DgvFdConfigs_CellClick;
+ dgvFdConfigs.CellValidating += DgvFdConfigs_CellValidating;
+ dgvFdConfigs.CellValueChanged += DgvFdConfigs_CellValueChanged;
+ dgvFdConfigs.DataError += DgvFdConfigs_DataError;
+
+ // 设置自动调整行高
+ dgvFdConfigs.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
+ dgvFdConfigs.RowHeadersVisible = false;
+ }
+ private void DgvFdConfigs_CellClick(object sender, DataGridViewCellEventArgs e)
+ {
+ if (e.RowIndex < 0) return;
+
+ var columnName = dgvFdConfigs.Columns[e.ColumnIndex].Name;
+
+ // 如果正在编辑其他行,阻止操作
+ if (isFDEditing && editingFDRowIndex != e.RowIndex)
+ {
+ MessageBox.Show("请先完成当前编辑操作", "提示",
+ MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ return;
+ }
+
+ var fdConfig = fdConfigs[e.RowIndex];
+
+ switch (columnName)
+ {
+ case "Edit":
+ HandleFDEdit(e.RowIndex);
+ break;
+ case "CommConfig":
+ HandleCommFdConfig(fdConfig);
+ break;
+ case "VariableConfig":
+ HandleVariableFdConfig(fdConfig);
+ break;
+ case "Delete":
+ HandleFdDelete(e.RowIndex, fdConfig);
+ break;
+ }
+ }
+ private void HandleFDEdit(int rowIndex)
+ {
+ if (!isFDEditing)
+ {
+ // 开始编辑
+ isFDEditing = true;
+ editingFDRowIndex = rowIndex;
+ SetColumnsFDReadOnly(false); // 设置其他列为可编辑
+
+ // 更改编辑按钮文本为"保存"
+ dgvFdConfigs.Rows[rowIndex].Cells["Edit"].Value = "保存";
+
+ // 禁用其他行的按钮
+ foreach (DataGridViewRow row in dgvFdConfigs.Rows)
+ {
+ if (row.Index != rowIndex)
+ {
+ if (row.Cells["Edit"] is DataGridViewButtonCell editCell)
+ editCell.Value = "";
+ if (row.Cells["CommConfig"] is DataGridViewButtonCell configCell)
+ configCell.Value = "";
+ if (row.Cells["Delete"] is DataGridViewButtonCell deleteCell)
+ deleteCell.Value = "";
+ }
+ }
+
+ // 禁用添加按钮
+ //btAddPLC.Enabled = false;
+ }
+ else if (rowIndex == editingFDRowIndex)
+ {
+ // 保存更改
+ //if (ValidateRow(rowIndex))
+ {
+ SaveFDChanges(rowIndex);
+ EndFDEditing();
+ }
+ }
+ }
+ private void EndFDEditing()
+ {
+ isFDEditing = false;
+ editingFDRowIndex = -1;
+ SetColumnsFDReadOnly(true);
+
+ // 恢复所有按钮文本和状态
+ foreach (DataGridViewRow row in dgvFdConfigs.Rows)
+ {
+ row.Cells["Edit"].Value = "编辑";
+ // row.Cells["CommConfig"].Value = "通信组";
+ // row.Cells["Delete"].Value = "删除";
+ }
+
+ // 启用添加按钮
+ //btAddPLC.Enabled = true;
+ }
+ private void HandleCommFdConfig(FDConfig fdconfig)
+ {
+ }
+ private void HandleVariableFdConfig(FDConfig fdconfig)
+ {
+
+ }
+ private void HandleFdDelete(int rowIndex, FDConfig fdconfig)
+ {
+ if (MessageBox.Show($"确定要删除 分档 {fdconfig.FdNum} 吗?", "确认删除",
+ MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ fdConfigs.RemoveAt(rowIndex);
+ SaveFDConfig();
+ RefreshFDDataGridView();
+ }
+ }
+ private void SaveFDChanges(int rowIndex)
+ {
+ try
+ {
+ var row = dgvFdConfigs.Rows[rowIndex];
+ var config = fdConfigs[rowIndex];
+
+ // 更新配置对象
+ config.OKLD1Type = row.Cells["OKLD1Type"].Value?.ToString() ?? "";
+ config.OKLD2Type = row.Cells["OKLD2Type"].Value?.ToString() ?? "";
+ config.OKLD3Type = row.Cells["OKLD3Type"].Value?.ToString() ?? "";
+ config.OKLD4Type = row.Cells["OKLD4Type"].Value?.ToString() ?? "";
+ config.NGLD5Type = row.Cells["NGLD5Type"].Value?.ToString() ?? "";
+ config.NGLD6Type = row.Cells["NGLD6Type"].Value?.ToString() ?? "";
+ config.NGLD7Type = row.Cells["NGLD7Type"].Value?.ToString() ?? "";
+
+ config.IsFDActive = row.Cells["IsFDActive"].Value != null &&
+ Convert.ToBoolean(row.Cells["IsFDActive"].Value);
+ config.IsNGActive = row.Cells["IsNGActive"].Value != null &&
+ Convert.ToBoolean(row.Cells["IsNGActive"].Value);
+
+ // 保存更改
+ SaveFDConfig();
+ MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ catch (Exception ex)
+ {
+ // 这里只显示错误信息,不再抛出异常
+ MessageBox.Show($"保存失败:{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void DgvFdConfigs_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
+ {
+ if (e.RowIndex < 0 || !isFDEditing || e.RowIndex != editingFDRowIndex) return;
+
+ string newValue = e.FormattedValue.ToString();
+ var column = dgvFdConfigs.Columns[e.ColumnIndex];
+
+ }
+ private void DgvFdConfigs_CellValueChanged(object sender, DataGridViewCellEventArgs e)
+ {
+ if (e.RowIndex < 0) return;
+ dgvFdConfigs.Rows[e.RowIndex].ErrorText = string.Empty;
+ }
+ private void DgvFdConfigs_DataError(object sender, DataGridViewDataErrorEventArgs e)
+ {
+ e.ThrowException = false;
+ string columnName = dgvFdConfigs.Columns[e.ColumnIndex].HeaderText;
+ MessageBox.Show($"'{columnName}'列的输入数据格式不正确", "数据错误",
+ MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ }
+ private void SaveFDConfig()
+ {
+ try
+ {
+ // 创建备份
+ if (File.Exists(FdConfigFilePath))
+ {
+ string backupFile = $"{FdConfigFilePath}.bak";
+ File.Copy(FdConfigFilePath, backupFile, true);
+ }
+
+ // 直接保存到目标文件
+ MiniExcel.SaveAs(FdConfigFilePath, fdConfigs, overwriteFile: true);
+ }
+ catch (IOException ex)
+ {
+ MessageBox.Show($"保存文件时发生IO错误:{ex.Message}\n请确保文件未被其他程序占用。",
+ "保存错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ throw;
+ }
+ catch (UnauthorizedAccessException ex)
+ {
+ MessageBox.Show($"没有足够的权限保存文件:{ex.Message}\n请确保有写入权限。",
+ "权限错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ throw;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"保存配置时发生错误:{ex.Message}",
+ "保存错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ throw;
+ }
+ }
+ private void RefreshFDDataGridView()
+ {
+ dgvFdConfigs.DataSource = null;
+ dgvFdConfigs.DataSource = new BindingList(fdConfigs);
+ }
+ #endregion
}
}
diff --git a/LargeSquareOne/FrmParamSet.resx b/LargeSquareOne/FrmParamSet.resx
index 0f15feb..656bea1 100644
--- a/LargeSquareOne/FrmParamSet.resx
+++ b/LargeSquareOne/FrmParamSet.resx
@@ -220,6 +220,32 @@
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
\ No newline at end of file