init: 导入项目到 meswork Gitea
This commit is contained in:
@@ -0,0 +1,247 @@
|
||||
using OpcData;
|
||||
using System;
|
||||
using SystemFramework;
|
||||
using System.Threading;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using DataLinkMesWork;
|
||||
|
||||
namespace MisDataName
|
||||
{
|
||||
//public partial class ___ { }
|
||||
public partial class MisData
|
||||
{
|
||||
|
||||
//
|
||||
private void TagData_MisData_TagDataOnChangeCustomeEvetnArgs(object msgEvent)
|
||||
{
|
||||
lock (locker)
|
||||
{
|
||||
try
|
||||
{
|
||||
CustomeEvetnArgs e = (CustomeEvetnArgs)msgEvent;
|
||||
string OpName = e.OpName.ToString();//工位号
|
||||
string MesCode = e.TagType.ToString();//变量类型代码
|
||||
object tagValue = e.TagValue;//变量(0或者1)
|
||||
string cmd = "";
|
||||
cmd = MesDataFunction.OpcOperation.hashtable_TagTypeTagName[MesCode];
|
||||
string mesServerdllName;
|
||||
|
||||
mesServerdllName = GetMesServeDllByOpName(OpName);
|
||||
//DoWhatPlc.ReturnValueString rv =
|
||||
//new DoWhatPlc.ReturnValueString(e.TagID.ToString(), e.TagValue.ToString(), e.OpName.ToString(), e.TagValueType.ToString(), e.TagType.ToString(), e.TagKeepTime.ToString(), mesServerdllName, fun, mesServerCode.ToString("00"));
|
||||
//string rvMsg = Newtonsoft.Json.JsonConvert.SerializeObject(rv);
|
||||
|
||||
//if (MesCode == "0") return;
|
||||
string fun = "fun_" + cmd;
|
||||
int mesServerCode;
|
||||
mesServerCode = GetMesServerCodeByOpName(OpName);
|
||||
string rvMsg = Newtonsoft.Json.JsonConvert.SerializeObject(e);
|
||||
|
||||
string msg;
|
||||
if (cmd == null)
|
||||
{
|
||||
|
||||
//DoWhatPlc.ReturnValueString rv =
|
||||
//new DoWhatPlc.ReturnValueString(e.TagID.ToString(), e.TagValue.ToString(), e.OpName.ToString(), e.TagTypeCodeID.ToString(), e.TagTypeID.ToString(), e.TagKeepTime.ToString(), mesServerdllName, fun, mesServerCode.ToString("00"),
|
||||
//e.TimeStamp, e.TimeStampBefore, e.TagValueBefore.ToString(), e.TagName.ToString(), e.ItemName.ToString(), e.ShaftID.ToString(), e.TagOrderBy.ToString());
|
||||
|
||||
//string rvMsg = Newtonsoft.Json.JsonConvert.SerializeObject(rv);
|
||||
cmd = MesCode;
|
||||
msg = $"PLC|{cmd}|{OpName}|{rvMsg}";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//if (Convert.ToInt32(MesDataFunction.OpcOperation.hashtable_MesTagTypeChange[cmd]) == 0 && MesDataFunction.OpcOperation.hashtable_MesTagTypeChange[cmd] != null) return;
|
||||
|
||||
//DoWhatPlc.ReturnValueString rv =
|
||||
//new DoWhatPlc.ReturnValueString(e.TagID.ToString(), e.TagValue.ToString(), e.OpName.ToString(), e.TagTypeCodeID.ToString(), e.TagTypeID.ToString(), e.TagKeepTime.ToString(), mesServerdllName, fun, mesServerCode.ToString("00"),
|
||||
//e.TimeStamp, e.TimeStampBefore, e.TagValueBefore.ToString(), e.TagName.ToString(), e.ItemName.ToString(), e.ShaftID.ToString(), e.TagOrderBy.ToString());
|
||||
|
||||
////DoWhatPlc.ReturnValueString rv =
|
||||
////new DoWhatPlc.ReturnValueString(e.TagID.ToString(), e.TagValue.ToString(), e.OpName.ToString(), e.TagValueType.ToString(), e.TagType.ToString(), e.TagKeepTime.ToString(), mesServerdllName, fun, mesServerCode.ToString("00"));
|
||||
//string rvMsg = Newtonsoft.Json.JsonConvert.SerializeObject(rv);
|
||||
|
||||
msg = $"PLC|{cmd}|{OpName}|{rvMsg}";
|
||||
|
||||
//MesServerWork.MIS_BASE.asyncSendMessagePLC(mesServerdllName, msg);
|
||||
|
||||
//MesServerFunction(OpName, tagValue, fun);
|
||||
|
||||
}
|
||||
MesServerWork.MIS_BASE.asyncSendMessagePLC(mesServerdllName, msg,OpName);
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, "TagData_Lable_TagDataOnChange");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//private void TagData_MisData_TagDataOnChange(object msgEvent)
|
||||
//{
|
||||
// lock (locker)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// CustomeEvetnArgs e = (CustomeEvetnArgs)msgEvent;
|
||||
// string OpName = e.OpName.ToString();//工位号
|
||||
// string MesCode = e.TagType.ToString();//变量类型代码
|
||||
// object tagValue = e.TagValue;//变量(0或者1)
|
||||
// string cmd = "";
|
||||
// cmd = MesDataFunction.OpcOperation.hashtable_TagTypeTagName[MesCode];
|
||||
// string mesServerdllName;
|
||||
|
||||
// mesServerdllName = GetMesServeDllByOpName(OpName);
|
||||
// //DoWhatPlc.ReturnValueString rv =
|
||||
// //new DoWhatPlc.ReturnValueString(e.TagID.ToString(), e.TagValue.ToString(), e.OpName.ToString(), e.TagValueType.ToString(), e.TagType.ToString(), e.TagKeepTime.ToString(), mesServerdllName, fun, mesServerCode.ToString("00"));
|
||||
// //string rvMsg = Newtonsoft.Json.JsonConvert.SerializeObject(rv);
|
||||
|
||||
// //if (MesCode == "0") return;
|
||||
// string fun = "fun_" + cmd;
|
||||
// int mesServerCode;
|
||||
// mesServerCode = GetMesServerCodeByOpName(OpName);
|
||||
|
||||
|
||||
// if (cmd == null)
|
||||
// {
|
||||
|
||||
|
||||
// string rvMsg = Newtonsoft.Json.JsonConvert.SerializeObject(e);
|
||||
// cmd = MesCode;
|
||||
// string msg = $"PLC|{cmd}|{OpName}|{rvMsg}";
|
||||
// MesServerWork.MIS_BASE.asyncSendMessagePLC(mesServerdllName, msg, OpName);
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// string rvMsg = Newtonsoft.Json.JsonConvert.SerializeObject(e);
|
||||
|
||||
|
||||
|
||||
|
||||
// string msg = $"PLC|{cmd}|{OpName}|{rvMsg}";
|
||||
|
||||
// MesServerWork.MIS_BASE.asyncSendMessagePLC(mesServerdllName, msg, OpName);
|
||||
|
||||
// //MesServerFunction(OpName, tagValue, fun);
|
||||
|
||||
// }
|
||||
// }
|
||||
// catch (Exception err)
|
||||
// {
|
||||
// ApplicationLog.WriteLog(err, "TagData_Lable_TagDataOnChange");
|
||||
// }
|
||||
// }
|
||||
|
||||
//}
|
||||
static object locker = new object();
|
||||
|
||||
/// <summary>
|
||||
/// MesServerFunction
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
/// <param name="fun"></param>
|
||||
private static void MesServerFunction(string OpName, object tagValue,string fun)
|
||||
{
|
||||
try
|
||||
{
|
||||
string ResultOK = "";
|
||||
int mesServerCode;
|
||||
mesServerCode = GetMesServerCodeByOpName(OpName);
|
||||
string mesServerdllName;
|
||||
mesServerdllName = GetMesServeDllByOpName(OpName);
|
||||
|
||||
|
||||
OpcData.CustomeEvetnArgs e = new OpcData.CustomeEvetnArgs();
|
||||
e.OpName = OpName;
|
||||
e.TagValue = tagValue;
|
||||
object[] Paramsters = new object[1];
|
||||
Paramsters[0] = e;
|
||||
|
||||
System.Reflection.Assembly assembly;
|
||||
|
||||
//自动工位不调用function
|
||||
if (mesServerCode == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
bool IsOK=false;
|
||||
lock (locker)
|
||||
{
|
||||
IsOK= MesDataFunction.OpcOperation.Hashtable_assembly.ContainsKey(mesServerdllName);
|
||||
}
|
||||
if (IsOK)
|
||||
{
|
||||
assembly = (System.Reflection.Assembly)MesDataFunction.OpcOperation.Hashtable_assembly[mesServerdllName];
|
||||
}
|
||||
else
|
||||
{
|
||||
assembly = System.Reflection.Assembly.Load(mesServerdllName);
|
||||
if (assembly == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MesDataFunction.OpcOperation.Hashtable_assembly.Add(mesServerdllName, assembly);
|
||||
}
|
||||
|
||||
ResultOK = Reflection.ReflectionMethod(assembly, "MesServerFunctions", "Functions_BASE_" + mesServerCode.ToString("00"), fun, Paramsters);
|
||||
if (ResultOK != "ok")
|
||||
{
|
||||
// ApplicationLog.WriteLog("ReflectionMethod is Error:" + OpName + fun + ResultOK);
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, "MesServerFunction");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据工位号获取MesServerCode
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <returns></returns>
|
||||
private static int GetMesServerCodeByOpName(string OpName)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (hashtable_MesServerCode.ContainsKey(OpName))
|
||||
{
|
||||
return Convert.ToInt32(hashtable_MesServerCode[OpName]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据工位号获取MesServerDll
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <returns></returns>
|
||||
private static string GetMesServeDllByOpName(string OpName)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (hashtable_MesDll.ContainsKey(OpName))
|
||||
{
|
||||
return hashtable_MesDll[OpName].ToString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, "GetMesServeDllByOpName");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user