天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

146 lines
6.2 KiB

using System;
using System.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using QMAPP.FJC.Entity.Basic;
using OpcHost.Init;
using OPCPLC;
using QMAPP.FJC.Entity;
using OpcHost.Common;
using QMAPP.FJC.Entity.ProcessParameter;
using System.Threading;
namespace OpcHost.Concrete
{
/// <summary>
/// 搪塑操作类
/// </summary>
public class SlushEquipOperate : EquipOperate
{
public override void GetMachineData()
{
bool readFlag = true;
while (readFlag)
{
List<ParameterConfig> machineMoldList = ParaInit.moldList
.Where(o => o.MACHINECODDE == machineInfo.MACHINECODDE).ToList<ParameterConfig>();
List<ParameterConfig> resultList = new List<ParameterConfig>();
//遍历搪塑设备下的模具
foreach (ParameterConfig pc in machineMoldList)
{
//定义OPCPLCAutomation字典中的key信息
string opcConStr = machineInfo.MACHINECODDE + pc.MOLDNUMBER;
#region 完成标记获取
if (ParaInit.paraConfigList.Count(o => o.MACHINECODDE == pc.MACHINECODDE && o.MOLDNUMBER == pc.MOLDNUMBER
&& o.COLUMNTYPE == OpcHostEnumGeter.COLUMNTYPE.COMPLETEFLAG.GetHashCode().ToString()) > 0)
{
//获取完成标记位
ParameterConfig completeParaConfig = ParaInit.paraConfigList.First(o => o.MACHINECODDE == pc.MACHINECODDE && o.MOLDNUMBER == pc.MOLDNUMBER
&& o.COLUMNTYPE == OpcHostEnumGeter.COLUMNTYPE.COMPLETEFLAG.GetHashCode().ToString());
//定义加工参数字典中key信息
string cmpFlgKey = pc.MACHINECODDE + "-" + pc.MOLDNUMBER + "-" + completeParaConfig.COLUMNCODE;
string completeFlag = ParaInit.opcplcConnectionList[opcConStr].ReadtagValue(ParaInit.parameterValueDict[cmpFlgKey]).ToString();
if (completeFlag == "1")
{
#region 加工工位完成标记
//获取所有的加工参数
List<ParameterConfig> moldparaList = ParaInit.paraConfigList
.Where(o => o.MACHINECODDE == pc.MACHINECODDE && o.MOLDNUMBER == pc.MOLDNUMBER
&& o.COLUMNTYPE == OpcHostEnumGeter.COLUMNTYPE.EQUIPSCANCODE.GetHashCode().ToString())
.ToList<ParameterConfig>();
//遍历所有的加工参数
foreach (var mp in moldparaList)
{
//获取参数在字典中的标记位
string paraKey = mp.MACHINECODDE + "-" + mp.MOLDNUMBER + "-" + mp.COLUMNCODE;
mp.PARAVALUE = ParaInit.opcplcConnectionList[opcConStr].ReadtagValue(ParaInit.parameterValueDict[paraKey]);
resultList.Add(mp);
}
//更新完成加工参数
ParaInit.opcplcConnectionList[opcConStr].WritetagValue(ParaInit.parameterValueDict[cmpFlgKey], 0);
//将加工参数传递到web服务中
#endregion
}
}
#endregion
#region 获取设备扫描条码标记信息
if (ParaInit.paraConfigList.Count(o => o.MACHINECODDE == pc.MACHINECODDE && o.MOLDNUMBER == pc.MOLDNUMBER
&& o.COLUMNTYPE == OpcHostEnumGeter.COLUMNTYPE.EQUIPSCANCODE.GetHashCode().ToString()) > 0)
{
//获取设备扫描条码
List<ParameterConfig> equipParaConfigList = ParaInit.paraConfigList.Where(o => o.MACHINECODDE == pc.MACHINECODDE && o.MOLDNUMBER == pc.MOLDNUMBER
&& o.COLUMNTYPE == OpcHostEnumGeter.COLUMNTYPE.EQUIPSCANCODE.GetHashCode().ToString()).ToList<ParameterConfig>();
List<string> codelist = new List<string>();
foreach (ParameterConfig epConfig in equipParaConfigList)
{
//获取参数在字典中的标记位
string paraKey = pc.MACHINECODDE + "-" + pc.MOLDNUMBER + "-" + epConfig.COLUMNCODE;
string code = ParaInit.opcplcConnectionList[opcConStr].ReadtagValue(ParaInit.parameterValueDict[paraKey]).ToString();
codelist.Add(code);
}
//返回给工控机终端
ChatEventArgs e = new ChatEventArgs();
//OpcHost.PLCService.ChatEventHandler chatterTo;//创建一个临时委托实例
//chatterTo = PLCService.chatters[pc.MACHINECODDE]; //查找成员字典中,找到要接收者的委托调用
//chatterTo.BeginInvoke(this, e, new AsyncCallback(EndAsync), null);//异步方式调用接收者的委托调用
}
#endregion
}
//设定休眠时间
Thread.Sleep(machineInfo.READINTERVAL);
}
}
//广播中线程调用完成的回调方法功能:清除异常多路广播委托的调用列表中异常对象(空对象)
private void EndAsync(IAsyncResult ar)
{
//OpcHost.PLCService.ChatEventHandler d = null;
//try
//{
// //封装异步委托上的异步操作结果
// System.Runtime.Remoting.Messaging.AsyncResult asres = (System.Runtime.Remoting.Messaging.AsyncResult)ar;
// d = ((OpcHost.PLCService.ChatEventHandler)asres.AsyncDelegate);
// d.EndInvoke(ar);
//}
//catch
//{
//}
}
}
}