diff --git a/ServicesCenter/WCF/OpcServerHost/App.config b/ServicesCenter/WCF/OpcServerHost/App.config
index 64d417f..22798cb 100644
--- a/ServicesCenter/WCF/OpcServerHost/App.config
+++ b/ServicesCenter/WCF/OpcServerHost/App.config
@@ -4,13 +4,13 @@
-
+
-
+
-
+
diff --git a/ServicesCenter/WCF/OpcServerHost/OpcDeal/ParaInit.cs b/ServicesCenter/WCF/OpcServerHost/OpcDeal/ParaInit.cs
index 105ec72..79e8db4 100644
--- a/ServicesCenter/WCF/OpcServerHost/OpcDeal/ParaInit.cs
+++ b/ServicesCenter/WCF/OpcServerHost/OpcDeal/ParaInit.cs
@@ -313,6 +313,55 @@ namespace OpcServerHost.Init
#endregion
+ #region 条码信息
+
+ List barcodePara = paraConfigList
+ .Where(o => o.MACHINECODDE == m.MACHINECODDE
+ && o.MOLDNUMBER == m.MOLDNUMBER
+ && o.COLUMNTYPE == OpcEnumGeter.COLUMNTYPE.BARCODE.GetHashCode().ToString())
+ .ToList();
+
+ if (barcodePara.Count > 0)
+ {
+ //创建该设备该模块下的条码组
+ opcplcConnection.CreateGroup(m.MACHINECODDE + ":" + m.MOLDNUMBER + ":BarCodePara");
+
+ //变该模块下的所有参数信息
+ foreach (var pc in barcodePara)
+ {
+ //初始化字典名称: 设备名称+模块编号+字段名称
+ string dicKeyStr = machineEntity.MACHINECODDE + ":" + m.MOLDNUMBER + ":" + pc.COLUMNCODE;
+
+ try
+ {
+
+ //初始化字段信息值为0
+ parameterValueDict.Add(dicKeyStr, 0);
+
+ //获取opc中tagName
+ string itemName = pc.CONNECTIONSTRING;
+
+ clientHandleValue++;
+
+ clientHandleDict.Add(clientHandleValue, dicKeyStr);
+
+ //将字典中的与PLC内存地址向绑定
+ //parameterValueDict[dicKeyStr] = opcplcConnection.AddKepItem(itemName, clientHandleValue);
+
+ opcItemDict[dicKeyStr] = opcplcConnection.AddKepOPCItem(itemName, clientHandleValue);
+ parameterValueDict[dicKeyStr] = opcItemDict[dicKeyStr].ServerHandle;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.Message);
+ Console.WriteLine(dicKeyStr);
+ continue;
+ }
+ }
+ }
+
+ #endregion
+
#region 监控组
//获取设备扫描条码完成标记和设备加工完成标记
@@ -324,6 +373,7 @@ namespace OpcServerHost.Init
o.COLUMNTYPE == OpcEnumGeter.COLUMNTYPE.COMPLETEFLAG.GetHashCode().ToString()
|| o.COLUMNTYPE == OpcEnumGeter.COLUMNTYPE.TEMPCOMPLETE.GetHashCode().ToString()
|| o.COLUMNTYPE == OpcEnumGeter.COLUMNTYPE.MOULDNUMBER.GetHashCode().ToString()
+ || o.COLUMNTYPE == OpcEnumGeter.COLUMNTYPE.EQUIPSCANFLAG.GetHashCode().ToString()
)
)
.ToList();
@@ -494,7 +544,7 @@ namespace OpcServerHost.Init
#region 获取参数
ParameterConfig paraConfig = GetResultParameterConfig(parameter);
-
+
var result = new object();
try
@@ -506,11 +556,11 @@ namespace OpcServerHost.Init
}
catch (Exception ex)
{
-
+
Console.WriteLine(paraConfig.COLUMNCODE + ":" + ex.Message);
WriteLog.Write(paraConfig.COLUMNCODE + ":" + ex.Message, currentPC.MACHINECODDE);
}
-
+
if (result != null)
{
paraConfig.PARAVALUE = result;
@@ -530,7 +580,7 @@ namespace OpcServerHost.Init
}
#endregion
-
+
#region 处理已经读取完加工参数标记
//目前主要针对浇注设备
@@ -566,9 +616,9 @@ namespace OpcServerHost.Init
#endregion
#region 将参数信息传递到web服务中
-
+
client.SubmitParameters(JsonConvertHelper.GetSerializes(resultList));
-
+
#endregion
@@ -638,6 +688,122 @@ namespace OpcServerHost.Init
#endregion
+ #region 捕获条码扫描完成标记
+ if (currentPC.COLUMNCODE == "PLC_Scan_Ok_t")
+ {
+ if (currentPC.COLUMNTYPE == OpcEnumGeter.COLUMNTYPE.EQUIPSCANFLAG.GetHashCode().ToString())
+ {
+
+ #region 提示扫描条码完成
+
+ if (itemValue == null)
+ {
+ continue;
+ }
+
+ //如果完成标记表示更新了加工参数
+ //获取所有的加工参数
+ if ((Boolean)itemValue == true)
+ {
+ Thread.Sleep(1000);
+
+ Console.WriteLine(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " Catch BarcodeScan Flag :" + currentPC.MACHINECODDE + ":" + currentPC.MOLDNUMBER + ":" + currentPC.COLUMNCODE);
+ WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " Catch BarcodeScan Flag :" + currentPC.COLUMNCODE, currentPC.MACHINECODDE);
+
+ #region 获取条码信息
+
+ bool ishaveBarcode = true;
+
+ //获取该设备模块下的条码配置信息
+ List barCodeParaList = paraConfigList
+ .Where(o =>
+ o.MACHINECODDE == machCode
+ && o.MOLDNUMBER == moldNumber
+ && o.COLUMNTYPE == OpcEnumGeter.COLUMNTYPE.BARCODE.GetHashCode().ToString()
+ )
+ .OrderBy(o => o.COLUMNCODE)
+ .ToList();
+
+ //确定组信息
+ if (barCodeParaList.Count > 0)
+ {
+ opcplcConnection.KepGroup = opcplcConnection.KepGroups.GetOPCGroup(currentPC.MACHINECODDE + ":" + currentPC.MOLDNUMBER.ToString() + ":BarCodePara");
+ opcplcConnection.KepItems = opcplcConnection.KepGroup.OPCItems;
+ }
+
+ //获取的信息集合
+ List getParaList = new List();
+
+ //循环获取条码信息
+ foreach (var parameter in barCodeParaList)
+ {
+ try
+ {
+ string item = parameter.MACHINECODDE + ":" + parameter.MOLDNUMBER + ":" + parameter.COLUMNCODE;
+
+ var result = opcplcConnection.ReadtagValue(opcItemDict[item]);
+
+ if (result != null)
+ {
+ parameter.PARAVALUE = result;
+ }
+
+ Console.WriteLine(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "Get Barcode " + " " + parameter.MACHINECODDE + ":" + parameter.MOLDNUMBER + ":" + parameter.COLUMNCODE + " " + ((result == null) ? " " : result.ToString()), currentPC.MACHINECODDE);
+ WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "Get Barcode " + ":" + parameter.COLUMNCODE + " " + ((result == null) ? " " : result.ToString()), currentPC.MACHINECODDE);
+
+ getParaList.Add(parameter);
+
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("获取" + parameter.COLUMNCODE + "值异常");
+ WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ex.Message, currentPC.MACHINECODDE);
+ continue;
+ }
+ }
+
+ if (ishaveBarcode == false)
+ {
+ Console.WriteLine("Fail to get barcode!");
+ WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "Fail to get barcode!", currentPC.MACHINECODDE);
+ continue;
+ }
+
+ #endregion
+
+ #region 在双攻通信的条件下将扫描的条码信息传送到工控机上
+
+
+ try
+ {
+ //定义参数信息
+ ChatEventArgs e = new ChatEventArgs();
+ //设备编号
+ e.MachineCode = machCode;
+ //传输参数的类别
+ e.MessageType = OpcEnumGeter.MESSAGETYPE.PRODUCTCODE.GetHashCode().ToString();
+ //传输参数的内容
+ e.MessageContent = JsonConvertHelper.GetSerializes(getParaList);
+
+ OpcService opcService = new OpcService();
+ opcService.ReturnProductCodeToMachine(e);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "Fail to connect to " + currentPC.MACHINECODDE + "!");
+ WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "Fail to connect to " + currentPC.MACHINECODDE + "!", currentPC.MACHINECODDE);
+ }
+
+ #endregion
+ }
+
+
+ #endregion
+ }
+
+ }
+ #endregion
+
#region 中断
if (currentPC.COLUMNTYPE == OpcEnumGeter.COLUMNTYPE.INTERRUPT.GetHashCode().ToString())
diff --git a/ServicesCenter/WindowsServices/OpcService/app.config b/ServicesCenter/WindowsServices/OpcService/app.config
index 45e2d82..a92e36e 100644
--- a/ServicesCenter/WindowsServices/OpcService/app.config
+++ b/ServicesCenter/WindowsServices/OpcService/app.config
@@ -4,14 +4,14 @@
-
-
-
+
+
+
-
-
+
+