commit e1eb90c6edf9241c667e0da8fe5675d13d214e0b Author: yexingqiang Date: Mon Jun 8 17:19:31 2026 +0800 chore: 初始化平芝126KV断路器线程序 diff --git a/Common/09MesDataFunction/MesDataFunction.sln b/Common/09MesDataFunction/MesDataFunction.sln new file mode 100644 index 0000000..5cc56d6 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32901.82 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MesDataFunction", "MesDataFunction\MesDataFunction.csproj", "{90E76FB4-646D-45E2-95DB-0B8AB4E465D6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {48DF007D-B08C-43B9-9AC7-78F6B2C23954} + EndGlobalSection +EndGlobal diff --git a/Common/09MesDataFunction/MesDataFunction/01-MesDataFunction.csproj b/Common/09MesDataFunction/MesDataFunction/01-MesDataFunction.csproj new file mode 100644 index 0000000..72b6042 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/01-MesDataFunction.csproj @@ -0,0 +1,151 @@ + + + + + Debug + AnyCPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6} + Library + Properties + MesDataFunction + 09MesDataFunction + v4.8 + 512 + true + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\dll_common\BasicData.dll + + + ..\..\..\dll_common\ConLink.dll + + + ..\..\..\dll_common\ConLink19.dll + + + ..\..\..\dll_common\DataLinkMesWork.dll + + + ..\..\..\dll_common\MesWork.DeviceDriver.dll + + + ..\..\..\dll_common\Monitor.MesWork.dll + + + ..\..\..\dll_common\MQTTnet.dll + + + ..\..\..\dll_common\MQTTnet.Extensions.ManagedClient.dll + + + False + ..\..\..\dll_common\Newtonsoft.Json.dll + + + ..\..\..\dll_common\NPOI.dll + + + ..\..\..\dll_common\NPOI.OOXML.dll + + + ..\..\..\dll_common\NPOI.OpenXml4Net.dll + + + ..\..\..\dll_common\NPOI.OpenXmlFormats.dll + + + ..\..\..\dll_common\Opc.Ua.Client.dll + + + ..\..\..\dll_common\Opc.Ua.Configuration.dll + + + ..\..\..\dll_common\Opc.Ua.Core.dll + + + ..\..\..\dll_common\OpcUaHelper.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Form + + + + + + + + + + + {1dc48c83-1842-4de8-acaf-26e1e7f7c58f} + 00_MyLog4Net + + + + + + + + + + \ No newline at end of file diff --git a/Common/09MesDataFunction/MesDataFunction/04-DataBaseAccess/DataAccess.cs b/Common/09MesDataFunction/MesDataFunction/04-DataBaseAccess/DataAccess.cs new file mode 100644 index 0000000..aa173d8 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/04-DataBaseAccess/DataAccess.cs @@ -0,0 +1,746 @@ +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Configuration; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataLinkMesWork1 +{ + public class DataAccess + { + // 读配置文件有问题,先直接写死 + public static string ConnectionString_MES = ConfigurationManager.AppSettings["ConnectionString_MES"]; + public static bool ExecuteNonQuery(string sql, string connectionString, out string errorMessage) + { + bool result = false; + errorMessage = ""; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + using (SqlCommand cmd = new SqlCommand(sql, conn)) + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + cmd.ExecuteNonQuery(); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + //ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL��䣺\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + + } + public static bool ExecuteDataset(string sql, string connectionString, out DataSet ds, out string errorMessage) + { + errorMessage = ""; + bool result = true; + errorMessage = ""; + ds = new DataSet(); + + /// SQLSERVER + /// SQLiteDB + try + { + //bool result = false; + errorMessage = ""; + ds = new DataSet(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.SelectCommand = new SqlCommand(sql, conn); + dsCommand.Fill(ds); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + //ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL��䣺\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + catch (Exception err) + { + + } + + return result; + + + } + /// + /// 增 删 改 + /// + /// + /// + /// + public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters) + { + string connectionString = ConnectionString_MES; + string errorMessage; + bool result = false; + errorMessage = ""; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlCommand cmd = new SqlCommand(procedureName, conn)) + { + cmd.CommandTimeout = 0; + cmd.CommandType = CommandType.StoredProcedure; + if (sqlParameters != null) + { + for (int i = 0; i < sqlParameters.Length; i++) + { + cmd.Parameters.Add(sqlParameters[i]); + } + } + cmd.ExecuteNonQuery(); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + if (conn.State == ConnectionState.Open) + conn.Close(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n�洢���̣�\r\n" + procedureName + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters,out DataTable dt) + { + string connectionString = ConnectionString_MES; + string errorMessage; + bool result = false; + errorMessage = ""; + //ds = new DataSet(); + dt = new DataTable(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.SelectCommand = new SqlCommand(procedureName, conn); + dsCommand.SelectCommand.CommandType = CommandType.StoredProcedure; + dsCommand.SelectCommand.CommandTimeout = 0; + if (sqlParameters != null) + { + for (int i = 0; i < sqlParameters.Length; i++) + { + dsCommand.SelectCommand.Parameters.Add(sqlParameters[i]); + } + } + + dsCommand.Fill(dt); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n�洢���̣�\r\n" + procedureName + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters, out DataSet ds) + { + string connectionString = ConnectionString_MES; + string errorMessage; + bool result = false; + errorMessage = ""; + ds = new DataSet(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.SelectCommand = new SqlCommand(procedureName, conn); + dsCommand.SelectCommand.CommandType = CommandType.StoredProcedure; + dsCommand.SelectCommand.CommandTimeout = 0; + if (sqlParameters != null) + { + for (int i = 0; i < sqlParameters.Length; i++) + { + dsCommand.SelectCommand.Parameters.Add(sqlParameters[i]); + } + } + + dsCommand.Fill(ds); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n�洢���̣�\r\n" + procedureName + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + + public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters, out string errorMessage) + { + string connectionString = ConnectionString_MES; + bool result = false; + errorMessage = ""; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlCommand cmd = new SqlCommand(procedureName, conn)) + { + cmd.CommandTimeout = 0; + cmd.CommandType = CommandType.StoredProcedure; + if (sqlParameters != null) + { + for (int i = 0; i < sqlParameters.Length; i++) + { + cmd.Parameters.Add(sqlParameters[i]); + } + } + cmd.ExecuteNonQuery(); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + if (conn.State == ConnectionState.Open) + conn.Close(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n�洢���̣�\r\n" + procedureName + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters, out DataTable dt, out string errorMessage) + { + string connectionString = ConnectionString_MES; + bool result = false; + errorMessage = ""; + //ds = new DataSet(); + dt = new DataTable(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.SelectCommand = new SqlCommand(procedureName, conn); + dsCommand.SelectCommand.CommandType = CommandType.StoredProcedure; + dsCommand.SelectCommand.CommandTimeout = 0; + if (sqlParameters != null) + { + for (int i = 0; i < sqlParameters.Length; i++) + { + dsCommand.SelectCommand.Parameters.Add(sqlParameters[i]); + } + } + + dsCommand.Fill(dt); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n�洢���̣�\r\n" + procedureName + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters, out DataSet ds, out string errorMessage) + { + string connectionString = ConnectionString_MES; + bool result = false; + errorMessage = ""; + ds = new DataSet(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.SelectCommand = new SqlCommand(procedureName, conn); + dsCommand.SelectCommand.CommandType = CommandType.StoredProcedure; + dsCommand.SelectCommand.CommandTimeout = 0; + if (sqlParameters != null) + { + for (int i = 0; i < sqlParameters.Length; i++) + { + dsCommand.SelectCommand.Parameters.Add(sqlParameters[i]); + } + } + + dsCommand.Fill(ds); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n�洢���̣�\r\n" + procedureName + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + + public static bool ExecuteDataset(string sql, out DataSet ds) + { + string errorMessage; + string connectionString = ConnectionString_MES; + bool result = false; + errorMessage = ""; + ds = new DataSet(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.SelectCommand = new SqlCommand(sql, conn); + dsCommand.Fill(ds); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL��䣺\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + + public static bool ExecuteDataTable(string sql, out DataTable dt) + { + //public static bool ExecuteDataTable(string sql, string connectionString, out DataTable dt, out string errorMessage) + string errorMessage; + string connectionString = ConnectionString_MES; + bool result = false; + errorMessage = ""; + dt = new DataTable(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.SelectCommand = new SqlCommand(sql, conn); + dsCommand.Fill(dt); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL��䣺\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + + public static DataTable ExecuteSQL(string sql, ref SqlParameter[] sqlParameters) + { + string connectionString = ConnectionString_MES; + string err; + bool result = false; + err = ""; + DataTable dt = new DataTable(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter(sql, conn)) + { + if (sqlParameters != null) + { + for (int i = 0; i < sqlParameters.Length; i++) + { + dsCommand.SelectCommand.Parameters.Add(sqlParameters[i]); + } + } + dsCommand.Fill(dt); + } + result = true; + } + catch (Exception e) + { + err = e.ToString(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteSelectMesWork\r\n" + sql + "\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return dt; + } + + public static bool ExecuteSQL(string sql) + { + string connectionString = ConnectionString_MES; + string errorMessage; + bool result = false; + errorMessage = ""; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + using (SqlCommand cmd = new SqlCommand(sql, conn)) + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + cmd.ExecuteNonQuery(); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL��䣺\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + + /// + /// 提供通用的调用存储过程的方法(增加数据的数据表的到数据库的调用) + /// + /// 存储过程名称 + /// 存储过程参数数组 + /// 增加数据的数据表 + /// + public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters, DataTable dt) + { + string connectionString = ConnectionString_MES; + string errorMessage; + bool result = false; + errorMessage = ""; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + // if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.InsertCommand = new SqlCommand(procedureName, conn); + dsCommand.InsertCommand.CommandType = CommandType.StoredProcedure; + for (int i = 0; i < sqlParameters.Length; i++) + { + dsCommand.InsertCommand.Parameters.Add(sqlParameters[i]); + } + if (dt == null) return false; + dt.AcceptChanges(); + for (int i = 0; i < dt.Rows.Count; i++) + { + dt.Rows[i].SetAdded(); + } + dsCommand.Update(dt); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n�洢���̣�\r\n" + procedureName + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + + /// + /// 提供通用的调用存储过程的方法(增加数据的数据表的到数据库的调用) + /// + /// + /// + /// + public static bool ExecuteStoredProcedure(string procedureName, out DataTable dt) + { + string connectionString = ConnectionString_MES; + string errorMessage; + bool result = false; + errorMessage = ""; + dt = new DataTable(); + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.SelectCommand = new SqlCommand(procedureName, conn); + dsCommand.SelectCommand.CommandType = CommandType.StoredProcedure; + + dsCommand.Fill(dt); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n�洢���̣�\r\n" + procedureName + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + + /// + /// + /// + /// + /// + /// + /// + public static bool ExecuteSQL(string sql, ref SqlParameter[] sqlParameters, DataTable dt) + { + string connectionString = ConnectionString_MES; + string errorMessage; + bool result = false; + errorMessage = ""; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + + + try + { + // if (!SqlServerConnectionStatus) return false; + conn.Open(); + using (SqlDataAdapter dsCommand = new SqlDataAdapter()) + { + dsCommand.InsertCommand = new SqlCommand(sql, conn); + + for (int i = 0; i < sqlParameters.Length; i++) + { + sqlParameters[i].IsNullable = true; + dsCommand.InsertCommand.Parameters.Add(sqlParameters[i]); + } + if (dt == null) return false; + dt.AcceptChanges(); + for (int i = 0; i < dt.Rows.Count; i++) + { + dt.Rows[i].SetAdded(); + } + dsCommand.Update(dt); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + //ApplicationConfig.ConnectionStringPIS_NEW_Value = "0"; + //TestConnection(); + //errorMessage = e.ToString(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteSQL\r\nSQL��䣺\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + + public static bool ExecuteNonQuery_newID(string sql, out long newID) + { + sql += ";select @@identity"; + string connectionString; + connectionString = ConnectionString_MES; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + try + { + using (SqlCommand cmd = new SqlCommand(sql, conn)) + { + conn.Open(); + newID = Convert.ToInt64(cmd.ExecuteScalar()); + } + return true; + } + catch (Exception e) + { + newID = 0; + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\n ExecuteNonQuery_newID\r\n�洢���̣�\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + return false; + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + } + + public static bool ExecuteOutNum(string sql, out int count) + { + string connectionString; + connectionString = ConnectionString_MES; + string errorMessage; + bool result = false; + errorMessage = ""; + using (SqlConnection conn = new SqlConnection(connectionString)) + { + count = 0; + try + { + using (SqlCommand cmd = new SqlCommand(sql, conn)) + { + //if (!SqlServerConnectionStatus) return false; + conn.Open(); + count = Convert.ToInt32(cmd.ExecuteScalar().ToString()); + } + //SqlServerConnectionStatus = true; + result = true; + } + catch (Exception e) + { + errorMessage = e.ToString(); + //TestConnection(); + ////ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL��䣺\r\n" + sql + "\r\n�����ַ�����\r\n" + connectionString); + } + finally + { + if (conn.State == ConnectionState.Open) + conn.Close(); + } + } + return result; + } + } + + +} diff --git a/Common/09MesDataFunction/MesDataFunction/04-DataBaseAccess/JsonHelper.cs b/Common/09MesDataFunction/MesDataFunction/04-DataBaseAccess/JsonHelper.cs new file mode 100644 index 0000000..5ec9f9c --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/04-DataBaseAccess/JsonHelper.cs @@ -0,0 +1,336 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Data; +using System.Runtime.Serialization.Json; +using System.Web.Script.Serialization; +//using System.Runtime.Serialization.Json; + +//using System.Runtime.Serialization.Json; + +public class JsonHelper +{ + #region 序列化和反序列化 + // 序列化 + public static string JsonSerializer(T t) + { + // 使用 DataContractJsonSerializer 将 T 对象序列化为内存流。 + DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(T)); + MemoryStream ms = new MemoryStream(); + // 使用 WriteObject 方法将 JSON 数据写入到流中。 + jsonSerializer.WriteObject(ms, t); + // 流转字符串 + string jsonString = Encoding.UTF8.GetString(ms.ToArray()); + ms.Close(); + //替换Json的Date字符串 + string p = @"\\/Date\((\d+)\+\d+\)\\/"; + MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertJsonDateToDateString); + Regex reg = new Regex(p); + jsonString = reg.Replace(jsonString, matchEvaluator); + return jsonString; + } + public static T JsonDeserialize(string jsonString) + { + //将"yyyy-MM-dd HH:mm:ss"格式的字符串转为"\/Date(1294499956278+0800)\/"格式 + string p = @"\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}"; + MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertDateStringToJsonDate); + Regex reg = new Regex(p); + jsonString = reg.Replace(jsonString, matchEvaluator); + DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(T)); + // 字符串转流 + MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonString)); + // 通过使用 DataContractJsonSerializer 的 ReadObject 方法,将 JSON 编码数据反序列化为T + T obj = (T)jsonSerializer.ReadObject(ms); + return obj; + } + public static string ConvertJsonDateToDateString(Match match) + { + string result = string.Empty; + DateTime dateTime = new DateTime(1970, 1, 1); + dateTime = dateTime.AddMilliseconds(long.Parse(match.Groups[1].Value)); + dateTime = dateTime.ToLocalTime(); + result = dateTime.ToString("yyyy-MM-dd HH:mm:ss"); + return result; + } + private static string ConvertDateStringToJsonDate(Match m) + { + string result = string.Empty; + DateTime dt = DateTime.Parse(m.Groups[0].Value); + dt = dt.ToUniversalTime(); + TimeSpan ts = dt - DateTime.Parse("1970-01-01"); + result = string.Format("\\/Date({0}+0800)\\/", ts.TotalMilliseconds); + return result; + } + #endregion + + // 对象转换为Json + public static string ObjectToJson(object obj) + { + JavaScriptSerializer js = new JavaScriptSerializer(); + js.MaxJsonLength = Int32.MaxValue; // 定义JavaScriptSerializer接受字符串的最大长度 hdk 20180524 + try + { + return js.Serialize(obj); + } + catch (Exception exception) + { + + throw new Exception(exception.Message); + } + } + // 数据表转化为集合 + public static List> DataTableToList(DataTable dt) + { + List> list = new List>(); + foreach (DataRow dataRow in dt.Rows) + { + Dictionary dic = new Dictionary(); + + + foreach (DataColumn dc in dt.Columns) + { + if (dataRow[dc.ColumnName].GetType() == typeof(DateTime)) + { + string str = Convert.ToDateTime(dataRow[dc.ColumnName]).ToString("yyyy-MM-dd HH:mm:ss"); + dic.Add(dc.ColumnName, str); + } + else if + (dataRow[dc.ColumnName].GetType() == typeof(byte[])) + { + string str = Convert.ToBase64String((byte[])dataRow[dc.ColumnName]); + dic.Add(dc.ColumnName, str); + } + else + { + dic.Add(dc.ColumnName, dataRow[dc.ColumnName]); + } + + //Type type1 = dt.Rows[0]["产品图片"].GetType(); + //Type type2 = typeof(byte[]); + + } + list.Add(dic); + } + return list; + } + /// + /// 表转换为Json + /// + /// + /// + public static string DataTableToJson(DataTable dt) + { + return ObjectToJson(DataTableToList(dt)); + } + /// + /// 将DataTable中的数据转换成JSON格式 + /// + /// 数据源DataTable + /// 是否输出数据总条数 + /// JSON中显示的数据总条数 + /// + public static string CreateJsonParameters(DataTable dt, bool displayCount, int totalcount) + { + StringBuilder JsonString = new StringBuilder(); + //Exception Handling + + if (dt != null) + { + JsonString.Append("{ "); + JsonString.Append("\"rows\":[ "); + for (int i = 0; i < dt.Rows.Count; i++) + { + JsonString.Append("{ "); + for (int j = 0; j < dt.Columns.Count; j++) + { + if (j < dt.Columns.Count - 1) + { + //if (dt.Rows[i][j] == DBNull.Value) continue; + if (dt.Columns[j].DataType == typeof(bool)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + dt.Rows[i][j].ToString().ToLower() + ","); + } + else if (dt.Columns[j].DataType == typeof(string)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + ObjectToJson(dt.Rows[i][j]).ToString() + ","); + //JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + + // dt.Rows[i][j].ToString().Replace("\"", "\\\"") + "\","); + } + else + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + dt.Rows[i][j] + "\","); + } + } + else if (j == dt.Columns.Count - 1) + { + //if (dt.Rows[i][j] == DBNull.Value) continue; + if (dt.Columns[j].DataType == typeof(bool)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + dt.Rows[i][j].ToString().ToLower()); + } + else if (dt.Columns[j].DataType == typeof(string)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + ObjectToJson(dt.Rows[i][j]).ToString()); + //JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + + // dt.Rows[i][j].ToString().Replace("\"", "\\\"") + "\""); + } + else + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + dt.Rows[i][j] + "\""); + } + } + } + /*end Of String*/ + if (i == dt.Rows.Count - 1) + { + JsonString.Append("} "); + } + else + { + JsonString.Append("}, "); + } + } + JsonString.Append("]"); + + if (displayCount) + { + JsonString.Append(","); + + JsonString.Append("\"total\":"); + JsonString.Append(totalcount); + } + + JsonString.Append("}"); + return JsonString.ToString().Replace("\n", ""); + } + else + { + return null; + } + } + public static string CreateJsonParameters(DataTable dt) + { + StringBuilder JsonString = new StringBuilder(); + //Exception Handling + + if (dt != null) + { + JsonString.Append("{ "); + JsonString.Append("\"rows\":[ "); + for (int i = 0; i < dt.Rows.Count; i++) + { + JsonString.Append("{ "); + for (int j = 0; j < dt.Columns.Count; j++) + { + if (j < dt.Columns.Count - 1) + { + //if (dt.Rows[i][j] == DBNull.Value) continue; + if (dt.Columns[j].DataType == typeof(bool)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + dt.Rows[i][j].ToString().ToLower() + ","); + } + else if (dt.Columns[j].DataType == typeof(string)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + ObjectToJson(dt.Rows[i][j]).ToString() + ","); + //JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + + // dt.Rows[i][j].ToString().Replace("\"", "\\\"") + "\","); + } + else + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + dt.Rows[i][j] + "\","); + } + } + else if (j == dt.Columns.Count - 1) + { + //if (dt.Rows[i][j] == DBNull.Value) continue; + if (dt.Columns[j].DataType == typeof(bool)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + dt.Rows[i][j].ToString().ToLower()); + } + else if (dt.Columns[j].DataType == typeof(string)) + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + + ObjectToJson(dt.Rows[i][j]).ToString()); + //JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + + // dt.Rows[i][j].ToString().Replace("\"", "\\\"") + "\""); + } + else + { + JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + dt.Rows[i][j] + "\""); + } + } + } + /*end Of String*/ + if (i == dt.Rows.Count - 1) + { + JsonString.Append("} "); + } + else + { + JsonString.Append("}, "); + } + } + JsonString.Append("]"); + + JsonString.Append("}"); + return JsonString.ToString().Replace("\n", ""); + } + else + { + return null; + } + } + StringBuilder result = new StringBuilder(); + StringBuilder sb = new StringBuilder(); + /// + /// 根据DataTable生成EasyUI Tree Json树结构 + /// + /// 数据源 + /// ID列 + /// Text列 + /// 节点Url + /// 关系字段 + /// 父ID + public string GetTreeJsonByTable(DataTable tabel, string idCol, string txtCol, string url, string rela, object pId) + { + result.Append(sb.ToString()); + sb.Clear(); + if (tabel.Rows.Count > 0) + { + sb.Append("["); + string filer = string.Format("{0}='{1}'", rela, pId); + DataRow[] rows = tabel.Select(filer); + if (rows.Length > 0) + { + foreach (DataRow row in rows) + { + sb.Append("{\"id\":\"" + row[idCol] + "\",\"text\":\"" + row[txtCol] + "\",\"attributes\":\"" + row[url] + "\",\"state\":\"open\""); + if (tabel.Select(string.Format("{0}='{1}'", rela, row[idCol])).Length > 0) + { + sb.Append(",\"children\":"); + GetTreeJsonByTable(tabel, idCol, txtCol, url, rela, row[idCol]); + result.Append(sb.ToString()); + sb.Clear(); + } + result.Append(sb.ToString()); + sb.Clear(); + sb.Append("},"); + } + sb = sb.Remove(sb.Length - 1, 1); + } + sb.Append("]"); + result.Append(sb.ToString()); + sb.Clear(); + } + return result.ToString(); + } +} \ No newline at end of file diff --git a/Common/09MesDataFunction/MesDataFunction/08-WebFun_base/MesWebFun_base.cs b/Common/09MesDataFunction/MesDataFunction/08-WebFun_base/MesWebFun_base.cs new file mode 100644 index 0000000..a9d1eb8 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/08-WebFun_base/MesWebFun_base.cs @@ -0,0 +1,165 @@ +using System; +namespace MesWebFun_base +{ + public partial class MisWebInterface + { + public static MesWebFun_base _MesWebFun_base = new MesWebFun_base(); + public string WebSocket_Function(string msg) + { + var responseStr = ""; + try + { + //返回的数据msg.data,包含了协议中的4部分9 + var arrays_signal = msg.Split('|'); + var m_Source = arrays_signal[0]; + var m_Command = arrays_signal[1]; + var m_Opname = arrays_signal[2]; + var m_Value = arrays_signal[3]; + // var opName = $("#tbx_opname").val(); + switch (m_Source) + { + case "MES": + + switch (m_Command) + { + //显示托盘信息 √ + case "ShowMoby": + try + { + responseStr = MesWebFun_base.MobySelect(m_Opname); + } + catch (Exception exception) + { + //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点:ShowMoby" + "|" + "info"); + } + break; + //显示操作指南√ + case "ProcessList": + try + { + responseStr = MesWebFun_base.ProcessList(m_Opname); + } + catch (Exception exception) + { + //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点:ProcessList" + "|" + "info"); + } + break; + //显示物料√ + case "MaterialList": + try + { + responseStr = MesWebFun_base.MaterialList(m_Opname); + } + catch (Exception exception) + { + //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点:MaterialList" + "|" + "info"); + } + break; + //显示操作图片√ + case "PicShow": + try + { + responseStr = MesWebFun_base.PictureShow(m_Opname); + } + catch (Exception exception) + { + //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点:PicShow" + "|" + "info"); + } + break; + //显示拧紧位置√ + case "ShaftPosition": + try + { + responseStr = MesWebFun_base.ShaftPotion_Select(m_Opname); + } + catch (Exception exception) + { + //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点:ShaftPosition" + "|" + "info"); + } + break; + //实时显示质量数据√ + case "ShowTimelyQuality": + try + { + responseStr = MesWebFun_base.Quality_Select(m_Opname); + } + catch (Exception exception) + { + //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点:ShowTimelyQuality" + "|" + "info"); + } + break; + //手动拧紧实时显示质量数据√ + case "ShowTimelyQuality_Tight": + try + { + responseStr = MesWebFun_base.Quality_Select(m_Opname); + } + catch (Exception exception) + { + //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点:ShowTimelyQuality_Tight" + "|" + "info"); + } + break; + + //√ + case "OrderFormList": + try + { + responseStr = MesWebFun_base.OrderFormList(m_Opname); + } + catch (Exception exception) + { + //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点:OrderFormList" + "|" + "info"); + } + break; + //弹窗消息√ + case "Notice": + try + { + responseStr = MesWebFun_base.ShowWindowNotice(m_Opname); + } + catch (Exception exception) + { + //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点:Notice" + "|" + "info"); + } + break; + //LED消息提醒√ + case "ScrollNotice": + try + { + responseStr = MesWebFun_base.ShowLEDNotice(m_Opname); + } + catch (Exception exception) + { + //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点:ScrollNotice" + "|" + "info"); + } + break; + //物料检测初始化√ + case "MaterialCheckPosition": + try + { + responseStr = MesWebFun_base.MaterialCheckPosition(m_Opname); + } + catch (Exception exception) + { + //ApplicationLog.WriteLog("信息提示" + "|" + "错误断点:MaterialCheckPosition" + "|" + "info"); + } + break; + + default: + // Web_Socket_Interface(m_Opname, msg); + break; + } + break; + } + } + catch (Exception exception) + { + var error = exception.ToString(); + //ApplicationLog.WriteLog("信息提示" + "|" + "系统出现错误,接受onmessage:" + "|" + error + "|" + "info"); + responseStr = ""; + } + return responseStr; + } + + } +} \ No newline at end of file diff --git a/Common/09MesDataFunction/MesDataFunction/08-WebFun_base/MesWebFun_baseFun.cs b/Common/09MesDataFunction/MesDataFunction/08-WebFun_base/MesWebFun_baseFun.cs new file mode 100644 index 0000000..f9004d2 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/08-WebFun_base/MesWebFun_baseFun.cs @@ -0,0 +1,1860 @@ +using System; +using System.Collections.Generic; +using System.Web; +using System.Text; + +using System.Data; +using MisDataFunDll; +//using SystemFramework; + +namespace MesWebFun_base +{ + public partial class MesWebFun_base + { + ///// + ///// 电子看板_发动机号_合格放行_记录_增加 + ///// + ///// + //private string Insert_ConfirmOk(string opName, string operatorNum, string type) + //{ + // string text = ""; + // try + // { + // // string operatorNum = HttpContext.Current.Request["userName"];//放行者工号 + // // string type = HttpContext.Current.Request["recordType"];//放行类型 + // MES.InsertRecord_ComfirmOkGO(opName, operatorNum, type); + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Insert_ConfirmOk"); + // } + // return text; + //} + + + + ///// + ///// 初始化节拍数据 + ///// + ///// + //private string InitOpNameOuputCount(string opnameValue) + //{ + // string text = ""; + // try + // { + // int outputValue = 0; //工位产量 + // int nowOutputValue = 0; //在线产量 + // int opNameBeatValue = 0; //工位节拍 + // int NowOpNameBeatValue = 0; //在线节拍 + // int classNumber = 0;//班次代码 + // MisDataFun.InitOpNameOuputCount(opnameValue, out outputValue, out nowOutputValue, out opNameBeatValue, out NowOpNameBeatValue, out classNumber); + // text = "{\"outputValue\":\"" + outputValue + "\",\"nowOutputValue\":\"" + nowOutputValue + "\",\"opNameBeatValue\":\"" + opNameBeatValue + "\",\"NowOpNameBeatValue\":\"" + NowOpNameBeatValue + "\",\"classNumber\":\"" + classNumber + "\"}"; + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:InitOpNameOuputCount"); + // } + // return text; + //} + + ///// + ///// 功能按钮 - 从数据库中初始化在线 / 离线 / 屏蔽的combobox + ///// + ///// + //private string Init_OnlineOutline(string opnameValue) + //{ + // string text = ""; + // try + // { + // System.Data.DataTable dt = null; + // MES.Init_OnlineOutline(opnameValue, out dt); + // string value = ""; + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // value = dt.Rows[0]["工位状态"].ToString(); + // } + // } + // text = "{\"value\":\"" + value + "\"}"; + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Init_OnlineOutline"); + // } + // return text; + //} + + ///// + ///// 功能按钮---将在线,离线,屏蔽更新到数据库中 + ///// + ///// + //private string Insert_OnlineOutline(string opnameValue, string selectValue) + //{ + // string text = ""; + // try + // { + // //string opnameValue = HttpContext.Current.Request["opnameValue"];//工位号 + // //string selectValue = HttpContext.Current.Request["selectValue"];//选择的值 + // if (selectValue == "") + // { + // selectValue = "0"; + // } + // int selectValueint = Convert.ToInt32(selectValue); + // bool falg = MES.Insert_OnlineOutline(opnameValue, selectValueint); + // if (falg) + // { + // text = "{\"falg\":\"1\"}"; + // } + // else + // { + // text = "{\"falg\":\"0\"}"; + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Insert_OnlineOutline"); + // } + // return text; + //} + + ///// + ///// 合格放行 + ///// + ///// + //private string functionButtonConfirmOk(string userName, string passWord) + //{ + // string text = ""; + // try + // { + // string roleFlag = ""; + // string loginFlag = ""; + // System.Data.DataTable dt_User = null; + // //string userName = HttpContext.Current.Request["function_button_confirmOkGo_userName"]; + // //string passWord = HttpContext.Current.Request["function_button_confirmOkGo_passWord"]; + + // BaseDataSystemMES.UserInfo_Login(userName, passWord, out dt_User); + // if (dt_User != null) + // { + // if (dt_User.Rows.Count == 1) + // { + // int roleCodSum = Convert.ToInt32(dt_User.Rows[0][0].ToString()); + // bool IsOK = false; + // RoleDistribution(roleCodSum, out IsOK); + // if (IsOK == true) + // { + // roleFlag = "1"; + // loginFlag = "1"; + // } + // else + // { + // roleFlag = "0"; + // } + // } + // else + // { + // loginFlag = "0"; + // } + // } + // else + // { + // loginFlag = "0"; + // } + // text = "{\"roleFlag\":\"" + roleFlag + "\",\"loginFlag\":\"" + loginFlag + "\"}"; + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:functionButtonConfirmOk"); + // } + // return text; + //} + + ///// + ///// 看用户是否有权限访问该页面 + ///// + ///// + ///// + //private void RoleDistribution(int roleCodSum, out bool IsOK) + //{ + // IsOK = false; + // //登录工位MES的权限是256 如果role&256>0则有权限登录MES软件 + // int roleCode = 64; + // //ArrayList aList = new ArrayList(); + // if ((roleCodSum & roleCode) > 0) + // { + // ////加了没用上 + // //aList.Add(roleCode); + + // switch (roleCode) + // { + // case 64: + // { + // //一级用户管理 + // IsOK = true; + // } + // break; + + // default: + // break; + // } + // } + //} + + ///// + ///// 选择订单_增加订单号 + ///// + ///// + //private string InsertOrderNum(string orderlist, string opName) + //{ + // //string orderlist = HttpContext.Current.Request["orderNum"]; + // MES.OrderNum_Add(opName, orderlist); + // return orderlist; + //} + + ///// + ///// 选择订单_增加发动机型号 + ///// + ///// + //private string InsertEngineNum(string opName, string enginetype, string enginetypecode) + //{ + // string orderlist = ""; + // //string enginetype = HttpContext.Current.Request["enginetype"]; + // //string enginetypecode = HttpContext.Current.Request["enginetypecode"]; + // int enginetypeID = Convert.ToInt32(enginetypecode); + // MES.EngineNum_Add(opName, enginetype, enginetypeID); + // return orderlist; + //} + + ///// + ///// 物料拉动_确认接受 + ///// + ///// + //private string AffirmReceive(string opName, string DistributionNums) + //{ + // string text = ""; + // try + // { + // bool falg = false; + // //string DistributionNums = HttpContext.Current.Request["DistributionNums"]; + // string[] array = DistributionNums.Split(','); + // string DistributionNum = ""; + // for (int i = 0; i < array.Length; i++) + // { + // DistributionNum = array[i]; + // falg = MaterialPull.DistributionNum(opName, DistributionNum); + // } + // if (falg) + // { + // text = "{\"falg\":\"1\"}"; + // } + // else + // { + // text = "{\"falg\":\"0\"}"; + // } + // } + // catch (Exception err) + // { + // //////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:AffirmReceive"); + // } + // return text; + //} + + ///// + ///// 设备管理_设备保养记录增加 + ///// + ///// + //private string equipmentmanagementSubmit(string opname, string mark) + //{ + // string text = ""; + // try + // { + // bool flag; + // // string mark = HttpContext.Current.Request["mark"]; + // flag = bizFacade.MES_MachineManage.Mes_MachineTakeCare_Insert(opname, mark); + // if (flag) + // { + // text = "{\"flag\":\"1\"}"; + // } + // else + // { + // text = "{\"flag\":\"0\"}"; + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:equipmentmanagementSubmit"); + // } + // return text; + //} + + ///// + ///// 获取对应工位的质量数据 + ///// + ///// + //private string QualityDataSelect(string opName, string opname) + //{ + // string qualitydata = ""; + // try + // { + // System.Data.DataTable dt = null; + // //string opName = HttpContext.Current.Request["value"]; + // //string opname = HttpContext.Current.Request["opname"]; + // MES.QualityDataSelect(opName, opname, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // qualitydata = JsonHelper.CreateJsonParameters(dt); + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:QualityDataSelect"); + // } + // return qualitydata; + //} + + + + ///// 获取设备保养类型 + ///// + ///// + //private string LoadMachineType(string opName) + //{ + // string Maintain = ""; + // try + // { + // System.Data.DataTable dt = null; + // //string opName = HttpContext.Current.Request["value"]; + // MES.LoadMachineType(opName, out dt); + // if (dt.Rows.Count > 0) + // { + // Maintain = JsonHelper.DataTableToJson(dt); + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:LoadMachineType"); + // } + // return Maintain; + //} + + + ///// 获取设备保养内容 + ///// + ///// + //private string ShowMaintainData(string opName, string MachineType) + //{ + // string Maintain = ""; + // try + // { + // System.Data.DataTable dt = null; + // //string opName = HttpContext.Current.Request["value"]; + // //string MachineType = HttpContext.Current.Request["machinetype"]; + // MES.ShowMaintainData(opName, MachineType, out dt); + // if (dt.Rows.Count > 0) + // { + // Maintain = JsonHelper.CreateJsonParameters(dt); + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:ShowMaintainData"); + // } + // return Maintain; + //} + + ///// + ///// 获取设备保养图片 + ///// + ///// + //private string ShowMaintainPic(string opName, string MachineType) + //{ + // string Maintain = ""; + // try + // { + // //string opName = HttpContext.Current.Request["value"]; + // //string MachineType = HttpContext.Current.Request["machinetype"]; + // byte[] imgBytesIn; + // MES.GetMaintainImageFile(opName, MachineType, out imgBytesIn); + // if (imgBytesIn == null) + // { + // return Maintain; + // } + // Maintain = Convert.ToBase64String(imgBytesIn); + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:ShowMaintainPic"); + // } + // return Maintain; + //} + + ///// + ///// 物料ando复位 + ///// + ///// + //private string submitAndoMaterialReset(string opname, string andoTypeCode, string andoListCode, string number) + //{ + // string text = ""; + // try + // { + // string number1 = ""; + // //string andoTypeCode = HttpContext.Current.Request["andoTypeCode"]; + // //string andoListCode = HttpContext.Current.Request["andoListCode"]; + // //string number = HttpContext.Current.Request["number"]; + + // string[] number_array = number.Split(','); + // string number_value = ""; + // string callInfo = "复位信息"; + + // for (int i = 0; i < number_array.Length - 1; i++) + // { + // number_value = number_array[i].ToString(); + // string[] valuelist = number_value.Split('_'); + // if (valuelist.Length >= 4) + // { + // number1 = valuelist[3]; + // bizFacade.ando_matertial.AndoMaterialReset(opname, number1, andoTypeCode, andoListCode, callInfo); + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:submitAndoMaterialReset"); + // } + + // return text; + //} + + ///// + ///// ando界面_质量ando复位 + ///// + ///// + //private string submitAndoQualityReset(string opname, string andoTypeCode, string andoListCode, string number) + //{ + // string text = ""; + // try + // { + // string number1 = ""; + // //string andoTypeCode = HttpContext.Current.Request["andoTypeCode"]; + // //string andoListCode = HttpContext.Current.Request["andoListCode"]; + // //string number = HttpContext.Current.Request["number"]; + // string[] valuelist = number.Split('_'); + // if (valuelist.Length >= 4) + // { + // number1 = valuelist[3]; + // } + + // //呼叫内容 + // string callInfo = "复位信息"; + // bool flag = bizFacade.ando_matertial.AndoMaterialReset(opname, number1, andoTypeCode, andoListCode, callInfo); + // if (flag) + // { + // text = "{\"flag\":\"1\"}"; + // } + // else + // { + // text = "{\"flag\":\"0\"}"; + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:submitAndoQualityReset"); + // } + // return text; + //} + + ///// + ///// 物料ando_更新ando的具体的tabel + ///// + ///// + //private string updataAndoMaterialTabel(string opname, string andoTypeCode) + //{ + // string text = ""; + // try + // { + // //string andoTypeCode = HttpContext.Current.Request["andoTypeCode"]; + // text = bizFacade.ando_matertial.CreatAndo_Material_table(opname, andoTypeCode); + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:updataAndoMaterialTabel"); + // } + // return text; + //} + + ///// + ///// 质量ando_更新ando的具体的tabel + ///// + ///// + //private string updataAndoQualityTabel(string opname, string andoTypeCode) + //{ + // string text = ""; + // try + // { + // // string andoTypeCode = HttpContext.Current.Request["andoTypeCode"]; + // text = bizFacade.ando_quality.CreatAndo_quality_table(opname, andoTypeCode); + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:updataAndoQualityTabel"); + // } + // return text; + //} + + ///// + ///// ando界面_提交物料ando信息(插入呼叫信息) + ///// + ///// + //private string submitAndoMaterialCall(string opname, string andoTypeCode, string andoListCode, string number) + //{ + // string text = ""; + // try + // { + // string number1 = ""; + // //System.Data.DataTable tb; + // //string andoTypeCode = HttpContext.Current.Request["andoTypeCode"]; + // //string andoListCode = HttpContext.Current.Request["andoListCode"]; + // //string number = HttpContext.Current.Request["number"]; + // string[] number_array = number.Split(','); + // string number_value = ""; + // string callInfo = "0"; + // int callCount = 0; + // string cardNumber = "0"; + // string noNumber = "0"; + + // for (int i = 0; i < number_array.Length - 1; i++) + // { + // number_value = number_array[i].ToString(); + // string[] valuelist = number_value.Split('_'); + // if (valuelist.Length >= 4) + // { + // number1 = valuelist[3]; + // bizFacade.ando_matertial.andoMaterialCall(opname, andoTypeCode, andoListCode, number1, callInfo, callCount, cardNumber, noNumber); + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:submitAndoMaterialCall"); + // } + // return text; + //} + + ///// + ///// 安东界面_质量ando_呼叫提交 + ///// + ///// + //private string submitAndoQualityCall() + //{ + // string text = ""; + // //string number1 = ""; + // //string opname = HttpContext.Current.Request["opname"]; + // //string andoTypeCode = HttpContext.Current.Request["andoTypeCode"]; + // //string andoListCode = HttpContext.Current.Request["andoListCode"]; + // //string number = HttpContext.Current.Request["number"]; + // //string[] valuelist = number.Split('_'); + // //if (valuelist.Length >= 4) + // //{ + // // number1 = valuelist[3]; + // //} + // //string callInfo = "0"; + // //int callCount = 5; + // //string cardNumber = "0"; + // //string noNumber = "0"; + // //bool flag = bizFacade.ando_matertial.andoMaterialCall(opname, andoTypeCode, andoListCode, number1, callInfo, callCount, cardNumber, noNumber); + // //if (flag) + // //{ + // // text = "{\"flag\":\"1\"}"; + // //} + // //else + // //{ + // // text = "{\"flag\":\"0\"}"; + // //} + // return text; + //} + + ///// + ///// 查询物料ando条数,为了左移动的 + ///// + ///// + //private string InitMaterailAndoCount(string opname, string andoTypeCode) + //{ + // string text = ""; + // try + // { + // System.Data.DataTable dt_material; + // System.Data.DataTable dt_quality; + // System.Data.DataTable dt_machine; + // //string andoTypeCode = HttpContext.Current.Request["andoTypeCode"]; + // //查询物料ando具体的button个数 + // bizFacade.ando_matertial.andoListSelect(opname, "1", out dt_material); + // int count_material = 0; + + // //不为空 + // if (dt_material != null) + // { + // if (dt_material.Rows.Count == 0) + // { + // count_material = 0; + // } + // else + // { + // count_material = dt_material.Rows.Count; + // } + // } + // //查询质量ando具体的button个数 + // bizFacade.ando_matertial.andoListSelect(opname, "2", out dt_quality); + // int count_quality = 0; + // if (dt_quality != null) + // { + // if (dt_quality.Rows.Count == 0) + // { + // count_quality = 0; + // } + // else + // { + // count_quality = dt_quality.Rows.Count; + // } + // } + // //查询设备ando具体的button个数 + // bizFacade.ando_matertial.andoListSelect(opname, "3", out dt_machine); + + // int count_machine = 0; + // if (dt_machine != null) + // { + // if (dt_machine.Rows.Count == 0) + // { + // count_machine = 0; + // } + // else + // { + // count_machine = dt_machine.Rows.Count; + // } + // } + // text = "{\"material_count\":\"" + count_material + "\",\"machine_count\":\"" + count_machine + "\",\"quality_count\":\"" + count_quality + "\"}"; + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:InitMaterailAndoCount"); + // } + // return text; + //} + + ///// + ///// 初始化ando + ///// + ///// + //private string InitMaterailAndo(string opname) + //{ + // string text = ""; + // try + // { + // text = bizFacade.ando_load.ando_loading(opname); + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:InitMaterailAndo"); + // } + // return text; + //} + + ///// + ///// ando_查询具体ando类型明细 + ///// + ///// + //private string InitComboboxAndoDetail() + //{ + // string text = ""; + // //System.Data.DataTable dt = null; + // //string andoType="1"; + // //bizFacade.ando.select_ando_detail(andoType, out dt); + // //text = JsonHelper.DataTableToJson(dt); + // return text; + //} + + ///// + ///// 初始化装配线MES + ///// + ///// + //private string MesloadingSelect(string opname, string languageType, string mainModule) + //{ + // string text = ""; + // try + // { + // System.Data.DataTable dt = null; + + // //string languageType = HttpContext.Current.Request["mainModule"]; + // //string mainModule = HttpContext.Current.Request["MesWebCode"]; + // bizFacade.MES_Loading.MES_Loading_select(languageType, mainModule, opname, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // text = JsonHelper.DataTableToJson(dt); + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MesloadingSelect"); + // } + // return text; + //} + + + + ///// + ///// 查询物料库存信息 + ///// + ///// + //private string MaterialListStock(string OpName) + //{ + // string jsonStr_Materail = ""; + // try + // { + // string orderNum = ""; + // int EngineTypeID = 0; + // string EngineType = ""; + // string EngineID = ""; + // string PartPallet_Code = ""; + // int IsrepairBarcode = 0; + // string repairBarcode = ""; + // string EngineTypeString = ""; + // MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + // DataTable dt_Material; + + // MisDataFun.PartMaterialVerify_Select(OpName, EngineTypeID, EngineType, out dt_Material); + // if (dt_Material != null) + // { + // if (dt_Material.Rows.Count > 0) + // { + // jsonStr_Materail = JsonHelper.CreateJsonParameters(dt_Material); + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialList"); + // } + // return jsonStr_Materail; + //} + + + + + + ///// + ///// 获得工步属性 + ///// + ///// + //private string StepProperty(string opName) + //{ + // string stepProperty = "512"; + // System.Data.DataTable dt = null; + // bizFacade.UserLogin.GetUrl(opName, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // stepProperty = dt.Rows[0]["工步属性"].ToString(); + // } + // } + // return stepProperty; + //} + + + + //private static string CreateJsonParameters(DataTable dt) + //{ + // StringBuilder JsonString = new StringBuilder(); + // //Exception Handling + // if (dt != null) + // { + // JsonString.Append("{ "); + // JsonString.Append("\"total\":"); + // JsonString.Append(dt.Rows.Count); + // JsonString.Append(","); + // JsonString.Append("\"rows\":[ "); + // for (int i = 0; i < dt.Rows.Count; i++) + // { + // JsonString.Append("{ "); + // for (int j = 0; j < dt.Columns.Count; j++) + // { + // if (j < dt.Columns.Count - 1) + // { + // //if (dt.Rows[i][j] == DBNull.Value) continue; + // if (dt.Columns[j].DataType == typeof(bool)) + // { + // JsonString.Append("\"JSON_" + dt.Columns[j].ColumnName.ToLower() + "\":" + + // dt.Rows[i][j].ToString().ToLower() + ","); + // } + // else if (dt.Columns[j].DataType == typeof(string)) + // { + // JsonString.Append("\"JSON_" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + + // dt.Rows[i][j].ToString().Replace("\"", "\\\"") + "\","); + // } + // else + // { + // JsonString.Append("\"JSON_" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + dt.Rows[i][j] + "\","); + // } + // } + // else if (j == dt.Columns.Count - 1) + // { + // //if (dt.Rows[i][j] == DBNull.Value) continue; + // if (dt.Columns[j].DataType == typeof(bool)) + // { + // JsonString.Append("\"JSON_" + dt.Columns[j].ColumnName.ToLower() + "\":" + + // dt.Rows[i][j].ToString().ToLower()); + // } + // else if (dt.Columns[j].DataType == typeof(string)) + // { + // JsonString.Append("\"JSON_" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + + // dt.Rows[i][j].ToString().Replace("\"", "\\\"") + "\""); + // } + // else + // { + // JsonString.Append("\"JSON_" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + dt.Rows[i][j] + "\""); + // } + // } + // } + // /*end Of String*/ + // if (i == dt.Rows.Count - 1) + // { + // JsonString.Append("} "); + // } + // else + // { + // JsonString.Append("}, "); + // } + // } + // JsonString.Append("]"); + // JsonString.Append("}"); + // return JsonString.ToString().Replace("\n", ""); + // } + // else + // { + // return null; + // } + //} + + ///// + ///// 获得机型 + ///// + ///// + //private string Orderenginetypeselect() + //{ + // string enginetypelist = ""; + // try + // { + // System.Data.DataTable dt = null; + // ShaftPosition.EngineType_Select(out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // enginetypelist = JsonHelper.DataTableToJson(dt); + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Orderenginetypeselect"); + // } + // return enginetypelist; + //} + + ///// + ///// 物料拉动_获取单号 + ///// + ///// + //private string MaterialPush_ListNumer(string opName) + //{ + // string listNumber = ""; + // try + // { + // System.Data.DataTable dt = null; + // MaterialPull.MaterialPush_ListNumer_Select(0, "", 1, opName, 0, "", out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // listNumber = JsonHelper.CreateJsonParameters(dt); + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialPush_ListNumer"); + // } + // return listNumber; + //} + + ///// + ///// 物料拉动_根据单号获取详细信息 + ///// + ///// + //private string MaterialPush_Details(string opname, string listNumer) + //{ + // string listDetails = ""; + // try + // { + // System.Data.DataTable dt = null; + // //单号 + // //string listNumer = HttpContext.Current.Request["listNumber"]; + // MaterialPull.MaterialPush_Details_Select(listNumer, opname, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // listDetails = JsonHelper.CreateJsonParameters(dt); + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialPush_Details"); + // } + // return listDetails; + //} + + ///// + ///// 物料拉动_根据单号获取详细信息 + ///// + ///// + //private string QualityDataButton_bgColor_Select(string opname) + //{ + // string text = ""; + // try + // { + // System.Data.DataTable dt = null; + // //单号 + // MES.QualityDataButton_bgColor_Select(opname, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count >= 0) + // { + // text = Buttons.Createbuttons(dt); + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:QualityDataButton_bgColor_Select"); + // } + // return text; + //} + + + + + + ///// + ///// 获取生产订单 + ///// + ///// + //private string GetOrderForm(string opname) + //{ + // string text = ""; + // try + // { + // System.Data.DataTable dt = null; + // MES.OpName_MIS_OrderForm_Select(opname, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // text = dt.Rows[0]["订单号"].ToString(); + // return text; + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:GetOrderForm"); + // } + // return text; + //} + + ///// + ///// 获取发动机型号 + ///// + ///// + //private string GetEngineType(string opname) + //{ + // string text = ""; + // try + // { + // System.Data.DataTable dt = null; + // MES.OpName_MIS_EngineType_Select(opname, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // text = dt.Rows[0]["产品型号代码"].ToString() + "&" + dt.Rows[0]["发动机型号"].ToString(); + // return text; + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:GetEngineType"); + // } + // return ("" + "&" + ""); + //} + + ///// + ///// + ///// + ///// + //private string ShowOpNameMessage(string opname) + //{ + // string text = ""; + // try + // { + // System.Data.DataTable dt = null; + // BaseDataSystemMES.GetOpNameByOpName(opname, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // text = dt.Rows[0]["工序名称"].ToString() + "&" + dt.Rows[0]["操作者工号"].ToString() + "&" + dt.Rows[0]["是否启用物料拉动"].ToString(); + // return text; + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:ShowOpNameMessage"); + // } + // return ("" + "&" + "" + "&" + "0"); + //} + + ///// + ///// 系统初始化时 + ///// + ///// + //private string WebLoginIn(string opname) + //{ + // string text = ""; + // MES.WebLoginIn(opname); + // return text; + //} + + + + ///// + ///// 获取对应工位的物料数据 + ///// + ///// + //private string MaterialDataSelect(string opName, string opname) + //{ + // string qualitydata = ""; + // try + // { + // System.Data.DataTable dt = null; + // //string opName = HttpContext.Current.Request["value"]; + // //string opname = HttpContext.Current.Request["opname"]; + // MES.MaterialDataSelect(opName, opname, out dt); + // if (dt != null) + // { + // //if (dt.Rows.Count > 0) + // { + // qualitydata = JsonHelper.CreateJsonParameters(dt); + // } + // } + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialDataSelect"); + // } + // return qualitydata; + //} + + ///// + ///// 电子看板_装配零件_查询 + ///// + ///// + //private string MaterialSelect(string opName, string enginetypeid, string enginetype) + //{ + // string text = ""; + // try + // { + // System.Data.DataTable dt = null; + // //string enginetypeid = HttpContext.Current.Request["enginetypeid"]; + // //string enginetype = HttpContext.Current.Request["enginetype"]; + // ShaftPosition.Material_Select(opName, enginetypeid, enginetype, out dt); + + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // text = JsonHelper.CreateJsonParameters(dt); + // } + // } + // } + // catch (Exception err) + // { + // //ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialSelect"); + // } + // return text; + //} + + //public string GetLoginOutUrl() + //{ + // string url = System.Configuration.ConfigurationManager.AppSettings["Linklogin"].ToString(); + // return url; + //} + + ///// + ///// 手动修改批次信息 + ///// + ///// + //private string MaterialManualUpdateBetch(string opName,string arrays, string enginetype) + //{ + // string text = ""; + // try + // { + // //string arrays = HttpContext.Current.Request["arrays"];//组合 + // //string enginetype = HttpContext.Current.Request["enginetype"];//产品型号 + + // //创建datatable + // DataRow row; + // DataTable dt = new DataTable(); + // dt.Columns.AddRange(new DataColumn[] { + // new DataColumn("零件图号"), + // new DataColumn("零件批号"), + // new DataColumn("生产厂家") }); + + // string[] collection = arrays.Split('^');//获取 + // if (collection.Length > 0) + // { + // for (int i = 0; i < collection.Length; i++) + // { + // string a = collection[i]; + // string[] a_array = a.Split('&'); + // if (a_array.Length > 2) + // { + // row = dt.NewRow(); + // string materialid = a_array[0].ToString(); + // string betch = a_array[1].ToString(); + // string factory = a_array[2].ToString(); + // row["零件图号"] = materialid; + // row["零件批号"] = betch; + // row["生产厂家"] = factory; + // dt.Rows.Add(row); + // } + // } + + // //修改到数据库 + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // MES.Material_Betch_Update(opName, enginetype, dt); + // } + // } + // } + // } + // catch (Exception err) + // { + // //ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialManualUpdateBetch"); + // } + // return text; + //} + + ///// + ///// 获得返修数量信息 + ///// + ///// + //private string GetRepaireNum(string opname) + //{ + // string text = ""; + // try + // { + // System.Data.DataTable dt = null; + // MES.OpName_MIS_RepiareNum_Select(opname, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // text = dt.Rows[0]["当前数量"].ToString() + "&" + dt.Rows[0]["设置数量"].ToString(); + // return text; + // } + // else + // { + // return text = "0&0"; + // } + // } + // else + // { + // return text = "0&0"; + // } + // } + // catch (Exception err) + // { + // //ApplicationLog.WriteLog(err, "MesWebFun_baseFun:GetEngineType"); + // } + // return ("" + "&" + ""); + //} + + ///// + ///// 插入返修数量 + ///// + ///// + //private string Insert_RepiareNum(string opnameValue, string selectValue) + //{ + // string text = ""; + // try + // { + // //string selectValue = HttpContext.Current.Request["CurrentNum"];//选择值 + // if (selectValue == "") + // { + // selectValue = "0"; + // } + // int selectValueint = Convert.ToInt32(selectValue); + // bool falg = MES.Insert_RepiareNum(opnameValue, selectValueint); + // if (falg) + // { + // text = "{\"falg\":\"1\"}"; + // } + // else + // { + // text = "{\"falg\":\"0\"}"; + // } + // } + // catch (Exception err) + // { + // //ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Insert_RepiareNum"); + // } + // return text; + //} + + ///// + ///// 初始化返修选择tree数据 + ///// + ///// + //private string Init_TreeData(string opnameValue) + //{ + // string text = ""; + // try + // { + // System.Data.DataTable dt; + // //string opnameValue = HttpContext.Current.Request["Opname"];//工位号 + // MES.Init_TreeData(opnameValue, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // text = JsonHelper.CreateJsonParameters(dt); + // } + // } + // } + // catch (Exception err) + // { + // //ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Init_TreeData"); + // } + // return text; + //} + + ///// + ///// 返修上线--初始化质量数据 + ///// + ///// + //private string Quality_Select_Repair(string OpName, string EngineID) + //{ + // string text = ""; + // try + // { + // DataTable dt; + // MES.QualitySelect(OpName, EngineID, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // text = JsonHelper.CreateJsonParameters(dt); + // } + // } + // } + // catch (Exception err) + // { + // //ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Quality_Select_Repair"); + // } + // return text; + //} + + ///// + ///// 返修上线-将选择的根节点数据更新到数据库中 + ///// + ///// + //private string Insert_selectTreeData(string opName, string engineTypeId, string selectIdsArray) + //{ + // string text = ""; + // try + // { + // //string engineTypeId = HttpContext.Current.Request["engineTypeId"];//产品型号代码 + // //string selectIdsArray = HttpContext.Current.Request["selectId"];//选中的节点数据数据 + // //创建datatable + // DataRow row; + // DataTable dt = new DataTable(); + // dt.Columns.AddRange(new DataColumn[] { + // new DataColumn("工位号"), + // new DataColumn("产品型号代码"), + // new DataColumn("序号") }); + // string[] collection = selectIdsArray.Split(',');//获取 + // if (collection.Length > 0) + // { + // for (int i = 0; i < collection.Length - 1; i++) + // { + // string idValue = collection[i]; + // row = dt.NewRow(); + // string opNameValue = opName; + // int engineTypeIdValue = Convert.ToInt32(engineTypeId); + // int selectId = Convert.ToInt32(idValue); + // row["工位号"] = opNameValue; + // row["产品型号代码"] = engineTypeIdValue; + // row["序号"] = selectId; + // dt.Rows.Add(row); + // } + // //修改到数据库 + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // MES.Insert_selectTreeData(dt); + // } + // } + // } + // } + // catch (Exception err) + // { + // //ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Insert_selectTreeData"); + // } + + // return text; + //} + + ///// + ///// 质量报警_根据按钮获取详细信息 20170318 + ///// + ///// + //public static string QualityDataButton_bgColor_alert_Select(string opname) + //{ + // string text = ""; + // try + // { + // System.Data.DataTable dt = null; + // //单号 + // //string opname = HttpContext.Current.Request["value"]; + // //string lineout_barcode = HttpContext.Current.Request["lineout_barcode"]; + // MES.QualityDataButton_bgColor_alert_Select(opname, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count >= 0) + // { + // text = Buttons.Createbuttons_alert(dt); + // } + // } + // } + // catch (Exception err) + // { + // //ApplicationLog.WriteLog(err, "MesWebFun_baseFun:QualityDataButton_bgColor_alert_Select"); + // } + // return text; + //} + + ///// + ///// 获取对应工位的物料数据_根据发动机 20170319 + ///// + ///// + //private string MaterialDataSelect_F_EnergineID(string opname, string energineID) + //{ + // string qualitydata = ""; + // try + // { + // System.Data.DataTable dt = null; + // //string energineID = HttpContext.Current.Request["value"]; + // MES.MaterialDataSelect_F_EnergineID(opname, energineID, out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // qualitydata = JsonHelper.CreateJsonParameters(dt); + // } + // } + // } + // catch (Exception err) + // { + // //ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialDataSelect"); + // } + // return qualitydata; + //} + + ///// + ///// 获取操作指南的PDF路径 + ///// + ///// + //private string GetPdfSrc(string OpName) + //{ + // string PdfSrc = ""; + // try + // { + // System.Data.DataTable dt = null; + + // string orderNum = ""; + // int EngineTypeID = 0; + // string EngineType = ""; + // string EngineID = ""; + // string PartPallet_Code = ""; + // int IsrepairBarcode = 0; + // string repairBarcode = ""; + // string EngineTypeString = ""; + // MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + // BaseDataSystemMES.GetPdfSrc(OpName, EngineTypeID.ToString(), out PdfSrc); + // } + // catch (Exception err) + // { + // //ApplicationLog.WriteLog(err, "MesWebFun_baseFun:GetPdfSrc"); + // } + // return PdfSrc; + //} + + + + #region 目前有用的函数 + + /// + /// 查询托盘信息 + /// + /// + public static string MobySelect(string OpName) + { + string data = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string workCode = ""; // 制造编号 + string projectName = ""; // 项目名称 + string splitCode = ""; // 间隔号 + string unidCode = ""; // 单元号 + string engineType = ""; // 本体类型 + string engineTypeModel = ""; // 附件类型 + string startTime = ""; // 开始时间 + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, + out workCode, out projectName, out splitCode, out unidCode, out engineType, out engineTypeModel, out startTime); + data = orderNum + "&" + EngineTypeID + "&" + EngineType + "&" + EngineID + "&" + PartPallet_Code + "&" + IsrepairBarcode + "&" + repairBarcode + "&" + + workCode + "&" + projectName + "&" + splitCode + "&" + unidCode + "&" + engineType + "&" + engineTypeModel + "&" + startTime; + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MobySelect"); + } + return data; + } + + /// + /// 查询操作图片 + /// + /// + public static string PictureShow(string OpName) + { + string data = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string workCode = ""; // 制造编号 + string projectName = ""; // 项目名称 + string splitCode = ""; // 间隔号 + string unidCode = ""; // 单元号 + string engineType = ""; // 本体类型 + string engineTypeModel = ""; // 附件类型 + string startTime = ""; // 开始时间 + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, + out workCode, out projectName, out splitCode, out unidCode, out engineType, out engineTypeModel, out startTime); + byte[] imgBytesIn; + MisDataFun.GetImageFile(OpName, EngineTypeID, out imgBytesIn); + if (imgBytesIn == null) + { + return data; + } + data = Convert.ToBase64String(imgBytesIn); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:PictureShow"); + } + return data; + } + + /// + /// 查询物料 + /// + /// + public static string MaterialList(string OpName) + { + string jsonStr_Materail = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string workCode = ""; // 制造编号 + string projectName = ""; // 项目名称 + string splitCode = ""; // 间隔号 + string unidCode = ""; // 单元号 + string engineType = ""; // 本体类型 + string engineTypeModel = ""; // 附件类型 + string startTime = ""; // 开始时间 + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, + out workCode, out projectName, out splitCode, out unidCode, out engineType, out engineTypeModel, out startTime); + DataTable dt_Material; + MisDataFun.PartMaterialVerify_Select(OpName, EngineTypeID, EngineType, out dt_Material); + if (dt_Material != null) + { + if (dt_Material.Rows.Count > 0) + { + jsonStr_Materail = JsonHelper.CreateJsonParameters(dt_Material); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialList"); + } + return jsonStr_Materail; + } + /// + /// 查询操作指南 + /// + /// + public static string ProcessList(string OpName) + { + string jsonStr_Process = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string workCode = ""; // 制造编号 + string projectName = ""; // 项目名称 + string splitCode = ""; // 间隔号 + string unidCode = ""; // 单元号 + string engineType = ""; // 本体类型 + string engineTypeModel = ""; // 附件类型 + string startTime = ""; // 开始时间 + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, + out workCode, out projectName, out splitCode, out unidCode, out engineType, out engineTypeModel, out startTime); + + DataTable dt_Proccess; + MisDataFun.Process_Select(OpName, EngineTypeID, EngineType, out dt_Proccess); + if (dt_Proccess != null) + { + if (dt_Proccess.Rows.Count > 0) + { + jsonStr_Process = JsonHelper.CreateJsonParameters(dt_Proccess); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:ProcessList"); + } + return jsonStr_Process; + } + /// + /// 创建动态div + /// + /// + public static string ShaftPotion_Select(string OpName) + { + string text = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string workCode = ""; // 制造编号 + string projectName = ""; // 项目名称 + string splitCode = ""; // 间隔号 + string unidCode = ""; // 单元号 + string engineType = ""; // 本体类型 + string engineTypeModel = ""; // 附件类型 + string startTime = ""; // 开始时间 + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, + out workCode, out projectName, out splitCode, out unidCode, out engineType, out engineTypeModel, out startTime); + + DataTable dt; + MisDataFun.ShaftPositionSelect(OpName, EngineTypeID, out dt); + if (dt != null) + { + if (dt.Rows.Count > 0) + { + text = JsonHelper.DataTableToJson(dt); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:ShaftPotion_Select"); + } + return text; + } + /// + /// 实时显示质量数据 + /// + /// + public static string Quality_Select(string OpName) + { + string text = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string workCode = ""; // 制造编号 + string projectName = ""; // 项目名称 + string splitCode = ""; // 间隔号 + string unidCode = ""; // 单元号 + string engineType = ""; // 本体类型 + string engineTypeModel = ""; // 附件类型 + string startTime = ""; // 开始时间 + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, + out workCode, out projectName, out splitCode, out unidCode, out engineType, out engineTypeModel, out startTime); + + DataTable dt; + MisDataFun.QualitySelect(OpName, EngineID, out dt); + if (dt != null) + { + if (dt.Rows.Count > 0) + { + text = JsonHelper.CreateJsonParameters(dt); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Quality_Select"); + } + return text; + } + /// + /// 订单完工,上线数量大于计划数量,界面提示 + /// + /// + private string OrderFormList_OrderComplete(string opName) + { + string text = ""; + try + { + int isCompleted;//订单数量是否完全上线 + int num_plan;//计划数量 + int num_complete;//上线数量 + MisDataFun.Select_OrderFormList_OrderComplete(opName, out isCompleted, out num_plan, out num_complete); + text = "{\"isCompleted\":\"" + isCompleted + "\",\"num_plan\":\"" + num_plan + "\",\"num_complete\":\"" + num_complete + "\"}"; + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:OrderFormList_OrderComplete"); + } + return text; + } + /// + /// 获得订单信息 + /// + /// + public static string OrderFormList(string opName) + { + string orderlist = ""; + try + { + System.Data.DataTable dt = null; + MisDataFun.OrderFormList_Select(opName, out dt); + //对其进行判断 + if (dt != null) + { + if (dt.Rows.Count > 0) + { + int planCount;//计划数量 + int finishCount;//完成数量 + int isOverCount;//是否超标,0表示未完成,1表示正好完成,2表示超过预期 + int isSelect;//选择标志 + int isCanSelect;//是否有订单选择权限 + string status;//状态 + for (int i = 0; i < dt.Rows.Count; i++) + { + planCount = 0; + finishCount = 0; + isOverCount = 0; + isSelect = 0; + isCanSelect = 0; + status = ""; + + if (dt.Rows[i]["计划数量"].ToString() != "") + { + planCount = Convert.ToInt32(dt.Rows[i]["计划数量"]); + } + if (dt.Rows[i]["完成数量"].ToString() != "") + { + finishCount = Convert.ToInt32(dt.Rows[i]["完成数量"]); + } + if (dt.Rows[i]["选择标志"].ToString() != "") + { + isSelect = Convert.ToInt32(dt.Rows[i]["选择标志"]); + } + if (dt.Rows[i]["订单选择权限"].ToString() != "") + { + isCanSelect = Convert.ToInt32(dt.Rows[i]["订单选择权限"]); + } + if (isSelect == 1)//表示选择当前订单,显示"√" + { + status = "√"; + } + if (finishCount == planCount)//完成数量>计划数量则表示超标 + { + isOverCount = 1; + } + if (finishCount > planCount)//完成数量>计划数量则表示超标 + { + isOverCount = 2; + } + //重新赋值 + dt.Rows[i]["状态"] = status; + dt.Rows[i]["是否超标"] = isOverCount;//0表示未完成,1表示正好完成,2表示超过预期 + dt.Rows[i]["选择标志"] = isSelect; + dt.Rows[i]["订单选择权限"] = isCanSelect; + } + } + } + + orderlist = JsonHelper.CreateJsonParameters(dt); + //orderlist = CreateJsonParameters(dt); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:OrderFormList"); + } + return orderlist; + } + /// + /// 消息提醒 + /// + /// + public static string ShowWindowNotice(string opname) + { + string text = ""; + try + { + System.Data.DataTable dt = null; + MisDataFun.ShowWindowNotice(opname, out dt); + if (dt != null) + { + if (dt.Rows.Count > 0) + { + text = JsonHelper.DataTableToJson(dt); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:ShowWindowNotice"); + } + return text; + } + /// + /// 消息滚动 + /// + /// + public static string ShowLEDNotice(string opname) + { + string text = ""; + try + { + DataTable dt = null; + MisDataFun.ShowLEDNotice(opname, out dt); + if (dt != null) + { + if (dt.Rows.Count > 0) + { + text = JsonHelper.DataTableToJson(dt); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:ShowLEDNotice"); + } + return text; + } + /// + /// 物料检测 + /// + /// + public static string MaterialCheckPosition(string OpName) + { + string text = ""; + try + { + DataTable dt; + MisDataFun.MaterialCheckSelect(OpName, out dt); + if (dt != null) + { + if (dt.Rows.Count > 0) + { + text = JsonHelper.DataTableToJson(dt); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialCheckPosition"); + } + return text; + } + + + + + + + + + + + + + + #endregion + + + } +} \ No newline at end of file diff --git a/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/MIS.SendMessage.cs b/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/MIS.SendMessage.cs new file mode 100644 index 0000000..120fb56 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/MIS.SendMessage.cs @@ -0,0 +1,100 @@ +using System; +using System.Data; +using System.Collections; +//using BasicData; +////using bizFacade; +//using SystemFramework; +using System.Configuration; +//using MesWork; +using MQTTnet.Client.Connecting; +using MQTTnet.Client.Disconnecting; +using MQTTnet.Client.Receiving; +using MQTTnet; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + public partial class MIS_SendMessage + { + /// + /// + /// + public static string MqttTargetTopic = ConfigurationManager.AppSettings["MqttTargetTopic"]; + /// + /// + /// + static new MesWebFun_base.MisWebInterface misWebInterface = new MesWebFun_base.MisWebInterface(); + /// + /// + /// + static readonly Object locker = new Object(); + /// + /// 发消息给通讯服务器 + /// + /// + public static string asyncSendMessage(string Message) + { + lock (locker) + { + //"MES|MachinePlan|OpName|Value + var array = Message.Split('|'); + var cmd = array[1]; + var opName = array[2]; + var topic = $"{MqttTargetTopic}/{opName}"; + Task.Run(() => Mqtt.Publish(topic, Message)); + + var responseStr = misWebInterface.WebSocket_Function(Message); + if (responseStr.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}")); + } + return responseStr; + } + } + + public static string asyncSendMessageDemo(string Message) + { + lock (locker) + { + //"MES|MachinePlan|OpName|Value + var array = Message.Split('|'); + var cmd = array[1]; + var opName = array[2]; + var topic = $"{MqttTargetTopic}/{opName}"; + + //Mqtt.Publish(topic, Message); + string responseStr = ""; + //var responseStr = misWebInterface.WebSocket_Function(Message); + //if (responseStr.Length > 0) + //{ + + // Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}"); + //} + return responseStr; + } + } + + /// + /// 发消息给通讯服务器 + /// + /// + public static string asyncSendMessageQos0(string Message) + { + lock (locker) + { + //"MES|MachinePlan|OpName|Value + var array = Message.Split('|'); + var cmd = array[1]; + var opName = array[2]; + var topic = $"{MqttTargetTopic}/{opName}"; + Mqtt.PublishQos0(topic, Message); + + return ""; + } + } + + + + } +} + diff --git a/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/Mqtt.cs b/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/Mqtt.cs new file mode 100644 index 0000000..e6a69e6 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/Mqtt.cs @@ -0,0 +1,281 @@ + +using MQTTnet; +using MQTTnet.Client; +using MQTTnet.Client.Connecting; +using MQTTnet.Client.Disconnecting; +using MQTTnet.Client.Options; +using MQTTnet.Client.Receiving; +using MQTTnet.Extensions.ManagedClient; +using MQTTnet.Formatter; + +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + public class Mqtt + { + /// + /// + /// + public static IManagedMqttClient mqttClient = null; + public static string MqttUrl = ConfigurationManager.AppSettings["MqttUrl"]; + /// + /// + /// + public static string topic = ""; + + + /// + /// + /// + /// + /// + public static async Task StartAsync() + { + string uri = MqttUrl; + //127.0.0.1:18083,123 + var array = uri.Split(new char[] { ':', ',' }); + string mqttUser = "MisDataFun"; + string mqttPassword = ""; + var options = new MqttClientOptions + { + ClientId = "MisDataFun-200170511", + ProtocolVersion = MqttProtocolVersion.V311, + ChannelOptions = new MqttClientTcpOptions { Server = array[0], Port = Convert.ToInt32(array[1]) }, + CleanSession = false, + SessionExpiryInterval = 300, + KeepAlivePeriod = TimeSpan.FromSeconds(20), + Credentials = new MqttClientCredentials + { + Username = mqttUser, + Password = Encoding.UTF8.GetBytes(mqttPassword) + } + }; + mqttClient = new MqttFactory().CreateManagedMqttClient(); + + //mqttClient.ConnectedHandler = new MqttClientConnectedHandlerDelegate(OnSubscriberConnected); + //mqttClient.DisconnectedHandler = new MqttClientDisconnectedHandlerDelegate(OnSubscriberDisconnected); + //mqttClient.ApplicationMessageReceivedHandler = new MqttApplicationMessageReceivedHandlerDelegate(OnSubscriberMessageReceived); + await mqttClient.StartAsync(new ManagedMqttClientOptions { ClientOptions = options }); + topic = array[2]; + await mqttClient.SubscribeAsync(new MqttTopicFilter { Topic = topic }); + + } + + + /// + /// + /// + /// + /// + /// + public static async Task Publish(string publish_topic, string publish_msg) + { + if (mqttClient != null) + { + try + { + await mqttClient.PublishAsync(new MqttApplicationMessageBuilder().WithTopic(publish_topic).WithPayload(publish_msg).WithExactlyOnceQoS().Build()); + + } + catch (Exception err) + { + + } + } + } + /// + /// + /// + /// + /// + /// + public static async Task PublishQos0(string publish_topic, string publish_msg) + { + if (mqttClient != null) + { + await mqttClient.PublishAsync(new MqttApplicationMessageBuilder().WithTopic(publish_topic).WithPayload(publish_msg).WithAtLeastOnceQoS().Build()); + } + } + /// + /// + /// + /// + public static async Task StopAsync() + { + if (mqttClient != null) + { + await mqttClient.UnsubscribeAsync(new string[] { topic }); + await mqttClient.StopAsync(); + } + } + ///// + ///// + ///// + ///// + //private static void OnSubscriberConnected(MqttClientConnectedEventArgs x) + //{ + // var rec = x.AuthenticateResult.ResultCode.ToString(); + // // label_State.Text = rec; + //} + ///// + ///// + ///// + ///// + //private static void OnSubscriberDisconnected(MqttClientDisconnectedEventArgs x) + //{ + // //var rec = x.AuthenticateResult.ResultCode.ToString(); + // //label_State.Text = rec; + //} + ///// + ///// + ///// + ///// + //private static void OnSubscriberMessageReceived(MqttApplicationMessageReceivedEventArgs x) + //{ + // var rec = x.ApplicationMessage.ConvertPayloadToString(); + // // txt_Rec.Text = txt_Rec.Text + rec + System.Environment.NewLine; + + //} + + + + } + + public class Mqtt2 + { + /// + /// + /// + public IManagedMqttClient mqttClient = null; + public string MqttUrl; + /// + /// + /// + public string topic = ""; + + public Mqtt2() + { + mqttClient = new MqttFactory().CreateManagedMqttClient(); + } + /// + /// + /// + /// + /// + public async Task StartAsync() + { + string uri = MqttUrl; + //127.0.0.1:18083,123 + var array = uri.Split(new char[] { ':', ',' }); + string mqttUser = ""; + string mqttPassword = ""; + var options = new MqttClientOptions + { + ClientId = Guid.NewGuid().ToString(), + ProtocolVersion = MqttProtocolVersion.V311, + ChannelOptions = new MqttClientTcpOptions { Server = array[0], Port = Convert.ToInt32(array[1]) }, + CleanSession = true, + KeepAlivePeriod = TimeSpan.FromSeconds(100), + Credentials = new MqttClientCredentials + { + Username = mqttUser, + Password = Encoding.UTF8.GetBytes(mqttPassword) + } + }; + //mqttClient.ConnectedHandler = new MqttClientConnectedHandlerDelegate(OnSubscriberConnected); + //mqttClient.DisconnectedHandler = new MqttClientDisconnectedHandlerDelegate(OnSubscriberDisconnected); + //mqttClient.ApplicationMessageReceivedHandler = new MqttApplicationMessageReceivedHandlerDelegate(OnSubscriberMessageReceived); + await mqttClient.StartAsync(new ManagedMqttClientOptions { ClientOptions = options }); + //topic = array[2]; + await mqttClient.SubscribeAsync(new MqttTopicFilter { Topic = topic }); + + } + + + /// + /// + /// + /// + /// + /// + public async Task Publish(string publish_topic, string publish_msg) + { + if (mqttClient != null) + { + try + { + await mqttClient.PublishAsync(new MqttApplicationMessageBuilder().WithTopic(publish_topic).WithPayload(publish_msg).WithExactlyOnceQoS().Build()); + + } + catch (Exception err) + { + + } + } + } + //static public async Task Publish(IManagedMqttClient mqttClient_1, string publish_topic, string publish_msg) + //{ + // if (mqttClient_1 != null) + // { + // try + // { + // await mqttClient_1.PublishAsync(new MqttApplicationMessageBuilder().WithTopic(publish_topic).WithPayload(publish_msg).WithExactlyOnceQoS().Build()); + + // } + // catch (Exception err) + // { + + // } + // } + //} + /// + /// + /// + /// + public async Task StopAsync() + { + if (mqttClient != null) + { + await mqttClient.UnsubscribeAsync(new string[] { topic }); + await mqttClient.StopAsync(); + } + } + ///// + ///// + ///// + ///// + //private static void OnSubscriberConnected(MqttClientConnectedEventArgs x) + //{ + // var rec = x.AuthenticateResult.ResultCode.ToString(); + // // label_State.Text = rec; + //} + ///// + ///// + ///// + ///// + //private static void OnSubscriberDisconnected(MqttClientDisconnectedEventArgs x) + //{ + // //var rec = x.AuthenticateResult.ResultCode.ToString(); + // //label_State.Text = rec; + //} + ///// + ///// + ///// + ///// + //private static void OnSubscriberMessageReceived(MqttApplicationMessageReceivedEventArgs x) + //{ + // var rec = x.ApplicationMessage.ConvertPayloadToString(); + // // txt_Rec.Text = txt_Rec.Text + rec + System.Environment.NewLine; + + //} + + + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/SendMessage.cs b/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/SendMessage.cs new file mode 100644 index 0000000..d5d8ee6 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/SendMessage.cs @@ -0,0 +1,666 @@ +using MisDataFunDll; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Net.Sockets; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + + /// + /// 命令 + ///显示托盘信息√ case "ShowMoby": + ///显示操作指南√ case "ProcessList": + ///显示物料√ case "MaterialList": + ///显示操作图片√ case "PicShow": + ///显示拧紧位置√ case "ShaftPosition": + ///实时显示质量数据√ case "ShowTimelyQuality": + ///手动拧紧实时显示质量数据√case "ShowTimelyQuality_Tight": + ///√ case "OrderFormList": + ///弹窗消息√ case "Notice": + ///LED消息提醒√ case "ScrollNotice": + ///物料检测初始化√ case "MaterialCheckPosition": + ///返修质量数据显示√ case "RepairQuality" + /// + /// + public class SendMessage + { + /// + /// MES/InstantMessaging/BQ + /// + public static string MqttTargetTopic = ConfigurationManager.AppSettings["MqttTargetTopic"]; + + /// + /// 5 显示订单、机型信息 上线工位 + /// + /// + public static void ShowMoby_FirstOpName(string opName) + { + var topic = $"{MqttTargetTopic}/{opName}"; + var responseStr = ShowMoby_String_FirstOpName(opName); + string cmd = "ShowMoby"; + if (responseStr.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}")); + } + } + /// + /// 5 显示订单、机型信息 非上线工位 + /// + /// + public static void ShowMoby(string opName, int type = 1) + { + var topic = $"{MqttTargetTopic}/{opName}"; + var responseStr = ShowMoby_String(opName, type); + string cmd = "ShowMoby"; + if (responseStr.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}")); + } + } + public static void MaterialList_Dif(string opName, string msgText) + { + var topic = $"{MqttTargetTopic}/{opName}"; + string cmd = "MaterialList_Dif"; + if (msgText.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{msgText}")); + } + } + public static void AsyncSendMessage_Notice(string opname, string notice) + { + //通知Web界面 + MisDataFun.Web_Notice_Insert(opname, notice); + Notice(opname); + } + public static void Notice(string opName) + { + var topic = $"{MqttTargetTopic}/{opName}"; + var responseStr = Notice_String(opName); + string cmd = "Notice"; + if (responseStr.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}")); + } + } + /// + /// 1(直接在界面通过选择机型确认工序内容) + /// + /// + public static void ProcessList(string opName) + { + var topic = $"{MqttTargetTopic}/{opName}"; + var responseStr = ProcessList_String(opName); + string cmd = "ProcessList"; + if (responseStr.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}")); + } + } + public static void ProcessList_FirstOpName(string opName) + { + var topic = $"{MqttTargetTopic}/{opName}"; + var responseStr = ProcessList_String_FirstOpName(opName); + string cmd = "ProcessList"; + if (responseStr.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}")); + } + } + /// + /// 2显示物料 + /// + /// + public static void MaterialList(string opName) + { + var topic = $"{MqttTargetTopic}/{opName}"; + var responseStr = MaterialList_String(opName); + string cmd = "MaterialList"; + if (responseStr.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}")); + } + + } + public static void MaterialList_FirstOpName(string opName) + { + var topic = $"{MqttTargetTopic}/{opName}"; + var responseStr = MaterialList_String_FirstOpName(opName); + string cmd = "MaterialList"; + if (responseStr.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}")); + } + + } + /// + /// 3显示操作指导图片 + /// + /// + public static void PicShow(string opName) + { + var topic = $"{MqttTargetTopic}/{opName}"; + var responseStr = PicShow_String(opName); + string cmd = "PicShow"; + if (responseStr.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}")); + } + } + public static void PicShow_FirstOpName(string opName) + { + var topic = $"{MqttTargetTopic}/{opName}"; + var responseStr = PicShow_String_FirstOpName(opName); + string cmd = "PicShow"; + if (responseStr.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}")); + } + } + + /// + /// 4订单完工模块刷新完成数量 + /// + /// + public static void OrderFormList(string opName) + { + var topic = $"{MqttTargetTopic}/{opName}"; + var responseStr = OrderFormList_String(); + string cmd = "OrderFormList"; + if (responseStr.Length > 0) + { + Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}")); + } + } + + //实时显示质量数据√ + public static void ShowTimelyQuality(string opName) + { + + } + + public static void SendActuallyCount(string OpName, int tagValue) + { + //当工件离开时,更新在线产量、在线节拍 + //if (tagValue == 0) + { + try + { + int opNameCount = 0;//在线产量 + int opNameCountTime = 0;//在线节拍 + + MisDataFun.OpNameCount_BQ(OpName, out opNameCount, out opNameCountTime); //基本数据_工作日历_班次产量查询_New + + SendInfomation("ActuallyCount", opNameCount.ToString() + "&" + opNameCountTime.ToString(), OpName); + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function01:SendActuallyCount"); + } + } + } + + public static void SendInfomation(string Command, string Value, string OpName) + { + + string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + } + + public static void AsyncSendMessage(string Message) + { + //lock (locker) + { + //"MES|MachinePlan|OpName|Value + var array = Message.Split('|'); + var cmd = array[1]; + var opName = array[2]; + var topic = $"{MqttTargetTopic}/{opName}"; + Task.Run(() => Mqtt.Publish(topic, Message)); + + } + + + } + private static string ProcessList_String(string OpName) + { + string jsonStr_Process = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string EngineTypeString = ""; + DataTable dt_Proccess; + + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + MisDataFun.Process_Select(OpName, EngineTypeID, EngineType, out dt_Proccess); + if (dt_Proccess != null) + { + if (dt_Proccess.Rows.Count > 0) + { + jsonStr_Process = JsonHelper.CreateJsonParameters(dt_Proccess); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:ProcessList"); + } + return jsonStr_Process; + } + private static string ProcessList_String_FirstOpName(string OpName) + { + string jsonStr_Process = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string EngineTypeString = ""; + DataTable dt_Proccess; + + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + MisDataFun.Process_Select(OpName, EngineTypeID, EngineType, out dt_Proccess); + if (dt_Proccess != null) + { + if (dt_Proccess.Rows.Count > 0) + { + jsonStr_Process = JsonHelper.CreateJsonParameters(dt_Proccess); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:ProcessList"); + } + return jsonStr_Process; + } + // + private static string PicShow_String(string OpName) + { + string data = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string EngineTypeString = ""; + byte[] imgBytesIn; + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + MisDataFun.GetImageFile(OpName, EngineTypeID, out imgBytesIn); + if (imgBytesIn == null) + { + return data; + } + data = Convert.ToBase64String(imgBytesIn); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:PictureShow"); + } + return data; + } + + private static string PicShow_String_FirstOpName(string OpName) + { + string data = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string EngineTypeString = ""; + byte[] imgBytesIn; + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + MisDataFun.GetImageFile(OpName, EngineTypeID, out imgBytesIn); + if (imgBytesIn == null) + { + return data; + } + data = Convert.ToBase64String(imgBytesIn); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:PictureShow"); + } + return data; + } + /// + /// 上线工位 + /// + /// + /// + private static string ShowMoby_String(string OpName, int type = 1) + { + string data = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string EngineTypeString = ""; + //非上线工位 + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + data = orderNum + "&" + EngineTypeID + "&" + EngineType + "&" + EngineID + "&" + PartPallet_Code + "&" + IsrepairBarcode + "&" + repairBarcode + "&" + EngineTypeString; + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MobySelect"); + } + return data; + } + private static string ShowMoby_String_FirstOpName(string OpName) + { + string data = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string EngineTypeString = ""; + //上线工位 + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + data = orderNum + "&" + EngineTypeID + "&" + EngineType + "&" + EngineID + "&" + PartPallet_Code + "&" + IsrepairBarcode + "&" + repairBarcode + "&" + EngineTypeString; + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MobySelect"); + } + return data; + } + private static string MaterialList_String(string OpName) + { + string jsonStr_Materail = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string EngineTypeString = ""; + + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + MisDataFun.PartMaterialVerify_Select(OpName, EngineTypeID, EngineType, out DataTable dt_Material); + if (dt_Material != null) + { + if (dt_Material.Rows.Count > 0) + { + jsonStr_Materail = JsonHelper.CreateJsonParameters(dt_Material); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialList"); + } + return jsonStr_Materail; + } + private static string MaterialList_String_FirstOpName(string OpName) + { + string jsonStr_Materail = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string EngineTypeString = ""; + + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + MisDataFun.PartMaterialVerify_Select(OpName, EngineTypeID, EngineType, out DataTable dt_Material); + if (dt_Material != null) + { + if (dt_Material.Rows.Count > 0) + { + jsonStr_Materail = JsonHelper.CreateJsonParameters(dt_Material); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialList"); + } + return jsonStr_Materail; + } + + private static string ShowTimelyQuality_String(string OpName) + { + string text = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string EngineTypeString = ""; + DataTable dt; + + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + MisDataFun.QualitySelect(OpName, EngineID, out dt); + if (dt != null) + { + if (dt.Rows.Count > 0) + { + text = JsonHelper.CreateJsonParameters(dt); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Quality_Select"); + } + return text; + } + private static string ShowTimelyQuality_String_FirstOpName(string OpName) + { + string text = ""; + try + { + string orderNum = ""; + int EngineTypeID = 0; + string EngineType = ""; + string EngineID = ""; + string PartPallet_Code = ""; + int IsrepairBarcode = 0; + string repairBarcode = ""; + string EngineTypeString = ""; + DataTable dt; + MisDataFun.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode, out EngineTypeString); + MisDataFun.QualitySelect(OpName, EngineID, out dt); + if (dt != null) + { + if (dt.Rows.Count > 0) + { + text = JsonHelper.CreateJsonParameters(dt); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Quality_Select"); + } + return text; + } + + private static string OrderFormList_String() + { + string enginetypelist = ""; + try + { + System.Data.DataTable dt = null; + MisDataFun.EngineType_Select(out dt); + if (dt != null) + { + if (dt.Rows.Count > 0) + { + enginetypelist = JsonHelper.DataTableToJson(dt); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Orderenginetypeselect"); + } + return enginetypelist; + } + + /// + /// 消息提醒 + /// + /// + private static string Notice_String(string opname) + { + string text = ""; + try + { + System.Data.DataTable dt = null; + MisDataFun.ShowWindowNotice(opname, out dt); + if (dt != null) + { + if (dt.Rows.Count > 0) + { + text = JsonHelper.DataTableToJson(dt); + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:ShowWindowNotice"); + } + return text; + } + + /// + /// 批量发送WEB消息(Value为BOOL值) + /// + /// 消息编号组合 + /// 消息值组合 + /// 工位号 + void Sendmessage(string MessageNumm, string Value, string OpName) + { + for (int i = 0; i < MessageNumm.Length; i++) + { + Sendmessage(MessageNumm[i], Value[i].ToString(), OpName); + + } + } + + /// + /// 选择发送给WEB的消息 + /// + /// 消息类型 + /// 消息工位 + static void Sendmessage(char Num, string Value, string OpName) + { + string SendMessage; + switch (Num) + { + case '1': + //1(直接在界面通过选择机型确认工序内容) + SendMessage = "MES|ProcessList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + + case '2': + //2显示物料 + SendMessage = "MES|MaterialList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + + case '3': + + //3显示操作指导图片 + SendMessage = "MES|PicShow|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '4': + //3显示操作指导图片 + SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + + case '5': + SendMessage = "MES|ShowMoby|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '6': + SendMessage = "MES|MaterialCheckPosition|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '7': + SendMessage = "MES|WorkStart|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '8': + SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '9': + SendMessage = "MES|ConfirmOkGo|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case 'a': + SendMessage = "MES|FixAllow|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case 'b': + SendMessage = "MES|ShaftPosition|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case 'c': + SendMessage = "MES|ShowQuality|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + } + } + ///// + ///// 发送信息到MES通讯服务器或者其他的 + ///// + ///// + //static private void AsyncSendMessage1(string Message) + //{ + // MIS_BASE.asyncSendMessage(Message); + //} + + + } +} \ No newline at end of file diff --git a/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/SendMessageFun.cs b/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/SendMessageFun.cs new file mode 100644 index 0000000..af96e4a --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/12SendMessageToWeb/SendMessageFun.cs @@ -0,0 +1,249 @@ +using MisDataFunDll; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + /// + /// 命令 + ///显示托盘信息√ case "ShowMoby": + ///显示操作指南√ case "ProcessList": + ///显示物料√ case "MaterialList": + ///显示操作图片√ case "PicShow": + ///显示拧紧位置√ case "ShaftPosition": + ///实时显示质量数据√ case "ShowTimelyQuality": + ///手动拧紧实时显示质量数据√case "ShowTimelyQuality_Tight": + ///√ case "OrderFormList": + ///弹窗消息√ case "Notice": + ///LED消息提醒√ case "ScrollNotice": + ///物料检测初始化√ case "MaterialCheckPosition": + ///返修质量数据显示√ case "RepairQuality" + /// + /// + public class SendMessageFun + { + /// + /// 批量发送WEB消息(Value为BOOL值) + /// 1:显示工序内容 + /// 2:显示物料 + /// 3:显示操作指导图片 + /// 5:显示机型、工件流水号、订单信息 + /// c:显示质量数据 + /// + /// 消息编号组合 + /// 消息值组合 + /// 工位号 + static public void SendMessage(string MessageNumm, string Value, string OpName) + { + for (int i = 0; i < MessageNumm.Length; i++) + { + SendMessageFun.SendMessage(MessageNumm[i], Value[i].ToString(), OpName); + + } + } + /// + /// 向WEB发送信息(value为字符串) + /// + /// 消息种类 + /// 消息内容 + /// 工位号 + static public void SendInfomation(string Command, string Value, string OpName) + { + + string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + } + + static public void AsyncSendMessage_Notice(string opname, string notice, string noticeType = "misServer") + { + //通知Web界面 + notice = $"{{\"Notice\":\"{notice}\",\"NoticeType\":\"{noticeType}\"}}"; + + MisDataFun.Web_Notice_Insert(opname, notice); + string SendMessage = "MES|Notice_Info|" + opname + "|" + notice; + MIS_SendMessage.asyncSendMessage(SendMessage); + } + /// + /// + /// + /// + /// + /// barcode mis + static public void AsyncSendMessage_Notice_Error(string opname, string notice, string noticeType) + { + //通知Web界面 + // notice: notice, noticeType: noticeType + + notice = $"{{\"Notice\":\"{notice}\",\"NoticeType\":\"{noticeType}\"}}"; + + MisDataFun.Web_Notice_Insert(opname, notice); + string SendMessage = "MES|Notice_Error|" + opname + "|" + notice; + MIS_SendMessage.asyncSendMessage(SendMessage); + } + /// + /// 选择发送给WEB的消息 + /// 1:显示工序内容 + /// 2:显示物料 + /// 3:显示操作指导图片 + /// 5:显示机型、工件流水号、订单信息 + /// c:显示质量数据 + /// + /// 消息类型 + /// 消息工位 + static void SendMessage(char Num, string Value, string OpName) + { + string SendMessage; + switch (Num) + { + case '1': + //1(直接在界面通过选择机型确认工序内容) + SendMessage = "MES|ProcessList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + + case '2': + //2显示物料 + SendMessage = "MES|MaterialList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + + case '3': + + //3显示操作指导图片 + SendMessage = "MES|PicShow|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '4': + //3显示操作指导图片 + SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + + case '5': + SendMessage = "MES|ShowMoby|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '6': + SendMessage = "MES|MaterialCheckPosition|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '7': + SendMessage = "MES|WorkStart|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '8': + SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '9': + SendMessage = "MES|ConfirmOkGo|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case 'a': + SendMessage = "MES|FixAllow|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case 'b': + SendMessage = "MES|ShaftPosition|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case 'c': + //SendMessage = "MES|ShowQuality|" + OpName + "|" + Value; + SendMessage = "MES|ShowTimelyQuality|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + } + } + + /// + /// 向WEB发送信息(value为字符串) + /// + /// 消息种类 + /// 消息内容 + /// 工位号 + //void SendInfomation(string Command, string Value, string OpName) + //{ + + // string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + //} + + + /// + /// 发送在线产量、在线节拍 + /// + /// + /// + private void SendActuallyCount(string OpName, int tagValue) + { + //当工件离开时,更新在线产量、在线节拍 + if (tagValue == 0) + { + try + { + int opNameCount = 0;//在线产量 + int opNameCountTime = 0;//在线节拍 + + MisDataFun.OpNameCount_New(OpName, out opNameCount, out opNameCountTime); //基本数据_工作日历_班次产量查询_New + + SendInfomation("ActuallyCount", opNameCount.ToString() + "&" + opNameCountTime.ToString(), OpName); + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function01:SendActuallyCount"); + } + } + } + + /// + /// 发送信息到MES通讯服务器或者其他的 + /// + /// + static public void AsyncSendMessage(string Message) + { + MIS_SendMessage.asyncSendMessage(Message); + } + + ///// + ///// 发送提示消息 + ///// + ///// + //static public void AsyncSendMessage_Notice(string opname, string notice) + //{ + // //通知Web界面 + // BaseDataSystemMES.Web_Notice_Insert(opname, notice); + // string SendMessage = "MES|Notice|" + opname + "|" + "1"; + // MIS_BASE.asyncSendMessage(SendMessage); + //} + + /// + /// 发送信息到打印机 + /// + /// + private void asyncSendMessageToMark(string Message) + { + string messageSend = (string)Message; + //UDPClientSend.Send_ALL(ApplicationConfig.MES_MarkPortNum, messageSend); + } + + /// + /// 发送信息到LED + /// + /// + private void asyncSendMessageLED(string OpName) + { + + //发送到大屏幕显示 41104 + string strMessage = "MIS|" + OpName + "|" + "0" + "|" + "1"; + //UDPClientSend.Send_ALL(ApplicationConfig.Port_ShowLED_ProductCount, strMessage); + + } + + + } +} + diff --git a/Common/09MesDataFunction/MesDataFunction/13MIS_FuntionSaveData/Funtion.Alarm.cs b/Common/09MesDataFunction/MesDataFunction/13MIS_FuntionSaveData/Funtion.Alarm.cs new file mode 100644 index 0000000..bd04a2f --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/13MIS_FuntionSaveData/Funtion.Alarm.cs @@ -0,0 +1,247 @@ +using DataLinkMesWork1; +using MesServerFunctions; +using MesServerWork; +using MisDataFunDll; +using Newtonsoft.Json; +using System; +using System.Collections; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; + +namespace MisDataSaveDate +{ + public partial class FuntionMesRead + { + + #region 2023.05.14,新增报警 + + public static Hashtable Base_TagIdList = new Hashtable(); + public static Hashtable Base_ObjList = new Hashtable(); + + + public static void GetAlarmInit() + { + Base_TagIdList.Clear(); + GetTagIdList("", out DataTable dt); + + for (int i = 0; i < dt.Rows.Count; i++) + { + string tagid = dt.Rows[i]["TagID"].ToString(); + + if (tagid[0].ToString() == "9") + { + var opName = dt.Rows[i]["工位号"].ToString(); + var ItemName = dt.Rows[i]["测量项目"].ToString(); // 报警内容 + var ShaftID = dt.Rows[i]["测量位置"].ToString(); // 报警类型 + + string SendMessage = "MES|PlcAlarm|" + opName + "|" + tagid + "&@TagValue&" + ItemName + "&" + ShaftID; + Base_TagIdList.Add(tagid, SendMessage); + + //在存一份报警对象到键值对中 + Base_ObjList.Add(tagid, dt.Rows[i]); + } + } + } + + //public static void Send_AlarmMsg(string tagid, string tagVvalue) + //{ + // var val = Base_TagIdList[tagid]; + // if (val != null) + // { + // //var msg = Base_TagIdList[tagid].ToString(); + // //var sendmsg = msg.Replace("@TagValue", tagVvalue); + // //SendMessageFun.AsyncSendMessage(sendmsg); + // string alarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + // var msg = Base_TagIdList[tagid].ToString(); + // var sendmsg = msg.Replace("@TagValue", tagVvalue) + "&" + alarmTime; + // SendMessageFun.AsyncSendMessage(sendmsg); + // // 去存一份记录到数据库 + // DataRow errObj = (DataRow)Base_ObjList[tagid]; + // MisDataFun.Alarm_Insert2(Convert.ToInt32(errObj["TagID"]), errObj["工位号"].ToString(), errObj["测量项目"].ToString(), Convert.ToInt32(tagVvalue), errObj["测量位置"].ToString()); + // } + //} + public static DataRow Send_AlarmMsg(string tagid, string tagVvalue) + { + var val = Base_TagIdList[tagid]; + DataRow errObj = null; + if (val != null) + { + //var msg = Base_TagIdList[tagid].ToString(); + //var sendmsg = msg.Replace("@TagValue", tagVvalue); + //SendMessageFun.AsyncSendMessage(sendmsg); + + var msg = Base_TagIdList[tagid].ToString(); + var sendmsg = msg.Replace("@TagValue", tagVvalue); + SendMessageFun.AsyncSendMessage(sendmsg); + // 去存一份记录到数据库 + errObj = (DataRow)Base_ObjList[tagid]; + + MisDataFun.Alarm_Insert2(Convert.ToInt32(errObj["TagID"]), errObj["工位号"].ToString(), errObj["测量项目"].ToString(), Convert.ToInt32(tagVvalue), errObj["测量位置"].ToString()); + } + return errObj; + } + + + + static public void GetTagIdList(string opName, out DataTable dt) + { + string procedureName; + procedureName = "MES_基本变量_原始数据_根据工位号查询"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt); + } + + + + + + #endregion + + public static void Alarm_Insert_Init(string Opname) + { + DataTable dt; + MisDataFun.Alarm_Moby_Search(out dt); + if (dt == null) return; + for (int i = 0; i < dt.Rows.Count; i++) + { + string TagId = dt.Rows[i]["TagId"].ToString(); + object tagValueStr = ""; + string tagValue = "0"; + MIS_BASE.Read_TagValueByTagID(TagId, out tagValueStr); + if (tagValueStr != null) + { + switch (tagValueStr.ToString().ToLower()) + { + case "1": + case "true": + tagValue = "1"; + break; + default: + tagValue = "0"; + break; + } + Send_AlarmMsg(TagId, tagValue); + } + } + } + + public static void Alarm_InitAlarm_Send(string opName, out Hashtable ht) + { + var tagValues = MIS_BASE.ReadPLC_OpName(opName); + //过滤出来质量数据 //获得带合格标志的质量数据 + var keyValues = tagValues.OrderBy(x => x.Key).ToDictionary(k => k.Key, v => v.Value); + ht = new Hashtable(); + + foreach (KeyValuePair _cd in keyValues) + { + var tf = _cd.Value; + string TagID = tf.TagID.ToString(); + if (TagID[0].ToString() == "9") + { + string tagValue = tf.TagValue.ToString(); + if (tf.TagValue == null) return; + switch (tagValue.ToLower()) + { + case "1": + case "true": + tagValue = "1"; + break; + default: + tagValue = "0"; + break; + } + if (tagValue == "1") + { + ht.Add(tf.TagID, tagValue); + } + } + } + } + public static bool Alarm_Insert(string TagID, string tagTypeID, string opName, int TagValue, + DateTime alarmStartTime, DateTime alarmEndTime, int TimeDiff, + string Text1, string Text2, string TagOrderBy) + { + + + string produceName = "测量数据工位报警全部_增加数据"; + SqlParameter[] thisParms = new SqlParameter[10]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@TagID", TagID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@TagTypeID", tagTypeID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@opName", opName); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@TagValue", TagValue); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@alarmStartTime", alarmStartTime); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@alarmEndTime", alarmEndTime); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@TimeDiff", TimeDiff); + thisParms[7] = new System.Data.SqlClient.SqlParameter("@Text1", Text1); + thisParms[8] = new System.Data.SqlClient.SqlParameter("@Text2", Text2); + thisParms[9] = new System.Data.SqlClient.SqlParameter("@TagOrderBy", TagOrderBy); + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms)) + { + + return true; + } + return false; + } + + /// + /// 报错详细工件记录日志 (有可能报错 所以封装) + /// + /// 1.申请上线 2.传递机型 3.允许保存 4.扫码 + /// + public static void Alarm_SaveFileLog4Error(string errorStep, object e, string FunName, Exception err) + { + try + { + MyLog4Net.MyLogHelper.Error($"{FunName}异常:", $"Message:{err.Message} InnerException: {err.InnerException}"); + string leftErrorStep; + if (errorStep == "PartLoad") + { + leftErrorStep = "申请上线"; + } + else if (errorStep == "EngineGetOver") + { + leftErrorStep = "传递机型"; + } + else if (errorStep == "MesRead") + { + leftErrorStep = "允许保存"; + } + else if (errorStep == "Barcode") + { + leftErrorStep = "扫码"; + } + else + { + leftErrorStep = $"未知类型{errorStep}"; + } + + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + MIS_BASE.GetEngineTypeFromPLC(OpName, out int EngineTypeID, out string EngineType, out string EngineID, out int PartPallet_Code, out string OrderForm); + MyLog4Net.MyLogHelper.Error($"{FunName}{leftErrorStep}操作异常:", $"工位号:{OpName}、总成号:{EngineID}、机型:{EngineType}、机型代码:{EngineTypeID}、订单号:{OrderForm}、托盘号:{PartPallet_Code}"); + + string saveString = $"{FunName}{leftErrorStep}操作异常 Message:{err.Message} InnerException: {err.InnerException}:工位号:{OpName}、总成号:{EngineID}、机型:{EngineType}、机型代码:{EngineTypeID}、订单号:{OrderForm}、托盘号:{PartPallet_Code}"; + var sql = + $"INSERT INTO 合力_系统日志 ([工位号],[日志类型],[日志文本])"+ + $" VALUES('{OpName}', 'system', '{saveString}')"; + DataAccess.ExecuteDataTable(sql, out DataTable dt); + } + catch (Exception ex) + { + MyLog4Net.MyLogHelper.Error($"{FunName}保存错误日志失败:", $"Message:{ex}"); + } + } + + public static void Alarm_SystemError(string FunName, Exception err) + { + MyLog4Net.MyLogHelper.Error($"系统{FunName}方法异常:", $"Message:{err.Message} InnerException:{err.InnerException}"); + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/13MIS_FuntionSaveData/Funtion.MesRead.cs b/Common/09MesDataFunction/MesDataFunction/13MIS_FuntionSaveData/Funtion.MesRead.cs new file mode 100644 index 0000000..3866226 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/13MIS_FuntionSaveData/Funtion.MesRead.cs @@ -0,0 +1,635 @@ +using BasicData; +using MesServerFunctions; +using MesServerWork; +using MisDataFunDll; +using Newtonsoft.Json; +using OpcBasic; +using System; +using System.Collections; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using DataLinkMesWork1; + +using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskBand; + +namespace MisDataSaveDateMesRead +{ + public partial class Funtion + { + + + /// + /// 允许保存(针对半自动和手动压装工位) + /// + /// + /// + public static int MesRead(string opName, string tagValue, string tagid, bool isCheck = false) + { + int qualityMask = 0; + + qualityMask = SaveQualityData(opName, Convert.ToInt32(tagValue), tagid, isCheck); + + + //if (tagValue == "0") + //{ + // MIS_BASE.Write_TagTypeID(20, opName, false); + //} + //else + //{ + // qualityMask = SaveQualityData(opName, Convert.ToInt32(tagValue), tagid, isCheck); + // MIS_BASE.Write_TagTypeID(20, opName, true); + //} + return qualityMask; + } + public static string GetRealTimeQualityData(string opName) + { + string message = ""; + DataTable dt1 = new DataTable(); + DataTable dt_WWW; + DataTable dt_WWW_Copy1; + DataTable dt_WWW_Copy2; + Hashtable valueList; + try + { + //读取工位全部数据 + var rtList = MIS_BASE.ReadPLC_OpName(opName); //GetDbAndMaxLengthByOpNameByBytes(opName); + var pp = JsonConvert.SerializeObject(rtList); + var tagValues = JsonConvert.DeserializeObject>(pp); + //过滤出来质量数据 //获得带合格标志的质量数据 + valueList = ReadPLC_OpName_Qd(tagValues); + + //获得带基本信息的质量数据表 + GetQualityDataTable(valueList, opName, MIS_BASE.BasicDataTagValue, MIS_BASE.BasicDataTagValueUpDown, out dt_WWW); + + dt_WWW_Copy1 = dt_WWW.Copy().Select("变量排序 = 1").CopyToDataTable(); + DataView dv1 = dt_WWW_Copy1.DefaultView; + dv1.Sort = "列位置 DESC"; + dt_WWW_Copy1 = dv1.ToTable(); + + dt_WWW_Copy2 = dt_WWW.Copy().Select("变量排序 = 2").CopyToDataTable(); + DataView dv2 = dt_WWW_Copy2.DefaultView; + dv2.Sort = "列位置 DESC"; + dt_WWW_Copy2 = dv2.ToTable(); + + dt1.Columns.Add("列位置", System.Type.GetType("System.String")); + dt1.Columns.Add("测量项目1", System.Type.GetType("System.String")); + dt1.Columns.Add("测量项目2", System.Type.GetType("System.String")); + dt1.Columns.Add("合格标志", System.Type.GetType("System.String")); + dt1.Columns.Add("名称", System.Type.GetType("System.String")); + + for (int i = 0; i < dt_WWW_Copy1.Rows.Count; i++) + { + if (Convert.ToInt32(dt_WWW_Copy1.Rows[i]["TagValue"]) > 45) + { + var dr = dt1.NewRow(); + dr["列位置"] = dt_WWW_Copy1.Rows[i]["列位置"].ToString(); + dr["测量项目1"] = dt_WWW_Copy1.Rows[i]["TagValue"].ToString(); + dr["合格标志"] = "1"; + dr["名称"] = dt_WWW_Copy1.Rows[i]["测量项目"].ToString(); + dt1.Rows.Add(dr); + } + } + for (int i = 0; i < dt_WWW_Copy2.Rows.Count; i++) + { + if (Convert.ToInt32(dt_WWW_Copy2.Rows[i]["TagValue"]) > 45) + { + var dr = dt1.NewRow(); + dr["列位置"] = dt_WWW_Copy2.Rows[i]["列位置"].ToString(); + dr["测量项目1"] = dt_WWW_Copy2.Rows[i]["TagValue"].ToString(); + dr["合格标志"] = "1"; + dr["名称"] = dt_WWW_Copy2.Rows[i]["测量项目"].ToString(); + dt1.Rows.Add(dr); + } + } + } + catch (Exception err) + { + } + message = JsonHelper.CreateJsonParameters(dt1); + + return message; + } + /// + /// 返回合格标志 + /// + /// + /// + /// + /// + private static int SaveQualityData(string opName, int tagValue, string tagID, bool isCheck = false) + + { + int id_tagCF; + int qualityMask = 0; + int engineTypeID = 0; + string engineID = ""; + string engineType = ""; + string partPallet = ""; + string orderFormPlc = ""; + DataTable dt_WWW; + Hashtable valueList; + try + { + + //读取工位全部数据 + var rtList = MIS_BASE.ReadPLC_OpName(opName); //GetDbAndMaxLengthByOpNameByBytes(opName); + var pp = JsonConvert.SerializeObject(rtList); + var tagValues = JsonConvert.DeserializeObject>(pp); + //过滤出来质量数据 //获得带合格标志的质量数据 + valueList = ReadPLC_OpName_Qd(tagValues); + + + engineTypeID = Convert.ToInt32(GetValueByTagTypeCodeID(tagValues, Convert.ToInt32(EnumTagTypeCodeID.EngineTypeID))); + engineID = GetValueByTagTypeCodeID(tagValues, Convert.ToInt32(EnumTagTypeCodeID.EngineID)).ToString(); + engineType = GetValueByTagTypeCodeID(tagValues, Convert.ToInt32(EnumTagTypeCodeID.EngineType)).ToString(); + orderFormPlc = GetValueByTagTypeCodeID(tagValues, Convert.ToInt32(EnumTagTypeCodeID.OrderFormPLC)).ToString(); + qualityMask = Convert.ToInt32(GetValueByTagTypeCodeID(tagValues, Convert.ToInt32(EnumTagTypeCodeID.QualityMask))); + + + + //获得带基本信息的质量数据表 + GetQualityDataTable(valueList, opName, MIS_BASE.BasicDataTagValue, + MIS_BASE.BasicDataTagValueUpDown, out dt_WWW); + + DateTime lastupdatetime = DateTime.Now; + //保存质量数 + BaseData_tagTable_QualityData_B5A_IndexInsert(engineID, tagID, engineType, engineTypeID, opName, qualityMask, partPallet, out id_tagCF); + BaseData_tagTable_QualityData_B5A_Insert(id_tagCF, engineTypeID, engineID, opName, dt_WWW, isCheck); + //保存质量数据到 接口表 + MisDataFun.SaveQualityInterfaceData(opName, engineID); + } + catch (Exception err) + { + //MIS_BASE.Write_TagTypeID(20, opName, true); + ////ApplicationLog.WriteLog(err, err.Message); + } + return qualityMask; + } + + public class QualityDataType1 + { + public int tagValueType; + public int tagTypeID; + public string opName; + public string tagID; + public object TagValeNormal; + public object TagValueDown; + public object TagValueUp; + public object Unit; + public object tagValue; + public int tagQuality; + public int tagOrderBy; + public int tagItemOrderBy; + public int tagProperty; + public int isGoodBad; + } + static public void GetQualityDataTable(Hashtable valuList, string opName, DataTable BasicDataTagValue, DataTable BasicDataTagValueUpDown, out DataTable dt) + { + //78 0:屏蔽MES;1:启用MES(必须MIS) + //79 通过线体工位PC实现下达工位工作状态:工位有三种状态:在线、离线、屏蔽。在线;0正常状态,实现正常功能。1离线:2屏蔽。(必须MIS) + //41 机体流向标志(1 BYTE):0普通工位:1:上线(发动机上线);2:下线(发动机下线);(必须PLC) + //51 返修工位,修改后的数据MES将数据写入PLC ,MES通知PLC数据修改完成。(YN) + //8 只要返修,必须由mes发送此信号,plc接收此信号后才能放行 + //(暂时没用)用于有扳手拧紧工位。通知设备螺钉拧紧完成。PC已经将数据保存到数据库中。(B5A) + + QualityDataType1 qualityData; + //是否有数据 + //bool isUsing; + + DataRow dr; + DataRow[] dr_WWW; + //MES_基本数据_测量范围 + DataRow[] dr_WWW_UpDown; + + dt = MisDataFun.BuildDataTables_WWW(); + + //测量位置 + string shaftID; + //测量项目 + string item; + //测量单位 + string unit; + //机体类型 + //原始数据中的机型代码 + int engineTypeID_Source; + //上限值 + string tagValueUp; + //下限值 + string tagValueDown; + //理论值 + string tagValeNormal; + //TagValue + // 合格标志 + //string IsGoodBad; + + foreach (DictionaryEntry valueItem in valuList) //ht为一个Hashtable实例 + { + try + { + qualityData = (QualityDataType1)valueItem.Value; + + + //if ((qualityData.tagProperty != 2) || (qualityData.tagProperty != 6)) + //{ + // continue ; + //} + //if ((qualityData.tagProperty == 2) || (qualityData.tagProperty == 6)) + { + //if (engineTypeID == 0) + //{ + // engineTypeID = 1; + //} + dr_WWW = BasicDataTagValue.Select("TagID = " + qualityData.tagID); + //try + //{ + // dr_WWW_UpDown = BasicDataTagValueUpDown.Select("TagID = " + qualityData.tagID); + //} + //catch { dr_WWW_UpDown = null; } + + + //if (dr_WWW.Length > 0) + //{ + // { + // engineTypeID_Source = Convert.ToInt32(dr_WWW[0]["机体类型"]); + // int temp; + // temp = engineTypeID_Source & engineTypeID; + // if (temp == 0) + // { + // continue; + // } + // if (qualityData.isGoodBad == -1) + // { + // continue; + // } + // } + //} + //else + //{ + // continue; + + //} + + try + { + shaftID = dr_WWW[0]["测量位置"].ToString(); + } + catch + { + shaftID = ""; + } + try + { + item = dr_WWW[0]["测量项目"].ToString(); + } + catch + { + item = ""; + } + try + { + unit = dr_WWW[0]["测量单位"].ToString(); + } + catch + { + unit = ""; + } + try + { + tagValueUp = qualityData.TagValueUp.ToString(); + //if (dr_WWW_UpDown != null && dr_WWW_UpDown.Length > 0) + //{ + // tagValueUp = dr_WWW_UpDown[0]["值上限"].ToString(); + //} + //else + //{ + // tagValueUp = ""; + //} + } + catch + { + tagValueUp = ""; + } + try + { + tagValueDown = ""; + tagValueDown = qualityData.TagValueDown.ToString(); + //if (dr_WWW_UpDown != null && dr_WWW_UpDown.Length > 0) + //{ + // tagValueDown = dr_WWW_UpDown[0]["值下限"].ToString(); + //} + } + catch + { + tagValueDown = ""; + } + try + { + tagValeNormal = ""; + tagValeNormal = qualityData.TagValeNormal.ToString(); + //if (dr_WWW_UpDown != null && dr_WWW_UpDown.Length > 0) + //{ + // tagValeNormal = dr_WWW_UpDown[0]["理论值"].ToString(); + //} + + } + catch + { + tagValeNormal = ""; + } + + dr = dt.NewRow(); + + dr["TagID"] = qualityData.tagID; + dr["测量位置"] = shaftID; + dr["测量项目"] = item; + dr["测量单位"] = unit; + dr["上限值"] = tagValueUp; + dr["下限值"] = tagValueDown; + dr["理论值"] = tagValeNormal; + dr["工位号"] = opName; + dr["列位置"] = qualityData.tagOrderBy; + dr["变量排序"] = qualityData.tagItemOrderBy; + + dr["IsGoodBad"] = qualityData.isGoodBad; + + switch (qualityData.tagTypeID)// + { + //合格标志数组 + case 8203: + dr["TagValue"] = MisDataFun.GetQualityData_GoodBad_String((bool[])qualityData.tagValue); + break; + case 8209: + dr["TagValue"] = ""; + break; + //非标准REAL + case 8210: + dr["TagValue"] = MisDataFun.GetNoNormalReal(qualityData.tagValue); + dt.Rows.Add(dr); + break; + default: + dr["TagValue"] = Convert.ToString(qualityData.tagValue); + dt.Rows.Add(dr); + break; + } + + ////福田对质量数据特殊处理,MA20保留4位小数点,其余保留两位 + //if (opName == "J07MA020") + //{ + // dr["TagValue"] = Convert.ToDouble(dr["TagValue"]).ToString("0.####"); + //} + //else + //{ + // dr["TagValue"] = Convert.ToDouble(dr["TagValue"]).ToString("0.##"); + //} + + //if (opName == "J07MA150") + //{ + // dr["变量排序"] = 1; + // dr["IsGoodBad"] = 1; + //} + + + } + + + + } + catch (Exception err) + { + //ApplicationLog.WriteLog(err, err.Message); + } + } + } + /// + /// 数据表 + /// + /// + private static object GetValueByTagTypeCodeID(ConcurrentDictionary opTagList, int TagTypeCodeID) + { + try + { + return opTagList.Where(x => x.Value.TagTypeCodeID == TagTypeCodeID).ToList()[0].Value.TagValue; + + } + catch (Exception err) { return "-3"; } + } + /// + /// 根据工位名称,读取工位对应的质量数据,带合格标志 + /// + /// + /// + public static Hashtable ReadPLC_OpName_Qd(ConcurrentDictionary tagValues) + { + //lock (l) + { + + //var tagValues = DtWebApi.ReadWritePLC.ReadPLC_OpName(opName); //GetDbAndMaxLengthByOpNameByBytes(opName); + + var keyValues = tagValues.Where(x => x.Value.TagTypeCodeID == 105).OrderBy(x => x.Key).ToDictionary(k => k.Key, v => v.Value); + + TagFormat tagFormatTemp; + int tagIndex = 1; + int isOK = 0; + string TagValeNormal = ""; + string TagValueDown = ""; + string TagValueUp = ""; + + Hashtable ht = new Hashtable(); + + for (int i = 0; i < keyValues.Count / 8; i++) + { + isOK = Convert.ToInt32(keyValues.ElementAt(i * 8 + 0).Value.TagValue); + TagValeNormal = keyValues.ElementAt(i * 8 + 3).Value.TagValue.ToString(); + TagValueUp = keyValues.ElementAt(i * 8 + 4).Value.TagValue.ToString(); + TagValueDown = keyValues.ElementAt(i * 8 + 5).Value.TagValue.ToString(); + + var TF1 = keyValues.ElementAt(i * 8 + 1).Value; + QualityDataType1 qualityDataType1; + qualityDataType1 = GetQualityDataType(TF1); + qualityDataType1.isGoodBad = isOK; + qualityDataType1.TagValeNormal = TagValeNormal; + qualityDataType1.TagValueDown = TagValueDown; + qualityDataType1.TagValueUp = TagValueUp; + ht.Add(qualityDataType1.tagID, qualityDataType1); + var TF2 = keyValues.ElementAt(i * 8 + 2).Value; + QualityDataType1 qualityDataType2; + qualityDataType2 = GetQualityDataType(TF2); + qualityDataType2.isGoodBad = isOK; + qualityDataType2.TagValeNormal = TagValeNormal; + qualityDataType2.TagValueDown = TagValueDown; + qualityDataType2.TagValueUp = TagValueUp; + ht.Add(qualityDataType2.tagID, qualityDataType2); + } + + + + //foreach (KeyValuePair _cd in keyValues) + //{ + // if (_cd.Key.ToString()[0].ToString() == "7") + // { + // tagFormatTemp = _cd.Value; + // if (tagIndex % 8 == 1) + // { + // isOK = Convert.ToInt32(tagFormatTemp.TagValue); + // } + // else if (tagIndex % 8 == 2) + // { + // var TF = _cd.Value; + + // QualityDataType qualityDataType; + // qualityDataType = GetQualityDataType(TF); + // qualityDataType.isGoodBad = isOK; + // ht.Add(qualityDataType.tagID, qualityDataType); + // } + // else if (tagIndex % 8 == 3) + // { + // var TF = (TagFormat)_cd.Value; + + // QualityDataType qualityDataType; + // qualityDataType = GetQualityDataType(TF); + // qualityDataType.isGoodBad = isOK; + // ht.Add(qualityDataType.tagID, qualityDataType); + // } + + // tagIndex++; + // } + // //Console.WriteLine($"key:{kv.Key} value:{kv.Value}"); + //} + return ht; + } + } + + //public static Hashtable ReadPLC_OpName_Entite(string opName) + //{ + // //lock (l) + // { + + // var tagValues = DtWebApi.ReadWritePLC.ReadPLC_OpName(opName); //GetDbAndMaxLengthByOpNameByBytes(opName); + + // var keyValues = tagValues.OrderBy(x => x.Key).ToDictionary(k => k.Key, v => v.Value); + + // TagFormat tagFormatTemp; + // int tagIndex = 1; + // int isOK = 0; + + // Hashtable ht = new Hashtable(); + + + // foreach (KeyValuePair _cd in keyValues) + // { + // if (_cd.Key.ToString()[0].ToString() == "7") + // { + // tagFormatTemp = _cd.Value; + // if (tagIndex % 3 == 1) + // { + // isOK = Convert.ToInt32(tagFormatTemp.TagValue); + // } + // else if (tagIndex % 3 == 2) + // { + // var TF = _cd.Value; + + // QualityDataType qualityDataType; + // qualityDataType = GetQualityDataType(TF); + // qualityDataType.isGoodBad = isOK; + // ht.Add(qualityDataType.tagID, qualityDataType); + // } + // else if (tagIndex % 3 == 0) + // { + // var TF = (TagFormat)_cd.Value; + + // QualityDataType qualityDataType; + // qualityDataType = GetQualityDataType(TF); + // qualityDataType.isGoodBad = isOK; + // ht.Add(qualityDataType.tagID, qualityDataType); + // } + + // tagIndex++; + // } + // //Console.WriteLine($"key:{kv.Key} value:{kv.Value}"); + // } + // return ht; + // } + //} + public static QualityDataType1 GetQualityDataType(TagFormat TF) + { + QualityDataType1 qualityDataType; + + qualityDataType = new QualityDataType1(); + + qualityDataType.tagID = TF.TagID; + qualityDataType.tagTypeID = TF.TagTypeID;//变量类型 + qualityDataType.opName = TF.OpName; + qualityDataType.tagValueType = TF.TagTypeCodeID; + int.TryParse(TF.TagOrderBy, out int TagOrderBy); + qualityDataType.tagOrderBy = TagOrderBy; + int.TryParse(TF.TagItemOrderBy, out int TagItemOrderBy); + qualityDataType.tagItemOrderBy = TagItemOrderBy; + qualityDataType.tagValue = TF.TagValue;//变量值 + + return qualityDataType; + } + + public static bool BaseData_tagTable_QualityData_B5A_IndexInsert(string EngineID, string tagID, string EngineType, int EngineTypeID, string opName, int isGoodBad, string PartPalletCode, out int Id_tagCF) + { + string procedureName; + procedureName = "测量数据合格索引_增加"; + Id_tagCF = 0; + SqlParameter[] thisParms = new SqlParameter[8]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@EngineID", EngineID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@TagID_CF", tagID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineType", EngineType); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", EngineTypeID); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@托盘编号", PartPalletCode); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@合格标志", isGoodBad); + thisParms[7] = new System.Data.SqlClient.SqlParameter("@Id_tagCF", Id_tagCF); + thisParms[7].Direction = ParameterDirection.Output; + + if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms)) + { + Id_tagCF = Convert.ToInt32(thisParms[7].Value.ToString()); + return true; + } + return false; + } + public static bool BaseData_tagTable_QualityData_B5A_Insert(int Id_tagCF, int engineTypeID, string engineID, string opName, DataTable dt, bool IsCheck = false) + { + string procedureName; + procedureName = "测量数据合格_增加"; + SqlParameter[] thisParms = new SqlParameter[15]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@Id_tagCF", Id_tagCF); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", engineTypeID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineID", engineID); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@TagID", SqlDbType.Int, 4, "TagID"); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@TagValue", SqlDbType.NVarChar, 100, "TagValue"); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@IsGoodBad", SqlDbType.Int, 4, "IsGoodBad"); + //是否保存无合格标志数据数据 + //thisParms[6] = new System.Data.SqlClient.SqlParameter("@IsCheck", IsCheck); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@测量位置", SqlDbType.NVarChar, 50, "测量位置"); + thisParms[7] = new System.Data.SqlClient.SqlParameter("@测量项目", SqlDbType.NVarChar, 50, "测量项目"); + thisParms[8] = new System.Data.SqlClient.SqlParameter("@工位号", opName); //为了给J07MA020 保留四位精度而设置 + thisParms[9] = new System.Data.SqlClient.SqlParameter("@理论值", SqlDbType.NVarChar, 50, "理论值"); + thisParms[10] = new System.Data.SqlClient.SqlParameter("@上限值", SqlDbType.NVarChar, 50, "上限值"); + thisParms[11] = new System.Data.SqlClient.SqlParameter("@下限值", SqlDbType.NVarChar, 50, "下限值"); + thisParms[12] = new System.Data.SqlClient.SqlParameter("@测量单位", SqlDbType.NVarChar, 50, "测量单位"); + thisParms[13] = new System.Data.SqlClient.SqlParameter("@列位置", SqlDbType.Int, 4, "列位置"); + thisParms[14] = new System.Data.SqlClient.SqlParameter("@变量排序", SqlDbType.Int, 4, "变量排序"); + //table.Columns.Add("TagID", typeof(System.Int32)); + //table.Columns.Add("TagValue", typeof(System.String)); + //table.Columns.Add("IsGoodBad", typeof(System.Int32)); + //table.Columns.Add("测量位置", typeof(System.String)); + //table.Columns.Add("测量项目", typeof(System.String)); + //table.Columns.Add("工位号", typeof(System.String)); + //table.Columns.Add("理论值", typeof(System.String)); + //table.Columns.Add("上限值", typeof(System.String)); + //table.Columns.Add("下限值", typeof(System.String)); + //table.Columns.Add("测量单位", typeof(System.String)); + //table.Columns.Add("列位置", typeof(System.Int32)); + //table.Columns.Add("变量排序", typeof(System.Int32)); + return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, dt); + } + } +} \ No newline at end of file diff --git a/Common/09MesDataFunction/MesDataFunction/13MIS_FuntionSaveData/GetQualityData_GoodBad.cs b/Common/09MesDataFunction/MesDataFunction/13MIS_FuntionSaveData/GetQualityData_GoodBad.cs new file mode 100644 index 0000000..45c05f8 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/13MIS_FuntionSaveData/GetQualityData_GoodBad.cs @@ -0,0 +1,99 @@ +using System; + +using System.Data; + + + +namespace MisDataSaveDateMesRead +{ + + public partial class Funtion + { + /// + /// 数据表 + /// + /// + static public DataTable BuildDataTables_WWW() + { + DataTable table; + DataColumnCollection columns; + table = new DataTable(); + columns = table.Columns; + table.Columns.Add("TagID", typeof(System.String)); + table.Columns.Add("TagValue", typeof(System.String)); + table.Columns.Add("IsGoodBad", typeof(System.Int32)); + table.Columns.Add("测量位置", typeof(System.String)); + table.Columns.Add("测量项目", typeof(System.String)); + table.Columns.Add("工位号", typeof(System.String)); + table.Columns.Add("理论值", typeof(System.String)); + table.Columns.Add("上限值", typeof(System.String)); + table.Columns.Add("下限值", typeof(System.String)); + table.Columns.Add("测量单位", typeof(System.String)); + table.Columns.Add("列位置", typeof(System.Int32)); + table.Columns.Add("变量排序", typeof(System.Int32)); + + return table; + } + /// + /// 返回非标准real + /// + /// + /// + static public string GetNoNormalReal(object vDataValue) + { + try + { + string real_a; + string real_b; + string groupValueString; + int length; + + //int real_b_Int; + + length = ((System.Array)(vDataValue)).Length; + groupValueString = ""; + if (length != 2) + return "0.0"; + + real_a = Convert.ToUInt16((((System.Array)(vDataValue)).GetValue(0))).ToString(); + real_b = Convert.ToUInt16((((System.Array)(vDataValue)).GetValue(1))).ToString("00"); + groupValueString = real_a + "." + real_b; + return groupValueString; + } + catch + { + ////ApplicationLog.WriteLog(err, "GetNoNormalReal"); + return "0.0"; + + } + } + + /// + /// 29 工位具体零件合格标志 + /// + /// + static public string GetQualityData_GoodBad_String(bool[] QualityData_GoodBad) + { + string str; + str = ""; + if (QualityData_GoodBad != null) + { + + for (int i = 0; i < QualityData_GoodBad.Length; i++) + { + str = str + (Convert.ToInt32(QualityData_GoodBad[i])).ToString() + "|"; + } + + } + return str; + + } + /// + /// 返回非标准real + /// + /// + /// + + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/CommFun_CATL.cs b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/CommFun_CATL.cs new file mode 100644 index 0000000..84a1056 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/CommFun_CATL.cs @@ -0,0 +1,18 @@ + +using System.Threading; + +namespace MisDataFunDll +{ + public partial class CommFun_CATL + { + + // 由于现在没有接口,先模拟调用webapi,输入参数1.电芯码,返回参数1.对比结果 + public static int GetCellInfo(string cellCode) + { + int result = 1; + Thread.Sleep(200); + return result; + + } + } +} \ No newline at end of file diff --git a/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.Base.DB.cs b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.Base.DB.cs new file mode 100644 index 0000000..77f7171 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.Base.DB.cs @@ -0,0 +1,299 @@ + +using DataLinkMesWork1; +using System.Data; +using System.Data.SqlClient; + +namespace MisDataFunDll +{ + public partial class MisDataFun + { + public static DataTable BaseData_tagTable_TagName() + { + DataTable dt = null; + string sql; + sql = "SELECT distinct[TagName],[变量类型代码] FROM[MES_基本变量_原始数据] "; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + public static DataTable GetMesServerCodeFromMIS() + { + DataTable dt; + string sql; + sql = "exec MES_计划BOM_工位与名称_查询应用程序"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + public static DataTable dt_Signal() + { + DataTable dt; + string sql; + sql = "SELECT * FROM [MES_基本变量_原始数据]"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + public static DataTable dt_Device() + { + DataTable dt; + string sql; + sql = "SELECT * FROM [MES_基本变量设备类型对应表]"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + public static DataTable dt_TagTypeDataType() + { + DataTable dt; + string sql; + sql = "SELECT TOP (1000) [序号],[变量类型],[TagTypeDataType],[TagName],[变量类型代码],[TagTypeChange],[MesTagTypeChange],[WebTagTypeChange],[信号点名称][变量类型名称] FROM [MES_基本变量变量类型代码]"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + public static DataTable GetCheckOpName() + { + DataTable dt = new DataTable(); + string produceName = "MES_计划BOM_工位与名称_查询"; + SqlParameter[] thisParms = null; + + + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt); + + return dt; + } + + /// + /// 查询工步属性 + /// + /// + public static DataTable GetworkStepPropertyFromMIS() + { + DataTable dt; + string sql; + sql = "SELECT distinct 工位号,工步属性 FROM [MES_计划BOM_工位与名称] where 是否监控=1"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + /// + /// 查询返修工位号 + /// + /// + public static DataTable GetOpNameRepairFromMIS() + { + DataTable dt; + string sql; + sql = "SELECT distinct 工位号,返修工位号 FROM [MES_计划BOM_工位与名称] where 是否监控=1"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + + + /// + /// 测量工位号和工位名称 + /// + /// + public static DataTable BaseData_tagTable_QualityData_OpName_Name() + { + DataTable dt; + string sql = "SELECT distinct [工位号],[工位名称] FROM [MES_计划BOM_工位与名称] " + + " where (监控属性代码 = '" + 1 + "')" + + " ORDER BY 工位号 "; + //来源于SQL Server + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + /// + /// MES_计划BOM_工位与名称 + /// + /// + public static DataTable BaseData_tagTable_OpName() + { + //DataTable dt; + //string sql = "SELECT * FROM [MES_计划BOM_工位与名称] " + // + " where (监控属性代码 = '" + ApplicationConfig.MES_Code.ToString() + "')" + // + " ORDER BY 工位号 "; + //DataAccess.ExecuteDataTable(sql, out dt); + //return dt; + + //2022.07.27.LLX 处理了一下子 + DataTable dt; + string sql = "SELECT * FROM [MES_计划BOM_工位与名称] " + + " where (监控属性代码 = '" + 1 + "') and [是否通过监控系统保存数据] is not null" + + " ORDER BY 工位号 "; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + /// + /// MES_基本变量_DB数据结构_根据工位代码_获得普通变量 + /// + /// + public static DataTable BaseData_tagTable_OpcServerMES(int mesCode, string opName) + { + DataTable dt; + string sql; + sql = "SELECT TagID,0 as TagValue,TagName,工位号,数据来源,TagTypeID,TagLong,列位置,测量位置,变量类型代码,测量项目,TagAdr,TagAdrDemo,变量特点,变量排序 " + + " FROM MES_基本变量_原始数据 " + + " where 变量类型代码 = " + mesCode.ToString() + " and 是否启用 = 1" + + " and 工位号='" + opName + "'" + + " and (监控属性代码 = '" + 1 + "')"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + /// + /// MES_基本变量_DB数据结构_根据工位代码_获得普通变量 + /// + /// + public static DataTable BaseData_tagTable_OpcServerMES(int mesCode) + { + DataTable dt; + string sql; + sql = "SELECT TagID,0 as TagValue,TagName,工位号,数据来源,TagTypeID,TagLong,列位置,测量位置,变量类型代码,测量项目,TagAdr,TagAdrDemo,变量特点,变量排序 " + + " FROM MES_基本变量_原始数据 " + + " where 变量类型代码 = " + mesCode.ToString() + " and 是否启用 = 1" + + " and (监控属性代码 = '" + 1 + "')"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + /// + /// MES_基本变量_DB数据结构_获得激发变量 + /// + /// + public static DataTable BaseData_tagTable_All() + { + //string errorMessage; + DataTable dt = null; + string sql; + sql = "SELECT TagID,0 as TagValue,TagName,工位号,数据来源,TagTypeID,TagLong,列位置,测量位置,变量类型代码,测量项目,TagAdr,TagAdrDemo,变量特点,变量排序 FROM [MES_基本变量_原始数据] " + + " where ((变量类型代码 >= 19 and 变量类型代码 <= 27) or (变量类型代码 = 101) or (变量类型代码 = 102) or (变量类型代码 = 105) or (变量类型代码 = 1000) or (变量类型代码 = 1001) or (变量类型代码 = 1002) or (变量类型代码 = 1003) or (变量类型代码 = 1004)) and (是否启用 = 1) " + + " and (监控属性代码 = '" + 1 + "')" + + " ORDER BY TagID "; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + /// + /// MES_基本变量_DB数据结构_获得激发变量 + /// + /// + public static DataTable BaseData_tagTable_All_B5A() + { + //string errorMessage; + DataTable dt = null; + string sql; + sql = "SELECT TagID,0 as TagValue,TagName,工位号,数据来源,TagTypeID,TagLong,列位置,测量位置,变量类型代码,测量项目,TagAdr,TagAdrDemo,变量特点,变量排序 FROM [MES_基本变量_原始数据] " + + " where ((变量类型代码 = 101) or (变量类型代码 = 102) ) and (是否启用 = 1) " + + " and (监控属性代码 = '" + 1 + "')" + + " ORDER BY TagID "; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + /// + /// 20170310 新加 + /// MES_基本变量_DB数据结构_获得所有普通变量(除101.102.103.104.105) + /// + /// + public static DataTable BaseData_tagTable_OpcServerMES_ALL_CF() + { + DataTable dt; + string sql; + sql = "SELECT TagID,0 as TagValue,TagName,工位号,数据来源,TagTypeID,TagLong,列位置,测量位置,变量类型代码,测量项目,TagAdr,TagAdrDemo,变量特点,变量排序 " + + " FROM MES_基本变量_原始数据 " + + " where 变量类型代码 <> 101 and 变量类型代码 <> 102 and 变量类型代码 <> 103 and 变量类型代码 <> 104 and 变量类型代码 <> 105 and 是否启用 = 1" + + " and (监控属性代码 = '" + 1 + "')"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + /// + /// 发动机类型转换表 + /// SELECT ID,发动机机型代码 FROM MES_计划BOM_发动机型号代码 + /// + /// + public static DataTable BaseData_tagTable_QualityData_EngineTypeID() + { + DataTable dt; + string sql; + sql = "SELECT ID,发动机机型代码 FROM MES_计划BOM_发动机型号代码 "; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + + /// + /// 测量合格标志 + /// 全部测量数据的测量工位 + /// + /// + public static DataTable BaseData_tagTable_QualityData_GoodBad_MIS_OpName_B5A() + { + DataTable dt; + string sql; + sql = "SELECT distinct 工位号 " + + " FROM MES_基本变量_原始数据 " + + " where 变量特点 = 8 and 是否启用 = 1 " + + " and (监控属性代码 = '" + 1 + "')"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + /// + /// 测量合格标志 + /// 全部测量数据的测量工位的数据来源 + /// + /// + public static DataTable BaseData_tagTable_QualityData_GoodBad_MIS_OpName(string opName) + { + DataTable dt; + string sql; + sql = "SELECT TagID,工位号,数据来源 " + + " FROM MES_基本变量_原始数据 " + + " where OpcServer_OPNAME = '1' and 是否启用 = 1 " + + " and 工位号='" + opName + "'" + + " and (监控属性代码 = '" + 1 + "')"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + /// + /// 测量合格标志 + /// 全部测量数据的测量工位的数据来源的测量变量 + /// + /// + public static DataTable BaseData_tagTable_QualityData_GoodBad_MIS_OpName(string opName, string opNameFrom) + { + DataTable dt; + string sql; + sql = "SELECT TagID " + + " FROM MES_基本变量_原始数据 " + + " where OpcServer_OPNAME = '2' and 是否启用 = 1 " + + " and 工位号='" + opName + "'" + + " and 数据来源='" + opNameFrom + "'" + + " and (监控属性代码 = '" + 1 + "')"; + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + /// + /// MES_基本变量_机型代码_查询 + /// + /// + static public void EngineType_Select(out DataTable dt) + { + dt = null; + string sql = "exec MES_基本变量_机型代码_查询"; + DataAccess.ExecuteDataTable(sql, out dt); + } + + + + + + + + + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.CommonUtils.cs b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.CommonUtils.cs new file mode 100644 index 0000000..8150218 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.CommonUtils.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; + +namespace MisDataFunDll +{ + public partial class MisDataFun + { + /// + /// Source|Cmd|OpName|TagValue + /// + /// + /// + public static List GetCmdStringList(string cmd) + { + List list = new List(); + string item; + int index; + try + { + index = cmd.IndexOf('|'); + item = cmd.Substring(0, index); + list.Add(item); + + cmd = cmd.Substring(index + 1); + index = cmd.IndexOf('|'); + item = cmd.Substring(0, index); + list.Add(item); + + cmd = cmd.Substring(index + 1); + index = cmd.IndexOf('|'); + item = cmd.Substring(0, index); + list.Add(item); + + item = cmd.Substring(index + 1); + + list.Add(item); + + } + catch { } + + + return list; + } + + + } +} \ No newline at end of file diff --git a/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.DB.cs b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.DB.cs new file mode 100644 index 0000000..6711bfb --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.DB.cs @@ -0,0 +1,1785 @@ + +using DataLinkMesWork1; +using MesServerFunctions; +using Newtonsoft.Json; +using NPOI.XWPF.UserModel; +using Opc.Ua.Export; +using System; +using System.Data; +using System.Data.SqlClient; +using System.Diagnostics.Eventing.Reader; + +namespace MisDataFunDll +{ + public partial class MisDataFun + { + + public class MobyTagType + { + /// + /// 配方号 + /// + public static string PLCRcipe = "配方号"; + /// + /// 工位号 + /// + public static string OpName = "工位号"; + /// + /// 订单号 + /// + public static string OrderForm = "订单号"; + /// + /// 订单号 + /// + public static string OrderForm_MES = "订单号_MES"; + /// + /// 产品型号代码 + /// + public static string EngineTypeID = "产品型号代码"; + /// + /// 变速器序列号 + /// 变速器序列号 + public static string EngineID = "变速器序列号"; + + /// + /// 发动机型号 + /// + public static string EngineType = "发动机型号"; + /// + /// 机型基本代码 + /// + public static string EngineTypeBasicID = "机型基本代码"; + /// + /// 机型基本代码 + /// + public static string EngineTypeBasic = "基本机型"; + /// + /// 变速器总成号 + /// + public static string EngineIDPrinte = "变速器总成号"; + /// + /// 托盘号 + /// + public static string PartPallet_Code = "托盘号"; + /// + /// 产品型号代码_MES + /// + public static string EngineTypeID_MES = "产品型号代码_MES"; + /// + /// 变速器序列号_MES + /// + public static string EngineID_MES = "变速器序列号_MES"; + /// + /// 发动机型号_MES + /// + public static string EngineType_MES = "发动机型号_MES"; + /// + /// 到达时间线外工位 + /// + public static string WorkStartOutSideIn = "到达时间线外工位"; + /// + /// 离开时间线外工位 + /// + public static string WorkStartOutSideOut = "离开时间线外工位"; + /// + /// 到达时间 + /// + public static string WorkStartIn = "到达时间"; + /// + /// 离开时间 + /// + public static string WorkStartOut = "离开时间"; + /// + /// 持续时间 + /// + public static string WorkStartTime = "持续时间"; + /// + /// 扫描条码 + /// + public static string BarCode = "扫描条码"; + /// + /// 工件到位 2 + /// + public static string WorkStart = "工件到位"; + /// + /// 传递机型 44 + /// + public static string EngineTypeGetOverPLC = "传递机型"; + /// + /// 申请上件 43 + /// + public static string PartLoad = "申请上件"; + /// + /// 允许保存 19 + /// + public static string MesRead = "允许保存"; + /// + /// 保存完成 20 + /// + public static string MesReadOver = "保存完成"; + /// + /// 允许工作 20 + /// + public static string FixAllow = "允许工作"; + + + + + /// [机床上电],[循环开始],[机床故障],[上料无件],[下料堵塞],[工件到位] + /// [传递机型],[申请上件],[允许保存],[保存完成],[合格标志],[前序合格] + /// [工号],[班次],[是否返修件],[合格放行],[不合格放行] + /// [到达时间],[离开时间],[持续时间] + // engineTypeID = Convert.ToInt32(thisParms[2].Value); + //engineType = thisParms[3].Value.ToString(); + //engineID = thisParms[4].Value.ToString(); + //palletCode = thisParms[5].Value.ToString(); + } + + /// + /// 测量数据工位_监控系统_MOBY_线首_增加 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static bool OpName_MIS_MOBY_Insert_FirstOpName(string opName, int engineTypeID, int engineTypeID_MES, string engineType, string engineType_MES, string engineID, string engineID_MES, int palletCode, string orderForm, string orderForm_MES) + { + string produceName = "测量数据工位_监控系统_MOBY_线首_增加"; + SqlParameter[] thisParms = new SqlParameter[10]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@产品型号代码", engineTypeID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@产品型号代码_MES", engineTypeID_MES); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@发动机型号", engineType); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@发动机型号_MES", engineType_MES); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@发动机号", engineID); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@发动机号_MES", engineID_MES); + thisParms[7] = new System.Data.SqlClient.SqlParameter("@订单号", orderForm); + thisParms[8] = new System.Data.SqlClient.SqlParameter("@订单号_MES", orderForm_MES); + thisParms[9] = new System.Data.SqlClient.SqlParameter("@托盘号", palletCode); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + /// + /// 测量数据工位_监控系统_MOBY_增加 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static bool OpName_MIS_MOBY_Insert(string opName, string tagType, string tagValue) + { + string produceName = "北汽福田工位状态监控MOBY_增加"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@变量类型", tagType); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@变量值", tagValue); + + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + /// + /// 生产计划_派工订单_工件追溯_校验 + /// + /// + /// + /// + public static DataTable WorkOrderCheck(string opName, string EngineID, string OrderFrom, string EngineType) + { + string produceName = "生产计划_派工订单_工件追溯_校验"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@工件编号", EngineID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@订单号", OrderFrom); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@机型", EngineType); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out DataTable dt); + return dt; + } + + /// + /// 接口_IOT接口_报工记录_是否报工判断 + /// + /// + /// + /// + public static DataTable IOT_ReqData_UpLoad_IsSend(string opName, string OrderFrom, string reqType) + { + string produceName = "接口_IOT接口_报工记录_是否报工判断"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@订单号", OrderFrom); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@报工类型", reqType); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out DataTable dt); + return dt; + } + + /// + /// 测量数据工位_监控系统_MOBY_增加 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static bool OpName_MIS_MOBY_Insert_JZ(string opName, string engineID) + { + string produceName = "测量数据工位_监控系统_MOBY_静置工位_增加"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", engineID); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + public static void BarCodeIsSecondVerification(string opName, out bool isSecondVerification) + { + isSecondVerification = false; + DataTable dt = new DataTable(); + string produceName = "测量数据工位_监控系统_是否二次验证_查询"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt); + if (dt.Rows.Count > 0) + { + string isVerification = dt.Rows[0]["是否验证"].ToString(); + if(isVerification == "1") + { + isSecondVerification = true; + } + } + } + /// + /// 日志_工位操作_增加 + /// + /// + /// + /// + /// + /// + public static bool LogRecording_OP(string OpName, string type, string msgType, string content) + { + string produceName = "日志_工位操作_增加"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", OpName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@消息类型", type); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@操作类型", msgType); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@内容", content); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + /// + /// 电子看板_工序内容_临时表_增加 + /// + /// + /// + public static bool MesServer_ProcessList_EngineTypeOver(string opName) + { + string produceName = "电子看板_工序内容_临时表_增加"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + /// + /// 电子看板_装配零件_临时表_增加 + /// + /// + /// + public static bool MesServer_Process_EngineTypeOver(string opName) + { + string produceName = "电子看板_装配零件_临时表_增加"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + /// + /// 测量数据工位_监控系统_MOBY_查询 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static void Moby_Select(string opName, out string OrderForm, out int EngineTypeID, out string EngineType, out string EngineID, out string PartPallet_Code, out int IsrepairBarcode, out string repairBarcode, out string EngineTypeString) + { + DataTable dt = new DataTable(); + OrderForm = ""; + EngineTypeID = 0; + EngineType = ""; + EngineID = ""; + PartPallet_Code = "0"; + IsrepairBarcode = 0; + repairBarcode = "0"; + EngineTypeString = ""; + try + { + string procedureName; + procedureName = "测量数据工位_监控系统_MOBY_查询"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt); + if (dt.Rows.Count > 0) + { + OrderForm = dt.Rows[0]["订单号"].ToString(); + EngineTypeID = Convert.ToInt32(dt.Rows[0]["产品型号代码"]); ; + EngineType = dt.Rows[0]["发动机型号"].ToString(); + EngineID = dt.Rows[0]["发动机号"].ToString(); + PartPallet_Code = dt.Rows[0]["托盘号"].ToString(); + } + } + catch + { + OrderForm = ""; + EngineTypeID = 0; + EngineType = ""; + EngineID = ""; + PartPallet_Code = "0"; + IsrepairBarcode = 0; + repairBarcode = ""; + EngineTypeString = ""; + } + } + + /// + /// 测量数据工位_监控系统_MOBY_查询 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static void Moby_Select(string opName, out string orderNum, + out int EngineTypeID, out string EngineType, out string EngineID, out string PartPallet_Code, + out int IsrepairBarcode, out string repairBarcode, + out string workCode, out string projectName, out string splitCode, out string unidCode, out string engineType, out string engineTypeModel, out string startTime) + { + orderNum = ""; + EngineTypeID = 0; + EngineType = ""; + EngineID = ""; + PartPallet_Code = ""; + IsrepairBarcode = 0; + repairBarcode = ""; + workCode = ""; // 制造编号 + projectName = ""; // 项目名称 + splitCode = ""; // 间隔号 + unidCode = ""; // 单元号 + engineType = ""; // 本体类型 + engineTypeModel = ""; // 附件类型 + startTime = ""; // 开始时间 + + try + { + string procedureName; + procedureName = "测量数据工位_监控系统_MOBY_查询"; + SqlParameter[] thisParms = new SqlParameter[15]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@订单号", SqlDbType.NVarChar, 50, "订单号"); + thisParms[1].Direction = ParameterDirection.Output; + thisParms[2] = new System.Data.SqlClient.SqlParameter("@产品型号代码", SqlDbType.Int, 4, "产品型号代码"); + thisParms[2].Direction = ParameterDirection.Output; + thisParms[3] = new System.Data.SqlClient.SqlParameter("@发动机型号", SqlDbType.NVarChar, 50, "发动机型号"); + thisParms[3].Direction = ParameterDirection.Output; + thisParms[4] = new System.Data.SqlClient.SqlParameter("@发动机号", SqlDbType.NVarChar, 50, "发动机号"); + thisParms[4].Direction = ParameterDirection.Output; + thisParms[5] = new System.Data.SqlClient.SqlParameter("@托盘号", SqlDbType.NVarChar, 50, "托盘号"); + thisParms[5].Direction = ParameterDirection.Output; + thisParms[6] = new System.Data.SqlClient.SqlParameter("@拆解标志", SqlDbType.Int, 4, "拆解标志"); + thisParms[6].Direction = ParameterDirection.Output; + thisParms[7] = new System.Data.SqlClient.SqlParameter("@拆解返修条码", SqlDbType.NVarChar, 50, "拆解返修条码"); + thisParms[7].Direction = ParameterDirection.Output; + thisParms[8] = new System.Data.SqlClient.SqlParameter("@制造编号", SqlDbType.NVarChar, 50, "制造编号"); + thisParms[8].Direction = ParameterDirection.Output; + thisParms[9] = new System.Data.SqlClient.SqlParameter("@间隔号", SqlDbType.NVarChar, 50, "间隔号"); + thisParms[9].Direction = ParameterDirection.Output; + thisParms[10] = new System.Data.SqlClient.SqlParameter("@单元号", SqlDbType.NVarChar, 50, "单元号"); + thisParms[10].Direction = ParameterDirection.Output; + thisParms[11] = new System.Data.SqlClient.SqlParameter("@项目名称", SqlDbType.NVarChar, 50, "项目名称"); + thisParms[11].Direction = ParameterDirection.Output; + thisParms[12] = new System.Data.SqlClient.SqlParameter("@本体类型", SqlDbType.NVarChar, 50, "本体类型"); + thisParms[12].Direction = ParameterDirection.Output; + thisParms[13] = new System.Data.SqlClient.SqlParameter("@附件类型", SqlDbType.NVarChar, 50, "附件类型"); + thisParms[13].Direction = ParameterDirection.Output; + thisParms[14] = new System.Data.SqlClient.SqlParameter("@开始时间", SqlDbType.NVarChar, 50, "开始时间"); + thisParms[14].Direction = ParameterDirection.Output; + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms); + if (thisParms[1].Value != null && thisParms[2].Value != null && thisParms[3].Value != null && thisParms[4].Value != null && thisParms[5].Value != null && thisParms[6].Value != null && thisParms[7].Value != null) + { + orderNum = thisParms[1].Value.ToString(); + EngineTypeID = Convert.ToInt32(thisParms[2].Value); ; + EngineType = thisParms[3].Value.ToString(); + EngineID = thisParms[4].Value.ToString(); + PartPallet_Code = thisParms[5].Value.ToString(); + IsrepairBarcode = Convert.ToInt32(thisParms[6].Value); + repairBarcode = thisParms[7].Value.ToString(); + workCode = thisParms[8].Value.ToString(); // 制造编号 + projectName = thisParms[9].Value.ToString(); // 项目名称 + splitCode = thisParms[10].Value.ToString();// 间隔号 + unidCode = thisParms[11].Value.ToString(); // 单元号 + engineType = thisParms[12].Value.ToString(); // 本体类型 + engineTypeModel = thisParms[13].Value.ToString(); // 附件类型 + startTime = thisParms[14].Value.ToString(); // 开始时间 + } + } + catch + { + orderNum = ""; + EngineTypeID = 0; + EngineType = ""; + EngineID = ""; + PartPallet_Code = ""; + IsrepairBarcode = 0; + repairBarcode = ""; + workCode = ""; // 制造编号 + projectName = ""; // 项目名称 + splitCode = ""; // 间隔号 + unidCode = ""; // 单元号 + engineType = ""; // 本体类型 + engineTypeModel = ""; // 附件类型 + } + } + + /// + /// 电子看板_工序内容_查询 + /// + /// 工位号 + /// 产品型号代码 + /// + static public void Process_Select(string opName, int engineTypeID, string EngineType, out DataTable dt) + { + dt = null; + string sql = "exec 电子看板_工序内容_查询 '" + opName + "','" + EngineType + "'"; + DataAccess.ExecuteDataTable(sql, out dt); + } + /// + /// 电子看板_装配零件_物料验证_查询 + /// + /// 工位号 + /// 发动机号 + /// + static public bool PartMaterialVerify_Select(string opName, int engineTypeID, string engineType, out DataTable dt) + { + dt = null; + string procedureName; + procedureName = "电子看板_装配零件_临时表_查询"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt); + } + /// + /// 电子看板_装配零件_临时表_判断_是否允许工作 + /// + /// + /// + /// + public static bool MesServer_Judge_IsCanWork(string opName, out int IsAllowWork) + { + IsAllowWork = 0; + string produceName = "电子看板_装配零件_临时表_判断_是否允许工作"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@是否允许工作", IsAllowWork); + thisParms[1].Direction = ParameterDirection.Output; + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms)) + { + IsAllowWork = Convert.ToInt32(thisParms[1].Value); + return true; + } + return false; + } + + /// + /// [电子看板_装配零件_临时表_增加_北汽] + /// + /// + /// + public static bool MesServer_Process_EngineTypeOverBQ(string opName) + { + string produceName = "电子看板_装配零件_临时表_增加_北汽"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + /// + /// 发送页面点位 同时存入数据库状态 + /// + /// + public static void MobySendWebAndSaveData(string OpName, string tagType, string tagValue) + { + MisDataFun.OpName_MIS_MOBY_Insert(OpName, tagType, tagValue); + // 判断是否为涉及前端页面的信号,如果是则同步发送点位 + string tagName = ""; + switch (tagType) + { + case "工件到位": + tagName = "WorkStart"; + break; + case "传递机型": + tagName = "EngineTypeGetOverPLC"; + break; + case "申请上件": + tagName = "PartLoad"; + break; + case "允许工作": + tagName = "FixAllow"; + break; + case "允许保存": + tagName = "MesRead"; + break; + case "保存完成": + tagName = "MesReadOver"; + break; + default: + break; + } + if (tagName != "") + { + SendMessageFun.SendInfomation(tagName, Convert.ToString(Convert.ToInt32(tagValue)), OpName); + } + } + + /// + /// 电子看板_装配零件_临时表_修改_零件条码 + /// + /// + /// + /// + /// + public static bool PartMaterial_DM_Update(string opName, string barCode, out bool IsSuccess) + { + IsSuccess = false; + string produceName = "电子看板_装配零件_临时表_修改_零件条码"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@条码", barCode); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@条码是否符合", IsSuccess); + thisParms[2].Direction = ParameterDirection.Output; + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms)) + { + IsSuccess = Convert.ToBoolean(thisParms[2].Value); + return true; + } + return false; + } + + /// + /// 测量数据合格索引_增加 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static bool BaseData_tagTable_QualityData_B5A_IndexInsert(string EngineID, string tagID, string EngineType, int EngineTypeID, string opName, int isGoodBad, string PartPalletCode, out int Id_tagCF) + { + string procedureName; + procedureName = "测量数据合格索引_增加"; + Id_tagCF = 0; + SqlParameter[] thisParms = new SqlParameter[8]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@EngineID", EngineID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@TagID_CF", tagID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineType", EngineType); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", EngineTypeID); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@托盘编号", PartPalletCode); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@合格标志", isGoodBad); + thisParms[7] = new System.Data.SqlClient.SqlParameter("@Id_tagCF", Id_tagCF); + thisParms[7].Direction = ParameterDirection.Output; + + if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms)) + { + Id_tagCF = Convert.ToInt32(thisParms[7].Value.ToString()); + return true; + } + return false; + } + /// + /// 测量数据合格_增加 + /// + /// + /// + /// + /// + /// + /// + /// + public static bool BaseData_tagTable_QualityData_B5A_Insert(int Id_tagCF, int engineTypeID, string engineID, string opName, DataTable dt, bool IsCheck = false) + { + string procedureName; + procedureName = "测量数据合格_增加"; + SqlParameter[] thisParms = new SqlParameter[15]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@Id_tagCF", Id_tagCF); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", engineTypeID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineID", engineID); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@TagID", SqlDbType.Int, 4, "TagID"); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@TagValue", SqlDbType.NVarChar, 100, "TagValue"); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@IsGoodBad", SqlDbType.Int, 4, "IsGoodBad"); + //是否保存无合格标志数据数据 + //thisParms[6] = new System.Data.SqlClient.SqlParameter("@IsCheck", IsCheck); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@测量位置", SqlDbType.NVarChar, 50, "测量位置"); + thisParms[7] = new System.Data.SqlClient.SqlParameter("@测量项目", SqlDbType.NVarChar, 50, "测量项目"); + thisParms[8] = new System.Data.SqlClient.SqlParameter("@工位号", opName); //为了给J07MA020 保留四位精度而设置 + thisParms[9] = new System.Data.SqlClient.SqlParameter("@理论值", SqlDbType.NVarChar, 50, "理论值"); + thisParms[10] = new System.Data.SqlClient.SqlParameter("@上限值", SqlDbType.NVarChar, 50, "上限值"); + thisParms[11] = new System.Data.SqlClient.SqlParameter("@下限值", SqlDbType.NVarChar, 50, "下限值"); + thisParms[12] = new System.Data.SqlClient.SqlParameter("@测量单位", SqlDbType.NVarChar, 50, "测量单位"); + thisParms[13] = new System.Data.SqlClient.SqlParameter("@列位置", SqlDbType.Int, 4, "列位置"); + thisParms[14] = new System.Data.SqlClient.SqlParameter("@变量排序", SqlDbType.Int, 4, "变量排序"); + //table.Columns.Add("TagID", typeof(System.Int32)); + //table.Columns.Add("TagValue", typeof(System.String)); + //table.Columns.Add("IsGoodBad", typeof(System.Int32)); + //table.Columns.Add("测量位置", typeof(System.String)); + //table.Columns.Add("测量项目", typeof(System.String)); + //table.Columns.Add("工位号", typeof(System.String)); + //table.Columns.Add("理论值", typeof(System.String)); + //table.Columns.Add("上限值", typeof(System.String)); + //table.Columns.Add("下限值", typeof(System.String)); + //table.Columns.Add("测量单位", typeof(System.String)); + //table.Columns.Add("列位置", typeof(System.Int32)); + //table.Columns.Add("变量排序", typeof(System.Int32)); + return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, dt); + } + /// + /// 测量数据合格_手动拧紧_增加 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static bool BaseData_tagTable_QualityData_B5A_Insert(int engineTypeID, string engineType, string engineID, string tagValue, int isGoodBad, string opName, string partPallet, int tagID, int tagID_CF, string MaxValue, string MinValue) + { + string procedureName; + procedureName = "测量数据合格_手动拧紧_增加"; + SqlParameter[] thisParms = new SqlParameter[11]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", engineTypeID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@EngineType", engineType); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineID", engineID); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@TagValue", tagValue); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@合格标志", isGoodBad); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@托盘编号", partPallet); + thisParms[7] = new System.Data.SqlClient.SqlParameter("@TagID", tagID); + thisParms[8] = new System.Data.SqlClient.SqlParameter("@TagID_CF", tagID_CF); + thisParms[9] = new System.Data.SqlClient.SqlParameter("@上限值", MaxValue); + thisParms[10] = new System.Data.SqlClient.SqlParameter("@下限值", MinValue); + return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms); + } + /// + /// 测量数据合格索引_增加_电芯 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static bool BaseData_tagTable_QualityData_B5A_IndexInsert_cell(string EngineID, string tagID, string EngineType, int EngineTypeID, string opName, int isGoodBad, string PartPalletCode, out int Id_tagCF) + { + string procedureName; + procedureName = "测量数据合格索引_增加_电芯"; + Id_tagCF = 0; + SqlParameter[] thisParms = new SqlParameter[8]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@EngineID", EngineID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@TagID_CF", tagID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineType", EngineType); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", EngineTypeID); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@托盘编号", PartPalletCode); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@合格标志", isGoodBad); + thisParms[7] = new System.Data.SqlClient.SqlParameter("@Id_tagCF", Id_tagCF); + thisParms[7].Direction = ParameterDirection.Output; + + if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms)) + { + Id_tagCF = Convert.ToInt32(thisParms[7].Value.ToString()); + return true; + } + return false; + } + /// + /// 测量数据合格_增加_电芯 + /// + /// + /// + /// + /// + /// + /// + /// + public static bool BaseData_tagTable_QualityData_B5A_Insert_cell(int Id_tagCF, int engineTypeID, string engineID, string opName, DataTable dt, bool IsCheck = false) + { + string procedureName; + procedureName = "测量数据合格_增加_电芯"; + SqlParameter[] thisParms = new SqlParameter[15]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@Id_tagCF", Id_tagCF); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", engineTypeID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineID", engineID); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@TagID", SqlDbType.Int, 4, "TagID"); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@TagValue", SqlDbType.NVarChar, 100, "TagValue"); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@IsGoodBad", SqlDbType.Int, 4, "IsGoodBad"); + //是否保存无合格标志数据数据 + //thisParms[6] = new System.Data.SqlClient.SqlParameter("@IsCheck", IsCheck); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@测量位置", SqlDbType.NVarChar, 50, "测量位置"); + thisParms[7] = new System.Data.SqlClient.SqlParameter("@测量项目", SqlDbType.NVarChar, 50, "测量项目"); + thisParms[8] = new System.Data.SqlClient.SqlParameter("@工位号", opName); //为了给J07MA020 保留四位精度而设置 + thisParms[9] = new System.Data.SqlClient.SqlParameter("@理论值", SqlDbType.NVarChar, 50, "理论值"); + thisParms[10] = new System.Data.SqlClient.SqlParameter("@上限值", SqlDbType.NVarChar, 50, "上限值"); + thisParms[11] = new System.Data.SqlClient.SqlParameter("@下限值", SqlDbType.NVarChar, 50, "下限值"); + thisParms[12] = new System.Data.SqlClient.SqlParameter("@测量单位", SqlDbType.NVarChar, 50, "测量单位"); + thisParms[13] = new System.Data.SqlClient.SqlParameter("@列位置", SqlDbType.Int, 4, "列位置"); + thisParms[14] = new System.Data.SqlClient.SqlParameter("@变量排序", SqlDbType.Int, 4, "变量排序"); + //table.Columns.Add("TagID", typeof(System.Int32)); + //table.Columns.Add("TagValue", typeof(System.String)); + //table.Columns.Add("IsGoodBad", typeof(System.Int32)); + //table.Columns.Add("测量位置", typeof(System.String)); + //table.Columns.Add("测量项目", typeof(System.String)); + //table.Columns.Add("工位号", typeof(System.String)); + //table.Columns.Add("理论值", typeof(System.String)); + //table.Columns.Add("上限值", typeof(System.String)); + //table.Columns.Add("下限值", typeof(System.String)); + //table.Columns.Add("测量单位", typeof(System.String)); + //table.Columns.Add("列位置", typeof(System.Int32)); + //table.Columns.Add("变量排序", typeof(System.Int32)); + return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, dt); + } + + /// + /// MES_装配数据_零部件追溯_增加 + /// + /// + /// + /// + public static bool Material_Insert(string opName, int m_ConfirmOkGo) + { + string produceName = "MES_装配数据_零部件追溯_增加"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@放行方式", m_ConfirmOkGo); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + /// + /// 测量数据发动机在线状态_增加数据 + /// + /// + /// + static public void WorkStartInsert_JZ(string opName, string engineID, int isOK) + { + string procedureName; + procedureName = "测量数据发动机在线状态_增加数据_JZ"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", engineID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@是否合格", isOK.ToString()); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms); + } + /// + /// 测量数据发动机在线状态_增加数据 + /// + /// + /// + static public void WorkStartInsert(string opName, int isOK) + { + string procedureName; + procedureName = "测量数据发动机在线状态_增加数据"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@是否合格", isOK.ToString()); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms); + } + + /// + /// 接口_IOT接口_报工记录_增加 + /// + /// + public static void IOT_Data_UpLode_Res_Save(string opName, string OrderID, string EngineID,string ReqType,bool reqIsOk,string ResText) + { + string produceName = "接口_IOT接口_报工记录_增加"; + SqlParameter[] thisParms = new SqlParameter[6]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@订单号", OrderID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@工件编号", EngineID); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@报工类型", ReqType); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@报工结果", reqIsOk); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@结果报文", ResText); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + + /// + /// CallWebApi_FactoryMes_NGRecordSave + /// + /// + public static void CallWebApi_FactoryMes_NGRecordSave(string InterfaceName, int AID, string InterfaceUrl, string ReqText, string ResText) + { + string produceName = "CallWebApi_FactoryMes_NGRecordSave"; + SqlParameter[] thisParms = new SqlParameter[5]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@接口名称", InterfaceName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@AID", AID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@接口地址", InterfaceUrl); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@请求内容", ReqText); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@响应内容", ResText); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + /// + /// 生产计划_派工订单_工件追溯_工位完工 + /// + /// + /// + /// + public static bool WorkOrderOpWorkOver(string opName, string EngineID, string OrderFrom) + { + string produceName = "生产计划_派工订单_工件追溯_工位完工"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@订单号", OrderFrom); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@工件编号", EngineID); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + /// + /// 生产计划_派工订单_工件追溯_工位完工 + /// + /// + /// + /// + public static bool SaveQualityInterfaceData(string opName, string EngineID) + { + string produceName = "接口_质量数据_增加"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@工件编号", EngineID); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + /// + /// 数据表 + /// + /// + static public DataTable BuildDataTables_WWW() + { + DataTable table; + DataColumnCollection columns; + table = new DataTable(); + columns = table.Columns; + table.Columns.Add("TagID", typeof(System.String)); + table.Columns.Add("TagValue", typeof(System.String)); + table.Columns.Add("IsGoodBad", typeof(System.Int32)); + table.Columns.Add("测量位置", typeof(System.String)); + table.Columns.Add("测量项目", typeof(System.String)); + table.Columns.Add("工位号", typeof(System.String)); + table.Columns.Add("理论值", typeof(System.String)); + table.Columns.Add("上限值", typeof(System.String)); + table.Columns.Add("下限值", typeof(System.String)); + table.Columns.Add("测量单位", typeof(System.String)); + table.Columns.Add("列位置", typeof(System.Int32)); + table.Columns.Add("变量排序", typeof(System.Int32)); + + return table; + } + + static public DataTable GetMobyTableByOpName(string opName) + { + DataTable dt; + string procedureName; + procedureName = "北汽福田工位状态监控MOBY_工位_查询"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt); + return dt; + } + + /// + /// 生产计划_派工订单_工件追溯_工件下线 + /// + /// + /// + /// + public static bool WorkOrderOpWorkOutLine(string EngineID, string OrderFrom) + { + string produceName = "生产计划_派工订单_工件追溯_工件下线"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@订单号", OrderFrom); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@工件编号", EngineID); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + + /// + /// XD_提前上料记录_获取 + /// + /// + /// + public static DataTable Get_ReqEarlyFeedingData(string opName) + { + DataTable dt = new DataTable(); + string produceName = "XD_提前上料记录_获取"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt); + return dt; + } + + /// + /// + /// + /// + /// + /// + /// + public static bool Location_MIS_MOBY_Insert(string opName, string tagType, string tagValue) + { + string produceName = "XD_库位Moby_增加"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@库位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@变量类型", tagType); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@变量值", tagValue); + + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + public static DataTable GetEngineType_Order(string opName) + { + DataTable dt = new DataTable(); + string produceName = "生产计划_派工订单_申请上线"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt)) + { + return dt; + } + return dt; + } + + public static DataTable GetEngineType_Order(string opName, string Program_No, out int EngineTypeID, out string EngineType, out string EngineID, out string OrderForm, out int isCheckOk, out int planCount, out int haveUplaodCount, out int remainingQuantity, out string msg) + { + DataTable dt = new DataTable(); + isCheckOk = 2; + EngineTypeID = 0; + EngineType = ""; + EngineID = ""; + OrderForm = ""; + planCount = 0; + haveUplaodCount = 0; + remainingQuantity = 0; + msg = ""; + string produceName = "平芝_生产上线_判断机型订单是否匹配_分线"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + //thisParms[1] = new System.Data.SqlClient.SqlParameter("@PLC_机型代码", Program_No); + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt)) + { + if (dt.Rows.Count > 0) + { + EngineTypeID = Convert.ToInt32(dt.Rows[0]["机型代码"]); + EngineType = dt.Rows[0]["机型"].ToString(); + EngineID = dt.Rows[0]["变速箱总成号"].ToString(); + OrderForm = dt.Rows[0]["订单号"].ToString(); + isCheckOk = Convert.ToInt32(dt.Rows[0]["是否匹配"]); + planCount = Convert.ToInt32(dt.Rows[0]["计划上料数量"]); + haveUplaodCount = Convert.ToInt32(dt.Rows[0]["已上料数量"]); + remainingQuantity = Convert.ToInt32(dt.Rows[0]["待上料数量"]); + msg = dt.Rows[0]["msg"].ToString(); + return dt; + } + } + return dt; + } + + /// + /// 29 工位具体零件合格标志 + /// + /// + static public string GetQualityData_GoodBad_String(bool[] QualityData_GoodBad) + { + string str; + str = ""; + if (QualityData_GoodBad != null) + { + + for (int i = 0; i < QualityData_GoodBad.Length; i++) + { + str = str + (Convert.ToInt32(QualityData_GoodBad[i])).ToString() + "|"; + } + + } + return str; + + } + + /// + /// 返回非标准real + /// + /// + /// + static public string GetNoNormalReal(object vDataValue) + { + try + { + string real_a; + string real_b; + string groupValueString; + int length; + + //int real_b_Int; + + length = ((System.Array)(vDataValue)).Length; + groupValueString = ""; + if (length != 2) + return "0.0"; + + real_a = Convert.ToUInt16((((System.Array)(vDataValue)).GetValue(0))).ToString(); + real_b = Convert.ToUInt16((((System.Array)(vDataValue)).GetValue(1))).ToString("00"); + groupValueString = real_a + "." + real_b; + return groupValueString; + } + catch + { + ////ApplicationLog.WriteLog(err, "GetNoNormalReal"); + return "0.0"; + + } + } + + /// + /// 测量数据工位_监控系统_MOBY_查询_PDC + /// + /// + /// + /// + public static void Moby_Select_PDC(string EngineID, out string OrderForm, out string EngineType, out int EngineTypeCode) + { + DataTable dt = new DataTable(); + OrderForm = ""; + EngineType = ""; + EngineTypeCode = 0; + try + { + string procedureName; + procedureName = "测量数据工位_监控系统_MOBY_查询_PDC"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID); + + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt); + if (dt.Rows.Count > 0) + { + OrderForm = dt.Rows[0]["订单号"].ToString(); + EngineType = dt.Rows[0]["产品型号"].ToString(); + EngineTypeCode = Convert.ToInt32(dt.Rows[0]["机型代码"].ToString()); + } + } + catch + { + OrderForm = ""; + EngineType = ""; + EngineTypeCode = 0; + } + } + + /// + /// 基本数据_工作日历_班次产量查询_Web页面显示_初始化查询 + /// + /// + /// + /// + public static void InitOpNameOuputCount(string opName, out int outputValue, out int nowOutputValue, + out int opNameBeatValue, out int NowOpNameBeatValue, out int classNumber) + { + outputValue = 0;//工位产量 + nowOutputValue = 0;//在线产量 + opNameBeatValue = 0;//工位节拍 + NowOpNameBeatValue = 0;//在线节拍 + classNumber = 0;//班次 + try + { + string procedureName; + procedureName = "Web页面显示_计划产量初始化查询"; + SqlParameter[] thisParms = new SqlParameter[6]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位产量", SqlDbType.Int, 4, "工位产量"); + thisParms[1].Direction = ParameterDirection.Output; + thisParms[2] = new System.Data.SqlClient.SqlParameter("@工位节拍", SqlDbType.Int, 4, "工位节拍"); + thisParms[2].Direction = ParameterDirection.Output; + thisParms[3] = new System.Data.SqlClient.SqlParameter("@在线产量", SqlDbType.Int, 4, "在线产量"); + thisParms[3].Direction = ParameterDirection.Output; + thisParms[4] = new System.Data.SqlClient.SqlParameter("@在线节拍", SqlDbType.Int, 4, "在线节拍"); + thisParms[4].Direction = ParameterDirection.Output; + thisParms[5] = new System.Data.SqlClient.SqlParameter("@班次代码", SqlDbType.Int, 4, "班次代码"); + thisParms[5].Direction = ParameterDirection.Output; + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms); + if (thisParms[1].Value != null && thisParms[2].Value != null && thisParms[3].Value != null && thisParms[4].Value != null && thisParms[5].Value != null) + { + outputValue = Convert.ToInt32(thisParms[1].Value); + opNameBeatValue = Convert.ToInt32(thisParms[2].Value); + nowOutputValue = Convert.ToInt32(thisParms[3].Value); + NowOpNameBeatValue = Convert.ToInt32(thisParms[4].Value); + classNumber = Convert.ToInt32(thisParms[5].Value); + } + } + catch + { + outputValue = 0; + opNameBeatValue = 0; + nowOutputValue = 0; + NowOpNameBeatValue = 0; + classNumber = 0; + } + } + + static public void GetImageFile(string opName, int engineTypeID, out byte[] pic) + { + string sql; + DataTable dt; + pic = null; + sql = "exec 电子看板_工位名称与产品型号产品图片_查询 '" + opName + "'," + engineTypeID.ToString(); + DataAccess.ExecuteDataTable(sql, out dt); + if (dt != null) + { + if (dt.Rows.Count > 0) + { + pic = (byte[])dt.Rows[0]["产品图片"]; + } + } + } + + /// + /// 电子看板_工位机型_质量数据测量位置_查询_工作顺序 + /// + /// 工位号 + /// 产品型号代码 + /// + static public bool ShaftPositionSelect(string opNum, int EngineTypeID, out DataTable dt) + { + string procedureName = "电子看板_工位机型_质量数据测量位置_临时表_查询"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opNum); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@产品型号代码", EngineTypeID); + return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt); + } + + + /// + /// 测量数据合格_查询 + /// + /// + /// + /// + /// + static public bool QualitySelect(string opName, string engineID, out DataTable dt) + { + string procedureName = "测量数据合格_查询"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", engineID); + return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt); + } + /// + /// 生产计划_派工订单_查询_工位执行_完工判断 + /// + /// + /// + /// + /// + public static void Select_OrderFormList_OrderComplete(string opName, out int isCompleted, out int num_plan, out int num_complete) + { + isCompleted = 0;//订单数量是否完全上线 + num_plan = 0;//计划数量 + num_complete = 0;//上线数量 + try + { + string procedureName; + procedureName = "生产计划_派工订单_查询_工位执行_完工判断"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@ISCOMPLETE", SqlDbType.Int, 4, "ISCOMPLETE"); + thisParms[1].Direction = ParameterDirection.Output; + thisParms[2] = new System.Data.SqlClient.SqlParameter("@NUM_PLAN", SqlDbType.Int, 4, "NUM_PLAN"); + thisParms[2].Direction = ParameterDirection.Output; + thisParms[3] = new System.Data.SqlClient.SqlParameter("@NUM_COMPLETE", SqlDbType.Int, 4, "NUM_COMPLETE"); + thisParms[3].Direction = ParameterDirection.Output; + + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms); + if (thisParms[1].Value != null && thisParms[2].Value != null && thisParms[3].Value != null) + { + isCompleted = Convert.ToInt32(thisParms[1].Value); + num_plan = Convert.ToInt32(thisParms[2].Value); + num_complete = Convert.ToInt32(thisParms[3].Value); + } + } + catch + { + isCompleted = 0; + num_plan = 0; + num_complete = 0; + } + } + /// + /// 生产计划_派工订单_查询_工位执行 + /// + /// 工位号 + /// + static public void OrderFormList_Select(string opName, out DataTable dt) + { + dt = null; + string sql = "exec 生产计划_派工订单_查询_工位执行 '" + opName + "'"; + DataAccess.ExecuteDataTable(sql, out dt); + } + /// + /// MES界面显示_弹窗消息_查询 + /// + /// + /// + /// + public static bool ShowWindowNotice(string opname, out DataTable dt) + { + string procedureName = "MES界面显示_弹窗消息_查询"; + SqlParameter[] sqlParameters = new SqlParameter[1]; + sqlParameters[0] = new System.Data.SqlClient.SqlParameter("@工位号", opname); + return DataAccess.ExecuteStoredProcedure(procedureName, ref sqlParameters, out dt); + } + + /// + /// MES界面显示_消息滚动_查询 + /// + /// + /// + /// + public static bool ShowLEDNotice(string opname, out DataTable dt) + { + string procedureName = "MES界面显示_消息滚动_查询"; + SqlParameter[] sqlParameters = new SqlParameter[1]; + sqlParameters[0] = new System.Data.SqlClient.SqlParameter("@工位号", opname); + return DataAccess.ExecuteStoredProcedure(procedureName, ref sqlParameters, out dt); + } + /// + /// 电子看板_工位机型_物料检测测量位置_查询_物料检测 + /// + /// + /// + /// + static public bool MaterialCheckSelect(string opName, out DataTable dt) + { + string procedureName = "电子看板_工位机型_物料检测测量位置_查询_物料检测"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt); + } + /// + /// 电芯进站 离站 + /// + /// + /// + /// + public static bool Cell_CheckDataAdd(string opName, string EngineID, string operationTime, int isOK) + { + string produceName = "测量数据合格_增加数据_电芯"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@操作时间", operationTime); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@合格标志", isOK); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + public static bool Cell_PassStation(string opName, string EngineID, string operationTime, int passType, int isOK = 1) + { + string produceName = "测量数据发动机在线状态_增加数据_电芯"; + SqlParameter[] thisParms = new SqlParameter[5]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@操作时间", operationTime); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@合格标志", isOK); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@过站类型", passType); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + /// + /// 报警接口记录 存储 + /// 关机(0)/开机(1)/报警(2)/故障(3) 运行(4) 待机(5) + /// 注意事项:当设备状态发生变化时,给表里插入一条数据。状态时间字段精确到年月日时分秒。当状态没变化时,不用重复去存数据,不同的故障告警,认为是不同的状态,当前如果是报警1,先存一条报警1,如果一直是报警1,就不用重复存报警1,当又产生了报警2时,需要给表里再存一条报警2。场景如下: + ////1.开机后,状态先存一条开机,3秒后,再继续存一条待机 + ////2.设备运行后,存一条运行 + ////3.有故障1时,存一条故障,内容为故障1 + ////4.有故障2时,存一条故障,内容为故障2 + ////5.故障1解除后,先存一条运行,如果还有故障2, 继续再存一条故障,内容为故障2 + ////6.故障2解除后,存一条运行或者待机(看设备具体是运行还是待机状态) + /// + /// 工位号 + /// 状态代码 + /// 故障代码 如状态为故障/报警,记录故障/报警代码。 + /// 故障名称 如状态为故障/报警,记录故障/报警名称 + /// 故障说明 如状态为故障/报警,记录故障/报警说明。 + /// 备注 + /// + public static bool errorPortSave(string opName, string DeviceStatus, string MalfunctionCode = null, string MalfunctionName = null, string Malfunctionexplain = null, string Remark = null, int? alarmRemove = null) + { + string produceName = "接口_工位运行状态_增加"; + SqlParameter[] thisParms = new SqlParameter[7]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@状态代码", DeviceStatus); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@故障代码", MalfunctionCode); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@故障名称", MalfunctionName); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@故障说明", Malfunctionexplain); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@备注", Remark); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@alarmRemove", (object)alarmRemove ?? DBNull.Value); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + + /// + /// 工位运行状态 存储 + /// + /// + /// + /// + public static bool WorkRunStatusSave(string opName, int toolPowered, int toolStart, float energy) + { + string produceName = "接口_工位使用情况_增加"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@机床上电", toolPowered); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@循环开始", toolStart); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@能耗", energy); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + + /// + /// MES界面显示_弹窗消息_增加 + /// + /// + /// + /// + public static bool Web_Notice_Insert(string opName, string notice) + { + string produceName = "MES界面显示_弹窗消息_增加"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@Notice", notice); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + /// + /// 基本数据_工作日历_班次产量查询_New + /// + /// + /// 在线产量 + /// 在线节拍 + static public void OpNameCount_New(string opName, out int opNameCount, out int opNameCountTime) + { + opNameCount = 0; + opNameCountTime = 0; + string procedureName; + procedureName = "基本数据_工作日历_班次产量查询_New"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@在线产量", 0); + thisParms[1].Direction = ParameterDirection.Output; + thisParms[2] = new System.Data.SqlClient.SqlParameter("@在线节拍", 0); + thisParms[2].Direction = ParameterDirection.Output; + if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms)) + { + opNameCount = Convert.ToInt32(thisParms[1].Value); + opNameCountTime = Convert.ToInt32(thisParms[2].Value); + } + } + /// + /// 基本数据_工作日历_班次产量查询_New + /// + /// + /// 在线产量 + /// 在线节拍 + static public void OpNameCount_BQ(string opName, out int opNameCount, out int opNameCountTime) + { + opNameCount = 0; + opNameCountTime = 0; + string procedureName; + procedureName = "基本数据_工作日历_班次产量查询_北汽"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@在线产量", 0); + thisParms[1].Direction = ParameterDirection.Output; + thisParms[2] = new System.Data.SqlClient.SqlParameter("@在线节拍", 0); + thisParms[2].Direction = ParameterDirection.Output; + if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms)) + { + opNameCount = Convert.ToInt32(thisParms[1].Value); + opNameCountTime = Convert.ToInt32(thisParms[2].Value); + } + } + /// + /// 电子看板_工位机型_质量数据测量位置_临时表_增加 + /// + /// + /// + public static bool MesServer_ShaftPosition_EngineTypeOver(string opName) + { + string produceName = "电子看板_工位机型_质量数据测量位置_临时表_增加"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + /// + /// 电子看板_工位机型_质量数据测量位置_临时表_查询_完成情况 + /// + /// + /// + /// + /// + /// + public static bool MesServer_ShaftPosition_Select_FinishResult(string opName, out int workGroupIndex, out string BoltCode, out bool sn_WorkingStepIsOver, out bool isHaveNg) + { + workGroupIndex = 0; + BoltCode = ""; + sn_WorkingStepIsOver = true; + isHaveNg = false; + + string produceName = "电子看板_工位机型_质量数据测量位置_临时表_查询_完成情况"; + SqlParameter[] thisParms = new SqlParameter[5]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@组号", SqlDbType.Int, 4); + thisParms[1].Direction = ParameterDirection.Output; + thisParms[2] = new System.Data.SqlClient.SqlParameter("@套筒号", SqlDbType.NVarChar, 50); + thisParms[2].Direction = ParameterDirection.Output; + thisParms[3] = new System.Data.SqlClient.SqlParameter("@是否全部完成", SqlDbType.Int, 4); + thisParms[3].Direction = ParameterDirection.Output; + thisParms[4] = new System.Data.SqlClient.SqlParameter("@是否全部完成", SqlDbType.Int, 4); + thisParms[4].Direction = ParameterDirection.Output; + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms)) + { + workGroupIndex = Convert.ToInt32(thisParms[1].Value); + BoltCode = thisParms[2].Value.ToString(); + sn_WorkingStepIsOver = Convert.ToBoolean(thisParms[3].Value); + isHaveNg = Convert.ToBoolean(thisParms[3].Value); + return true; + } + return false; + } + + + /// + /// 电子看板_工位机型_质量数据测量位置_临时表_修改 + /// + /// + /// + /// + /// + /// + public static bool MesServer_ShaftPosition_Update(string opName, int workGroupIndex, int IsOK, out bool IsFinish) + { + IsFinish = true; + string produceName = "电子看板_工位机型_质量数据测量位置_临时表_修改"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@组号", workGroupIndex); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@合格标志", IsOK); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@是否全部完成", SqlDbType.Int, 4); + thisParms[3].Direction = ParameterDirection.Output; + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms)) + { + IsFinish = Convert.ToBoolean(thisParms[3].Value); + return true; + } + return false; + } + /// + /// 电子看板_工位机型_质量数据测量位置_临时表_查询_完成情况 + /// + /// 工位号 + /// 拧紧序号 + /// 套筒号 + /// 工步属性 + /// 是否全部完成 + /// + public static bool MesServer_ShaftPosition_Select_FinishResult(string opName, out int ProcessCode, out int BoltCode, out int workStepProperty, out bool sn_WorkingStepIsOver, out bool isHaveNg) + { + BoltCode = 0; + ProcessCode = 512; + workStepProperty = 0; + sn_WorkingStepIsOver = true; + isHaveNg = false; + + string produceName = "电子看板_工位机型_质量数据测量位置_临时表_查询_完成情况"; + SqlParameter[] thisParms = new SqlParameter[6]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@拧紧序号", SqlDbType.Int, 4); + thisParms[1].Direction = ParameterDirection.Output; + thisParms[2] = new System.Data.SqlClient.SqlParameter("@套筒号", SqlDbType.Int, 4); + thisParms[2].Direction = ParameterDirection.Output; + thisParms[3] = new System.Data.SqlClient.SqlParameter("@工步属性", SqlDbType.Int, 4); + thisParms[3].Direction = ParameterDirection.Output; + thisParms[4] = new System.Data.SqlClient.SqlParameter("@是否全部完成", SqlDbType.Int, 4); + thisParms[4].Direction = ParameterDirection.Output; + thisParms[5] = new System.Data.SqlClient.SqlParameter("@是否存在不合格", SqlDbType.Int, 4); + thisParms[5].Direction = ParameterDirection.Output; + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms)) + { + ProcessCode = Convert.ToInt32(thisParms[1].Value); + BoltCode = Convert.ToInt32(thisParms[2].Value); + workStepProperty = Convert.ToInt32(thisParms[3].Value); + sn_WorkingStepIsOver = Convert.ToBoolean(thisParms[4].Value); + isHaveNg = Convert.ToBoolean(thisParms[5].Value); + return true; + } + return false; + } + + + /// + /// 电子看板_工位机型_质量数据测量位置_临时表_修改_重新拧紧 + /// + /// 工位号 + /// 拧紧序号 + /// + public static bool MesServer_ShaftPosition_FixAllow_Again(string opName, int ProcessCode) + { + string produceName = "电子看板_工位机型_质量数据测量位置_临时表_修改_重新拧紧"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@组号", ProcessCode); + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms)) + { + return true; + } + return false; + } + + /// + /// 测量数据项目 + /// 用于B5A项目 + /// + /// + public static DataTable BaseData_tagTable_QualityData_Item_B5A() + { + DataTable dt; + string sql; + sql = "SELECT TagID,0 as TagValue,TagName,工位号,数据来源,TagTypeID,TagLong,列位置,测量位置,变量类型代码,测量项目,TagAdr,TagAdrDemo,变量特点,变量排序 FROM [MES_基本变量_原始数据] " + + " where (TagID <> 0 ) and " + + " ((变量类型代码 = 9) " + + " or (变量类型代码 = 10) " + + " or (变量类型代码 = 11) " + + " or (变量类型代码 = 80) " + + " or (变量类型代码 = 101) " + + " or (变量类型代码 = 102) " + + + " or (变量类型代码 = 78) " + + " or (变量类型代码 = 79) " + + " or (变量类型代码 = 41) " + + " or (变量类型代码 = 51) " + + " or (变量类型代码 = 8) " + + " or (变量类型代码 = 21) " + + + " or (变量类型代码 = 105)) " + + " and (是否启用 = 1)"; + + DataAccess.ExecuteDataTable(sql, out dt); + return dt; + } + + /// + /// 测量数据合格索引_分线数据_删除 + /// + /// + /// + /// + public static bool BaseData_tagTable_QualityData_B5A_SubTable_Delete + (string engineID, string opName) + { + string procedureName; + procedureName = "测量数据合格索引_分线数据_删除"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@EngineID", engineID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms); + } + /// + /// MES_装配数据_零部件追溯_增加_不合格 + /// + /// + /// + /// + public static bool Material_Insert_NG(string opName, int m_ConfirmOkGo) + { + string produceName = "MES_装配数据_零部件追溯_增加_不合格"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@放行方式", m_ConfirmOkGo); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + /// + /// 测量数据发动机在线状态_查询_是否已工作 + /// + /// + /// 新零件号(机型) + /// + public static DataTable EngineIsTwoWork(string opName, string OrderForm, string EngineID) + { + DataTable dt = new DataTable(); + string produceName = "测量数据发动机在线状态_查询_是否已工作"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@订单号", OrderForm); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@总成号", EngineID); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt); + return dt; + } + + /// + /// 测量数据发动机在线状态_增加数据 + /// + /// + /// + static public DataTable CheckAllFinish(string opName, string EngineID, int type) + { + string procedureName; + DataTable dt = new DataTable(); + procedureName = "测量数据工位_测试工位状态_修改"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@type", type); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt); + return dt; + } + + + + + + + + + + + + + + + + + + /// + /// 报警工位记录表_新增 + /// + /// + /// + /// + /// + /// + static public void Alarm_Insert2(int TagID, string opName, string Text, int Status, string errType) + { + //@TagID , + //@工位号, + // @报警内容, + // @报警类型, + // @报警状态 + string procedureName; + procedureName = "报警工位记录表_新增"; + SqlParameter[] thisParms = new SqlParameter[5]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@TagID", TagID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@报警内容", Text); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@报警类型", errType); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@报警状态", Status); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms); + } + /// + /// 报警工位记录表_MOBY_查询 + /// + public static void Alarm_Moby_Search(out DataTable dt) + { + string procedureName; + procedureName = "报警工位记录表_MOBY_查询"; + SqlParameter[] thisParms = new SqlParameter[0]; + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt); + } + + /// + /// 生产计划_派工订单_配送信息_验证记录_校验 + /// + /// + /// + public static DataTable Get_MaterialsScanOverRes(string opName, string order, string engineID, string materialsCode) + { + DataTable dt = new DataTable(); + string produceName = "生产计划_派工订单_配送信息_验证记录_校验"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@订单号", order); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@工件编号", engineID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@物料编码", materialsCode); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt); + return dt; + } + + /// + /// 开完工 + /// + /// + /// + /// + /// 1 开工 2 完工 3 重置(用不到) + public static void OpWork_StartOrOver(string OpName,string EngineID,string OrderFrom,int Type) + { + string procedureName; + procedureName = "生产计划_派工订单_工位状态_开完工"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@制造编号", OrderFrom); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@间隔编号", EngineID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@工位号", OpName); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@Type", Type); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out DataTable dt); + } + + /// + /// [电子看板_工序内容_转入临时] + /// + /// + /// + public static bool ProcessDataToTemp(string opName, int EngineTypeID, string OrderForm, string EngineID) + { + string produceName = "电子看板_工序内容_转入临时"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@机型代码", EngineTypeID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@工件编号", OrderForm); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@订单号", EngineID); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.MES.cs b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.MES.cs new file mode 100644 index 0000000..f62ac3f --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.MES.cs @@ -0,0 +1,163 @@ +using DataLinkMesWork1; + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; + +namespace MisDataFunDll +{ + public partial class MisDataFun + { + static object locker = new object(); + /// + ///引用程序集Hashtable + /// + public static Hashtable Hashtable_assembly = new Hashtable(); + public static Hashtable hashtable_MesServerCode = new Hashtable(); + public static Hashtable hashtable_MesDll = new Hashtable(); + public static Hashtable hashtable_TagTypeTagName = new Hashtable(); + public static Hashtable hashtable_TagName = new Hashtable(); + + /// + /// + /// + /// 变量名称对应的变量类型代码 + /// 变量类型代码对应的变量名称 + public static void GetBaseData_tagTable_TagName(out Hashtable hashtable_TagName, out Hashtable hashtable_TagTypeTagName) + { + hashtable_TagName = new Hashtable(); + hashtable_TagTypeTagName = new Hashtable(); + + string tagName; + string tagTypeCode; + DataTable dt;//GetMesServerCodeFromMIS + dt = BaseData_tagTable_TagName(); + if (dt != null) + { + for (int i = 0; i < dt.Rows.Count; i++) + { + tagName = dt.Rows[i]["TagName"].ToString(); + tagTypeCode = dt.Rows[i]["变量类型代码"].ToString(); + if (!hashtable_TagName.Contains(tagName)) + { + hashtable_TagName.Add(tagName, tagTypeCode); + } + if (!hashtable_TagTypeTagName.Contains(tagTypeCode)) + { + hashtable_TagTypeTagName.Add(tagTypeCode, tagName); + } + } + } + } + + public static void GetMesServerCodeAndMesDll(out Hashtable hashtable_MesServerCode, out Hashtable hashtable_MesDll) + { + hashtable_MesServerCode = new Hashtable(); + hashtable_MesDll = new Hashtable(); + + string OpName; + string MesServerCode; + string MesDll; + DataTable dt;//GetMesServerCodeFromMIS + dt = GetMesServerCodeFromMIS(); + if (dt != null) + { + for (int i = 0; i < dt.Rows.Count; i++) + { + OpName = dt.Rows[i]["工位号"].ToString(); + MesServerCode = dt.Rows[i]["MesServerCode"].ToString(); + MesDll = dt.Rows[i]["MesDll"].ToString(); + if (!hashtable_MesDll.Contains(OpName)) + { + hashtable_MesDll.Add(OpName, MesDll); + } + if (!hashtable_MesServerCode.Contains(OpName)) + { + hashtable_MesServerCode.Add(OpName, MesServerCode); + } + } + } + } + + + /// + /// MesServerFunction + /// + /// + /// + /// + public static void TransferInfToMES(object text) + { + try + { + string recData = text.ToString(); + List dataArray = GetCmdStringList(recData); + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 Barcode + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + string mesServerdllName; + //获得工位对应的 dll + if (!GetMesServerDllNameByOpName(out mesServerdllName, m_OpName)) return; + if (mesServerdllName == null) return; + if (mesServerdllName.Length < 1) return; + + string ResultOK = ""; + object[] Paramsters = new object[1]; + Paramsters[0] = text; + + System.Reflection.Assembly assembly = null; + + bool IsOK = Hashtable_assembly.ContainsKey(mesServerdllName); + if (IsOK) + { + assembly = (System.Reflection.Assembly)Hashtable_assembly[mesServerdllName]; + } + else + { + assembly = System.Reflection.Assembly.Load(mesServerdllName); + if (assembly == null) + { + return; + } + Hashtable_assembly.Add(mesServerdllName, assembly); + } + ResultOK = Reflection.ReflectionMethod(assembly, "MesServerFunctions", "FunctionMES", "FunWork", Paramsters); + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "TransferInf"); + } + + } + /// + /// 获得工位对应的 dll + /// + /// + /// + /// + private static bool GetMesServerDllNameByOpName(out string mesServerdllName, string opName) + { + try + { + mesServerdllName = hashtable_MesDll[opName].ToString(); + return true; + } + catch + { + mesServerdllName = ""; + return false; + } + } + + + + } +} \ No newline at end of file diff --git a/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.ShaftPositionData.cs b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.ShaftPositionData.cs new file mode 100644 index 0000000..563c988 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.ShaftPositionData.cs @@ -0,0 +1,156 @@ +using DataLinkMesWork1; +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MisDataFunDll +{ + public partial class ShaftPosition + { + /// + /// 测量数据合格_电子看板_质量数据_临时表_增加_返修工位 + /// @EngineID nvarchar(50)=null, + /// @EngineType nvarchar(50)=null, + /// @EngineTypeID int = null, + /// @工位号 nvarchar(50)=null, + /// @工位号返修工位 nvarchar(50)=null, + /// @订单号 nvarchar(50)=null, + /// @合格标志 int + /// + /// 工件号 + /// 机型 + /// 机型代码 + /// 工位号(被返修的工位号) + /// 工位号返修工位 + /// 订单号 + /// 合格标志 + static public void ShaftPosition_Data_OpNameRepair_Insert(string engineID, string engineType, int engineTypeID, string opName, string opNameRepair, string orderForm, int isOK) + { + string procedureName; + procedureName = "测量数据合格_电子看板_质量数据_临时表_增加_返修工位"; + SqlParameter[] thisParmsSql = new SqlParameter[7]; + thisParmsSql[0] = new SqlParameter("@EngineID", engineID); + thisParmsSql[1] = new SqlParameter("@EngineType", engineType); + thisParmsSql[2] = new SqlParameter("@EngineTypeID", engineTypeID); + thisParmsSql[3] = new SqlParameter("@工位号", opName); + thisParmsSql[4] = new SqlParameter("@工位号返修工位", opNameRepair); + thisParmsSql[5] = new SqlParameter("@订单号", orderForm); + thisParmsSql[6] = new SqlParameter("@合格标志", isOK); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParmsSql); + } + /// + /// 测量数据合格_电子看板_质量数据_临时表_增加 + /// @EngineID nvarchar(50)=null, + /// @EngineType nvarchar(50)=null, + /// @EngineTypeID int = null, + /// @工位号 nvarchar(50)=null, + /// @订单号 nvarchar(50)=null, + /// @合格标志 int + /// + /// 工件号 + /// 机型 + /// 机型代码 + /// 工位号 + /// 订单号 + /// 合格标志 + static public void ShaftPosition_Data_Insert(string engineID, string engineType, int engineTypeID, string opName, string orderForm, int isOK) + { + string procedureName; + procedureName = "测量数据合格_电子看板_质量数据_临时表_增加"; + SqlParameter[] thisParmsSql = new SqlParameter[6]; + thisParmsSql[0] = new SqlParameter("@EngineID", engineID); + thisParmsSql[1] = new SqlParameter("@EngineType", engineType); + thisParmsSql[2] = new SqlParameter("@EngineTypeID", engineTypeID); + thisParmsSql[3] = new SqlParameter("@工位号", opName); + thisParmsSql[4] = new SqlParameter("@订单号", orderForm); + thisParmsSql[5] = new SqlParameter("@合格标志", isOK); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParmsSql); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + static public void ShaftPosition_Data_Insert_RepairOpName(string opName, int shaftStep, string engineID, string engineType, int engineTypeID, int orderBy, string tagValue, int isOK) + { + string procedureName; + procedureName = "电子看板_质量数据_临时表_增加_备用拧紧工位"; + SqlParameter[] thisParmsSql = new SqlParameter[8]; + thisParmsSql[0] = new SqlParameter("@工位号", opName); + thisParmsSql[1] = new SqlParameter("@序号", shaftStep); + thisParmsSql[2] = new SqlParameter("@EngineID", engineID); + thisParmsSql[3] = new SqlParameter("@EngineType", engineType); + thisParmsSql[4] = new SqlParameter("@EngineTypeID", engineTypeID); + thisParmsSql[5] = new SqlParameter("@变量排序", orderBy); + thisParmsSql[6] = new SqlParameter("@测量值", tagValue); + thisParmsSql[7] = new SqlParameter("@合格标志", isOK); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParmsSql); + } + /// + /// 电子看板_质量数据_临时表_增加 + /// + /// 工位号 + /// 序号 + /// 工件号 + /// 机型 + /// 机型代码 + /// 变量代码 + /// 变量值 + /// 合格标志 + static public void ShaftPosition_Data_Insert(string opName, int shaftStep, string engineID, string engineType, int engineTypeID, int tagID, string tagValue, int isOK) + { + string procedureName; + procedureName = "电子看板_质量数据_临时表_增加"; + SqlParameter[] thisParmsSql = new SqlParameter[8]; + thisParmsSql[0] = new SqlParameter("@工位号", opName); + thisParmsSql[1] = new SqlParameter("@序号", shaftStep); + thisParmsSql[2] = new SqlParameter("@EngineID", engineID); + thisParmsSql[3] = new SqlParameter("@EngineType", engineType); + thisParmsSql[4] = new SqlParameter("@EngineTypeID", engineTypeID); + thisParmsSql[5] = new SqlParameter("@TagID", tagID); + thisParmsSql[6] = new SqlParameter("@测量值", tagValue); + thisParmsSql[7] = new SqlParameter("@合格标志", isOK); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParmsSql); + } + /// + /// 电子看板_工位机型_质量数据测量位置_查询_工作顺序 + /// + /// + /// + /// + static public void ShaftPosition_Select_WorkingStep(string opName, int engineTypeID, out DataTable dt) + { + dt = null; + + string sql = "exec 电子看板_工位机型_质量数据测量位置_查询_工作顺序 '" + opName + "'," + engineTypeID.ToString(); + DataAccess.ExecuteDataTable(sql, out dt); + } + + /// + /// 电子看板_质量数据_临时表_删除 + /// + /// 工位号 + /// 列位置 + /// EngineID + static public void ShaftPosition_Data_Delete(string opName, int shaftStep, string engineID) + { + string procedureName; + procedureName = "电子看板_质量数据_临时表_删除"; + SqlParameter[] thisParmsSql = new SqlParameter[3]; + thisParmsSql[0] = new SqlParameter("@工位号", opName); + thisParmsSql[1] = new SqlParameter("@列位置", shaftStep); + thisParmsSql[2] = new SqlParameter("@EngineID", engineID); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParmsSql); + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.TagTypeCodeID.cs b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.TagTypeCodeID.cs new file mode 100644 index 0000000..ad1531b --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/MisDataFun.TagTypeCodeID.cs @@ -0,0 +1,462 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +///1 X WorkStart 2 工件到位(PLC) 工件到位。托盘到达工位,并且托盘上有工件。 +///2 X RepairPartStatusPLC 3 RepairPartStatusPLC 备用 +///3 STRING RepairPathString 4 RepairPathString "工位返修字符串(121211112222111),前2位是西门子字符串格式,第一位是总长度,第二位是实际长度" +///4 X EngineTypeGetOverMES 5 传递机型(MES) MES传递总成信息给PLC(上线工位) +///5 X PartPalletGoOver 6 PartPalletGoOver 上线工位。0:正常工作;1:空托盘放行,PLC读取到此标志不走申请上线逻辑。 +///6 X MaterialVerifyOver 7 MaterialVerifyOver MES保存完质量数据,物料数据等与PLC信号交互完成后通知PLC,所以工步都完成,才可以放行工件,正常工作时工件放行的必要条件。 +///7 X FalseGo 8 FalseGo 按MES界面[不合格放行]按钮,MES发送此信号。操作者判断工件不合格,通知设备,按不合格方式放行工件,工件流转到返修下线工位后,返修下线。MES工作完成MES0.3=1,MES合格放行MES0.5=0,MES0.4=1 +///8 INT EngineTypeID 9 EngineTypeID MES发动机机型标志(必须PLC) +///9 STRING EngineID 10 EngineID MES发动机编号(必须PLC) +///10 STRING EngineType 11 机型(MES) MES发动机机型(必须PLC) +///11 X PartPalletStatus 13 PartPalletStatus MES激发变量托盘到位离开(必须PLC) +///12 X HeartBeatPLC 14 HeartBeatPLC 心跳处理:PLC收到MES心跳信号后,PLC延时5秒后,数值取反再写回PLC,写回PLC开始计时,如果5秒钟MES无反馈报通讯故障。 +///13 X HeartBeatMIS 15 HeartBeatMIS 间隔时间5S,心跳处理。收到PLC心跳信号后,MES按原值回写。PLC收到MES信号后延时5秒,取反写入,以此循环。 +///14 X TargetTimeRead 16 TargetTimeRead MES允许可读工位运行时间 +///15 Int MachineTargetTime 17 MachineTargetTime 目标运行时间 +///16 Int MachineActualTime 18 MachineActualTime 实际运行时间 +///17 X MesRead 19 允许保存(PLC) 质量数据可以读数据 +///18 X MesReadOver 20 保存完成(MES) MES保存完数据(必须MIS) +///19 INT QualityMask 21 合格标志(PLC) 质量数据工位合格标志0:没有工作;1:合格 ;2 :不合格(必须PLC) +///20 B PalletInfo 22 PalletInfo 0空托盘,1合格件,2不合格件 +///21 INT RepairStatusPLC 23 RepairStatusPLC 0正常件,1返修件 +///22 INT OrderNo 24 订单号(MES) 订单号(MES) +///23 X StorageNo 25 库位号(MES) 库位号(MES) +///24 X AllowPass 26 允许放行(MES) 允许放行 +///25 X PartLoadFinish 27 PartLoadFinish PartLoadFinish +///26 X Reserved_7 28 Reserved_7 备用 +///27 X Reserved_8 29 Reserved_8 备用 +///28 X Reserved_9 30 Reserved_9 备用 +///29 X Reserved_10 31 Reserved_10 备用 +///30 X Reserved_11 32 Reserved_11 备用 +///31 X Reserved_12 33 Reserved_12 备用 +///32 X Reserved_13 34 Reserved_13 备用 +///33 X Reserved_14 35 Reserved_14 备用 +///34 Int PLCSPareint1 36 PLCSPareint1 备用 +///35 Int PLCSPareint2 37 PLCSPareint2 备用 +///36 Int PLCSPareint3 38 PLCSPareint3 备用 +///37 STRING PLCSarestring1 39 PLCSarestring1 备用 +///38 STRING PLCSarestring2 40 PLCSarestring2 备用 +///39 STRING MarkID 42 MarkID 机体打标号(MES)前2位是西门子字符串格式,第一位是总长度,第二位是实际长度 +///40 X PartLoad 43 PartLoad 上线工位,PLC向MES申请总成编号。收到该信号后,MES将机型标志(DBB22 ~23)、总成号(DBB24 ~63)、总成机型DBB64 ~103写入PLC。之后MES通过信号“传递机型(DBX0.1)”通知PLC。 +///41 X EngineTypeGetOverPLC 44 传递机型(PLC) PLC将机型标志(DBB50…51)、工件编号(DBB52…101)、产品型号(DBB102…187)、托盘编号(DBB188…189)准备完毕后,通知MES。 +///42 X PartLoadOK 48 PartLoadOK 备用 +///43 X Reserved_18 49 Reserved_18 备用 +///44 X PalletDown 50 PalletDown 暂时保留,项目未使用 +///45 X ConfirmOkGo 51 ConfirmOkGo 按MES界面[合格放行]按钮,MES发送此信号。操作者判断工件合格,通知设备,工件按合格方式放行工件。MES工作完成MES0.3=1,MES合格放行MES0.5=1,MES0.4=0 +///46 X ResetDevice 52 ResetDevice 针对手动工位,无HMI,需要复位设备在MES页面操作。 +///47 X UnloadCompleted 53 UnloadCompleted 暂时保留,项目未使用 +///48 X MachineTime_ReadOver 54 MachineTime_ReadOver 备用 +///49 X Reserved_19 58 Reserved_19 备用 +///50 X FixOK 59 FixOK 手动拧紧工位,单工步螺栓拧紧完成,通知PC读取数据。 +///51 X Reserved_21 61 Reserved_21 备用 +///52 X Reserved_22 62 Reserved_22 备用 +///53 X Reserved_23 63 Reserved_23 备用 +///54 X Reserved_24 64 Reserved_24 备用 +///55 X Reserved_25 65 Reserved_25 备用 +///56 X FixAllow 66 FixAllow "设备工作的必须信号,对于有物料验证的工位,MES验证完成给出此信号,对于无物料验证工位,MES直接给出此信号。" +///57 X FixOver 67 FixOver 用于手动拧紧且有质量数据工位。通知设备当前工步拧紧螺钉工作结束。 +///58 X MatchingCompleted 68 MatchingCompleted 分线上总线,匹配成功是1;不成功是0。 +///59 X Match 69 Match 分线上总线,匹配成功是1;不成功是0。 +///60 X Reserved_2 70 Reserved_2 备用 +///61 X IsAutoGetEngineID 71 IsAutoGetEngineID 自动手动申请工件编号。0是自动方式;1:手动方式。暂时保留,生成流水号方式是在数据库中实现的 +///62 X RepairUplineMES 72 RepairUplineMES 上线清空MOBY(针对上线工位):通知PLC从新开始申请上线流程 +///63 INT EngineTypeID_MES 73 机型代码(MES) MES发动机机型标志(必须MES) +///64 STRING EngineID_MES 74 工件编号(MES) MES发动机编号(必须MES) +///65 STRING EngineType_MES 75 EngineType_MES MES发动机机型(必须MES) +///66 X Reserved_20 76 Reserved_20 备用 +///67 INT ProcessCode 77 ProcessCode 手动拧紧工位:由MES通知PLC拧紧序号 +///68 B OnLineState 79 OnLineState 通过线体工位PC实现下达工位工作状态:工位有三种状态:在线、离线、屏蔽。在线:0正常状态,实现正常功能。1离线:设备脱离MES工作,进入不交互模式。 +///69 INT PartPalletCode 80 托盘号(MES) 托盘编号(B5A) +///70 INT BoltCode 88 BoltCode 手动拧紧工位:指导PLC所用套筒 +///71 INT RepairStatus 93 RepairStatus "0正常件,1返修件。对于上线工位MES给出是正常上线还是返修上线,返修路径" +///72 DInt Reserved_15 110 Reserved_15 备用 +///73 DInt Reserved_16 111 Reserved_16 备用 +///74 B Reserved_17 112 Reserved_17 备用 +///75 INT SPareint1 113 SPareint1 备用int1 +///76 INT SPareint2 114 SPareint2 备用int2 +///77 INT SPareint3 115 SPareint3 备用int3 +///78 STRING Sparestring1 116 Sparestring1 备用字符串1 +///79 STRING Sparestring2 117 Sparestring2 备用字符串2 +///80 X MachineStatusPutOn 1000 机床上电(PLC) 机床上电(必须PLC) +///81 X MachineStatusWorkOn 1001 循环开始(PLC) 循环开始(必须PLC) +///82 X MachineStatusAlarm 1002 设备报警(PLC) 机床故障(必须PLC) +///83 X MachineStatusNoPart 1003 MachineStatusNoPart 上料无件(必须PLC) +///84 X MachineStatusBlock 1004 MachineStatusBlock 下料堵塞(必须PLC) + + +namespace MisDataFunDll +{ + /// + /// 这是变量类型代码的配置,几乎是不变的 + /// 请不要随意修改,为了保证变量版本同一,并且方便维护,请联系发行人修改! + /// 请注意,此修改为全局修改! + /// + public enum EnumTagTypeCodeID + { + /// + /// 工件到位(PLC) + /// 变量类型:Bool + /// 解释:托盘到达工位,并且托盘上有工件。 + /// + WorkStart = 2, + /// + /// + /// + RepairPartStatusPLC = 3, + /// + /// 工位返修字符串 + /// 变量类型:String + /// 解释:工位返修字符串 + /// + RepairPathString = 4, + /// + /// 传递机型(MES) + /// 变量类型:Bool + /// 解释:MES传递总成信息给PLC(上线工位) + /// + EngineTypeGetOverMES = 5, + /// + /// + /// + PartPalletGoOver = 6, + /// + /// + /// + MaterialVerifyOver = 7, + /// + /// + /// + FalseGo = 8, + /// + /// + /// + EngineTypeID = 9, + /// + /// + /// + EngineID = 10, + /// + /// 机型(MES) + /// 变量类型:String + /// + EngineType = 11, + /// + /// + /// + PartPalletStatus = 13, + /// + /// + /// + HeartBeatPLC = 14, + /// + /// + /// + HeartBeatMIS = 15, + /// + /// + /// + TargetTimeRead = 16, + /// + /// + /// + MachineTargetTime = 17, + /// + /// + /// + MachineActualTime = 18, + /// + /// 允许保存(PLC) + /// 变量类型:Bool + /// + MesRead = 19, + /// + /// 保存完成(MES) + /// 变量类型:Bool + /// + MesReadOver = 20, + /// + /// 合格标志(PLC) + /// 变量类型:Int + /// + QualityMask = 21, + /// + /// + /// + PalletInfo = 22, + /// + /// + /// + RepairStatusPLC = 23, + /// + /// 订单号(MES) + /// 变量类型:Int + /// + OrderNo = 24, + /// + /// 库位号(MES) + /// 变量类型:Bool + /// + StorageNo = 25, + /// + /// 允许放行(MES) + /// 变量类型:Bool + /// + AllowPass = 26, + /// + /// + /// + PartLoadFinish = 27, + /// + /// + /// + Reserved_7 = 28, + /// + /// + /// + Reserved_8 = 29, + /// + /// + /// + Reserved_9 = 30, + /// + /// + /// + Reserved_10 = 31, + /// + /// + /// + Reserved_11 = 32, + /// + /// + /// + Reserved_12 = 33, + /// + /// + /// + Reserved_13 = 34, + /// + /// + /// + Reserved_14 = 35, + /// + /// + /// + PLCSPareint1 = 36, + /// + /// + /// + PLCSPareint2 = 37, + /// + /// + /// + PLCSPareint3 = 38, + /// + /// 订单号(PLC) + /// + OrderFormPLC = 39, + /// + /// + /// + PLCSarestring2 = 40, + /// + /// + /// + MarkID = 42, + /// + /// + /// + PartLoad = 43, + /// + /// 传递机型(PLC) + /// 变量类型:Bool + /// + EngineTypeGetOverPLC = 44, + /// + /// + /// + PartLoadOK = 48, + /// + /// + /// + Reserved_18 = 49, + /// + /// + /// + PalletDown = 50, + /// + /// + /// + ConfirmOkGo = 51, + /// + /// + /// + ResetDevice = 52, + /// + /// + /// + UnloadCompleted = 53, + /// + /// + /// + MachineTime_ReadOver = 54, + /// + /// + /// + Reserved_19 = 58, + /// + /// + /// + FixOK = 59, + /// + /// + /// + Reserved_21 = 61, + /// + /// + /// + Reserved_22 = 62, + /// + /// + /// + Reserved_23 = 63, + /// + /// + /// + Reserved_24 = 64, + /// + /// + /// + Reserved_25 = 65, + /// + /// + /// + FixAllow = 66, + /// + /// + /// + FixOver = 67, + /// + /// + /// + MatchingCompleted = 68, + /// + /// + /// + Match = 69, + /// + /// + /// + Reserved_2 = 70, + /// + /// + /// + IsAutoGetEngineID = 71, + /// + /// + /// + RepairUplineMES = 72, + /// + /// 机型代码(MES) + /// 变量类型:Int + /// + EngineTypeID_MES = 73, + /// + /// 工件编号(MES) + /// 变量类型:String + /// + EngineID_MES = 74, + /// + /// + /// + EngineType_MES = 75, + /// + /// + /// + Reserved_20 = 76, + /// + /// + /// + ProcessCode = 77, + /// + /// + /// + OnLineState = 79, + /// + /// 托盘号(MES) + /// 变量类型:Int + /// + PartPalletCode = 80, + /// + /// + /// + BoltCode = 88, + /// + /// + /// + RepairStatus = 93, + /// + /// + /// + Reserved_15 = 110, + /// + /// + /// + Reserved_16 = 111, + /// + /// + /// + Reserved_17 = 112, + /// + /// + /// + SPareint1 = 113, + /// + /// + /// + SPareint2 = 114, + /// + /// + /// + /// + /// MES订单号 + /// + OrdeFormMES = 116, + /// + /// + /// + Sparestring2 = 117, + /// + /// 机床上电(PLC) + /// 变量类型:Bool + /// + MachineStatusPutOn = 1000, + /// + /// 循环开始(PLC) + /// 变量类型:Bool + /// + MachineStatusWorkOn = 1001, + /// + /// 设备报警(PLC) + /// 变量类型:Bool + /// + MachineStatusAlarm = 1002, + /// + /// 上料无件(PLC) + /// 变量类型:Bool + /// + MachineStatusNoPart = 1003, + /// + /// 下料堵塞(PLC) + /// 变量类型:Bool + /// + MachineStatusBlock = 1004, + + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/Reflection.cs b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/Reflection.cs new file mode 100644 index 0000000..d7bd835 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/14MisDataFunctionDB/Reflection.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Reflection; +using System.Web; +using System.ComponentModel; + +namespace MisDataFunDll +{ + /// + /// + /// + public class Reflection + { + /// + /// 通过反射调用动态连接库方法 + /// + /// 程序集(DLL) + /// 命名空间名称,如果无命名空间写“” + /// 类名 + /// 方法名 + /// 函数参数数组 + static public string ReflectionMethod(Assembly assembly, string Namespace, string Classname, string Method, object[] Paramsters) + { + try + { + + Type t; + //类 + if (Namespace == "") + { + t = assembly.GetType(Classname); + } + else + { + t = assembly.GetType(Namespace + "." + Classname); + } + if (t == null) + { + return "类不存在"; + } + ////方法 + MethodInfo mi = t.GetMethod(Method); //获取方法 + if (mi == null) + { + return "方法不存在"; + } + ParameterInfo[] paramsInfo = mi.GetParameters(); + for (int i = 0; i < paramsInfo.Length; i++) + { + Type tType = paramsInfo[i].ParameterType; + //改变参数类型 + Paramsters[i]= SD_ChanageType(Paramsters[i],tType); + } + /// 建一个实例化的类 + object instanceObject = Activator.CreateInstance(t); + mi.Invoke(instanceObject, Paramsters); + return "ok"; + } + catch(Exception err) + { + return err.ToString(); + + } + + } + /// + /// + /// + /// + /// + /// + public static object SD_ChanageType(object value, Type convertsionType) + { + //判断convertsionType类型是否为泛型,因为nullable是泛型类, + if (convertsionType.IsGenericType && + //判断convertsionType是否为nullable泛型类 + convertsionType.GetGenericTypeDefinition().Equals(typeof(Nullable<>))) + { + if (value == null || value.ToString().Length == 0) + { + return null; + } + + //如果convertsionType为nullable类,声明一个NullableConverter类,该类提供从Nullable类到基础基元类型的转换 + NullableConverter nullableConverter = new NullableConverter(convertsionType); + //将convertsionType转换为nullable对的基础基元类型 + convertsionType = nullableConverter.UnderlyingType; + } + return Convert.ChangeType(value, convertsionType); + } + } +} \ No newline at end of file diff --git a/Common/09MesDataFunction/MesDataFunction/LoadTagTypeCodeID.cs b/Common/09MesDataFunction/MesDataFunction/LoadTagTypeCodeID.cs new file mode 100644 index 0000000..8418da8 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/LoadTagTypeCodeID.cs @@ -0,0 +1,128 @@ +//using BasicData; +//using MesWork; +//using OpcBasic; +using MesServerWork; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static MesServerWork.MIS_BASE; + +namespace MesDataFunction +{ + public class LoadTagTypeCodeID + { + + + public static void Load(string path) + { + MIS_BASE.hashtable_TagType = new NameValueCollection(); + MIS_BASE.hashtable_TagTypeTagName = new NameValueCollection(); + MIS_BASE.hashtable_TagTypeChange = new NameValueCollection(); + MIS_BASE.hashtable_MesTagTypeChange = new NameValueCollection(); + MIS_BASE.hashtable_WebTagTypeChange = new NameValueCollection(); + MIS_BASE.hashtable_TagTypeDataType = new NameValueCollection(); + + var dt = NPOITest.ExeclHelper.ExcelToDataTable(path, "变量类型代码", true); + for (int i = 0; i < dt.Rows.Count; i++) + { + //序号 变量类型 TagTypeDataType TagName 变量类型代码 TagTypeChange MesTagTypeChange WebTagTypeChange 信号点名称 变量类型名称 + + var TagTypeDataType = dt.Rows[i]["TagTypeDataType"].ToString(); + var TagName = dt.Rows[i]["TagName"].ToString(); + var 变量类型代码 = dt.Rows[i]["变量类型代码"].ToString(); + var TagTypeChange = dt.Rows[i]["TagTypeChange"].ToString(); + var WebTagTypeChange = dt.Rows[i]["WebTagTypeChange"].ToString(); + var MesTagTypeChange = dt.Rows[i]["MesTagTypeChange"].ToString(); + + //OpcOperation.hashtable_TagType.Add(TagName, 变量类型代码); + //OpcOperation.hashtable_TagTypeTagName.Add(变量类型代码, TagName); + //OpcOperation.hashtable_TagTypeChange.Add(TagName, TagTypeChange); + //OpcOperation.hashtable_MesTagTypeChange.Add(TagName, MesTagTypeChange); + //OpcOperation.hashtable_WebTagTypeChange.Add(TagName, WebTagTypeChange); + //OpcOperation.hashtable_TagTypeDataType.Add(变量类型代码, TagTypeDataType); + if (!MIS_BASE.hashtable_TagType.AllKeys.Contains(TagName)) + MIS_BASE.hashtable_TagType.Add(TagName, 变量类型代码); + if (!MIS_BASE.hashtable_TagTypeTagName.AllKeys.Contains(变量类型代码)) + MIS_BASE.hashtable_TagTypeTagName.Add(变量类型代码, TagName); + if (!MIS_BASE.hashtable_TagTypeChange.AllKeys.Contains(TagName)) + MIS_BASE.hashtable_TagTypeChange.Add(TagName, TagTypeChange); + if (!MIS_BASE.hashtable_MesTagTypeChange.AllKeys.Contains(TagName)) + MIS_BASE.hashtable_MesTagTypeChange.Add(TagName, MesTagTypeChange); + if (!MIS_BASE.hashtable_WebTagTypeChange.AllKeys.Contains(TagName)) + MIS_BASE.hashtable_WebTagTypeChange.Add(TagName, WebTagTypeChange); + if (!MIS_BASE.hashtable_TagTypeDataType.AllKeys.Contains(变量类型代码)) + MIS_BASE.hashtable_TagTypeDataType.Add(变量类型代码, TagTypeDataType); + } + HashtableList.hashtable_TagTypeTagName_Temp = new Hashtable(); + foreach (string key in MIS_BASE.hashtable_TagTypeTagName.Keys) + { + HashtableList.hashtable_TagTypeTagName_Temp.Add(key, MIS_BASE.hashtable_TagTypeTagName[key]); + } + HashtableList.hashtable_TagTypeDataType_Temp = new NameValueCollection(); + foreach (string key in MIS_BASE.hashtable_TagTypeDataType.Keys) + { + HashtableList.hashtable_TagTypeDataType_Temp.Add(key, MIS_BASE.hashtable_TagTypeDataType[key]); + } + HashtableList.hashtable_TagType_Temp = new NameValueCollection(); + foreach (string key in MIS_BASE.hashtable_TagType.Keys) + { + HashtableList.hashtable_TagType_Temp.Add(key, MIS_BASE.hashtable_TagType[key]); + } + } + + public static void Load(DataTable dt) + { + MIS_BASE.hashtable_TagType = new NameValueCollection(); + MIS_BASE.hashtable_TagTypeTagName = new NameValueCollection(); + MIS_BASE.hashtable_TagTypeChange = new NameValueCollection(); + MIS_BASE.hashtable_MesTagTypeChange = new NameValueCollection(); + MIS_BASE.hashtable_WebTagTypeChange = new NameValueCollection(); + MIS_BASE.hashtable_TagTypeDataType = new NameValueCollection(); + + for (int i = 0; i < dt.Rows.Count; i++) + { + //序号 变量类型 TagTypeDataType TagName 变量类型代码 TagTypeChange MesTagTypeChange WebTagTypeChange 信号点名称 变量类型名称 + var TagTypeDataType = dt.Rows[i]["TagTypeDataType"].ToString(); + var TagName = dt.Rows[i]["TagName"].ToString(); + var 变量类型代码 = dt.Rows[i]["变量类型代码"].ToString(); + var TagTypeChange = dt.Rows[i]["TagTypeChange"].ToString(); + var WebTagTypeChange = dt.Rows[i]["WebTagTypeChange"].ToString(); + var MesTagTypeChange = dt.Rows[i]["MesTagTypeChange"].ToString(); + if (!MIS_BASE.hashtable_TagType.AllKeys.Contains(TagName)) + MIS_BASE.hashtable_TagType.Add(TagName, 变量类型代码); + if (!MIS_BASE.hashtable_TagTypeTagName.AllKeys.Contains(变量类型代码)) + MIS_BASE.hashtable_TagTypeTagName.Add(变量类型代码, TagName); + if (!MIS_BASE.hashtable_TagTypeChange.AllKeys.Contains(TagName)) + MIS_BASE.hashtable_TagTypeChange.Add(TagName, TagTypeChange); + if (!MIS_BASE.hashtable_MesTagTypeChange.AllKeys.Contains(TagName)) + MIS_BASE.hashtable_MesTagTypeChange.Add(TagName, MesTagTypeChange); + if (!MIS_BASE.hashtable_WebTagTypeChange.AllKeys.Contains(TagName)) + MIS_BASE.hashtable_WebTagTypeChange.Add(TagName, WebTagTypeChange); + if (!MIS_BASE.hashtable_TagTypeDataType.AllKeys.Contains(变量类型代码)) + MIS_BASE.hashtable_TagTypeDataType.Add(变量类型代码, TagTypeDataType); + } + HashtableList.hashtable_TagTypeTagName_Temp = new Hashtable(); + foreach (string key in MIS_BASE.hashtable_TagTypeTagName.Keys) + { + HashtableList.hashtable_TagTypeTagName_Temp.Add(key, MIS_BASE.hashtable_TagTypeTagName[key]); + } + HashtableList.hashtable_TagTypeDataType_Temp = new NameValueCollection(); + foreach (string key in MIS_BASE.hashtable_TagTypeDataType.Keys) + { + HashtableList.hashtable_TagTypeDataType_Temp.Add(key, MIS_BASE.hashtable_TagTypeDataType[key]); + } + HashtableList.hashtable_TagType_Temp = new NameValueCollection(); + foreach (string key in MIS_BASE.hashtable_TagType.Keys) + { + HashtableList.hashtable_TagType_Temp.Add(key, MIS_BASE.hashtable_TagType[key]); + } + } + + } + +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/InitTagValueListData.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/InitTagValueListData.cs new file mode 100644 index 0000000..e4cc6aa --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/InitTagValueListData.cs @@ -0,0 +1,83 @@ +//using DataLinkMesWork; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +//using SystemFramework; + +namespace MesServerWork +{ + public class InitTagValueListData + { + public InitTagValueListData() + { + DataTable dt = ReadMesServerData(); + + InitMesReadTagKey(); + initAllItemValue(dt); + } + + DataTable ReadMesServerData() + { + return null;// MesWork.PlcLinkForm.dt_BasicData.Select($"是否启用 = 1 and 监控属性代码 = '{1}'").CopyToDataTable(); + } + + void InitMesReadTagKey() + { + DataTable dt = null;// MesWork.PlcLinkForm.dt_BasicData.Select($"是否启用 = 1 and 变量类型代码=19 and 监控属性代码 = '{1}'").CopyToDataTable(); ; + + for (int i = 0; i < dt.Rows.Count; i++) + { + if (MesReadTagKey_Hash.ContainsKey(dt.Rows[i]["工位号"].ToString())) + { + MesReadTagKey_Hash[dt.Rows[i]["工位号"].ToString()] = dt.Rows[i]["TagID"].ToString(); + } + else + { + MesReadTagKey_Hash.Add(dt.Rows[i]["工位号"].ToString(), dt.Rows[i]["TagID"].ToString()); + } + + } + + } + void initAllItemValue(DataTable dt) + { + for (int i = 0; i < dt.Rows.Count; i++) + { + if (ItemValue_Hash.ContainsKey(dt.Rows[i]["TagID"])) + { + if (Convert.ToInt32(dt.Rows[i]["列位置"]) != 0) + { + ItemValue_Hash[dt.Rows[i]["TagID"]] = dt.Rows[i]["测量项目"].ToString() + "(" + dt.Rows[i]["列位置"].ToString() + ")"; + } + else + { + ItemValue_Hash[dt.Rows[i]["TagID"]] = dt.Rows[i]["测量项目"].ToString(); + } + + } + else + { + if (Convert.ToInt32(dt.Rows[i]["列位置"]) != 0) + { + ItemValue_Hash[dt.Rows[i]["TagID"]] = dt.Rows[i]["测量项目"].ToString() + "(" + dt.Rows[i]["列位置"].ToString() + ")"; + } + else + { + ItemValue_Hash[dt.Rows[i]["TagID"]] = dt.Rows[i]["测量项目"].ToString(); + } + } + + } + + + } + + + public static Hashtable MesReadTagKey_Hash = new Hashtable(); + public static Hashtable ItemValue_Hash = new Hashtable(); + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.Barcode.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.Barcode.cs new file mode 100644 index 0000000..1df2dfe --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.Barcode.cs @@ -0,0 +1,95 @@ +using System; +using System.Data; +using System.Collections; + +using System.Windows.Forms; +//using bizFacade; +using System.Collections.Specialized; +//using MesWork; +//using SystemFramework; +using bizFacade; + +namespace MesServerWork +{ + public partial class MIS_BASE + { + static object lockerBarcode = new object(); + + /// + ///1.扫描配送单号,用于接收物料,扫描单号的时候,将接收的物料信息显示在“物料拉动”Tab区域 + ///2.扫描料箱标签/看板卡,用于追溯物料批次信息 + ///3.扫描零件条码,根据零件图号进行防错 + ///第一步,判断条码类型,根据条码类型,执行对应的存储过程 + ///第二步,条码类型(将扫描的条码保存到对应的表中) + ///第三步,扫描完成之后给出允许工作信号 + /// 处理页面扫描条码 + /// + /// + /// + static public void Barcode(object e) + { + lock (lockerBarcode) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string barcode = Convert.ToString(msgEvent.TagValue); + string AlarmStr = ""; + + int IsAllowWork; + bool IsSuccess = false; + bool EngineGetOver_PLC_NextWorkStep; + //传递机型是否到位 + MIS_BASE.Read_EngineGetOver_PLC(OpName, out EngineGetOver_PLC_NextWorkStep); + + BaseDataSystemMES.PartMaterial_DM_Update(OpName, barcode, out IsSuccess); + if (!IsSuccess) + { + AsyncSendMessage_Notice(OpName, "条码无效,请确认"); + return; + } + else + { + SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息 + } + + + + //获取是否允许工作 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + //此处逻辑有问题 需要考虑到批次扫描 提示PLC未传递机型的情况 + if (EngineGetOver_PLC_NextWorkStep && IsSuccess) + { + if (IsAllowWork == 1) + { + BaseDataSystemMES.Material_Insert(OpName, 1); + + //if (!BaseDataSystemMES.QualityVerifyStatusOutline(OpName, out AlarmStr)) + //{ + // SendInfomation("LineoutAlert", AlarmStr, OpName); + // return; + //} + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + } + else + { + AsyncSendMessage_Notice(OpName, "PLC未传递机型"); + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:Barcode"); + } + } + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.ConfirmOkGo.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.ConfirmOkGo.cs new file mode 100644 index 0000000..26b9cfa --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.ConfirmOkGo.cs @@ -0,0 +1,47 @@ +using System; +using System.Data; +using System.Collections; + +using System.Windows.Forms; +//using bizFacade; +using System.Collections.Specialized; +//using MesWork; +//using SystemFramework; + +namespace MesServerWork +{ + public partial class MIS_BASE + { + static object lockerConfirmOkGo = new object(); + + static public void ConfirmOkGo(object e) + { + lock (lockerConfirmOkGo) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + + //BaseDataSystemMES.Material_Insert(OpName, 1); + + //更新订单完工数量及物料 + Sendmessage("24", "11", OpName); + + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:ConfirmOkGo"); + } + } + + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.EngineTypeGetOver_PLC_Work.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.EngineTypeGetOver_PLC_Work.cs new file mode 100644 index 0000000..670819c --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.EngineTypeGetOver_PLC_Work.cs @@ -0,0 +1,139 @@ +using System; +using System.Data; +using System.Collections; + +using System.Windows.Forms; +//using bizFacade; +using System.Collections.Specialized; +//using MesWork; +//using SystemFramework; +using bizFacade; + +namespace MesServerWork +{ + public partial class MIS_BASE + { + static object lockerEngineTypeGetOver_PLC_Work = new object(); + + + static public void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code,string OrderForm) + { + lock (lockerEngineTypeGetOver_PLC_Work) + { + int IsAllowWork; + int RepairPartStatusPLC = 0; + int MES_QualityMask = 1; + //string OrderForm = "";//订单号 + DataTable dt; + + if (EngineTypeID <= 0) + { + AsyncSendMessage_Notice(OpName, "PLC传递机型为空"); + return; + } + + //第一步,查询订单号,保存机型、机型代码、总成号、托盘号、订单号到数据库 + BaseDataSystemMES.GetEngineID_Select(OpName, EngineID, out dt); + if (dt != null && dt.Rows.Count > 0) + { + OrderForm = Convert.ToString(dt.Rows[0]["订单号"]); + } + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, OrderForm, EngineTypeID, EngineType, EngineID, PartPallet_Code, 0, 0, ""); + SaveMobyMessage(OpName, EngineTypeID, EngineType, EngineID, OrderForm); + + //第二步,将零件信息转移到零件_临时表中(本地BOM与订单BOM的选择显示关系) + BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName); + + //通知web显示 + Sendmessage("5123", "1111", OpName); + MIS_BASE.Read_PalletInfo(OpName, out MES_QualityMask);//合格标志 + MIS_BASE.Read_RepairStatus_PLC(OpName, out RepairPartStatusPLC);//返修标志 + SendInfomation("QualityMask", Convert.ToString(MES_QualityMask), OpName);//显示合格标志 + SendInfomation("RepairPartStatusPLC", Convert.ToString(RepairPartStatusPLC), OpName);//显示返修标志 + + if (MES_QualityMask == 2) + { + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + SendInfomation("NgGO", "1", OpName);//显示不合格标志 + return; + } + + + //第三步,用于工件离开后完工数量统计及工件编号追溯 + BaseDataSystemMES.MaterialPush_EngineIDStatus_Insert(OpName);//更新订单产量 + + //第四步,获取是否允许工作 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + //暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况 + if (IsAllowWork == 1) + { + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + } + + + } + + /// + /// 保存MOBY信息 + /// + /// + /// + /// + /// + static private void SaveMobyMessage(string OpName, int engineTypeID, string engineType, string engineID, string orderForm) + { + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineTypeID[OpName] = engineTypeID; + } + if (MIS_BASE.hashtable_EngineGetOver_EngineType.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineType[OpName] = engineType; + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineID[OpName] = engineID; + } + if (MIS_BASE.hashtable_EngineGetOver_OrderForm.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_OrderForm[OpName] = orderForm; + } + } + + /// + /// 返修件需要工作 + /// + /// 工位号 + static private void IsNeedRepaire_OK(string OpName) + { + string orderForm = ""; + int engineTypeID; + string engineType = ""; + string engineID = ""; + string palletCode = ""; + int isRepair; + string repairCode = ""; + //从监控系统中查询出本工位信息 + BaseDataSystemMES.OpName_MIS_Moby_Select(OpName, + out orderForm, out engineTypeID, out engineType, + out engineID, out palletCode, out isRepair, out repairCode); + + EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode),orderForm); + } + + + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.FalseGO.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.FalseGO.cs new file mode 100644 index 0000000..92ee314 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.FalseGO.cs @@ -0,0 +1,48 @@ +using System; +using System.Data; +using System.Collections; + +using System.Windows.Forms; +//using bizFacade; +using System.Collections.Specialized; +//using MesWork; +//using SystemFramework; + +namespace MesServerWork +{ + public partial class MIS_BASE + { + static object lockerFalseGO = new object(); + + + static public void FalseGO(object e) + { + lock (lockerConfirmOkGo) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + //总合格标志2(不合格) + + //BaseDataSystemMES.Material_Insert_NG(OpName, 2); + + Sendmessage("24", "11", OpName); + + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.Material_Insert.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.Material_Insert.cs new file mode 100644 index 0000000..fc78eb6 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.Material_Insert.cs @@ -0,0 +1,59 @@ +using System; +using System.Data; +using System.Collections; + +using System.Windows.Forms; +//using bizFacade; +using System.Collections.Specialized; +//using MesWork; +//using SystemFramework; +using bizFacade; + +namespace MesServerWork +{ + public partial class MIS_BASE + { + static object lockerMaterial_Insert = new object(); + + static public void Material_Insert(string OpName) + { + lock (lockerMaterial_Insert) + { + try + { + //int tagValue = Convert.ToInt32(msgEvent.TagValue); + int IsAllowWork; + //第四步,获取是否允许工作 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + bool EngineGetOver_PLC_NextWorkStep; + //传递机型是否到位 + MIS_BASE.Read_EngineGetOver_PLC(OpName, out EngineGetOver_PLC_NextWorkStep); + + //暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况 + if (EngineGetOver_PLC_NextWorkStep&&IsAllowWork == 1) + { + BaseDataSystemMES.Material_Insert(OpName, 1); + + //更新订单完工数量及物料 + Sendmessage("24", "11", OpName); + + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:ConfirmOkGo"); + } + } + + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.MesReadOver.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.MesReadOver.cs new file mode 100644 index 0000000..260cd1a --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.MesReadOver.cs @@ -0,0 +1,66 @@ +using System; +using System.Data; +using System.Collections; + +using System.Windows.Forms; +//using bizFacade; +using System.Collections.Specialized; +//using MesWork; +//using SystemFramework; + +namespace MesServerWork +{ + public partial class MIS_BASE + { + static object lockerMesReadOver = new object(); + + /// + /// 保存完成(针对半自动和手动压装工位) + /// + /// + /// + static public void MesReadOver(object e) + { + lock (lockerMesReadOver) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + var tagValue = msgEvent.TagValue.ToString(); + + if (tagValue == "1" | tagValue.ToLower() == "true") + { + int qualityMask; + MIS_BASE.Read_QualityMask(OpName, out qualityMask); + + SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName);//发给Web页面显示质量数据 + + if (qualityMask == 1)//全部OK,给出合格放行 + { + //如果存在线外扫描工位,根据扫描条码绑定线外数据 需要时解除禁用 + //BaseDataSystemMES.TransLaunchDataByMainMaterial(OpName, EngineType, EngineID, EngineTypeID); + + //如果存在线外排队工位,根据排队编号绑定线外数据 需要时解除禁用 + ////BaseDataSystemMES.MailLineAndSubLineData_InsertByEngineID_Subline(OpName,EngineID, EngineTypeID, EngineType); + + MIS_BASE.Write_ConfirmOkGo(OpName, true); + //MIS_BASE.Write_FalseGO(OpName, false); + } + else + { + //MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FalseGO(OpName, true); + } + + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:MesReadOver"); + } + } + + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.SendMessage.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.SendMessage.cs new file mode 100644 index 0000000..92bfe0a --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.SendMessage.cs @@ -0,0 +1,162 @@ +using System; +using System.Data; +using System.Collections; + +using System.Windows.Forms; +//using bizFacade; +using System.Collections.Specialized; +//using MesWork; +//using SystemFramework; +using bizFacade; + +namespace MesServerWork +{ + public partial class MIS_BASE + { + + /// + /// 发送提示消息 + /// + /// + static private void AsyncSendMessage_Notice(string opname, string notice) + { + //通知Web界面 + BaseDataSystemMES.Web_Notice_Insert(opname, notice); + string SendMessage = "MES|Notice|" + opname + "|" + "1"; + MIS_BASE.asyncSendMessage(SendMessage); + } + + /// + /// 向WEB发送信息(value为字符串) + /// + /// 消息种类 + /// 消息内容 + /// 工位号 + static public string SendInfomation(string Command, string Value, string OpName) + { + string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value; + return AsyncSendMessage(SendMessage); + } + + /// + /// 发送信息到MES通讯服务器或者其他的 + /// + /// + static private string AsyncSendMessage(string Message) + { + return MIS_BASE.asyncSendMessage(Message); + } + + + /// + /// 批量发送WEB消息(Value为BOOL值) + /// + /// 消息编号组合 + /// 消息值组合 + /// 工位号 + static void Sendmessage(string MessageNumm, string Value, string OpName) + { + for (int i = 0; i < MessageNumm.Length; i++) + { + Sendmessage(MessageNumm[i], Value[i].ToString(), OpName); + + } + } + /// + /// 选择发送给WEB的消息 + /// + /// 消息类型 + /// 消息工位 + static string Sendmessage(char Num, string Value, string OpName) + { + string SendMessage; + string result = ""; + switch (Num) + { + case '1': + //1(直接在界面通过选择机型确认工序内容) + SendMessage = "MES|ProcessList|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '2': + //2显示物料 + SendMessage = "MES|MaterialList|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '3': + //3显示操作指导图片 + SendMessage = "MES|PicShow|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '4': + //4订单完工模块刷新完成数量 + SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '5': + SendMessage = "MES|ShowMoby|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '6': + SendMessage = "MES|MaterialCheckPosition|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '7': + SendMessage = "MES|WorkStart|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '8'://清除MES生成编号 + + break; + case '9': + SendMessage = "MES|ConfirmOkGo|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case 'a': + SendMessage = "MES|FixAllow|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + } + return result; + } + ///// + ///// 向WEB发送信息(value为字符串) + ///// + ///// 消息种类 + ///// 消息内容 + ///// 工位号 + //string SendInfomation(string Command, string Value, string OpName) + //{ + // string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value; + // return AsyncSendMessage(SendMessage); + //} + + + /// + /// 发送在线产量、在线节拍 + /// + /// + /// + private void SendActuallyCount(string OpName, int tagValue) + { + //当工件离开时,更新在线产量、在线节拍 + if (tagValue == 0) + { + try + { + int opNameCount = 0;//在线产量 + int opNameCountTime = 0;//在线节拍 + //基本数据_工作日历_班次产量查询_New + BaseDataSystemMES.OpNameCount_New(OpName, out opNameCount, out opNameCountTime); + string SendMessage; + SendMessage = "MES|ActuallyCount|" + OpName + "|" + opNameCount.ToString() + "&" + opNameCountTime.ToString(); + AsyncSendMessage(SendMessage); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:SendActuallyCount"); + } + } + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.WebSubmit.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.WebSubmit.cs new file mode 100644 index 0000000..e472489 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.WebSubmit.cs @@ -0,0 +1,282 @@ +using System; +using System.Data; +using System.Collections; + +using System.Windows.Forms; +//using bizFacade; +using System.Collections.Specialized; +//using MesWork; +//using SystemFramework; +using System.Threading; +using bizFacade; + +namespace MesServerWork +{ + public partial class MIS_BASE + { + static object lockerWebSubmit = new object(); + + + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + static public void WebSubmit(object e) + { + lock (lockerWebSubmit) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string Content = Convert.ToString(msgEvent.TagValue); + + string[] dataArray = Content.Split('|'); + if (dataArray.Length != 2) + return; + //消息类型 + string m_Command = dataArray[0].ToString(); + //消息参数 + string m_Value = dataArray[1].ToString(); + //消息参数数量 + string[] m_Value_array = m_Value.Split('&'); + //消息参数长度 + int m_Value_length = m_Value_array.Length; + + //工件信息 + string engineID = ""; + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + engineID = MIS_BASE.hashtable_EngineGetOver_EngineID[OpName].ToString(); + } + + DoWhatPlc.CustomeEvetnArgs _e = new DoWhatPlc.CustomeEvetnArgs(); + _e.OpName = OpName; + _e.TagValue = m_Value; + + //根据请求的命令处理逻辑 + switch (m_Command) + { + case "Barcode": + if (m_Value_length > 1) return; + fun_Barcode(_e); + break; + case "ConfirmOkGo"://合格放行 + //删除不合格放行记录 + //修改托盘状态 + //Update_PalletStatus(OpName, 1, false); + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_ConfirmOkGo(OpName, true); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "FalseGO"://返修放行 + //修改托盘状态 + //Update_PalletStatus(OpName, 3, false); + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + break; + case "NgGO"://不合格放行 + //修改托盘状态 + //Update_PalletStatus(OpName, 2, false); + //保存不合格信息(必须保存不合格放行信息,由于B5A的Moby没有不合格标志位) + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Insert(OpName, engineID, "", ""); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + break; + case "OnLineState"://在线0、离线1、屏蔽2 + try + { + if (m_Value_length > 1) return; + int a = Convert.ToInt32(m_Value); + if (a <= 2) + { + BaseDataSystemMES.IsOnLine_Update(OpName, m_Value.ToString()); + MIS_BASE.Write_OnLineState(OpName, Convert.ToInt32(m_Value)); + } + } + catch + { + + } + break; + case "Reset"://复位,将MES所有的信息都复位了 + SetMoby(OpName);//将MES所有信号清空 + break; + case "FixAllow"://重新拧紧 + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_FixAllow(OpName, true); + break; + case "IsAutoGetEngineID"://自动手动申请编号(线首) + if (m_Value_length > 1) return; + MIS_BASE.Write_IsAutoGetEngineID(OpName, Convert.ToInt32(m_Value)); + break; + case "PartPalletGoOver"://空托盘放行 + int Is_PartPalletGoOver; + MIS_BASE.Read_PartPalletGoOver(OpName, out Is_PartPalletGoOver); + if (Is_PartPalletGoOver == 1) + { + MIS_BASE.Write_PartPalletGoOver(OpName, 1); + } + else + { + MIS_BASE.Write_PartPalletGoOver(OpName, 0); + } + break; + case "SetMoby"://清空托盘(线首) + SetMoby(OpName);//将MES所有信号清空 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "RepairUplineMES"://返修上线 + MIS_BASE.Write_RepairUpline_MES(OpName, true); + break; + case "CancelRepair"://将返修件置为正常件 + + break; + case "PartPalletCode"://申请写入托盘号 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "WritePartPalletCode"://写入托盘号 + if (m_Value_length > 1) return; + MIS_BASE.Write_PalletCode(OpName, Convert.ToInt32(m_Value)); + break; + case "Normal"://启用正常拧紧工位 + MIS_BASE.Write_Normal(OpName, 1); + MIS_BASE.Write_UnNormal(OpName, 0); + break; + case "UnNormal"://启用备用拧紧工位 + MIS_BASE.Write_Normal(OpName, 0); + MIS_BASE.Write_UnNormal(OpName, 1); + break; + case "ResetDevice"://复位设备 + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + break; + case "IsNeedRepaire"://返修上线(返修上线点) + if (Convert.ToInt32(m_Value) == 1) + { + //修改托盘状态 + MIS_BASE.Write_PalletInfo(OpName, 3); + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + IsNeedRepaire_OK(OpName); + + } + else if (Convert.ToInt32(m_Value) == 0) + { + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + else + { } + + break; + case "ContinueMatch": + BaseDataSystemMES.QualityVerifyStatus_Hash_Write(OpName, true); + break; + //初始化网页信号 + case "IniSingalToWeb": + InitializeSingalToWeb(OpName); + break; + case "Reset_Engine"://返修上线(返修上线点) + SetMoby(OpName);//将MES所有信号清空 + //fun_EngineTypeGetOverPLC(OpName, 0); + //fun_EngineTypeGetOverPLC(OpName, 1); + break; + + + default: break; + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WebSubmit"); + } + } + + } + + //1.工件到位后,PLC给MES传递机型(DBX0.4)(44), + //MES判断条码是否全部扫描完成 + //PLC给出允许保存(DBX100.2)(19),MES见到(DBX100.2)(19)为1后给出保存完成(DBX102.2)(20), + //PLC见到保存完成(DBX102.2)(20)为1后,清空允许保存(DBX100.2)(19), + //MES见到允许保存(DBX100.2)(19)为0后,清空保存完成(DBX102.2)(20) + //MES判断总合格标志(INT104)(21)为1后,给出合格放行(DBX2.5)(51) + /// + /// 扫描条码 + /// + /// + /// + static public void fun_Barcode(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(Barcode, e); + } + static private void SetMoby(string OpName) + { + try + { + //清空Moby时,需要将MES信号清空 + MIS_BASE.Write_ClearMesMoby(OpName); + + BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName); + + Sendmessage("5123", "1111", OpName); + + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + } + catch + { + + } + } + /// 网页重现登录,恢复关闭前的页面状态 + /// + /// 工位号 + static private void InitializeSingalToWeb(string Opname) + { + + //工件到位 DBX0.1 + bool S_WorkStart; + bool S_FixAllow; + bool S_EngineGetOver; + bool S_MaterialVerifyOver; + + MIS_BASE.Read_WorkStart(Opname, out S_WorkStart); + MIS_BASE.Read_FixAllow(Opname, out S_FixAllow); + MIS_BASE.Read_EngineGetOver_PLC(Opname, out S_EngineGetOver); + MIS_BASE.Read_MaterialVerifyOver(Opname, out S_MaterialVerifyOver); + + + + if (S_WorkStart == true) + { + SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname); + } + + if (S_EngineGetOver == true) + { + + SendInfomation("EngineTypeGetOverPLC", Convert.ToString(Convert.ToInt32(S_EngineGetOver)), Opname); + Sendmessage("5123", "1111", Opname); + } + if (S_FixAllow == true) + { + SendInfomation("FixAllow", Convert.ToString(Convert.ToInt32(S_FixAllow)), Opname); + } + if (S_MaterialVerifyOver == true) + { + SendInfomation("MaterialVerifyOver", Convert.ToString(Convert.ToInt32(S_MaterialVerifyOver)), Opname); + } + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.WorkStart.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.WorkStart.cs new file mode 100644 index 0000000..ec1d4c4 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Functions.WorkStart.cs @@ -0,0 +1,45 @@ +using System; +using System.Data; +using System.Collections; + +using System.Windows.Forms; +////using bizFacade; +using System.Collections.Specialized; +//using MesWork; +//using SystemFramework; +using System.Threading; + +namespace MesServerWork +{ + public partial class MIS_BASE + { + static object lockerWorkStart = new object(); + + + + /// + /// 工件到位与离开时,清空MES自身信号 + /// + /// + /// + static private void WorkStart(object e) + { + lock (lockerWorkStart) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WorkStart"); + } + } + + } + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Hashtable.TagID.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Hashtable.TagID.cs new file mode 100644 index 0000000..bc3387a --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Hashtable.TagID.cs @@ -0,0 +1,805 @@ +using System; +using System.Data; +using System.Collections; + +using System.Windows.Forms; +//using bizFacade; +using System.Collections.Specialized; +using MisDataFunDll; +//using MesWork; + + +namespace MesServerWork +{ + public partial class MIS_BASE // : Form + { + /// + /// 全部数据列表 + /// + public static DataTable BasicDataTagValue; + /// + /// MES_基本数据_测量范围 + /// + public static DataTable BasicDataTagValueUpDown; + /// + /// 是否通过监控系统保存数据 + /// 1:通过监控系统保存采集的质量数据;0:不通过监控系统保存采集的质量数据 + /// + static public Hashtable hashtable_tagTable_OpName_SaveData; + /// + /// 变量代码与列位置 + /// + static public Hashtable hashtable_tagTable_TagID_TagOrderBy; + /// + /// 变量代码与变量排序 + /// + static public Hashtable hashtable_tagTable_TagID_TagItemOrderBy; + /// + /// 变量代码与变量特点 + /// 0:没定义1:工位合格标志2:需要合格标志的测量数据3:每个工位的合格标志4:物料5:IQA码6:压装数据7:压装合格标志8:(自动拧紧)工位合格标志 + /// + static public Hashtable hashtable_tagTable_TagID_TagProperty; + /// + /// 发动机类型转换表 + /// SELECT ID,发动机机型代码 FROM MES_计划BOM_发动机型号代码 + /// + public static Hashtable hashtable_EngineTypeID; + + /// + /// 工位号与工位上下线类型 + /// (0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线) + /// (5分线上线 总线)(6分线上线 分线) + /// + public static Hashtable hashtableOpName_OpType; + /// + /// 工位号与大屏幕代码 + /// 对应LED大屏幕(1,2,3,4) + /// + public static Hashtable hashtableOpName_LedID; + /// + /// 大屏幕显示产量端口(41104) + /// + public static Hashtable hashtableOpName_LedID_Port; + + /// + /// 大屏幕显示Andon大屏幕代码 1 + /// + public static Hashtable hashtableOpName_AndonID; + + /// + /// 大屏幕显示Andon端口 (41105) + /// + public static Hashtable hashtableOpName_AndonID_Port; + + + /// + /// 是否有打印机(0,1) + /// + public static Hashtable hashtableOpName_IsPrinter; + + /// + /// 打印机通讯端口 + /// + public static Hashtable hashtableOpName_IsPrinter_Port; + + + + /// + /// 工位号与目标循环时间 + /// + public static Hashtable hashtableOpName_TargetTime; + /// + /// 工位号与线体类型 + /// + public static Hashtable hashtableOpName_LineType; + /// + /// 是否有工位计算机 + /// + public static Hashtable hashtableOpName_IsHaveComputer; + /// + /// 变量名称 + /// + public static Hashtable hashtableTagID_TagName; + /// + /// 工位号 + /// + public static Hashtable hashtableTagID_OpName; + /// + /// 数据来源 + /// + public static Hashtable hashtableTagID_OpNameFrom; + + /// + /// 工位名称 + /// + static Hashtable hashtableTagID_OpName_Name; + /// + /// 测量位置 + /// + public static Hashtable hashtableTagID_ShaftID; + /// + /// 测量项目 + /// + public static Hashtable hashtableTagID_ItemVale; + /// + /// 变量代码与变量类型 + /// + public static Hashtable hashtable_tagTable_TagID_TagTypeID_All; + + + + /// + ///工位号与机床状态 + /// [测量数据机床状态] + /// + public static Hashtable m_MachineStatus_OpName; + /// + ///工位号与工件离开 1->0 =0 无工件或工件离开 + ///工位号与工件到位 0->1 =1 有工件或工件到达 + ///[测量数据发动机在线状态] + /// + public static Hashtable m_WorkStart_OpName; + + /// + ///工位号与工件到位时间 + ///工位号与工件到位 0->1 + ///[测量数据发动机在线状态] + /// + public static Hashtable m_WorkStart_OpName_Time; + + /// + ///工位号与工件到位时间 + ///工位号与工件到位 0->1,零件运动方向 + /// + public static Hashtable m_WorkStart_OpName_PartMoveDirection; + + + /// + ///工位号与发动机号 + /// + public static Hashtable m_EngineTrace_OpName; + /// + ///工位号与发动机号_时间 + /// + public static Hashtable m_EngineTrace_OpName_Time; + /// + ///工位号与合格标志 + ///[测量数据发动机在线状态] + /// + public static Hashtable m_QualityMask_OpName; + + /// + ///工位号与机型 + ///[测量数据发动机在线状态] + /// + public static Hashtable m_EngineNumberType_OpName; + /// + ///工位号与发动机号 + ///[测量数据发动机在线状态] + /// + public static Hashtable m_EngineNumber_OpName; + + /// + ///工位号与订单号 + ///[测量数据发动机在线状态] + /// + public static Hashtable m_OrderForm_OpName; + /// + ///工位号与操作者工号 + ///[测量数据发动机在线状态] + /// + public static Hashtable m_OperatorCode_OpName; + + + /// + /// 测量合格标志 + /// 全部测量数据的测量工位 + /// 全部测量数据的测量工位的数据来源 + /// 全部测量数据的测量工位的数据来源的测量变量 + /// + public static Hashtable hashtable_QualityData_GoodBad_MIS_OpName; + /// + /// 列位置 + /// + public static Hashtable hashtable_QualityData_GoodBad_Index; + + /// + /// MesServerCode + /// + public static Hashtable hashtable_MesServerCode; + /// + /// MesDll + /// + public static Hashtable hashtable_MesDll; + /// + /// 各个工位是否允许工作 + /// + public static Hashtable hashtable_IsAllowWork; + + /// + /// 返修工位是否需要强制合格放行 + /// //20141104 ljl + /// + public static Hashtable hashtable_IsConfirmOkGo; + + + /// + /// 工步属性哈西表 + /// + public static Hashtable hashtable_workStepProperty; + + /// + /// 工作顺序哈西表 + /// + public static Hashtable hashtable_WorkGroupIndex; + + /// + /// 返修工位哈西表 + /// + public static Hashtable hashtable_OpNameRepair; + + /// + /// 记录工件到位的发动机机型代码 + /// + public static Hashtable hashtable_EngineGetOver_EngineTypeID; + /// + /// 记录工件到位的发动机机型 + /// + public static Hashtable hashtable_EngineGetOver_EngineType; + /// + /// 记录工件到位的发动机号 + /// + public static Hashtable hashtable_EngineGetOver_EngineID; + /// + /// 记录工件到位的订单号 + /// + public static Hashtable hashtable_EngineGetOver_OrderForm; + + /// + /// 拧紧/压装过程中的合格标志 + /// + public static Hashtable hashtable_QualityMesRead; + + + /// + /// 物料检测哈希表 + /// + public static Hashtable hashtable_CheckMaterial; + + /// + /// 托盘状态哈希表 + /// + public static Hashtable hashtable_PalletInfo; + /// + ///[测量数据机床状态_分拆统计] + ///各个工位机床上电开始时间 + ///机床上电产生 0->1 + ///机床上电解除 1->0 + /// + public static Hashtable m_MachineStatusPutOn_OpName_Time; + /// + ///[测量数据机床状态_分拆统计] + ///各个工位循环开始 开始时间 + ///循环开始产生 0->1 + ///循环开始解除 1->0 + /// + public static Hashtable m_MachineStatusWorkOn_OpName_Time; + /// + ///[测量数据机床状态_分拆统计] + ///各个工位机床故障开始时间 + ///机床故障产生 0->1 + ///机床故障解除 1->0 + /// + public static Hashtable m_MachineStatusAlarm_OpName_Time; + /// + ///[测量数据机床状态_分拆统计] + ///各个工位上料无件开始时间 + ///上料无件产生 0->1 + ///上料无件解除 1->0 + /// + public static Hashtable m_MachineStatusNoPart_OpName_Time; + /// + ///[测量数据机床状态_分拆统计] + ///各个工位下料堵塞开始时间 + ///下料堵塞产生 0->1 + ///下料堵塞解除 1->0 + /// + public static Hashtable m_MachineStatusBlock_OpName_Time; + + /// + ///工位号与托盘离开 1->0 + ///工位号与托盘到位 0->1 + ///[测量数据_监控系统_托盘到位] + /// + public static Hashtable m_PartPalletStatus_OpName; + /// + ///工位号与托盘离开 1->0 + ///工位号与托盘到位 0->1 + ///[测量数据_监控系统_托盘到位] + /// + public static Hashtable m_PartPalletStatus_OpName_Time; + /// + /// 托盘到位(1)托盘离开(0) (DBX101.7)(13) + /// + /// + /// + + /// + ///[测量数据机床状态_分拆统计] + ///各个工位机床上电开始时间 + ///机床上电产生 0->1 + ///机床上电解除 1->0 + /// + public static Hashtable m_MachineStatusPutOn_OpName; + /// + ///[测量数据机床状态_分拆统计] + ///各个工位循环开始 开始时间 + ///循环开始产生 0->1 + ///循环开始解除 1->0 + /// + public static Hashtable m_MachineStatusWorkOn_OpName; + /// + ///[测量数据机床状态_分拆统计] + ///各个工位机床故障开始时间 + ///机床故障产生 0->1 + ///机床故障解除 1->0 + /// + public static Hashtable m_MachineStatusAlarm_OpName; + /// + ///[测量数据机床状态_分拆统计] + ///各个工位上料无件开始时间 + ///上料无件产生 0->1 + ///上料无件解除 1->0 + /// + public static Hashtable m_MachineStatusNoPart_OpName; + /// + ///[测量数据机床状态_分拆统计] + ///各个工位下料堵塞开始时间 + ///下料堵塞产生 0->1 + ///下料堵塞解除 1->0 + /// + public static Hashtable m_MachineStatusBlock_OpName; + + public static NameValueCollection hashtable_TagTypeDataType ; + public static NameValueCollection hashtable_TagType; + /// + /// 托盘代码(DBB86)(80) + /// + /// + /// + + /// + /// 创建MesServerCode哈西表 + /// + static public void InitHashtable_MesServerCode() + { + hashtable_MesServerCode = new Hashtable(); + hashtable_IsAllowWork = new Hashtable(); + hashtable_WorkGroupIndex = new Hashtable(); + hashtable_EngineGetOver_EngineTypeID = new Hashtable(); + hashtable_EngineGetOver_EngineType = new Hashtable(); + hashtable_EngineGetOver_EngineID = new Hashtable(); + hashtable_EngineGetOver_OrderForm = new Hashtable(); + hashtable_QualityMesRead = new Hashtable(); + hashtable_CheckMaterial = new Hashtable(); + hashtable_PalletInfo = new Hashtable(); + hashtable_IsConfirmOkGo = new Hashtable(); + hashtable_MesDll = new Hashtable(); + + string OpName; + string MesServerCode; + string MesDll; + string workStepProperty; + string OpNameRepair; + DataTable dt; + dt = MisDataFun.GetMesServerCodeFromMIS(); + if (dt != null) + { + for (int i = 0; i < dt.Rows.Count; i++) + { + OpName = dt.Rows[i]["工位号"].ToString(); + MesServerCode = dt.Rows[i]["MesServerCode"].ToString(); + MesDll = dt.Rows[i]["MesDll"].ToString(); + hashtable_MesDll.Add(OpName, MesDll); + hashtable_MesServerCode.Add(OpName, MesServerCode); + hashtable_IsAllowWork.Add(OpName, 1); + hashtable_IsConfirmOkGo.Add(OpName, 0);//20141104 ljl + hashtable_PalletInfo.Add(OpName, 0);//20141104 ljl + hashtable_WorkGroupIndex.Add(OpName, 1); + hashtable_EngineGetOver_EngineTypeID.Add(OpName, 0); + hashtable_EngineGetOver_EngineType.Add(OpName, ""); + hashtable_EngineGetOver_EngineID.Add(OpName, ""); + hashtable_EngineGetOver_OrderForm.Add(OpName, ""); + hashtable_QualityMesRead.Add(OpName, 0); + hashtable_CheckMaterial.Add(OpName, new bool[16]); + } + } + HashtableList.hashtable_MesServerCode_Temp = hashtable_MesServerCode; + HashtableList.hashtable_MesDll_Temp = hashtable_MesDll; + + HashtableList.hashtable_EngineGetOver_EngineID_Temp = hashtable_EngineGetOver_EngineID; + HashtableList.hashtable_EngineGetOver_EngineTypeID_Temp = hashtable_EngineGetOver_EngineTypeID; + HashtableList.hashtable_EngineGetOver_EngineType_Temp = hashtable_EngineGetOver_EngineType; + HashtableList.hashtable_EngineGetOver_OrderForm_Temp = hashtable_EngineGetOver_OrderForm; + + //初始化工步属性 + hashtable_workStepProperty = new Hashtable(); + dt = MisDataFun.GetworkStepPropertyFromMIS(); + if (dt != null) + { + for (int i = 0; i < dt.Rows.Count; i++) + { + OpName = dt.Rows[i]["工位号"].ToString(); + workStepProperty = dt.Rows[i]["工步属性"].ToString(); + hashtable_workStepProperty.Add(OpName, workStepProperty); + } + } + + //返修工位 + hashtable_OpNameRepair = new Hashtable(); + dt = MisDataFun.GetOpNameRepairFromMIS(); + if (dt != null) + { + for (int i = 0; i < dt.Rows.Count; i++) + { + OpName = dt.Rows[i]["工位号"].ToString(); + OpNameRepair = dt.Rows[i]["返修工位号"].ToString(); + hashtable_OpNameRepair.Add(OpName, OpNameRepair); + } + } + + HashtableList.hashtable_OpNameRepair_Temp = hashtable_OpNameRepair; + HashtableList.hashtable_workStepProperty_Temp = hashtable_workStepProperty; + HashtableList.hashtable_QualityMesRead_Temp = hashtable_QualityMesRead; + HashtableList.hashtable_IsAllowWork_Temp = hashtable_IsAllowWork; + HashtableList.hashtable_WorkGroupIndex_Temp = hashtable_WorkGroupIndex; + + + + } + + + /// + /// 创建合格标志哈西表 + /// + private static void InitHashtable_QualityData_GoodBad() + { + //列位置 + string index; + // + int tagID; + DataTable dt ; + dt = MisDataFun.BaseData_tagTable_All_B5A(); + + hashtable_QualityData_GoodBad_Index = new Hashtable(); + for (int i = 0; i < dt.Rows.Count; i++) + { + tagID = Convert.ToInt32(dt.Rows[i]["TagID"]); + index = (dt.Rows[i]["列位置"]).ToString(); + hashtable_QualityData_GoodBad_Index.Add(tagID, index); + } + + hashtable_EngineTypeID = new Hashtable(); + dt = MisDataFun.BaseData_tagTable_QualityData_EngineTypeID(); + for (int i = 0; i < dt.Rows.Count; i++) + { + tagID = Convert.ToInt32(dt.Rows[i]["发动机机型代码"]); + index = (dt.Rows[i]["ID"]).ToString(); + hashtable_EngineTypeID.Add(tagID, index); + } + //工位号 + DataTable dt_OpName; + //工位号数据来源 + DataTable dt_OpNameFrom; + //数据来源对应的TagID + DataTable dt_OpNameTagID; + string opName; + string opNameFrom; + hashtable_QualityData_GoodBad_MIS_OpName = new Hashtable(); + // 测量合格标志 + // 全部测量数据的测量工位的数据来源 + Hashtable hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom; + + // 测量合格标志 + // 全部测量数据的测量工位的数据来源的测量变量 + Hashtable hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom_TagID; + dt_OpName = MisDataFun.BaseData_tagTable_QualityData_GoodBad_MIS_OpName_B5A(); + if (dt_OpName != null) + { + //有不合格标志的测量工位 + for (int i = 0; i < dt_OpName.Rows.Count; i++) + { + //有不合格标志的测量工位 对应的 数据来源工位号 + hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom = new Hashtable(); + opName = dt_OpName.Rows[i]["工位号"].ToString(); + dt_OpNameFrom = MisDataFun.BaseData_tagTable_QualityData_GoodBad_MIS_OpName(opName); + if (dt_OpNameFrom != null) + { + for (int j = 0; j < dt_OpNameFrom.Rows.Count; j++) + { + opNameFrom = dt_OpNameFrom.Rows[j]["数据来源"].ToString(); + dt_OpNameTagID = MisDataFun.BaseData_tagTable_QualityData_GoodBad_MIS_OpName(opName, opNameFrom); + // + hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom_TagID = new Hashtable(); + if (dt_OpNameTagID != null) + { + for (int k = 0; k < dt_OpNameTagID.Rows.Count; k++) + { + tagID = Convert.ToInt32(dt_OpNameTagID.Rows[k]["TagID"]); + hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom_TagID.Add(tagID, tagID); + } + } + tagID = Convert.ToInt32(dt_OpNameFrom.Rows[j]["TagID"]); + //全部测量数据的测量工位的数据来源的测量变量 + hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom.Add(tagID, hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom_TagID); + } + } + hashtable_QualityData_GoodBad_MIS_OpName.Add(opName, hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom); + } + } + } + + + public static NameValueCollection hashtable_TagTypeID_OpName_ToTagID; + + /// + /// 变量代码与其他字段的对应关系 + /// + public static void InitHashtableTagID() + { + //变量代码 + string tagID; + //变量名称 + string tagName; + //工位号 + string opNmae; + //测量位置 + string shaftID; + //测量项目 + string itemVale; + //变量排序 + int tagItemOrderBy; + //变量特点 + // 0:没定义1:工位合格标志2:需要合格标志的测量数据3:每个工位的合格标志4:物料5:IQA码6:压装数据7:压装合格标志8:(自动拧紧)工位合格标志 + int tagProperty; + //列位置 + int tagOrderBy; + InitHashtable_QualityData_GoodBad(); + //MesServerCode哈希表创建 + InitHashtable_MesServerCode(); + //列位置 + hashtable_tagTable_TagID_TagOrderBy = new Hashtable(); + // 变量代码与变量排序 + hashtable_tagTable_TagID_TagItemOrderBy = new Hashtable(); + // 变量代码与变量特点 + // 0:没定义1:工位合格标志2:需要合格标志的测量数据3:每个工位的合格标志4:物料5:IQA码6:压装数据7:压装合格标志8:(自动拧紧)工位合格标志 + hashtable_tagTable_TagID_TagProperty = new Hashtable(); + hashtable_tagTable_OpName_SaveData = new Hashtable(); + //工位号与机床状态 + //[测量数据发动机在线状态] + m_MachineStatus_OpName = new Hashtable(); + ////工位号与工件离开 0 + ////工位号与工件到位 1 + ////[测量数据发动机在线状态] + //m_WorkStart_OpName = new Hashtable(); + ////工位号与工件到位时间 + ////工位号与工件到位 0->1 + ////[测量数据发动机在线状态] + //m_WorkStart_OpName_Time = new Hashtable(); + //工位号与发动机号 + //[测量数据发动机在线状态] + m_EngineTrace_OpName = new Hashtable(); + m_EngineTrace_OpName_Time = new Hashtable(); + //工位号与合格标志 + //[测量数据发动机在线状态] + m_QualityMask_OpName = new Hashtable(); + //工位号与目标循环时间 + hashtableOpName_TargetTime = new Hashtable(); + //工位号与线体类型 + hashtableOpName_LineType = new Hashtable(); + //是否有工位计算机 + hashtableOpName_IsHaveComputer = new Hashtable(); + + //工位号与机型 + //[测量数据发动机在线状态] + m_EngineNumberType_OpName = new Hashtable(); + //工位号与发动机号 + //[测量数据发动机在线状态] + m_EngineNumber_OpName = new Hashtable(); + //工位号与订单号 + //[测量数据发动机在线状态] + m_OrderForm_OpName = new Hashtable(); + //工位号与操作者工号 + //[测量数据发动机在线状态] + m_OperatorCode_OpName = new Hashtable(); + + + // + // 变量名称 + // + hashtableTagID_TagName = new Hashtable(); + // + // 工位号 + // + hashtableTagID_OpName = new Hashtable(); + // + // 数据来源 + // + hashtableTagID_OpNameFrom = new Hashtable(); + // + // 工位名称 + // + hashtableTagID_OpName_Name = new Hashtable(); + // + // 测量位置 + // + hashtableTagID_ShaftID = new Hashtable(); + // + // 测量项目 + // + hashtableTagID_ItemVale = new Hashtable(); + + hashtable_tagTable_TagID_TagTypeID_All = new Hashtable(); + + // 工位号与工位上下线类型 + // (0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线) + // (5 分线上线 总线) (6 分线上线 总线) + hashtableOpName_OpType = new Hashtable(); + // 工位号与大屏幕代码 + // 对应LED大屏幕(1,2,3,4) + hashtableOpName_LedID = new Hashtable(); + + + + + // 大屏幕显示产量端口(41104) + hashtableOpName_LedID_Port = new Hashtable(); + // 大屏幕显示Andon大屏幕代码 1 + hashtableOpName_AndonID = new Hashtable(); + // 大屏幕显示Andon端口 (41105) + hashtableOpName_AndonID_Port = new Hashtable(); + // 是否有打印机(0,1) + hashtableOpName_IsPrinter = new Hashtable(); + // 打印机通讯端口 (缸盖打印机 41101) (发动机上线打印机 41102) (发动机下线打印机 41103) + hashtableOpName_IsPrinter_Port = new Hashtable(); + + m_WorkStart_OpName_Time = new Hashtable(); + m_WorkStart_OpName = new Hashtable(); + + + m_MachineStatusPutOn_OpName_Time = new Hashtable(); + m_MachineStatusPutOn_OpName = new Hashtable(); + m_MachineStatusWorkOn_OpName_Time = new Hashtable(); + m_MachineStatusWorkOn_OpName = new Hashtable(); + m_MachineStatusAlarm_OpName_Time = new Hashtable(); + m_MachineStatusAlarm_OpName = new Hashtable(); + m_MachineStatusNoPart_OpName_Time = new Hashtable(); + m_MachineStatusNoPart_OpName = new Hashtable(); + m_MachineStatusBlock_OpName_Time = new Hashtable(); + m_MachineStatusBlock_OpName = new Hashtable(); + + + + + m_WorkStart_OpName_PartMoveDirection = new Hashtable(); + m_PartPalletStatus_OpName_Time = new Hashtable(); + m_PartPalletStatus_OpName = new Hashtable(); + + hashtable_TagTypeID_OpName_ToTagID = new NameValueCollection(); + + + + DataTable dt; + DateTime dateTime; + dateTime = DateTime.Now; + dt = MisDataFun.BaseData_tagTable_All(); + + //变量类型代码 + int TagTypeID; + for (int i = 0; i < dt.Rows.Count; i++) + { + tagID = dt.Rows[i]["TagID"].ToString (); + tagName = Convert.ToString(dt.Rows[i]["TagName"]); + opNmae = Convert.ToString(dt.Rows[i]["工位号"]); + shaftID = Convert.ToString(dt.Rows[i]["测量位置"]); + itemVale = Convert.ToString(dt.Rows[i]["测量项目"]); + TagTypeID = Convert.ToInt32(dt.Rows[i]["变量类型代码"]); + tagItemOrderBy = Convert.ToInt32(dt.Rows[i]["变量排序"]); + tagProperty = Convert.ToInt32(dt.Rows[i]["变量特点"]); + tagOrderBy = Convert.ToInt32(dt.Rows[i]["列位置"]); + + hashtableTagID_TagName.Add(tagID, tagName); + hashtableTagID_OpName.Add(tagID, opNmae); + hashtableTagID_ShaftID.Add(tagID, shaftID); + hashtableTagID_ItemVale.Add(tagID, itemVale);//列位置 + hashtable_tagTable_TagID_TagTypeID_All.Add(tagID, TagTypeID); + hashtable_tagTable_TagID_TagItemOrderBy.Add(tagID, tagItemOrderBy); + hashtable_tagTable_TagID_TagProperty.Add(tagID, tagProperty); + hashtable_tagTable_TagID_TagOrderBy.Add(tagID, tagOrderBy); + + + } + dt = MisDataFun.BaseData_tagTable_OpName(); + for (int i = 0; i < dt.Rows.Count; i++) + { + //是否通过监控系统保存数据 + // 1:通过监控系统保存采集的质量数据;0:不通过监控系统保存采集的质量数据 + hashtable_tagTable_OpName_SaveData.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["是否通过监控系统保存数据"])); + + hashtableOpName_TargetTime.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToString(dt.Rows[i]["目标循环时间"])); + hashtableOpName_LineType.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToString(dt.Rows[i]["线体类型"])); + hashtableOpName_IsHaveComputer.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToString(dt.Rows[i]["是否有工位计算机"])); + //用于LED显示 + // [MES_计划BOM_工位与名称] + // 工位上下线类型 + //(0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线) + hashtableOpName_OpType.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["工位上下线类型"])); + hashtableOpName_LedID.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["大屏幕代码"])); + m_WorkStart_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime); + m_WorkStart_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0); + + + m_MachineStatusPutOn_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime); + m_MachineStatusPutOn_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0); + m_MachineStatusWorkOn_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime); + m_MachineStatusWorkOn_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0); + m_MachineStatusAlarm_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime); + m_MachineStatusAlarm_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0); + m_MachineStatusNoPart_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime); + m_MachineStatusNoPart_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0); + m_MachineStatusBlock_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime); + m_MachineStatusBlock_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0); + + + + m_WorkStart_OpName_PartMoveDirection.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0); + + + m_PartPalletStatus_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime); + m_PartPalletStatus_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0); + try + { + hashtableOpName_LedID_Port.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["大屏幕显示产量端口"])); + } + catch { } + try + { + hashtableOpName_AndonID.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["大屏幕显示Andon大屏幕代码"])); + } + catch { } + try + { + hashtableOpName_AndonID_Port.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["大屏幕显示Andon端口"])); + } + catch { } + try { hashtableOpName_IsPrinter.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["是否有打印机"])); } + catch { } + try + { + hashtableOpName_IsPrinter_Port.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["打印机通讯端口"])); + } + catch { } + } + + + //20170310 CLB新加 + dt = MisDataFun.BaseData_tagTable_OpcServerMES_ALL_CF(); + for (int i = 0; i < dt.Rows.Count; i++) + { + try + { + hashtable_TagTypeID_OpName_ToTagID.Add(Convert.ToString(dt.Rows[i]["工位号"]) + "_" + Convert.ToString(dt.Rows[i]["变量类型代码"]), Convert.ToString(dt.Rows[i]["TagID"])); + //hashtable_TagTypeID_OpName_ToTagID; + } + catch(Exception err) + { + + } + } + + + + + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Hashtable.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Hashtable.cs new file mode 100644 index 0000000..19cfd3a --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Hashtable.cs @@ -0,0 +1,91 @@ +using System; +using System.Data; +using System.Collections; + +using System.Windows.Forms; +//using bizFacade; +using System.Collections.Specialized; +using MisDataFunDll; +//using MesWork; + + +namespace MesServerWork +{ + public partial class MIS_BASE // : Form + { + public class HashtableList + { + /// + /// MesServerCode + /// + static public Hashtable hashtable_MesServerCode_Temp; + /// + /// MesDll + /// + static public Hashtable hashtable_MesDll_Temp; + static public NameValueCollection hashtable_TagTypeDataType_Temp; + static public NameValueCollection hashtable_TagType_Temp; + static public Hashtable hashtable_TagTypeTagName_Temp; + + static public Hashtable hashtable_EngineGetOver_EngineTypeID_Temp; + static public Hashtable hashtable_EngineGetOver_EngineType_Temp; + static public Hashtable hashtable_EngineGetOver_EngineID_Temp; + static public Hashtable hashtable_EngineGetOver_OrderForm_Temp; + + static public Hashtable hashtable_OpNameRepair_Temp; + + static public Hashtable hashtable_WorkGroupIndex_Temp; + static public Hashtable hashtable_workStepProperty_Temp; + static public Hashtable hashtable_QualityMesRead_Temp; + static public Hashtable hashtable_IsAllowWork_Temp; + /// + /// 工位号与工位上下线类型 + /// (0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线) + /// 5 分线上线(总线) 6 分线上线(分线) + /// + static public Hashtable hashtableOpName_OpType_Temp; + + static public Hashtable hashtable_tagTable_OpName_SaveData_Temp; + + + public Hashtable hashtable_tagTable_OpName_SaveData; + + + /// + /// + /// 工位号与工位上下线类型 + /// (0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线) + /// 5 分线上线(总线) 6 分线上线(分线) + /// + public Hashtable hashtableOpName_OpType; + public Hashtable hashtable_IsAllowWork; + public Hashtable hashtable_QualityMesRead; + public Hashtable hashtable_workStepProperty; + public Hashtable hashtable_OpNameRepair; + /// + /// MesServerCode + /// + public Hashtable hashtable_MesServerCode; + public Hashtable hashtable_TagTypeTagName; + + /// + /// MesDll + /// + public Hashtable hashtable_MesDll; + public NameValueCollection hashtable_TagTypeDataType; + public NameValueCollection hashtable_TagType; + + + public Hashtable hashtable_EngineGetOver_EngineTypeID; + public Hashtable hashtable_EngineGetOver_EngineType; + public Hashtable hashtable_EngineGetOver_EngineID; + public Hashtable hashtable_EngineGetOver_OrderForm; + + public Hashtable hashtable_WorkGroupIndex; + + public DataTable BasicDataTagValue; + public DataTable BasicDataTagValueUpDown; + public Hashtable hashtable_EngineTypeID; + } + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Machine.ServicePlan.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Machine.ServicePlan.cs new file mode 100644 index 0000000..61d5684 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.Machine.ServicePlan.cs @@ -0,0 +1,98 @@ +using System; +using System.Data; +using System.Windows.Forms; +//using bizFacade; +//using DataLinkMesWork; +//using SystemFramework; + +namespace MesServerWork +{ + public partial class MIS_BASE + { + /// + /// 设备保养计划 + /// + /// + /// + /// + public delegate void MachinePlan_Invoke(string OpName, string MachineType, string PlanID); + /// + /// 设备保养计划 + /// + public MachinePlan_Invoke machinePlan_Invoke; + /// + /// 设备保养 + /// + /// + /// 设备保养类型 + /// 工作日历流水号 + public void MachinePlan(string OpName, string MachineType, string PlanID) + { + try + { + string SendMessage; + SendMessage = "MES|MachinePlan|" + OpName + "|" + MachineType + "&" + PlanID; + asyncSendMessage(SendMessage); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "MachinePlan"); + } + } + + /// + /// 设备保养计划Timer + /// + private Timer timer_Machine; + /// + /// 初始化设备保养计划 + /// + public void InitMachinePlan(MachinePlan_Invoke machinePlan_Invoke) + { + this.machinePlan_Invoke = machinePlan_Invoke; + timer_Machine = new Timer(); + timer_Machine.Interval = 60000;//每隔一分钟查询一次 + timer_Machine.Tick += new EventHandler(timer_Machine_Tick); + timer_Machine.Start(); + } + + /// + /// 分钟调度 + /// + /// + /// + private void timer_Machine_Tick(object sender, EventArgs e) + { + try + { + //if (ApplicationConfig.Is_MachinePlan == 1) + //{ + // DataTable dt; + // string opName; + // string machineType;//保养类型代码 + // string planID;//工作日历流水号 + // BaseDataSystemMES.MachinePlan_Select(out dt); + // if (dt != null) + // { + // if (dt.Rows.Count > 0) + // { + // for (int i = 0; i < dt.Rows.Count; i++) + // { + // opName = dt.Rows[i]["工位号"].ToString(); + // machineType = dt.Rows[i]["保养类型代码"].ToString(); + // planID = dt.Rows[i]["工作日历流水号"].ToString(); + // BaseDataSystemMES.Rolling_news_Add(opName, opName + "工位有设备保养计划,请相关人员进行保养!!!"); + // BeginInvoke(machinePlan_Invoke, new object[] { opName, machineType, planID }); + // } + // } + // } + //} + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "timer_Machine_Tick"); + } + } + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.OpcServerMIS.Read.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.OpcServerMIS.Read.cs new file mode 100644 index 0000000..f768d82 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.OpcServerMIS.Read.cs @@ -0,0 +1,1196 @@ + +using MisDataFunDll; +using System; +using SystemFramework; +//using SystemFramework; +//using bizFacade; + +namespace MesServerWork +{ + + public partial class MIS_BASE + { + + + /// + /// 通过TagTypeName读取PLC数据 + /// + /// + /// + static private void Read_TagValueByTagTypeName(string cmd, string opName, out string tagValue) + { + tagValue = "-1"; + int tagTypeID; + try + { + tagTypeID = Convert.ToInt32(MIS_BASE.hashtable_TagType[cmd]); + string msg = "MES|" + tagTypeID.ToString() + "|" + opName + "|" + tagValue; + //tagValue = ChatService.MesReadWhisperMessage(msg); + MIS_BASE.ReadTagValue(tagTypeID, opName, out tagValue); + } + catch (Exception err) + { + ApplicationLog.WriteLog(err, "Read_TagValueByTagTypeName_FUNC;工位号:" + opName + ";命令:" + cmd + ";值:" + tagValue); + } + + } + + /// + /// 通过TagID读取对应值 + /// + /// + /// + public static void Read_TagValueByTagID(string TagID, out object tagValue) + { + tagValue = "0"; + try + { + tagValue = MIS_BASE.ReadPLC(TagID).ToString(); + } + catch (Exception err) + { + ApplicationLog.WriteLog(err, "Read_TagValueByTagID_FUNC"); + } + } + + /// + /// 根据变量类型代码、工位号获得对应值 + /// + /// + /// + /// + public static void Read_TagValueByTagTypeID(int tagTypeID, string opName, out string tagValueStr) + { + tagValueStr = "-1"; + + try + { + MIS_BASE.ReadTagValue(tagTypeID, opName, out tagValueStr); + } + catch (Exception err) + { + ApplicationLog.WriteLog(err, "Read_TagValueByTagTypeID_FUNC"); + } + } + + /// + /// 根据变量类型代码、工位号获得对应值 + /// + /// + /// + /// + public static void Read_TagValueByTagTypeID(int tagTypeID, string opName, out object tagValueStr) + { + tagValueStr = "-1"; + + try + { + tagValueStr = MIS_BASE.ReadPLC(tagTypeID, opName); + } + catch (Exception err) + { + ApplicationLog.WriteLog(err, "Read_TagValueByTagTypeID_FUNC"); + } + } + /// + /// 根据变量类型代码、工位号获得对应值 + /// + /// + /// + /// + public static string Read_TagValueByTagTypeID(int tagTypeID, string opName) + { + string tagValueStr = "-1"; + try + { + MIS_BASE.ReadTagValue(tagTypeID, opName, out tagValueStr); + + } + catch (Exception err) + { + ApplicationLog.WriteLog(err, "Read_TagValueByTagTypeID_FUNC"); + } + return tagValueStr; + } + + /// + /// 读取数据通过(TagTypeName&opName) + /// + /// + /// + public static void Read_TagTypeName(string cmd, string opName, out string tagValueStr) + { + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + } + + /// + /// 读取数据通过(TagTypeID&opName) + /// + /// + /// + public static void Read_TagTypeID(int tagTypeID, string opName, out string tagValueStr) + { + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + } + + + + + + + /// + /// 订单号(string)(25) + /// + /// + /// + public static void Read_OrderForm(string opName, out string tagValue) + { + int tagTypeID = 39; + tagValue = ""; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValue); + } + /// + /// 总成编号(string)(26) + /// + /// + /// + public static void Read_AssemblyCode(string opName, out string tagValue) + { + tagValue = ""; + string cmd = "AssemblyCode"; + Read_TagValueByTagTypeName(cmd, opName, out tagValue); + //tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + } + /// + /// 配方号1(dint)(27) + /// + /// + /// + public static void Read_Recipe1(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "Recipe1"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + } + /// + /// 配方号2(dint)(28) + /// + /// + /// + public static void Read_Recipe2(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "Recipe2"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + } + + /// + /// 订单号(string)(116) + /// + /// + /// + public static void Read_OrderForm_MES(string opName, out string tagValue) + { + int tagTypeID = 116; + tagValue = ""; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValue); + //tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + } + /// + /// 总成编号(string)(62) + /// + /// + /// + public static void Read_AssemblyCode_MES(string opName, out string tagValue) + { + tagValue = ""; + string cmd = "AssemblyCode_MES"; + Read_TagValueByTagTypeName(cmd, opName, out tagValue); + //tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + } + /// + /// 配方号1(dint)(63) + /// + /// + /// + public static void Read_Recipe1_MES(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "Recipe1_MES"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + } + /// + /// 配方号2(dint)(64) + /// + /// + /// + public static void Read_Recipe2_MES(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "Recipe2_MES"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + } + + /// + /// 匹配结果(DBX3.4)(69) + /// 匹配是否成功 + /// + /// + /// + public static void Read_MatchSuccess(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "Match"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 是否匹配(DBX3.3)(68) + /// + /// + /// + public static void Read_MatchingCompleted(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "MatchingCompleted"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + + /// + /// MES保存完数据(必须MIS)(X102.2)(20) + /// + /// + /// + public static void Read_MesReadOver(string opName, out bool tagValue) + { + tagValue = false; + int tagTypeID = 20; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// 发动机到位(X0.1)(2) + /// + /// + /// + public static void Read_WorkStart(string opName, out bool tagValue) + { + tagValue = false; + int tagTypeID = 2; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + } + + /// + /// 发动机机型标志(INT4)(9) + /// + public static void Read_EngineTypeID(string opName, out int tagValue) + { + int tagTypeID = 9; + tagValue = 0; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + /// + /// 发动机ID(STRING6.38)(10) + /// + public static void Read_EngineID(string opName, out string tagValue) + { + int tagTypeID = 10; + tagValue = ""; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = tagValueStr; + } + //public static void Read_OrderForm(string opName, out string tagValue) + //{ + // tagValue = ""; + // string tagTypeID = "39"; + // string tagValueStr; + // tagValueStr = DtWebApi.ReadWritePLC.ReadPLC(tagTypeID, opName).ToString(); + // tagValue = tagValueStr; + //} + /// + /// 发动机型号(STRING46.38)(11) + /// + public static void Read_EngineType(string opName, out string tagValue) + { + int tagTypeID = 11; + tagValue = ""; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = tagValueStr; + + } + + /// + /// 工位直通(X101.6)(1006) + /// + public static void Read_PartGoOver(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "PartGoOver"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 托盘到位(1)托盘离开(0) (DBX101.5)(13) + /// + public static void Read_PartPalletStatus(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "PartPalletStatus"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + } + + /// + /// 加工时间变量目标时间 (DINT 106)(17) + /// + public static void Read_MachineTime_TargetTime(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "TargetTime"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + /// + /// 加工时间变量实际时间 (DINT 110)(18) + /// + public static void Read_MachineTime_ActualTime(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "ActualTime"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 质量数据总成合格标志(INT104)(21) + /// + public static void Read_QualityMask(string opName, out int tagValue) + { + tagValue = 0; + int tagTypeID = 21; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + if (tagValueStr == "1" | tagValueStr.ToLower () == "true") + { + tagValueStr = "1"; + } + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 机体流向标志(1 BYTE): + /// 0普通工位: + /// 1:上线(发动机上线); + /// 2:下线(发动机下线);(INT114)(41) + /// + public static void Read_PartMoveDirection(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "PartMoveDirection"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + } + + + /// + /// 强制MES(X103.0)(78) + /// + public static void Read_Mes_MustTest(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "IsMES"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + /// + /// 工位三种状态:在线、离线、屏蔽(0,1,2)(DBB116)(79) + /// + public static void Read_OnLineState(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "OnLineState"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + } + + /// + /// 变量类型代码=44 CF0.4 + /// PLC向MES传递机型,机型代码,零件编号完成,通知PLC。 + /// 机型可读 + /// + /// + /// + public static void Read_EngineGetOver_PLC(string opName, out bool tagValue) + { + tagValue = false; + int tagTypeID = 44; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// X100.2允许保存质量数据(19) + /// + /// + /// + public static void Read_QualityData_Read_CF(string opName, out bool tagValue) + { + tagValue = false; + int tagTypeID = 19; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt64(tagValueStr)); + + } + + /// + /// MES向PLC传递机型(DBX2.1)(5) + /// + /// + /// + public static void Read_EngineTypeGetOver_MES(string opName, out bool tagValue) + { + tagValue = false; + int tagTypeID = 5; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// X2.3 工作完成(7) + /// + /// + /// + public static void Read_MaterialVerifyOver(string opName, out bool tagValue) + { + tagValue = false; + int tagTypeID = 7; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// 申请上线(DBX0.3)(43) + /// + /// + /// + public static void Read_PartLoad(string opName, out bool tagValue) + { + tagValue = false; + int tagTypeID = 43; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// 上线完成(DBX0.3)(48) + /// + /// + /// + public static void Read_PartLoad_OK(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "PartLoadOK"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// 合格放行(51) + /// + /// + /// + public static void Read_ConfirmOkGo(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "ConfirmOkGo"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// 拧紧结束(DBX1.1)(59) + /// + /// + /// + public static void Read_FixOK(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "FixOK"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// 蘑菇按钮(DBX1.3)(61) + /// + /// + /// + public static void Read_NextPushButton(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "NextPushButton"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// 允许拧紧(DBX3.1)(66) + /// + /// + /// + public static void Read_FixAllow(string opName, out bool tagValue) + { + tagValue = false; + int tagTypeID = 66; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// 拧紧结束确认(DBX3.2)(67) + /// + /// + /// + public static void Read_FixOver(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "FixOver"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + ///返修上线,在上线工位,MES依据工件情况,设定为返修件,PLC见到MES设定为1后,将返修标志写入到DBX0.2为1 + ///MES设定完返修返修上线后,MES清空该信号 + ///DBX3.7(72) + /// + /// + /// + public static void Read_RepairUpline_MES(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "RepairUplineMES"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + + + /// + /// 匹配结果(DBX3.4)(69) + /// + /// + /// + public static void Read_Match(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "Match"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + } + + /// + /// 发动机机型代码(DBB404)(73)[false] + /// + /// + /// + public static void Read_EngineTypeID_MES(string opName, out int EngineTypeID) + { + int tagTypeID = 73; + EngineTypeID = 0; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + EngineTypeID = Convert.ToInt32(tagValueStr); + + } + + /// + /// 发动机机型(DBB446)(75) + /// + /// + /// + public static void Read_EngineType_MES(string opName, out string EngineType) + { + int tagTypeID = 75; + EngineType = ""; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + EngineType = tagValueStr; + + } + + /// + /// 发动机号(DBB406)(74) + /// + /// + /// + public static void Read_EngineID_MES(string opName, out string EngineID) + { + int tagTypeID = 74; + EngineID = ""; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + EngineID = tagValueStr; + + } + + /// + /// 拧紧序号(77) + /// + /// + /// + public static void Read_ProcessCode(string opName, out int tagValue) + { + int tagTypeID = 77; + tagValue = 0; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + + /// + /// 套筒号、子程序代码子程序(DBB26)(2025)[false] + /// + /// + /// + public static void Read_BoltCode(string opName, out int tagValue) + { + int tagTypeID = 88; + tagValue = 0; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + + /// + /// 托盘代码(DBB86)(80) + /// + public static void Read_PalletCode(string opName, out int tagValue) + { + int tagTypeID = 80; + tagValue = 0; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + } + /// + /// 获得机型,零件编号,机型代码,托盘号,(从PLC) + /// + /// + /// + /// + /// + /// + public static void GetEngineTypeFromPLC(string opName, out int EngineTypeID, out string EngineType, out string EngineID, out int PartPallet_Code,out string OrderForm) + { + Read_EngineTypeID(opName,out EngineTypeID); + Read_EngineType(opName, out EngineType); + Read_EngineID(opName, out EngineID); + Read_OrderForm(opName, out OrderForm); + Read_PalletCode(opName, out PartPallet_Code); + } + /// + /// /// 获得机型,零件编号,机型代码,托盘号,(从MES) + /// + /// + /// + /// + /// + /// + public static void GetEngineTypeFromPLC_MES(string opName, out int EngineTypeID, out string EngineType, out string EngineID, out string OrderForm) + { + Read_EngineTypeID_MES(opName, out EngineTypeID); + Read_EngineType_MES(opName, out EngineType); + Read_EngineID_MES(opName, out EngineID); + Read_OrderForm_MES(opName, out OrderForm); + } + + /// + /// 获得机型,零件编号,机型代码,托盘号,(从DB) + /// + /// + /// + /// + /// + /// + public static void GetEngineTypeFromDB(string opName, out int EngineTypeID, out string EngineType, out string EngineID, out int PartPallet_Code) + { + string orderForm = ""; + int isRepair = 0; + string repairCode = ""; + string palletCode = "0"; + string EngineTypeString = ""; + MisDataFun.Moby_Select(opName, + out orderForm, out EngineTypeID, out EngineType, + out EngineID, out palletCode, out isRepair, out repairCode, out EngineTypeString); + PartPallet_Code = Convert.ToInt32(palletCode); + } + + /// + /// 0:不修改;1:可以修改。(上线工位)通知PLC。(DBX1.2)(76) + /// + /// + /// + public static void Read_PartPalletCode_PLC_ToMES(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "PartPalletCodePLCToMES"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 通知写入托盘号(DBX3.5)(70) + /// + /// + /// + public static void Read_PartPalletCode_PLC(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "PartPalletCodePLC"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 变量类型代码=86,打印第一行(机型),用于线首打印机。STRING 486 .38 + /// + /// + /// + public static void Read_PrintBarCode1_MES(string opName, out string tagValue) + { + tagValue = ""; + string cmd = "PrintBarCode1MES"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = tagValueStr; + + } + + /// + /// 变量类型代码=87,打印第二行(流水号),用于线首打印机。STRING 526 .38 + /// + /// + /// + public static void Read_PrintBarCode2_MES(string opName, out string tagValue) + { + tagValue = ""; + string cmd = "PrintBarCode2MES"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = tagValueStr; + + } + + + /// + /// 上线工位。0:正常工作;1:空托盘放行(DBX2.2)(6) + /// + /// + /// + public static void Read_PartPalletGoOver(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "PartPalletGoOver"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 自动手动申请工件编号,0是自动方式;1:手动方式。切换时,(DBX2.1)(71) + /// + /// + /// + public static void Read_IsAutoGetEngineID(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "IsAutoGetEngineID"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 正常拧紧时选择(DBX100.3)(81) + /// + /// + /// + public static void Read_Normal(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "Normal"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 备用拧紧时选择(DBX100.4)(82) + /// + /// + /// + public static void Read_UnNormal(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "UnNormal"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 允许拧紧2(DBX100.5)(83) + /// + /// + /// + public static void Read_FixAllow_2(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "FixAllow2"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 拧紧结束2(DBX100.6)(84) + /// + /// + /// + public static void Read_FixOK_2(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "FixOK2"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 拧紧结束确认2(DBX100.7)(85) + /// + /// + /// + public static void Read_FixOver_2(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "FixOver2"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 拧紧顺序2(DBX101.7)(1007) + /// MES通知PLC开始拧紧顺序(0为其他位,1为第一位置)(必须MES) + /// + /// + /// + public static void Read_WriteShaft_2(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "WriteShaft2"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + } + + + /// + /// 返修上线(DBX2.6)(52) + /// + /// + /// + public static void Read_PartLoadFinish(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "PartLoadFinish"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 返修上线后,PLC确认(DBX1.0)(58) + /// + /// + /// + public static void Read_PartLoadOver(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "PartLoadOver"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 变量类型代码=22,读取托盘信息 DBW126 + /// + /// + /// + public static void Read_PalletInfo(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "PalletInfo"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + } + + /// + /// 变量类型代码=23,读取托盘信息 DBW194 + /// + /// + /// + public static void Read_RepairStatus_PLC(string opName, out int tagValue) + { + int tagTypeID = 23; + tagValue = 0; + string cmd = "RepairStatusPLC"; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// PLC将MOBY信息成功写入到了对应的DB,然后通知MES(DBX1.5)(63) + /// + /// + /// + public static void Read_PalletMobyReadOver(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "PalletMobyReadOver"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + + /// + /// 在线返修状态(DBX4.0)(91) + /// + /// + /// + public static void Read_OnlineRepair(string opName, out int tagValue) + { + tagValue = 0; + string cmd = "OnlineRepair"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToInt32(tagValueStr); + + } + + /// + /// 离线返修状态(DBX4.1)(92) + /// + /// + /// + public static void Read_OutLineRepair(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "OutLineRepair"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// MES通知PLC修改托盘状态成功(DBX4.2)(93) + /// + /// + /// + public static void Read_UpdatePalletOK(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "UpdatePalletOK"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + } + + + /// + /// MES向PLC要求申请下线(DBX0.7)(50) + /// + /// + /// + public static void Read_PalletDown(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "PalletDown"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + + /// + /// 物料检测(99) + /// + /// + /// + public static void Read_CheckMaterial(string opName, out object tagValue) + { + tagValue = new bool[16]; + string cmd = "CheckMaterial"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// 备用功能是否启用(95) + /// + /// + /// + public static void Read_BakOpNameIsWork(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "BakOpNameIsWork"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + } + + + /// + /// 质量呼叫(DBX301.2)(2011) + /// + /// + /// + public static void Read_QualityCall(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "QualityCall"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + } + + /// + /// 物料呼叫(DBX301.3)(2012) + /// + /// + /// + public static void Read_MaterialCall(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "MaterialCall"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + + } + + /// + /// 故障呼叫(DBX301.4)(2013) + /// + /// + /// + public static void Read_FaultCall(string opName, out bool tagValue) + { + tagValue = false; + string cmd = "FaultCall"; + string tagValueStr; + Read_TagValueByTagTypeName(cmd, opName, out tagValueStr); + tagValue = Convert.ToBoolean(Convert.ToInt32(tagValueStr)); + } + + public static void Read_PartScanCode(int tagTypeID, string opName, out string tagValue) + { + tagValue = ""; + string tagValueStr; + Read_TagValueByTagTypeID(tagTypeID, opName, out tagValueStr); + tagValue = tagValueStr; + } + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.OpcServerMIS.Write.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.OpcServerMIS.Write.cs new file mode 100644 index 0000000..7d1826b --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.OpcServerMIS.Write.cs @@ -0,0 +1,574 @@ +using System; +//using SystemFramework; + + +namespace MesServerWork +{ + + public partial class MIS_BASE + { + + + //static public void WritePLC(int tagType, string opName, object tagValue) + //{ + // Write_TagTypeID(tagType, opName, tagValue); + //} + /// + /// + /// + /// + public delegate void DemoHandler(object sender, DeviceDriver_BasicData.CustomeEvetnArgs e); + /// + /// + /// + public static event DemoHandler OPCTagDataDemo; + + /// + /// 根据tagType,工位号写入PLC对应值 + /// + /// + /// + static private void Write_TagValueByTagTypeName(string cmd, string opName,object tagValue) + { + int tagTypeID = 0; + string msg; + try + { + tagTypeID = Convert.ToInt32(MIS_BASE.hashtable_TagType[cmd]); + MIS_BASE.WriteTagValue(tagTypeID, opName, tagValue); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Write_TagValueByTagTypeName_FUNC"); + } + + } + + /// + /// 根据TagTypeID,工位号写入PLC对应值 + /// + /// + /// + static public void Write_TagValueByTagTypeID(int tagTypeID, string opName, object tagValue) + { + string msg; + object tagValueOb; + object newTagValue= tagValue; + try + { + MIS_BASE.WriteTagValue(tagTypeID, opName, tagValue); + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Write_TagValueByTagTypeID_FUNC"); + } + + } + + /// + /// 通过TagID写入PLC数据 + /// + /// + /// + public static void Write_TagID(string TagID, object tagValue) + { + try + { + MIS_BASE.WritePLC(TagID, tagValue); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Write_TagValueByTagID_FUNC"); + } + } + + + /// + /// 清空MES信号 MES传递机型(5) 允许工作(66) 合格放行(51) 不合格放行(8) 拧紧结束(67) 工作完成(7) 保存完成(20) 加工时间保存完成(54) 匹配完成(68) 默认false + /// + /// + /// + public static void Write_ClearMesMoby(string opName) + { + MIS_BASE.Write_EngineTypeGetOver_MES(opName, false); + MIS_BASE.Write_FixAllow(opName, false); + MIS_BASE.Write_ConfirmOkGo(opName, false); + MIS_BASE.Write_FalseGO(opName, false); + MIS_BASE.Write_FixOver(opName, false); + MIS_BASE.Write_MesWorkFinish(opName, false); + MIS_BASE.Write_MesReadOver(opName, false); + MIS_BASE.Write_MachineTime_ReadOver(opName, false); + MIS_BASE.Write_MatchingCompleted(opName, false); + } + + + /// + /// 订单号(string)(25) + /// + /// + /// + public static void Write_OrderForm(string opName, string tagValue) + { + string cmd = "OrderForm"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + /// + /// 总成编号(string)(26) + /// + /// + /// + public static void Write_AssemblyCode(string opName, string tagValue) + { + string cmd = "AssemblyCode"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + /// + /// 配方号1(dint)(27) + /// + /// + /// + public static void Write_Recipe1(string opName, int tagValue) + { + string cmd = "Recipe1"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + /// + /// 配方号2(dint)(28) + /// + /// + /// + public static void Write_Recipe2(string opName, int tagValue) + { + tagValue = 0; + string cmd = "Recipe2"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + + + + /// + /// 总成编号(string)(62) + /// + /// + /// + public static void Write_AssemblyCode_MES(string opName, string tagValue) + { + + string cmd = "AssemblyCode_MES"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + /// + /// 配方号1(dint)(63) + /// + /// + /// + public static void Write_Recipe1_MES(string opName, int tagValue) + { + string cmd = "Recipe1_MES"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + /// + /// 配方号2(dint)(64) + /// + /// + /// + public static void Write_Recipe2_MES(string opName, int tagValue) + { + string cmd = "Recipe2_MES"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + + + /// + /// 各个工位返修状态(4) + /// + /// + /// + public static void Write_RepairPathString(string opName, string tagValue) + { + string cmd = "RepairPathString"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + + + /// + /// 加工时间保存完数据 DBX102.1 (54) + /// + /// + /// + public static void Write_MachineTime_ReadOver(string opName, bool tagValue) + { + + int tagTypeID = 54; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + /// + /// 工位三种状态:在线、离线、屏蔽(0,1,2)(DBB116)(79) + /// + /// + /// + public static void Write_OnLineState(string opName, int tagValue) + { + string cmd = "OnLineState"; + Write_TagValueByTagTypeName(cmd, opName,Convert .ToInt16 ( tagValue)); + } + + /// + /// 托盘编号(PLC)(80) + /// + /// + /// + public static void Write_PalletCode(string opName, int tagValue) + { + string cmd = "PartPalletCode"; + Write_TagValueByTagTypeName(cmd, opName, Convert.ToInt16(tagValue)); + } + + /// + /// MES向PLC传递机型(5) + /// + /// + /// + public static void Write_EngineTypeGetOver_MES(string opName, bool tagValue) + { + int tagTypeID = 5; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + /// + /// PLC向MES传递机型(44) + /// + /// + /// + public static void Write_EngineTypeGetOver_PLC(string opName, bool tagValue) + { + string cmd = "EngineTypeGetOverPLC"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + + /// + /// PLC向MES质量数据可以读 允许保存(19) DBX587.0 + /// + /// + /// + public static void Write_MesRead_PLC(string opName, bool tagValue) + { + string cmd = "MesRead"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + + + /// + /// 工件到位 + /// + /// + /// + public static void Write_WorkStart(string opName, bool tagValue) + { + string cmd = "WorkStart"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + + /// + /// 拧紧结束确认(67) + /// + /// + /// + public static void Write_FixOver(string opName, bool tagValue) + { + + int tagTypeID = 67; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + /// + ///返修上线,在上线工位,MES依据工件情况,设定为返修件,PLC见到MES设定为1后,将返修标志写入到DBX0.2为1 + ///MES设定完返修返修上线后,MES清空该信号 + ///DBX3.7(72) + /// + /// + /// + public static void Write_RepairUpline_MES(string opName, bool tagValue) + { + int tagTypeID = 72; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + /// + /// 匹配完成(68) + /// + /// + /// + public static void Write_MatchingCompleted(string opName, bool tagValue) + { + int tagTypeID = 68; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + + + + /// + /// 匹配结果(69) + /// + /// + /// + public static void Write_Match(string opName, bool tagValue) + { + int tagTypeID = 69; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + + } + + /// + /// 空托盘放行(DBX2.2)(6) + /// + /// + /// + public static void Write_PartPalletGoOver(string opName, int tagValue) + { + int tagTypeID = 6; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + + /// + /// 自动手动申请工件编号,0是自动方式;1:手动方式。切换时,(DBX2.1)(71) + /// + /// + /// + public static void Write_IsAutoGetEngineID(string opName, int tagValue) + { + string cmd = "IsAutoGetEngineID"; + Write_TagValueByTagTypeName(cmd, opName, Convert.ToInt16(tagValue)); + } + + + /// + /// 正常拧紧时选择(DBX100.3)(81) + /// + /// + /// + public static void Write_Normal(string opName, int tagValue) + { + string cmd = "Normal"; + Write_TagValueByTagTypeName(cmd, opName, Convert.ToInt16(tagValue)); + } + /// + /// 备用拧紧时选择(DBX100.4)(82) + /// + /// + /// + public static void Write_UnNormal(string opName, int tagValue) + { + string cmd = "UnNormal"; + Write_TagValueByTagTypeName(cmd, opName, Convert.ToInt16(tagValue)); + } + + /// + /// 变量类型代码=52,复位设备(MES)DBX0.6 + /// 通知PLC复位设备 + /// + /// + /// + public static void Write_ResetDevice(string opName, bool tagValue) + { + string cmd = "PartLoadFinish"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + + /// + ///托盘状态(22) + /// + /// + /// + public static void Write_PalletInfo(string opName, int tagValue) + { + string cmd = "PalletInfo"; + Write_TagValueByTagTypeName(cmd, opName, Convert.ToInt16(tagValue)); + } + /// + /// 返修标志(93) + /// + /// + /// + public static void Write_RepairStatusMES(string opName, int tagValue) + { + string cmd = "RepairStatusMES"; + Write_TagValueByTagTypeName(cmd, opName, Convert.ToInt16(tagValue)); + } + + /// + /// MES通知PLC修改托盘状态成功 + /// + /// + /// + public static void Write_UpdatePalletOK(string opName, bool tagValue) + { + string cmd = "UpdatePalletOK"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + + #region MES交互区写值 + + /// + /// 工作完成(7)(MES) + /// + /// + /// + public static void Write_MesWorkFinish(string opName, bool tagValue) + { + int tagTypeID = 7; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + /// + /// 合格方式放行(51)(MES) + /// + /// + /// + public static void Write_ConfirmOkGo(string opName, bool tagValue) + { + int tagTypeID = 51; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + /// + /// 允许拧紧(66)(MES) + /// + /// + /// + public static void Write_FixAllow(string opName, bool tagValue) + { + int tagTypeID = 66; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + /// + /// 不合格放行(8) + /// + /// + /// + public static void Write_FalseGO(string opName, bool tagValue) + { + int tagTypeID = 8; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + /// + /// 拧紧序号(77) + /// + /// + /// + public static void Write_ProcessCode(string opName, int tagValue) + { + int tagTypeID = 77; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + + /// + /// 套筒号(88) + /// + /// + /// + public static void Write_BoltCode(string opName, int tagValue) + { + int tagTypeID = 88; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + /// + /// MES保存完数据(必须MIS)(X102.2)(20) + /// + /// + /// + public static void Write_MesReadOver(string opName, bool tagValue) + { + int tagTypeID = 20; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + /// + /// 工作完成(7) + /// + /// + /// + public static void Write_MaterialVerifyOver(string opName, bool tagValue) + { + string cmd = "MaterialVerifyOver"; + Write_TagValueByTagTypeName(cmd, opName, tagValue); + } + public static void Write_TagTypeID(int tagTypeID, string opName, object tagValue) + { + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + /// + /// 变量类型代码=73,机型代码。DBB404~405 机型标志 + /// + /// + /// + public static void Write_EngineTypeID_MES(string opName, int tagValue) + { + int tagTypeID = 73; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + public static void Write_OpNameIsOk(string opName,int qualityMask) + { + + // -99 是复位 + if (qualityMask == -99) + { + Write_TagValueByTagTypeID(51, opName, false); + Write_TagValueByTagTypeID(8, opName, false); + } + else if(qualityMask == 1) + { + // 51 合格放行 + Write_TagValueByTagTypeID(51, opName, true); + } + else + { + // 8 不合格放行 + Write_TagValueByTagTypeID(8, opName, true); + } + } + + /// + /// 变量类型代码=74,零件编号。DBB406~445 发动机编号 + /// + /// + /// + public static void Write_EngineID_MES(string opName, string tagValue) + { + int tagTypeID = 74; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + /// + /// 变量类型代码=75,零件机型。DBB446~485 发动机机型 + /// + /// + /// + public static void Write_EngineType_MES(string opName, string tagValue) + { + int tagTypeID = 75; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + /// + /// 订单号(string)(116) + /// + /// + /// + public static void Write_OrderForm_MES(string opName, string tagValue) + { + int tagTypeID = 116; + Write_TagValueByTagTypeID(tagTypeID, opName, tagValue); + } + + #endregion + + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.QualityData.Read.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.QualityData.Read.cs new file mode 100644 index 0000000..92dbfdf --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS.QualityData.Read.cs @@ -0,0 +1,75 @@ +using System; +using System.Data; +using System.Collections; +using MisDataFunDll; + +namespace MesServerWork +{ + public partial class MIS_BASE + { + + /// + /// 读取质量数据 + /// + /// + public static void ReadPLC_Sync_ValueList(string opName, out Hashtable valueList) + { + valueList = null; + ReadPLCData(opName, out valueList); + } + /// + /// 根据工位号 同步读取数据 + /// + /// 工位号 + /// PLC仅仅值列表 + private static void ReadPLCData(string opName, out Hashtable valueList) + { + valueList = new Hashtable(); + + System.Data.DataTable dt; + dt = MisDataFun.BaseData_tagTable_QualityData_Item_B5A(); + + object tagValueStr = "0"; + for (int i = 0; i < dt.Rows.Count; i++) + { + if (opName == dt.Rows[i]["工位号"].ToString()) + { + + DeviceDriver_BasicData.CustomeEvetnArgs qualityDataType; + qualityDataType = new DeviceDriver_BasicData.CustomeEvetnArgs(); + + qualityDataType.TagID = dt.Rows[i]["TagID"].ToString (); + qualityDataType.TagTypeID = Convert.ToInt32(dt.Rows[i]["TagTypeID"]);//变量类型 + qualityDataType.OpName = opName;// + qualityDataType.IsGoodBad = 192;// + qualityDataType.TagQuality = 192;// + qualityDataType.TagValueType = Convert.ToInt32(dt.Rows[i]["变量类型代码"]); + qualityDataType.TagOrderBy = Convert.ToInt32(dt.Rows[i]["列位置"]); + qualityDataType.TagItemOrderBy = Convert.ToInt32(dt.Rows[i]["变量排序"]); + qualityDataType.TagProperty = Convert.ToInt32(dt.Rows[i]["变量特点"]); ;//变量特点 + + MIS_BASE.Read_TagValueByTagID(qualityDataType.TagID.ToString(), out tagValueStr); + + if (Convert.ToInt32(qualityDataType.TagTypeID) == 18) + { + qualityDataType.TagValue = Convert.ToInt32(tagValueStr);//变量值 + } + else + { + qualityDataType.TagValue = tagValueStr;//变量值 + } + valueList.Add(qualityDataType.TagID, qualityDataType); + } + } + } + } + + public class QualityDataSaveList + { + public Hashtable valuList; + public DataTable BasicDataTagValue; + public DataTable BasicDataTagValueUpDown; + public Hashtable hashtable_EngineTypeID; + public Hashtable hashtable_tagTable_OpName_SaveData; + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS_BASE.cs b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS_BASE.cs new file mode 100644 index 0000000..bd2012d --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesDataFunction/MIS_BASE.cs @@ -0,0 +1,341 @@ +using BasicData; + +using MesWork; +using Newtonsoft.Json; +using NPOI.Util; +using OpcBasic; +using System; +using System.Collections; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Linq; +using System.Net.Http; +using System.Runtime.Remoting.Messaging; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerWork +{ + + /* +HeartBeatMIS 15 +EngineTypeGetOverMES 5 +PartPalletGoOver 6 +MaterialVerifyOver 7 +FalseGo 8 +ConfirmOkGo 51 +PartLoadFinish 52 +UnloadCompleted 53 +MachineTime_ReadOver 54 +FixAllow 66 +FixOver 67 +MatchingCompleted 68 +Match 69 +Reserved_1 70 +IsAutoGetEngineID 71 +RepairUplineMES 72 +ProcessCode 77 +BoltCode 88 +RepairStatus 93 +Reserved_3 24 +Reserved_4 25 +Reserved_5 26 +Reserved_6 27 +Reserved_7 28 +Reserved_8 29 +Reserved_9 30 +Reserved_10 31 +Reserved_11 32 +Reserved_12 33 +Reserved_13 34 +Reserved_14 35 +MesReadOver 20 +Reserved_15 110 +Reserved_16 111 +Reserved_17 112 +OnLineState 79 +EngineTypeID_MES 73 +EngineID_MES 74 +EngineType_MES 75 +MarkID 42 +RepairPathString 4 +SPareint1 113 +SPareint2 114 +SPareint3 115 +Sparestring1 116 +Sparestring2 117 +HeartBeatPLC 14 +WorkStart 2 +RepairPartStatusPLC 3 +PartLoad 43 +EngineTypeGetOverPLC 44 +PartLoadOK 48 +Reserved_18 49 +PalletDown 50 +Reserved_19 58 +FixOK 59 +Reserved_20 76 +Reserved_21 61 +Reserved_22 62 +Reserved_23 63 +Reserved_24 64 +Reserved_25 65 +EngineTypeID 9 +EngineID 10 +EngineType 11 +PartPalletCode 80 +PalletInfo 22 +MesRead 19 +PutOn 1000 +WorkOn 1001 +Alarm 1002 +NoPart 1003 +Block 1004 +PartPalletStatus 13 +TargetTimeRead 16 +QualityMask 21 +RepairStatusPLC 23 +MachineTargetTime 17 +MachineActualTime 18 +PLCSPareint1 36 +PLCSPareint2 37 +PLCSPareint3 38 +PLCSarestring1 39 +PLCSarestring2 40 + */ + + + + public partial class MIS_BASE + { + + + /// + ///引用程序集Hashtable + /// + public static Hashtable Hashtable_assembly = new Hashtable(); + /// + /// + /// + static public NameValueCollection hashtable_TagTypeTagName = null; + + /// + /// + /// + static public NameValueCollection hashtable_TagTypeChange = null; + /// + /// + /// + static public NameValueCollection hashtable_WebTagTypeChange = null; + /// + /// + /// + static public NameValueCollection hashtable_MesTagTypeChange = null; + /// + /// + /// + static readonly object l = new object(); + /// + /// + /// + /// + /// + /// + public static object ReadPLC(int tagTypeCodeID, string opName) + { + try + { + return PlcLinkForm.ReadPLC(tagTypeCodeID, opName); + + } + catch { return "-3"; } + } + /// + /// + /// + /// + /// + private static object ReadPLC(string tagID) + { + return PlcLinkForm.ReadPLC(tagID); + } + /// + /// 20230218 + /// 按组读质量数据,返回带合格标志的质量数据列表 + /// + /// + /// + public static Hashtable ReadPLC_Sync_DataList_MesRead_ByOnlyDataGroup(string opName) + { + lock (l) + { + + var tagValues = GetDbAndMaxLengthByOpNameByBytes(opName); + + var keyValues = tagValues.OrderBy(x => x.Key).ToDictionary(k => k.Key, v => v.Value); + + TagFormat tagFormatTemp; + int tagIndex = 1; + int isOK = 0; + + Hashtable ht = new Hashtable(); + + + foreach (KeyValuePair _cd in keyValues) + { + if (_cd.Key.ToString()[0].ToString() == "7") + { + tagFormatTemp = (TagFormat)_cd.Value; + if (tagIndex % 3 == 1) + { + isOK = Convert.ToInt32(tagFormatTemp.TagValue); + } + else if (tagIndex % 3 == 2) + { + var TF = (TagFormat)_cd.Value; + + QualityDataType qualityDataType; + qualityDataType = GetQualityDataType(TF); + qualityDataType.isGoodBad = isOK; + ht.Add(qualityDataType.tagID, qualityDataType); + } + else if (tagIndex % 3 == 0) + { + var TF = (TagFormat)_cd.Value; + + QualityDataType qualityDataType; + qualityDataType = GetQualityDataType(TF); + qualityDataType.isGoodBad = isOK; + ht.Add(qualityDataType.tagID, qualityDataType); + } + + tagIndex++; + } + //Console.WriteLine($"key:{kv.Key} value:{kv.Value}"); + } + return ht; + } + } + + public static ConcurrentDictionary GetDbAndMaxLengthByOpNameByBytes(string opName) + { + string tagStartAdr = ""; + ushort tagAdrListMaxLength = 0; + PlcLinkForm.GetDbAndMaxLengthByOpName(opName, out tagStartAdr, out tagAdrListMaxLength); + var tagAdrListTagFormat = PlcLinkForm.ReadQualityDataList(opName, tagStartAdr, tagAdrListMaxLength); + return tagAdrListTagFormat; + } + + + public static BasicData.QualityDataType GetQualityDataType(TagFormat TF) + { + QualityDataType qualityDataType; + + qualityDataType = new QualityDataType(); + + qualityDataType.tagID = TF.TagID; + qualityDataType.tagTypeID = TF.TagTypeID;//变量类型 + qualityDataType.opName = TF.OpName; + qualityDataType.tagQuality = TF.Code; + qualityDataType.tagValueType = TF.TagTypeCodeID; + int.TryParse(TF.TagOrderBy, out int TagOrderBy); + qualityDataType.tagOrderBy = TagOrderBy; + int.TryParse(TF.TagItemOrderBy, out int TagItemOrderBy); + qualityDataType.tagItemOrderBy = TagItemOrderBy; + qualityDataType.tagProperty = Convert.ToInt32( TF.TagProperty);//变量特点 + qualityDataType.tagValue = TF.TagValue;//变量值 + + return qualityDataType; + } + /// + /// + /// + /// + /// + /// + private static void ReadTagValue(int tagTypeCodeID, string opName, out string tagValue) + { + tagValue = "0"; + try + { + var tagValueObj = PlcLinkForm.ReadPLC(tagTypeCodeID, opName); + var type = tagValueObj.GetType().Name.ToLower(); + if (type == "bool" | type == "boolean") + { + var val = tagValueObj.ToString().ToLower(); + + if (val == "true") + { + tagValue = "1"; + } + } + else + { + tagValue = tagValueObj.ToString(); + } + } + catch { } + } + + /// + /// + /// + /// + /// + /// + private static bool WritePLC(string tagID, object tagValue) + { + return PlcLinkForm.WritePLC(tagID, tagValue); + } + /// + /// + /// + /// + /// + /// + /// + public static bool WritePLC(int tagTypeCodeID, string opName, object tagValue) + { + return PlcLinkForm.WritePLC(tagTypeCodeID, opName, tagValue); + } + /// + /// + /// + /// + /// + /// + /// + private static bool WriteTagValue(int tagTypeCodeID, string opName, object tagValue) + { + return PlcLinkForm.WritePLC(tagTypeCodeID, opName, tagValue); + } + + public static ConcurrentDictionary ReadPLC_OpName(string opName) + { + try + { + string tagStartAdr = ""; + ushort tagAdrListMaxLength = 0; + PlcLinkForm.GetDbAndMaxLengthByOpName(opName, out tagStartAdr, out tagAdrListMaxLength); + var tagAdrListTagFormat0 = PlcLinkForm.ReadQualityDataList(opName, tagStartAdr, tagAdrListMaxLength); + + var pp = JsonConvert.SerializeObject(tagAdrListTagFormat0); + var tagAdrListTagFormat = JsonConvert.DeserializeObject>(pp); + + + return tagAdrListTagFormat; + } + catch (Exception err) + { + return null; + + } + + } + + } + + + +} diff --git a/Common/09MesDataFunction/MesDataFunction/MesWorkPlc.cs b/Common/09MesDataFunction/MesDataFunction/MesWorkPlc.cs new file mode 100644 index 0000000..68db1b0 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MesWorkPlc.cs @@ -0,0 +1,41 @@ + +using MesWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesDataFunction +{ + public class MesWorkPlc: PlcLinkForm + { + + public static Action D_OPCTagData_TagDataOnChangeMIS = null; + + /// + /// 监控数据的所有变化,从这里产生 + /// + /// + /// + public override void OPCTagData_TagDataOnChangeMIS(object sender, DeviceDriver_BasicData.CustomeEvetnArgs e) + { + Console.WriteLine($"【【{e.TagName}【【{e.TagValueBefore}->{e.TagValue}【【{e.TagKeepTime}"); + + if (D_OPCTagData_TagDataOnChangeMIS != null) + D_OPCTagData_TagDataOnChangeMIS(e); + // OPCTagData_TagDataOnChange(sender, e); + } + + /// + /// 定时触发,检测PLC在线状态,周期:3 s + /// + /// + /// + public override void PlcStateEvent(object sender, DeviceDriver_BasicData.PlcStateEvetnArgs eState) + { + + } + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MisDataFunction/Heartbeat.cs b/Common/09MesDataFunction/MesDataFunction/MisDataFunction/Heartbeat.cs new file mode 100644 index 0000000..75d41ea --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MisDataFunction/Heartbeat.cs @@ -0,0 +1,25 @@ +//using bizFacade; +using System; +using System.Collections; +using System.Data; +//using SystemFramework; + +namespace MisDataFunction +{ + partial class Function + { + + private static void Heartbeat(string opName, string tagValue) + { + if (tagValue == "1") + { + Write_TagValueByTagTypeID(15, opName, true); + } + else + { + Write_TagValueByTagTypeID(15, opName, false); + } + } + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MisDataFunction/MIS.Interface.cs b/Common/09MesDataFunction/MesDataFunction/MisDataFunction/MIS.Interface.cs new file mode 100644 index 0000000..904c975 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MisDataFunction/MIS.Interface.cs @@ -0,0 +1,326 @@ + +using bizFacade; +using DoWhatPlc; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +//using SystemFramework; + +namespace MisDataFunction +{ + public partial class Function: MIS_BASE + { + + + + /// + /// 处理MIS逻辑 TagName 变量类型代码 变量类型名称 + /// WorkStart 2 工件到位。托盘到达工位,并且托盘上有工件。 + ///RepairPartStatusPLC 3 备用 + ///RepairPathString 4 工位返修字符串(121211112222111),前2位是西门子字符串格式,第一位是总长度,第二位是实际长度 + ///EngineTypeGetOverMES 5 MES传递总成信息给PLC(上线工位) + ///PartPalletGoOver 6 上线工位。0:正常工作;1:空托盘放行,PLC读取到此标志不走申请上线逻辑。 + ///MaterialVerifyOver 7 MES保存完质量数据,物料数据等与PLC信号交互完成后通知PLC,所以工步都完成,才可以放行工件,正常工作时工件放行的必要条件。 + ///FalseGo 8 按MES界面[不合格放行] 按钮,MES发送此信号。操作者判断工件不合格,通知设备,按不合格方式放行工件,工件流转到返修下线工位后,返修下线。MES工作完成MES0.3=1,MES合格放行MES0.5=0,MES0.4=1 + ///EngineTypeID 9 MES发动机机型标志(必须PLC) + ///EngineID 10 MES发动机编号(必须PLC) + ///EngineType 11 MES发动机机型(必须PLC) + ///PartPalletStatus 13 MES激发变量托盘到位离开(必须PLC) + ///HeartBeatPLC 14 心跳处理:PLC收到MES心跳信号后,PLC延时5秒后,数值取反再写回PLC,写回PLC开始计时,如果5秒钟MES无反馈报通讯故障。 + ///HeartBeatMIS 15 间隔时间5S,心跳处理。收到PLC心跳信号后,MES按原值回写。PLC收到MES信号后延时5秒,取反写入,以此循环。 + ///TargetTimeRead 16 MES允许可读工位运行时间 + ///MachineTargetTime 17 目标运行时间 + ///MachineActualTime 18 实际运行时间 + ///MesRead 19 质量数据可以读数据 + ///MesReadOver 20 MES保存完数据(必须MIS) + ///QualityMask 21 质量数据工位合格标志0:没有工作;1:合格 ;2 :不合格(必须PLC) + ///PalletInfo 22 0空托盘,1合格件,2不合格件 + ///RepairStatusPLC 23 0正常件,1返修件 + ///Reserved_3 24 备用 + ///Reserved_4 25 备用 + ///Reserved_5 26 备用 + ///Reserved_6 27 备用 + ///Reserved_7 28 备用 + ///Reserved_8 29 备用 + ///Reserved_9 30 备用 + ///Reserved_10 31 备用 + ///Reserved_11 32 备用 + ///Reserved_12 33 备用 + ///Reserved_13 34 备用 + ///Reserved_14 35 备用 + ///PLCSPareint1 36 备用 + ///PLCSPareint2 37 备用 + ///PLCSPareint3 38 备用 + ///PLCSarestring1 39 备用 + ///PLCSarestring2 40 备用 + ///MarkID 42 机体打标号(MES)前2位是西门子字符串格式,第一位是总长度,第二位是实际长度 + ///PartLoad 43 上线工位,PLC向MES申请总成编号。收到该信号后,MES将机型标志(DBB22 ~23)、总成号(DBB24 ~63)、总成机型DBB64 ~103写入PLC。之后MES通过信号“传递机型(DBX0.1)”通知PLC。 + ///EngineTypeGetOverPLC 44 PLC将机型标志(DBB50…51)、工件编号(DBB52…101)、产品型号(DBB102…187)、托盘编号(DBB188…189)准备完毕后,通知MES。 + ///PartLoadOK 48 备用 + ///Reserved_18 49 备用 + ///PalletDown 50 暂时保留,项目未使用 + ///ConfirmOkGo 51 按MES界面[合格放行] 按钮,MES发送此信号。操作者判断工件合格,通知设备,工件按合格方式放行工件。MES工作完成MES0.3=1,MES合格放行MES0.5=1,MES0.4=0 + ///ResetDevice 52 针对手动工位,无HMI,需要复位设备在MES页面操作。 + ///UnloadCompleted 53 暂时保留,项目未使用 + ///MachineTime_ReadOver 54 备用 + ///Reserved_19 58 备用 + ///FixOK 59 手动拧紧工位,单工步螺栓拧紧完成,通知PC读取数据。 + ///Reserved_21 61 备用 + ///Reserved_22 62 备用 + ///Reserved_23 63 备用 + ///Reserved_24 64 备用 + ///Reserved_25 65 备用 + ///FixAllow 66 设备工作的必须信号,对于有物料验证的工位,MES验证完成给出此信号,对于无物料验证工位,MES直接给出此信号。 + ///FixOver 67 用于手动拧紧且有质量数据工位。通知设备当前工步拧紧螺钉工作结束。 + ///MatchingCompleted 68 分线上总线,匹配成功是1;不成功是0。 + ///Match 69 分线上总线,匹配成功是1;不成功是0。 + ///Reserved_2 70 备用 + ///IsAutoGetEngineID 71 自动手动申请工件编号。0是自动方式;1:手动方式。暂时保留,生成流水号方式是在数据库中实现的 + ///RepairUplineMES 72 上线清空MOBY(针对上线工位):通知PLC从新开始申请上线流程 + ///EngineTypeID_MES 73 MES发动机机型标志(必须MES) + ///EngineID_MES 74 MES发动机编号(必须MES) + ///EngineType_MES 75 MES发动机机型(必须MES) + ///Reserved_20 76 备用 + ///ProcessCode 77 手动拧紧工位:由MES通知PLC拧紧序号 + ///OnLineState 79 通过线体工位PC实现下达工位工作状态:工位有三种状态:在线、离线、屏蔽。在线:0正常状态,实现正常功能。1离线:设备脱离MES工作,进入不交互模式。 + ///PartPalletCode 80 托盘编号(B5A) + ///BoltCode 88 手动拧紧工位:指导PLC所用套筒 + ///RepairStatus 93 0正常件,1返修件。对于上线工位MES给出是正常上线还是返修上线,返修路径 + ///Reserved_15 110 备用 + ///Reserved_16 111 备用 + ///Reserved_17 112 备用 + ///SPareint1 113 备用int1 + ///SPareint2 114 备用int2 + ///SPareint3 115 备用int3 + ///Sparestring1 116 备用字符串1 + ///Sparestring2 117 备用字符串2 + ///MachineStatusPutOn 1000 机床上电(必须PLC) + ///MachineStatusWorkOn 1001 循环开始(必须PLC) + ///MachineStatusAlarm 1002 机床故障(必须PLC) + ///MachineStatusNoPart 1003 上料无件(必须PLC) + ///MachineStatusBlock 1004 下料堵塞(必须PLC) + ///Alarm 103 设备报警 + /// + /// + public static void MIS_Funtion(object e) + { + try + { + + string recData = e.ToString(); + string[] dataArray = recData.Split('|'); + if (dataArray.Length != 4) + return; + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + DoWhatPlc.ReturnValueString rv = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + //Console.WriteLine($"【【{rv.TagID}【【【【{ rv.TagKeepTime}"); + + int tagType; + string opName; + string tagValue; + int tagid; + DoWhatPlc.ReturnValueString msgEvent = rv; + if (msgEvent.TagValue == null) return; + tagType = Convert.ToInt32(msgEvent.TagTypeID); + opName = msgEvent.OpName.ToString(); + tagid = Convert.ToInt32(msgEvent.TagID); + + + //int tagType; + //string opName; + //string tagValue; + //int tagid; + //DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + //if (msgEvent.TagValue == null) return; + //tagType = Convert.ToInt32(msgEvent.TagType); + //opName = msgEvent.OpName.ToString(); + //tagid = Convert.ToInt32(msgEvent.TagKey); + switch (Convert.ToInt32(msgEvent.TagTypeCodeID)) + { + case 11: + switch (msgEvent.TagValue.ToLower()) + { + case "1": + case "true": + tagValue = "1"; + break; + default: + tagValue = "0"; + break; + } + break; + default: + tagValue = msgEvent.TagValue.ToString(); + break; + } + ///根据信号处理逻辑 + switch (tagType) + { + case 19: + //允许保存 + MesRead(opName, tagValue, tagid); + break; + case 14: + //心跳 + Heartbeat(opName, tagValue); + break; + case 44://PLC传递机型过后 才允许保存过站信息,否则不允许保存 + //if (tagValue == "1") + //{ + // IsEngTypeGetOver_Write(opName, true); + + // EngineData Enginedata = new EngineData(DtWebApi.ReadWritePLC.ReadPLC("10", opName).ToString(), Convert.ToInt32(DtWebApi.ReadWritePLC.ReadPLC("80", opName))); + // //EngineData Enginedata = new EngineData(MesDataFunction.OpcOperation.ReadPLC(10, opName).ToString(), Convert.ToInt32(MesDataFunction.OpcOperation.ReadPLC(80, opName))); + // //保存产品编号、托盘号 保存过站信息用 + // EngineData_Hash_Write(opName, Enginedata); + //} + break; + case 2://工件到位 + WorkStart( rv); + + + //WorkStart(opName, tagValue); + break; + case 51: + if (hashtableOpName_IsHaveComputer[opName].ToString() == "1") + { + SaveProductLeaveData(opName, 1); + } + + break; + case 8: + if (hashtableOpName_IsHaveComputer[opName].ToString() == "1") + { + SaveProductLeaveData(opName, 2); + } + break; + case 103: + + Alarm_Insert(rv); + + break; + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, err.Message); + } + } + private static void Alarm_Insert(ReturnValueString rv) + { + string TagID; + string opName; + string tagTypeID; + int TagValue; + + DateTime alarmStartTime; + DateTime alarmEndTime; + int TimeDiff; + string TagOrderBy; + string Text1; + string Text2; + TagID = rv.TagID; + tagTypeID = rv.TagTypeID; + opName = rv.OpName; + TagValue = Convert.ToInt32( rv.TagValue); + + alarmStartTime = Convert.ToDateTime( rv.TimeStampBefore); + alarmEndTime = Convert.ToDateTime( rv.TimeStamp); + TimeDiff = Convert.ToInt32(rv.TagKeepTime); + TagOrderBy = rv.TagOrderBy; + Text1 = rv.ItemName; + Text2 = rv.ShaftID; + + BaseDataSystemMES.Alarm_Insert(TagID, tagTypeID, opName, TagValue, + alarmStartTime, alarmEndTime, TimeDiff, Text1, Text2, TagOrderBy); + } + private static void WorkStart(ReturnValueString rv) + { + + + + var ro = rv.ReturnValueToObject(); + + string opName = ro.OpName; + DateTime arrivedTime = ro.TimeStampBefore; + DateTime leavedTime = ro.TimeStamp; + int TimeDiff = ro.TagKeepTime; + int targetTime = 0; + string isPass = ""; + + int QualityMark=0; + string tagValue="0"; + switch (ro.TagValue.ToString().ToLower()) + { + case "1": + case "true": + tagValue = "1"; + break; + default: + tagValue = "0"; + break; + } + //if (ro.TagValue.ToString() == "0") + //{ + // //Write_TagTypeID(5, opName, false);//MES传递机型 + // //Write_TagTypeID(66, opName, false);//允许工作 + // //Write_TagTypeID(51, opName, false);//合格放行 + // //Write_TagTypeID(8, opName, false);//不合格放行 + // //Write_TagTypeID(7, opName, false);//工作完成 + // //Write_TagTypeID(20, opName, false);//保存完成 + + // //string isHaveComputer = hashtableOpName_IsHaveComputer[opName].ToString(); + // //if (Convert.ToInt32(isHaveComputer) == 0)//自动工位 读合格标志 + // //{ + // // if (IsEngTypeGetOver_Read(opName)) + // // { + // // //PLC未传递机型 不保存过站信息 + // // SaveProductLeaveData_AutoWorkStation(opName, Convert.ToInt32(DtWebApi.ReadWritePLC.ReadPLC("21", opName))); + // // //SaveProductLeaveData_AutoWorkStation(opName, Convert.ToInt32(MesDataFunction.OpcOperation.ReadPLC(21, opName))); + // // } + + // //} + + // ////清空信号 + // ////m_WorkStart_OpName[opName] = 0;//清空工件到位标志 + // ////通知WEB更新产量 + // //SendActuallyCount(opName, 0); + //} + + QualityMark = Convert.ToInt32(ReadPLC(21, opName)); + + if (QualityMark == 1) + { + isPass = "1"; + } + else + { + isPass = "0"; + } + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(opName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code,out OrderForm); + + //EngineData Enginedata = (EngineData)EngineData_Hash_Read(opName); + BaseDataSystemMES.WorkStartInsert_AutoWorkStation(opName, EngineID, PartPallet_Code, arrivedTime, leavedTime, TimeDiff, targetTime, null, isPass, 0); + + } + + + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/MisDataFunction/MesRead.cs b/Common/09MesDataFunction/MesDataFunction/MisDataFunction/MesRead.cs new file mode 100644 index 0000000..f716152 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MisDataFunction/MesRead.cs @@ -0,0 +1,465 @@ +//using BasicData; +using bizFacade; +using DoWhatPlc; +using Newtonsoft.Json; +//using bizFacade; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +//using SystemFramework; + +namespace MisDataFunction +{ + partial class Function + { + /// + /// 获取质量数据Hashtable + /// + /// + /// + //static public Hashtable ReadPLC_Sync_DataList_MesRead(string opName) + //{ + // return (Hashtable)MesDataFunction.OpcOperation.ReadPLC_Sync_DataList_MesRead(opName); + //} + static object lockerReadPLC_Sync_DataList_MesRead1 = new object(); + public static void ReadPLC_Sync_DataList_MesRead(string opName, out Hashtable valueList, out DataTable BasicDataTagValue, out DataTable BasicDataTagValueUpDown, out Hashtable hashtable_EngineTypeID, out Hashtable hashtable_tagTable_OpName_SaveData) + { + //QualityDataSaveList QualityDataType + valueList = new Hashtable(); + //var qualityDataSaveList = DtWebApi.SaveData.ReadPLC_Sync_DataList_MesRead(opName); + var qualityDataSaveList = MesServerWork.MIS_BASE.ReadPLC_Sync_DataList_MesRead(opName); + foreach (DictionaryEntry de in qualityDataSaveList.valuList) + { + valueList.Add(de.Key, JsonConvert.DeserializeObject(de.Value.ToString())); + } + BasicDataTagValue = qualityDataSaveList.BasicDataTagValue; + BasicDataTagValueUpDown = qualityDataSaveList.BasicDataTagValueUpDown; + hashtable_EngineTypeID = qualityDataSaveList.hashtable_EngineTypeID; + hashtable_tagTable_OpName_SaveData = qualityDataSaveList.hashtable_tagTable_OpName_SaveData; + } + public static Hashtable ReadPLC_Sync_DataList_MesRead(string opName) + { + lock (lockerReadPLC_Sync_DataList_MesRead1) + { + Hashtable ht = new Hashtable(); + var cd = ReadPLC_GroupData(opName); + //var cd = PlcLinkForm.ReadPLC_GroupData(opName); + + foreach (var _cd in cd) + { + var tagID = Convert.ToInt32(_cd.TagID); + var TF =_cd.TF; + + QualityDataType qualityDataType; + qualityDataType = new QualityDataType(); + + qualityDataType.tagID = TF.TagID; + qualityDataType.tagTypeID = TF.TagTypeID;//变量类型 + qualityDataType.opName = opName; + qualityDataType.isGoodBad = 192; + int.TryParse(TF.TagQuality, out int TagQuality); + qualityDataType.tagQuality = TagQuality; + qualityDataType.tagValueType = TF.TagTypeCodeID; + int.TryParse(TF.TagOrderBy, out int TagOrderBy); + qualityDataType.tagOrderBy = TagOrderBy; + int.TryParse(TF.TagItemOrderBy, out int TagItemOrderBy); + qualityDataType.tagItemOrderBy = TagItemOrderBy; + qualityDataType.tagProperty = TF.TagProperty;//变量特点 + qualityDataType.tagValue = TF.TagValue;//变量值 + + ht.Add(tagID, qualityDataType); + } + return ht; + } + + } + + /// + /// 允许保存(针对半自动和手动压装工位) + /// + /// + /// + private static void MesRead(string opName, string tagValue, int tagid) + { + if (tagValue == "0") + { + Write_TagValueByTagTypeID(20, opName, false); + } + else + { + SaveQualityData(opName, Convert.ToInt32(tagValue), tagid); + } + } + + private static void SaveQualityData(string opName, int tagValue, int tagID) + { + try + { + int id_tagCF; + int qualityMask = 0; + int engineTypeID = 0; + string engineID = ""; + string engineType = ""; + string engineTraceCode = ""; + string engineCap = ""; + string partPallet = ""; + DataTable dt_WWW; + dt_WWW = BaseDataSystemMES.BuildDataTables_WWW(); + Hashtable valueList; + //valueList = ReadPLC_Sync_DataList_MesRead(opName); + ReadPLC_Sync_DataList_MesRead(opName, out valueList, out BasicDataTagValue, out BasicDataTagValueUpDown, out hashtable_EngineTypeID, out hashtable_tagTable_OpName_SaveData); + valueList = GetQualityData_GoodBad_Values(valueList); + int mes_MustTest = 0; + int onLineState = 0; + int partMoveDirection = 0; + int pressIsOK = 0; + int pressIsNoOK = 0; + BaseDataSystemMES.GetQualityDataTable_B5A(valueList, opName, BasicDataTagValue, + BasicDataTagValueUpDown, + out dt_WWW,//数据列表 + out qualityMask,//工位合格标志 + out engineTypeID,//发动机类型代码 + out engineID,//发动机编号 + out engineType, //发动机型号 + out partPallet,//托盘编号 + out engineTraceCode, //发动机条码 + out engineCap,//缸盖号, + hashtable_EngineTypeID,//发动机类型转换表 + out mes_MustTest, out onLineState, out partMoveDirection, out pressIsOK, out pressIsNoOK); + + + + + // 1:通过监控系统保存采集的质量数据;0:不通过监控系统保存采集的质量数据 + if (Convert.ToInt32(hashtable_tagTable_OpName_SaveData[opName]) != 0) + { + DateTime lastupdatetime = DateTime.Now; + + BaseDataSystemMES.BaseData_tagTable_QualityData_B5A_IndexInsert(engineID, tagID, engineType, engineTypeID, opName, qualityMask, partPallet, out id_tagCF); + BaseDataSystemMES.BaseData_tagTable_QualityData_B5A_Insert(id_tagCF, engineTypeID, engineID, opName, dt_WWW); + + } + Write_TagValueByTagTypeID(20, opName, true); + #region + //string orderForm = ""; + //string operatorCode = ""; + //int shiftCode = 1; + //DateTime arrivedTime; + //DateTime leavedTime; + //int TimeDiff; + //int targetTime = 0; + //string lineType = ""; + //string isPass; + //int machineWorkOn = 0; + //int arrivedOrLeaved = 2; + //int cartColorOpName = 0; + //int cartColorConfirm = 0; + //// int partMoveDirection; + //int partGoOver = 0; + //if (qualityMask == 1) + //{ + // isPass = "PASS"; + //} + //else + //{ + // isPass = "FAIL"; + //} + + ////工位上下线类型 + ////(0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线) + //int OpNameUpDownType; + //OpNameUpDownType = Convert.ToInt32(hashtableOpName_OpType[opName]); + //arrivedTime = (DateTime)m_WorkStart_OpName_Time[opName]; + //leavedTime = DateTime.Now; + //TimeDiff = Convert.ToInt32(leavedTime.Subtract(arrivedTime).TotalSeconds); + + //lineType = hashtableOpName_LineType[opName].ToString(); + + //string isHaveComputer = hashtableOpName_IsHaveComputer[opName].ToString(); + ////isHaveComputer = MIS_BASE.hashtable_tagTable_OpName_SaveData[opName].ToString(); + ////有计算机的工位,通过工位计算机保存[测量数据发动机在线状态]。 + //if (Convert.ToInt32(isHaveComputer) == 0) + //{ + // //1->0 工件离开 工件刚刚离开 + // if (Convert.ToInt32(m_WorkStart_OpName[opName]) == 1) + // { + + // //[测量数据发动机在线状态] + // QualityDataSystem.WorkStartInsert + // (opName, orderForm, engineTypeID, engineType, engineID, partPallet.ToString(), operatorCode, shiftCode, + // arrivedTime, leavedTime, TimeDiff, targetTime, lineType, isPass, machineWorkOn, + // arrivedOrLeaved, cartColorOpName, cartColorConfirm, partMoveDirection, partGoOver, mes_MustTest, onLineState, OpNameUpDownType); + // } + //} + #endregion + } + catch (Exception err) + { + Write_TagValueByTagTypeID(20, opName, true); + ////ApplicationLog.WriteLog(err, err.Message); + } + + } + public static void SaveQualityData_Mes(string opName, int tagID) + { + try + { + int id_tagCF; + int qualityMask = 0; + int engineTypeID = 0; + string engineID = ""; + string engineType = ""; + string engineTraceCode = ""; + string engineCap = ""; + string partPallet = ""; + DataTable dt_WWW; + dt_WWW = BaseDataSystemMES.BuildDataTables_WWW(); + Hashtable valueList; + valueList = ReadPLC_Sync_DataList_MesRead(opName); + valueList = GetQualityData_GoodBad_Values(valueList); + int mes_MustTest = 0; + int onLineState = 0; + int partMoveDirection = 0; + int pressIsOK = 0; + int pressIsNoOK = 0; + BaseDataSystemMES.GetQualityDataTable_B5A(valueList, opName, BasicDataTagValue, + BasicDataTagValueUpDown, + out dt_WWW,//数据列表 + out qualityMask,//工位合格标志 + out engineTypeID,//发动机类型代码 + out engineID,//发动机编号 + out engineType, //发动机型号 + out partPallet,//托盘编号 + out engineTraceCode, //发动机条码 + out engineCap,//缸盖号, + hashtable_EngineTypeID,//发动机类型转换表 + out mes_MustTest, out onLineState, out partMoveDirection, out pressIsOK, out pressIsNoOK); + // 1:通过监控系统保存采集的质量数据;0:不通过监控系统保存采集的质量数据 + if (Convert.ToInt32(hashtable_tagTable_OpName_SaveData[opName]) != 0) + { + DateTime lastupdatetime = DateTime.Now; + BaseDataSystemMES.BaseData_tagTable_QualityData_B5A_IndexInsert(engineID, tagID, engineType, engineTypeID, opName, qualityMask, partPallet, out id_tagCF); + //BaseDataSystemMES.BaseData_tagTable_QualityData_B5A_Insert(id_tagCF, engineTypeID, engineID, opName, dt_WWW); + + } + + + } + catch (Exception err) + { + Write_TagValueByTagTypeID(20, opName, true); + ////ApplicationLog.WriteLog(err, err.Message); + } + + } + + /// + /// 确定合格标志 + /// + /// + /// + static public Hashtable GetQualityData_GoodBad_Values(Hashtable valuList) + { + try + { + Hashtable valuList_Temp; + valuList_Temp = (Hashtable)valuList.Clone(); + int[] value_GoodBad_New = new int[128]; + int tagID; + QualityDataType value; + //1:获得合格标志 + foreach (DictionaryEntry de in valuList) //ht为一个Hashtable实例 + { + tagID = Convert.ToInt32(de.Key); + value = (QualityDataType)de.Value; + + //拧紧数据合格标志 + if (value.tagProperty == 1) + { + if (value.tagTypeID == 8203) + { + value_GoodBad_New = (int[])value.tagValue; + break; + } + else + { + value_GoodBad_New[value.tagOrderBy - 1] = Convert.ToInt32(value.tagValue); + } + } + //拧紧数据合格标志 + if (value.tagProperty == 8) + { + if (value.tagTypeID == 8203) + { + value_GoodBad_New = (int[])value.tagValue; + break; + } + else + { + value_GoodBad_New[value.tagOrderBy - 1] = Convert.ToInt32(value.tagValue); + } + } + //压装数据合格标志 + if (value.tagProperty == 7) + { + value_GoodBad_New[value.tagOrderBy - 1] = Convert.ToInt32(value.tagValue); + } + } + //将合格标志赋予每个变量 + foreach (DictionaryEntry de in valuList) //ht为一个Hashtable实例 + { + tagID = Convert.ToInt32(de.Key); + value = (QualityDataType)de.Value; + //201706061720新加 + if (value .tagTypeID ==11) + { + if (value.tagValue.ToString ()=="False") + { + value.tagValue ="0"; + } + else + { + value.tagValue = "1"; + } + valuList_Temp[tagID] = value; + //value.tagValue = Convert.ToInt32(value.tagValue); + } + + + //测量变量 + if (value.tagProperty == 2 || value.tagProperty == 6) + { + try + { + if (value_GoodBad_New != null) + { + value.isGoodBad = Convert.ToInt32(value_GoodBad_New[value.tagOrderBy - 1]); + valuList_Temp[tagID] = value; + } + else + { + value.isGoodBad = 0; + valuList_Temp[tagID] = value; + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, err.Message); + + } + } + + + + } + return valuList_Temp; + } + catch//转换出了故障时 + { + return valuList; + } + } + + + + /// + /// 制定工位PLC是否传递过机型 (默认不传递机型不保存过站信息) + /// + static Hashtable EngTypeGetOver = new Hashtable(); + + static Hashtable EngineData_Hash = new Hashtable(); //保存 + + public static void IsEngTypeGetOver_Write(string OpName, bool value) + { + if (EngTypeGetOver.ContainsKey(OpName)) + { + EngTypeGetOver[OpName] = value; + } + else + { + EngTypeGetOver.Add(OpName, value); + } + } + + + public static bool IsEngTypeGetOver_Read(string OpName) + { + if (EngTypeGetOver.ContainsKey(OpName)) + { + return Convert.ToBoolean(EngTypeGetOver[OpName]); + } + else + { + return true; + } + } + + public static void EngineData_Hash_Write(string OpName, object value) + { + if (EngineData_Hash.ContainsKey(OpName)) + { + EngineData_Hash[OpName] = value; + + } + else + { + EngineData_Hash.Add(OpName, value); + } + } + + public static object EngineData_Hash_Read(string OpName) + { + if (EngineData_Hash.ContainsKey(OpName)) + { + return EngineData_Hash[OpName]; + } + else + { + return null; + } + + } + + + private DataTable ChangeQualificationMark(DataTable dt) + { + var dtNew = dt.Copy(); + for (int i = 0; i < dt.Rows.Count; i++) + { + var 变量排序 = dt.Rows[i]["变量排序"].ToString(); + if (变量排序 == "0") + { + + } + } + + + return dtNew; + } + + + + + } + struct EngineData + { + public EngineData(string engineID, int pallet) + { + EngineID = engineID; + Pallet = pallet; + } + + public string EngineID;//工件编号 + //public string EngineType; + //public int EngineTypeID; + public int Pallet;//托盘号 + + } + + + + + + +} diff --git a/Common/09MesDataFunction/MesDataFunction/MisDataFunction/WorkStart.cs b/Common/09MesDataFunction/MesDataFunction/MisDataFunction/WorkStart.cs new file mode 100644 index 0000000..0ab46b5 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/MisDataFunction/WorkStart.cs @@ -0,0 +1,236 @@ +//using BasicData; +using bizFacade; +//using DataBaseAccess; +//using bizFacade; +using DataLinkMesWork; +using MesServerWork; +using System; +using System.Collections; +using System.Data; +using System.Data.SqlClient; +//using SystemFramework; + +namespace MisDataFunction +{ + partial class Function + { + /// + /// 工件到位与离开时,清空MES自身信号 + /// + /// + /// + private static void WorkStart(string opName, string tagValue) + { + try + { + //工位没有工件,或工件刚刚离开 工件离开工位后,清空该工位的发动机号 + if (tagValue == "0") + { + Write_TagValueByTagTypeID(5, opName, false);//MES传递机型 + Write_TagValueByTagTypeID(66, opName, false);//允许工作 + Write_TagValueByTagTypeID(51, opName, false);//合格放行 + Write_TagValueByTagTypeID(8, opName, false);//不合格放行 + Write_TagValueByTagTypeID(7, opName, false);//工作完成 + Write_TagValueByTagTypeID(20, opName, false);//保存完成 + + //string isHaveComputer = hashtableOpName_IsHaveComputer[opName].ToString(); + //if (Convert.ToInt32(isHaveComputer) == 0)//自动工位 读合格标志 + { + if (IsEngTypeGetOver_Read(opName)) + { + //PLC未传递机型 不保存过站信息 + SaveProductLeaveData_AutoWorkStation(opName, Convert.ToInt32(Read_TagValueByTagTypeID(21, opName))); + //SaveProductLeaveData_AutoWorkStation(opName, Convert.ToInt32(MesDataFunction.OpcOperation.ReadPLC(21, opName))); + } + + } + + //清空信号 + //m_WorkStart_OpName[opName] = 0;//清空工件到位标志 + //通知WEB更新产量 + SendActuallyCount(opName,0); + } + else + { + //保存工件到达数据 + //m_WorkStart_OpName_Time[opName] = DateTime.Now; + //m_WorkStart_OpName[opName] = 1; + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, err.Message); + + } + } + /// + /// 保存过站信息 (数据库读机型信息) + /// + /// + /// + static void SaveProductLeaveData(string opName, int QualityMark) + { + try + { + if (!IsEngTypeGetOver_Read(opName)) + { + //PLC未传递机型 不保存过站信息 + return; + } + IsEngTypeGetOver_Write(opName, false);//清空传递机型标志 + + DateTime arrivedTime; + DateTime leavedTime; + int TimeDiff; + int targetTime = 0; + string lineType = ""; + string isPass; + if (QualityMark == 1) + { + isPass = "PASS"; + } + else + { + isPass = "FAIL"; + } + //工位上下线类型 + //(0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线) + int OpNameUpDownType; + OpNameUpDownType = Convert.ToInt32(hashtableOpName_OpType[opName]); + arrivedTime = (DateTime)m_WorkStart_OpName_Time[opName]; + leavedTime = DateTime.Now; + TimeDiff = Convert.ToInt32(leavedTime.Subtract(arrivedTime).TotalSeconds); + lineType = hashtableOpName_LineType[opName].ToString(); + + //1->0 工件离开 工件刚刚离开 + //if (Convert.ToInt32(m_WorkStart_OpName[opName]) == 1) + //{ + // WorkStartInsert(opName, arrivedTime, leavedTime, TimeDiff, targetTime, lineType, isPass, OpNameUpDownType); + //} + //通知WEB更新产量 + SendActuallyCount(opName, 0); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, err.Message); + + } + + + } + /// + /// 保存过站信息 (数据库读机型信息) + /// + /// + /// + static void SaveProductLeaveData_AutoWorkStation(string opName, int QualityMark) + { + try + { + if (!IsEngTypeGetOver_Read(opName)) + { + //PLC未传递机型 不保存过站信息 + return; + } + IsEngTypeGetOver_Write(opName, false);//清空传递机型标志 + + DateTime arrivedTime; + DateTime leavedTime; + int TimeDiff; + int targetTime = 0; + string lineType = ""; + string isPass; + if (QualityMark == 1) + { + isPass = "PASS"; + } + else + { + isPass = "FAIL"; + } + //工位上下线类型 + //(0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线) + int OpNameUpDownType; + //OpNameUpDownType = Convert.ToInt32(hashtableOpName_OpType[opName]); + // arrivedTime = (DateTime)m_WorkStart_OpName_Time[opName]; + leavedTime = DateTime.Now; + //TimeDiff = Convert.ToInt32(leavedTime.Subtract(arrivedTime).TotalSeconds); + //lineType = hashtableOpName_LineType[opName].ToString(); + + //1->0 工件离开 工件刚刚离开 + //if (Convert.ToInt32(m_WorkStart_OpName[opName]) == 1) + //{ + // //查询工件编号、托盘号 + //EngineData Enginedata = (EngineData)EngineData_Hash_Read(opName); + //WorkStartInsert_AutoWorkStation(opName, Enginedata.EngineID, Enginedata.Pallet, arrivedTime, leavedTime, TimeDiff, targetTime, lineType, isPass, OpNameUpDownType); + //} + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, err.Message); + + } + + + } + + /// + /// 测量数据发动机在线状态_增加数据 + /// + /// + /// + /// + /// + /// + /// + static public void WorkStartInsert(string opName, DateTime arrivedTime, DateTime leavedTime, int TimeDiff, int Target, string lineType, string isPass, int OpNameUpDownType) + { + string procedureName; + procedureName = "测量数据发动机在线状态_增加数据"; + SqlParameter[] thisParms = new SqlParameter[8]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@到达时间", arrivedTime); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@离开时间", leavedTime); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@在线时间", TimeDiff); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@目标时间", Target); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@线体类型", lineType); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@是否合格", isPass); + thisParms[7] = new System.Data.SqlClient.SqlParameter("@工位上下线类型", OpNameUpDownType); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms); + } + + + + /// + /// 发送在线产量、在线节拍 + /// + /// + /// + static void SendActuallyCount(string OpName, int tagValue) + { + //当工件离开时,更新在线产量、在线节拍 + if (tagValue == 0) + { + try + { + int opNameCount = 0;//在线产量 + int opNameCountTime = 0;//在线节拍 + //基本数据_工作日历_班次产量查询_New + BaseDataSystemMES.OpNameCount_New(OpName, out opNameCount, out opNameCountTime); + + string SendMessage; + SendMessage = "MES|ActuallyCount|" + OpName + "|" + opNameCount.ToString() + "&" + opNameCountTime.ToString(); + + MIS_BASE.asyncSendMessage(SendMessage); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function01:SendActuallyCount"); + } + } + } + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/Properties/AssemblyInfo.cs b/Common/09MesDataFunction/MesDataFunction/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..057bcf1 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("MesDataFunction")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("MesDataFunction")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("90e76fb4-646d-45e2-95db-0b8ab4e465d6")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Common/09MesDataFunction/MesDataFunction/ToPrinter/PP.cs b/Common/09MesDataFunction/MesDataFunction/ToPrinter/PP.cs new file mode 100644 index 0000000..a861074 --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/ToPrinter/PP.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesDataFunction +{ + public class PP + { + + public static string ConnectionString_MES { get; set; } + public static string PrintURL { get; set; } + public static int IsDemoMesServer { get; set; } + + + + + + + + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/ToPrinter/PrintTo.cs b/Common/09MesDataFunction/MesDataFunction/ToPrinter/PrintTo.cs new file mode 100644 index 0000000..7e3d91d --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/ToPrinter/PrintTo.cs @@ -0,0 +1,65 @@ +using MesWork; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesDataFunction +{ + public class PrintTo + { + + /// + /// + /// + /// + public static bool Print(bool isSinglePrint,string url,string[] strArray) + { + if (PP.IsDemoMesServer == 1) + { + var list = new List(); + foreach (string str in strArray) + { + var printStr = str; + if (isSinglePrint) + { + printStr = str.Replace("^XB", ""); + } + list.Add(printStr); + } + + File.WriteAllText($"PrintContent_{DateTime .Now.ToString ("yyyy_MM_dd_HH_mm_ss")}.print", string.Join (" ", list)); + + return true; + } + + + var sucess = false; + try + { + var client = new System.Net.Sockets.TcpClient(); + client.Connect(url.Split(':')[0], Convert.ToInt32(url.Split(':')[1])); + + foreach (string str in strArray) + { + var printStr = str; + if (isSinglePrint) + { + printStr = str.Replace("^XB", ""); + } + client.Client.Send(System.Text.Encoding.ASCII.GetBytes(printStr)); + } + client.Close(); + + sucess = true; + } + catch (Exception err) { } + + return sucess; + } + + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/ToPrinter/Print_Sql.cs b/Common/09MesDataFunction/MesDataFunction/ToPrinter/Print_Sql.cs new file mode 100644 index 0000000..69fb29d --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/ToPrinter/Print_Sql.cs @@ -0,0 +1,80 @@ +using MesDataFunction; +using MesWork; +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesDataFunction +{ + public class Print_Sql + { + + + public static bool Select_Print_Template(out DataTable dt_Print_Template) + { + /* +SELECT [IDG],[TemplateName],[TemplateContent],[DefSelect],[UpdateTime] FROM [OL_Repair_Print_Template] + */ + + bool success = false; + var sql = +@" +SELECT [IDG],[TemplateName],[DefSelect],[UpdateTime] FROM [OL_Repair_Print_Template] +ORDER BY [UpdateTime] +"; + success = DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, PP.ConnectionString_MES, out DataTable dt, out string err2); + dt_Print_Template = dt; + return success; + + } + + public static bool Select_Print_TemplateStr(string IDG, out string templateStr) + { + /* +SELECT [IDG],[TemplateName],[TemplateContent],[DefSelect],[UpdateTime] FROM [OL_Repair_Print_Template] + */ + templateStr = ""; + bool success = false; + var sql = + $" DECLARE @IDG nvarchar(50) = '{IDG}'" + +@" +SELECT [TemplateContent] FROM [OL_Repair_Print_Template] +WHERE [IDG] = @IDG +"; + success = DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, PP.ConnectionString_MES, out DataTable dt, out string err2); + if (dt.Rows.Count > 0) + { + templateStr = dt.Rows[0]["TemplateContent"].ToString(); + } + return success; + + } + + public static bool Select_Print_Template_Def(out string templateStr) + { + /* +SELECT [IDG],[TemplateName],[TemplateContent],[DefSelect],[UpdateTime] FROM [OL_Repair_Print_Template] + */ + templateStr = ""; + bool success = false; + var sql = +@" +SELECT top 1 [TemplateContent] FROM [OL_Repair_Print_Template] +WHERE [DefSelect]= 'True' +"; + success = DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, PP.ConnectionString_MES, out DataTable dt, out string err2); + if (dt.Rows.Count > 0) + { + templateStr = dt.Rows[0]["TemplateContent"].ToString(); + } + return success; + + } + + + } +} diff --git a/Common/09MesDataFunction/MesDataFunction/ToPrinter/PrinterCommandCenter.cs b/Common/09MesDataFunction/MesDataFunction/ToPrinter/PrinterCommandCenter.cs new file mode 100644 index 0000000..9b83dcc --- /dev/null +++ b/Common/09MesDataFunction/MesDataFunction/ToPrinter/PrinterCommandCenter.cs @@ -0,0 +1,33 @@ +using MesWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesDataFunction +{ + public class PrinterCommandCenter + { + + public static bool PrintToPrinter(string code) + { + bool success = false; + + Print_Sql.Select_Print_Template_Def(out string templateStr); + var printContent = Template_Make_Zpl(templateStr, code); + + PrintTo.Print(true, PP.PrintURL, new string[] { printContent }); + + return success; + } + + + public static string Template_Make_Zpl(string templateStr,string TowCode) + { + return templateStr.Replace("@TowCode", TowCode); + } + + + } +} diff --git a/Common/MyLog4Net/00_MyLog4Net.csproj b/Common/MyLog4Net/00_MyLog4Net.csproj new file mode 100644 index 0000000..1c1c6ad --- /dev/null +++ b/Common/MyLog4Net/00_MyLog4Net.csproj @@ -0,0 +1,61 @@ + + + + + Debug + AnyCPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F} + Library + Properties + MyLog4Net + MyLog4Net + v4.8 + 512 + true + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\log4net.2.0.14\lib\net45\log4net.dll + + + + + + + + + + + + + + + + + + + + + Always + + + + \ No newline at end of file diff --git a/Common/MyLog4Net/MyLogEventArgs.cs b/Common/MyLog4Net/MyLogEventArgs.cs new file mode 100644 index 0000000..a913363 --- /dev/null +++ b/Common/MyLog4Net/MyLogEventArgs.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MyLog4Net +{ + public class MyLogEventArgs : EventArgs + { + public string Message { get; set; } + public string Module { get; set; } + } +} diff --git a/Common/MyLog4Net/MyLogHelper.cs b/Common/MyLog4Net/MyLogHelper.cs new file mode 100644 index 0000000..cb446e4 --- /dev/null +++ b/Common/MyLog4Net/MyLogHelper.cs @@ -0,0 +1,65 @@ +using log4net; +using System; + +namespace MyLog4Net +{ + public class MyLogHelper + { + public delegate void MyLogEventHandler(object sender, MyLogEventArgs e); + public static event MyLogEventHandler LogCommit; + + /// + /// 普通日志 + /// + /// 日志内容 + public static void Info(string module, string message) + { + ILog log = LogManager.GetLogger(module); + if (log.IsInfoEnabled) + { + log.Info(message); + + var e = new MyLogEventArgs(); + e.Module = module; + e.Message = message; + LogCommit?.Invoke(null, e); + } + } + /// + /// 错误日志带异常 + /// + /// 错误日志 + public static void Error(string module, string message, Exception ex) + { + ILog log = LogManager.GetLogger(module); + if (log.IsErrorEnabled) + { + log.Error(message, ex); + + var e = new MyLogEventArgs(); + e.Module = module; + e.Message = message; + LogCommit?.Invoke(null, e); + } + } + + /// + /// 错误日志不带异常 + /// + /// 错误日志 + public static void Error(string module, string message) + { + ILog log = LogManager.GetLogger(module); + if (log.IsErrorEnabled) + { + log.Error(message); + + var e = new MyLogEventArgs(); + e.Module = module; + e.Message = message; + LogCommit?.Invoke(null, e); + } + } + } + +} diff --git a/Common/MyLog4Net/Properties/AssemblyInfo.cs b/Common/MyLog4Net/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1228254 --- /dev/null +++ b/Common/MyLog4Net/Properties/AssemblyInfo.cs @@ -0,0 +1,37 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Log4Net")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Log4Net")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("1dc48c83-1842-4de8-acaf-26e1e7f7c58f")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)] diff --git a/Common/MyLog4Net/log4net.config b/Common/MyLog4Net/log4net.config new file mode 100644 index 0000000..92f4d40 --- /dev/null +++ b/Common/MyLog4Net/log4net.config @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Common/MyLog4Net/packages.config b/Common/MyLog4Net/packages.config new file mode 100644 index 0000000..a0798f9 --- /dev/null +++ b/Common/MyLog4Net/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/MES基础数据.xlsx b/MES基础数据.xlsx new file mode 100644 index 0000000..2740181 Binary files /dev/null and b/MES基础数据.xlsx differ diff --git a/Mes32X32.ico b/Mes32X32.ico new file mode 100644 index 0000000..ec465b2 Binary files /dev/null and b/Mes32X32.ico differ diff --git a/MisDataFun.sln b/MisDataFun.sln new file mode 100644 index 0000000..244fe8f --- /dev/null +++ b/MisDataFun.sln @@ -0,0 +1,88 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33205.214 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MisDataFun", "MisDataFun\MisDataFun\MisDataFun.csproj", "{DD9131C7-BF40-45B0-827A-C5E46FC8A89E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "01-MesDataFunction", "Common\09MesDataFunction\MesDataFunction\01-MesDataFunction.csproj", "{90E76FB4-646D-45E2-95DB-0B8AB4E465D6}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Function", "Function", "{4BF576F8-7AFE-41D3-A998-2AE62375DEC6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "00_MyLog4Net", "Common\MyLog4Net\00_MyLog4Net.csproj", "{1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Function1051", "MisDataFunction\Function1051\Function1051.csproj", "{B5A0BAA3-C1A7-4AAB-9486-2E650ADACA7E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Function1052", "MisDataFunction\Function1052\Function1052.csproj", "{5FEE5C91-8419-49FF-B2C2-47476F0B8C68}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Function1053", "MisDataFunction\Function1053\Function1053.csproj", "{CA8A12C5-7BF0-4489-93FA-180B1C492BBA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DD9131C7-BF40-45B0-827A-C5E46FC8A89E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DD9131C7-BF40-45B0-827A-C5E46FC8A89E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DD9131C7-BF40-45B0-827A-C5E46FC8A89E}.Debug|x86.ActiveCfg = Debug|Any CPU + {DD9131C7-BF40-45B0-827A-C5E46FC8A89E}.Debug|x86.Build.0 = Debug|Any CPU + {DD9131C7-BF40-45B0-827A-C5E46FC8A89E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DD9131C7-BF40-45B0-827A-C5E46FC8A89E}.Release|Any CPU.Build.0 = Release|Any CPU + {DD9131C7-BF40-45B0-827A-C5E46FC8A89E}.Release|x86.ActiveCfg = Release|Any CPU + {DD9131C7-BF40-45B0-827A-C5E46FC8A89E}.Release|x86.Build.0 = Release|Any CPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Debug|x86.ActiveCfg = Debug|Any CPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Debug|x86.Build.0 = Debug|Any CPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Release|Any CPU.Build.0 = Release|Any CPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Release|x86.ActiveCfg = Release|Any CPU + {90E76FB4-646D-45E2-95DB-0B8AB4E465D6}.Release|x86.Build.0 = Release|Any CPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}.Debug|x86.ActiveCfg = Debug|Any CPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}.Debug|x86.Build.0 = Debug|Any CPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}.Release|Any CPU.Build.0 = Release|Any CPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}.Release|x86.ActiveCfg = Release|Any CPU + {1DC48C83-1842-4DE8-ACAF-26E1E7F7C58F}.Release|x86.Build.0 = Release|Any CPU + {B5A0BAA3-C1A7-4AAB-9486-2E650ADACA7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B5A0BAA3-C1A7-4AAB-9486-2E650ADACA7E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B5A0BAA3-C1A7-4AAB-9486-2E650ADACA7E}.Debug|x86.ActiveCfg = Debug|Any CPU + {B5A0BAA3-C1A7-4AAB-9486-2E650ADACA7E}.Debug|x86.Build.0 = Debug|Any CPU + {B5A0BAA3-C1A7-4AAB-9486-2E650ADACA7E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B5A0BAA3-C1A7-4AAB-9486-2E650ADACA7E}.Release|Any CPU.Build.0 = Release|Any CPU + {B5A0BAA3-C1A7-4AAB-9486-2E650ADACA7E}.Release|x86.ActiveCfg = Release|Any CPU + {B5A0BAA3-C1A7-4AAB-9486-2E650ADACA7E}.Release|x86.Build.0 = Release|Any CPU + {5FEE5C91-8419-49FF-B2C2-47476F0B8C68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5FEE5C91-8419-49FF-B2C2-47476F0B8C68}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5FEE5C91-8419-49FF-B2C2-47476F0B8C68}.Debug|x86.ActiveCfg = Debug|Any CPU + {5FEE5C91-8419-49FF-B2C2-47476F0B8C68}.Debug|x86.Build.0 = Debug|Any CPU + {5FEE5C91-8419-49FF-B2C2-47476F0B8C68}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5FEE5C91-8419-49FF-B2C2-47476F0B8C68}.Release|Any CPU.Build.0 = Release|Any CPU + {5FEE5C91-8419-49FF-B2C2-47476F0B8C68}.Release|x86.ActiveCfg = Release|Any CPU + {5FEE5C91-8419-49FF-B2C2-47476F0B8C68}.Release|x86.Build.0 = Release|Any CPU + {CA8A12C5-7BF0-4489-93FA-180B1C492BBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CA8A12C5-7BF0-4489-93FA-180B1C492BBA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CA8A12C5-7BF0-4489-93FA-180B1C492BBA}.Debug|x86.ActiveCfg = Debug|Any CPU + {CA8A12C5-7BF0-4489-93FA-180B1C492BBA}.Debug|x86.Build.0 = Debug|Any CPU + {CA8A12C5-7BF0-4489-93FA-180B1C492BBA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CA8A12C5-7BF0-4489-93FA-180B1C492BBA}.Release|Any CPU.Build.0 = Release|Any CPU + {CA8A12C5-7BF0-4489-93FA-180B1C492BBA}.Release|x86.ActiveCfg = Release|Any CPU + {CA8A12C5-7BF0-4489-93FA-180B1C492BBA}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {B5A0BAA3-C1A7-4AAB-9486-2E650ADACA7E} = {4BF576F8-7AFE-41D3-A998-2AE62375DEC6} + {5FEE5C91-8419-49FF-B2C2-47476F0B8C68} = {4BF576F8-7AFE-41D3-A998-2AE62375DEC6} + {CA8A12C5-7BF0-4489-93FA-180B1C492BBA} = {4BF576F8-7AFE-41D3-A998-2AE62375DEC6} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9BB32B35-134E-4853-B853-73A014D416DF} + EndGlobalSection +EndGlobal diff --git a/MisDataFun/MisDataFun/Mes32X32.ico b/MisDataFun/MisDataFun/Mes32X32.ico new file mode 100644 index 0000000..ec465b2 Binary files /dev/null and b/MisDataFun/MisDataFun/Mes32X32.ico differ diff --git a/MisDataFun/MisDataFun/MisDataFun.Designer.cs b/MisDataFun/MisDataFun/MisDataFun.Designer.cs new file mode 100644 index 0000000..cd1bade --- /dev/null +++ b/MisDataFun/MisDataFun/MisDataFun.Designer.cs @@ -0,0 +1,1986 @@ + +namespace MisDataSaveDate +{ + partial class MesServerMisDataFun + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 窗体设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MesServerMisDataFun)); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.ToolStripMenuItem_PlcDebug = new System.Windows.Forms.ToolStripMenuItem(); + this.帮助ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.版本信息ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.关于迈思ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.webApi调试ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.groupBox5 = new System.Windows.Forms.GroupBox(); + this.textBox_WEB_TO_MES = new System.Windows.Forms.TextBox(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.textBox_PLC_TO_MES = new System.Windows.Forms.TextBox(); + this.panel8 = new System.Windows.Forms.Panel(); + this.button4 = new System.Windows.Forms.Button(); + this.button5 = new System.Windows.Forms.Button(); + this.button6 = new System.Windows.Forms.Button(); + this.button7 = new System.Windows.Forms.Button(); + this.button8 = new System.Windows.Forms.Button(); + this.button9 = new System.Windows.Forms.Button(); + this.button10 = new System.Windows.Forms.Button(); + this.button11 = new System.Windows.Forms.Button(); + this.button12 = new System.Windows.Forms.Button(); + this.button13 = new System.Windows.Forms.Button(); + this.button14 = new System.Windows.Forms.Button(); + this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.checkBox2 = new System.Windows.Forms.CheckBox(); + this.button15 = new System.Windows.Forms.Button(); + this.label6 = new System.Windows.Forms.Label(); + this.button16 = new System.Windows.Forms.Button(); + this.label7 = new System.Windows.Forms.Label(); + this.richTextBox1 = new System.Windows.Forms.RichTextBox(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.textBox_MES_TO_WEB = new System.Windows.Forms.TextBox(); + this.panel1 = new System.Windows.Forms.Panel(); + this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); + this.checkBox_PLC_TO_MES = new System.Windows.Forms.CheckBox(); + this.button_PLC_TO_MES_Clear = new System.Windows.Forms.Button(); + this.button_PLC_TO_MES_Big = new System.Windows.Forms.Button(); + this.button_PLC_TO_MES_Small = new System.Windows.Forms.Button(); + this.panel3 = new System.Windows.Forms.Panel(); + this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); + this.dataGridView_CheckOpName = new System.Windows.Forms.DataGridView(); + this.选择 = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.工位号 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.checkBox__MES_TO_WEB = new System.Windows.Forms.CheckBox(); + this.button_MES_TO_WEB_Clear = new System.Windows.Forms.Button(); + this.button_MES_TO_WEB_Small = new System.Windows.Forms.Button(); + this.button_MES_TO_WEB_Big = new System.Windows.Forms.Button(); + this.panel4 = new System.Windows.Forms.Panel(); + this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel(); + this.button_WEB_TO_MES_Big = new System.Windows.Forms.Button(); + this.button_WEB_TO_MES_Small = new System.Windows.Forms.Button(); + this.checkBox_WEB_TO_MES = new System.Windows.Forms.CheckBox(); + this.button_WEB_TO_MES_Clear = new System.Windows.Forms.Button(); + this.panel5 = new System.Windows.Forms.Panel(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.textBox_MqttText = new System.Windows.Forms.TextBox(); + this.panel2 = new System.Windows.Forms.Panel(); + this.tableLayoutPanel5 = new System.Windows.Forms.TableLayoutPanel(); + this.panel6 = new System.Windows.Forms.Panel(); + this.button_SaveData = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.comboBox_OpNameList = new System.Windows.Forms.ComboBox(); + this.label2 = new System.Windows.Forms.Label(); + this.button_ToWEB = new System.Windows.Forms.Button(); + this.button_WebToMES = new System.Windows.Forms.Button(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabPage6 = new System.Windows.Forms.TabPage(); + this.tabPage1 = new System.Windows.Forms.TabPage(); + this.tabPage2 = new System.Windows.Forms.TabPage(); + this.tabPage3 = new System.Windows.Forms.TabPage(); + this.tabPage4 = new System.Windows.Forms.TabPage(); + this.tabPage5 = new System.Windows.Forms.TabPage(); + this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader9 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader10 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.panel7 = new System.Windows.Forms.Panel(); + this.dgv_OpName = new System.Windows.Forms.DataGridView(); + this.OpCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.OpName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.MesDll = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.PLC = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.PLC代码 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.label11 = new System.Windows.Forms.Label(); + this.label10 = new System.Windows.Forms.Label(); + this.label12 = new System.Windows.Forms.Label(); + this.button20 = new System.Windows.Forms.Button(); + this.MesEngineDataWritePlc = new System.Windows.Forms.Button(); + this.button18 = new System.Windows.Forms.Button(); + this.textBox1_EngineID = new System.Windows.Forms.TextBox(); + this.textBox2_EngineTypeID = new System.Windows.Forms.TextBox(); + this.textBox3_palletCode = new System.Windows.Forms.TextBox(); + this.button17 = new System.Windows.Forms.Button(); + this.button1 = new System.Windows.Forms.Button(); + this.panel_Signal_Conf = new System.Windows.Forms.Panel(); + this.pb_OnLine_Print = new System.Windows.Forms.PictureBox(); + this.label28 = new System.Windows.Forms.Label(); + this.pb_OnLine_SQL = new System.Windows.Forms.PictureBox(); + this.label14 = new System.Windows.Forms.Label(); + this.pb_OnLine_MQTT = new System.Windows.Forms.PictureBox(); + this.label15 = new System.Windows.Forms.Label(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.txt_PLC_39 = new System.Windows.Forms.TextBox(); + this.txt_PLC_11 = new System.Windows.Forms.TextBox(); + this.txt_PLC_10 = new System.Windows.Forms.TextBox(); + this.txt_PLC_9 = new System.Windows.Forms.TextBox(); + this.txt_Interval = new System.Windows.Forms.TextBox(); + this.cb_F5 = new System.Windows.Forms.CheckBox(); + this.label27 = new System.Windows.Forms.Label(); + this.label26 = new System.Windows.Forms.Label(); + this.label25 = new System.Windows.Forms.Label(); + this.label24 = new System.Windows.Forms.Label(); + this.btn_PLC_59 = new System.Windows.Forms.Button(); + this.btn_PLC_2 = new System.Windows.Forms.Button(); + this.btn_PLC_43 = new System.Windows.Forms.Button(); + this.btn_PLC_1002 = new System.Windows.Forms.Button(); + this.btn_MES_5 = new System.Windows.Forms.Button(); + this.btn_PLC_1001 = new System.Windows.Forms.Button(); + this.btn_PLC_44 = new System.Windows.Forms.Button(); + this.btn_PLC_1000 = new System.Windows.Forms.Button(); + this.btn_MES_66 = new System.Windows.Forms.Button(); + this.btn_MES_7 = new System.Windows.Forms.Button(); + this.btn_PLC_19 = new System.Windows.Forms.Button(); + this.btn_MES_20 = new System.Windows.Forms.Button(); + this.label13 = new System.Windows.Forms.Label(); + this.button2 = new System.Windows.Forms.Button(); + this.label4 = new System.Windows.Forms.Label(); + this.richTextBox1_mqtt = new System.Windows.Forms.RichTextBox(); + this.timer_Status = new System.Windows.Forms.Timer(this.components); + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.toolStripStatusLabel_RunningStatu = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabel_RunningStatus = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabel_StartTime = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabel3 = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabel_RunTime = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabel_WorkStationNum = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabel4 = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabel_Version = new System.Windows.Forms.ToolStripStatusLabel(); + this.menuStrip1.SuspendLayout(); + this.tableLayoutPanel1.SuspendLayout(); + this.groupBox5.SuspendLayout(); + this.groupBox1.SuspendLayout(); + this.panel8.SuspendLayout(); + this.groupBox3.SuspendLayout(); + this.panel1.SuspendLayout(); + this.tableLayoutPanel3.SuspendLayout(); + this.panel3.SuspendLayout(); + this.tableLayoutPanel2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CheckOpName)).BeginInit(); + this.panel4.SuspendLayout(); + this.tableLayoutPanel4.SuspendLayout(); + this.panel5.SuspendLayout(); + this.panel2.SuspendLayout(); + this.tableLayoutPanel5.SuspendLayout(); + this.panel6.SuspendLayout(); + this.tabControl1.SuspendLayout(); + this.panel7.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dgv_OpName)).BeginInit(); + this.groupBox4.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pb_OnLine_Print)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pb_OnLine_SQL)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pb_OnLine_MQTT)).BeginInit(); + this.groupBox2.SuspendLayout(); + this.statusStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // menuStrip1 + // + this.menuStrip1.GripMargin = new System.Windows.Forms.Padding(2, 2, 0, 2); + this.menuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24); + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.ToolStripMenuItem_PlcDebug, + this.帮助ToolStripMenuItem, + this.webApi调试ToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Padding = new System.Windows.Forms.Padding(6, 3, 0, 3); + this.menuStrip1.Size = new System.Drawing.Size(1580, 34); + this.menuStrip1.TabIndex = 2; + this.menuStrip1.Text = "menuStrip1"; + // + // ToolStripMenuItem_PlcDebug + // + this.ToolStripMenuItem_PlcDebug.Name = "ToolStripMenuItem_PlcDebug"; + this.ToolStripMenuItem_PlcDebug.Size = new System.Drawing.Size(130, 28); + this.ToolStripMenuItem_PlcDebug.Text = "PLC信号调试"; + this.ToolStripMenuItem_PlcDebug.Click += new System.EventHandler(this.ToolStripMenuItem_PlcDebug_Click); + // + // 帮助ToolStripMenuItem + // + this.帮助ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.版本信息ToolStripMenuItem, + this.关于迈思ToolStripMenuItem}); + this.帮助ToolStripMenuItem.Name = "帮助ToolStripMenuItem"; + this.帮助ToolStripMenuItem.Size = new System.Drawing.Size(62, 28); + this.帮助ToolStripMenuItem.Text = "帮助"; + // + // 版本信息ToolStripMenuItem + // + this.版本信息ToolStripMenuItem.Name = "版本信息ToolStripMenuItem"; + this.版本信息ToolStripMenuItem.Size = new System.Drawing.Size(182, 34); + this.版本信息ToolStripMenuItem.Text = "版本信息"; + this.版本信息ToolStripMenuItem.Click += new System.EventHandler(this.版本信息ToolStripMenuItem_Click); + // + // 关于迈思ToolStripMenuItem + // + this.关于迈思ToolStripMenuItem.Name = "关于迈思ToolStripMenuItem"; + this.关于迈思ToolStripMenuItem.Size = new System.Drawing.Size(182, 34); + this.关于迈思ToolStripMenuItem.Text = "关于迈思"; + this.关于迈思ToolStripMenuItem.Click += new System.EventHandler(this.关于迈思ToolStripMenuItem_Click); + // + // webApi调试ToolStripMenuItem + // + this.webApi调试ToolStripMenuItem.Name = "webApi调试ToolStripMenuItem"; + this.webApi调试ToolStripMenuItem.Size = new System.Drawing.Size(132, 28); + this.webApi调试ToolStripMenuItem.Text = "WebApi调试"; + this.webApi调试ToolStripMenuItem.Click += new System.EventHandler(this.webAPI接口测试ToolStripMenuItem_Click); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 2; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 300F)); + this.tableLayoutPanel1.Controls.Add(this.groupBox5, 0, 2); + this.tableLayoutPanel1.Controls.Add(this.groupBox1, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.groupBox3, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.panel1, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.panel3, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.panel4, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.panel5, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.panel2, 0, 3); + this.tableLayoutPanel1.Location = new System.Drawing.Point(501, 478); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 4; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 30F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 30F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(885, 512); + this.tableLayoutPanel1.TabIndex = 3; + // + // groupBox5 + // + this.groupBox5.Controls.Add(this.textBox_WEB_TO_MES); + this.groupBox5.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox5.Location = new System.Drawing.Point(3, 258); + this.groupBox5.Name = "groupBox5"; + this.groupBox5.Size = new System.Drawing.Size(579, 96); + this.groupBox5.TabIndex = 4; + this.groupBox5.TabStop = false; + this.groupBox5.Text = "页面发送到MES系统信息"; + // + // textBox_WEB_TO_MES + // + this.textBox_WEB_TO_MES.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBox_WEB_TO_MES.Location = new System.Drawing.Point(3, 24); + this.textBox_WEB_TO_MES.Multiline = true; + this.textBox_WEB_TO_MES.Name = "textBox_WEB_TO_MES"; + this.textBox_WEB_TO_MES.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBox_WEB_TO_MES.Size = new System.Drawing.Size(573, 69); + this.textBox_WEB_TO_MES.TabIndex = 1; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.textBox_PLC_TO_MES); + this.groupBox1.Controls.Add(this.panel8); + this.groupBox1.Location = new System.Drawing.Point(3, 3); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(579, 96); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "设备PLC信号"; + // + // textBox_PLC_TO_MES + // + this.textBox_PLC_TO_MES.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBox_PLC_TO_MES.Location = new System.Drawing.Point(3, 24); + this.textBox_PLC_TO_MES.Multiline = true; + this.textBox_PLC_TO_MES.Name = "textBox_PLC_TO_MES"; + this.textBox_PLC_TO_MES.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBox_PLC_TO_MES.Size = new System.Drawing.Size(573, 69); + this.textBox_PLC_TO_MES.TabIndex = 0; + // + // panel8 + // + this.panel8.Controls.Add(this.button4); + this.panel8.Controls.Add(this.button5); + this.panel8.Controls.Add(this.button6); + this.panel8.Controls.Add(this.button7); + this.panel8.Controls.Add(this.button8); + this.panel8.Controls.Add(this.button9); + this.panel8.Controls.Add(this.button10); + this.panel8.Controls.Add(this.button11); + this.panel8.Controls.Add(this.button12); + this.panel8.Controls.Add(this.button13); + this.panel8.Controls.Add(this.button14); + this.panel8.Controls.Add(this.checkBox1); + this.panel8.Controls.Add(this.checkBox2); + this.panel8.Controls.Add(this.button15); + this.panel8.Controls.Add(this.label6); + this.panel8.Controls.Add(this.button16); + this.panel8.Controls.Add(this.label7); + this.panel8.Controls.Add(this.richTextBox1); + this.panel8.Location = new System.Drawing.Point(-490, -396); + this.panel8.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.panel8.Name = "panel8"; + this.panel8.Size = new System.Drawing.Size(1558, 969); + this.panel8.TabIndex = 5; + // + // button4 + // + this.button4.Location = new System.Drawing.Point(765, 460); + this.button4.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(112, 34); + this.button4.TabIndex = 1479; + this.button4.Text = "工作完成M"; + this.button4.UseVisualStyleBackColor = true; + // + // button5 + // + this.button5.Location = new System.Drawing.Point(765, 420); + this.button5.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(112, 34); + this.button5.TabIndex = 1479; + this.button5.Text = "工作完成M"; + this.button5.UseVisualStyleBackColor = true; + // + // button6 + // + this.button6.Location = new System.Drawing.Point(765, 376); + this.button6.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button6.Name = "button6"; + this.button6.Size = new System.Drawing.Size(112, 34); + this.button6.TabIndex = 1478; + this.button6.Text = "工作完成M"; + this.button6.UseVisualStyleBackColor = true; + this.button6.Click += new System.EventHandler(this.workOverMES_Click); + // + // button7 + // + this.button7.Location = new System.Drawing.Point(765, 333); + this.button7.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button7.Name = "button7"; + this.button7.Size = new System.Drawing.Size(112, 34); + this.button7.TabIndex = 1478; + this.button7.Text = "保存完成M"; + this.button7.UseVisualStyleBackColor = true; + this.button7.Click += new System.EventHandler(this.saveOverMES_Click); + // + // button8 + // + this.button8.Location = new System.Drawing.Point(765, 290); + this.button8.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button8.Name = "button8"; + this.button8.Size = new System.Drawing.Size(112, 34); + this.button8.TabIndex = 1478; + this.button8.Text = "允许保存P"; + this.button8.UseVisualStyleBackColor = true; + this.button8.Click += new System.EventHandler(this.allowSavePLC_Click); + // + // button9 + // + this.button9.Location = new System.Drawing.Point(764, 246); + this.button9.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button9.Name = "button9"; + this.button9.Size = new System.Drawing.Size(112, 34); + this.button9.TabIndex = 1478; + this.button9.Text = "允许工作M"; + this.button9.UseVisualStyleBackColor = true; + this.button9.Click += new System.EventHandler(this.allowWorkMES_Click); + // + // button10 + // + this.button10.Location = new System.Drawing.Point(764, 202); + this.button10.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button10.Name = "button10"; + this.button10.Size = new System.Drawing.Size(112, 34); + this.button10.TabIndex = 1478; + this.button10.Text = "传递机型P"; + this.button10.UseVisualStyleBackColor = true; + this.button10.Click += new System.EventHandler(this.EngineGetOverPLC_Click); + // + // button11 + // + this.button11.Location = new System.Drawing.Point(764, 159); + this.button11.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button11.Name = "button11"; + this.button11.Size = new System.Drawing.Size(112, 34); + this.button11.TabIndex = 1478; + this.button11.Text = "传递机型M"; + this.button11.UseVisualStyleBackColor = true; + this.button11.Click += new System.EventHandler(this.EngineGetOverMES_Click); + // + // button12 + // + this.button12.Location = new System.Drawing.Point(765, 116); + this.button12.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button12.Name = "button12"; + this.button12.Size = new System.Drawing.Size(112, 34); + this.button12.TabIndex = 1478; + this.button12.Text = "申请上线P"; + this.button12.UseVisualStyleBackColor = true; + this.button12.Click += new System.EventHandler(this.PartLoadPLC_Click); + // + // button13 + // + this.button13.Location = new System.Drawing.Point(764, 72); + this.button13.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button13.Name = "button13"; + this.button13.Size = new System.Drawing.Size(112, 34); + this.button13.TabIndex = 1478; + this.button13.Text = "工件到位P"; + this.button13.UseVisualStyleBackColor = true; + this.button13.Click += new System.EventHandler(this.WorkStartPLC_Click); + // + // button14 + // + this.button14.Location = new System.Drawing.Point(1054, 9); + this.button14.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button14.Name = "button14"; + this.button14.Size = new System.Drawing.Size(237, 58); + this.button14.TabIndex = 1477; + this.button14.Text = "初始化报警"; + this.button14.UseVisualStyleBackColor = true; + this.button14.Click += new System.EventHandler(this.button2_Click); + // + // checkBox1 + // + this.checkBox1.AutoSize = true; + this.checkBox1.Location = new System.Drawing.Point(16, 40); + this.checkBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.checkBox1.Name = "checkBox1"; + this.checkBox1.Size = new System.Drawing.Size(106, 22); + this.checkBox1.TabIndex = 1475; + this.checkBox1.Text = "质量数据"; + this.checkBox1.UseVisualStyleBackColor = true; + // + // checkBox2 + // + this.checkBox2.AutoSize = true; + this.checkBox2.Location = new System.Drawing.Point(16, 10); + this.checkBox2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.checkBox2.Name = "checkBox2"; + this.checkBox2.Size = new System.Drawing.Size(106, 22); + this.checkBox2.TabIndex = 1476; + this.checkBox2.Text = "监控数据"; + this.checkBox2.UseVisualStyleBackColor = true; + // + // button15 + // + this.button15.Location = new System.Drawing.Point(1300, 9); + this.button15.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button15.Name = "button15"; + this.button15.Size = new System.Drawing.Size(242, 58); + this.button15.TabIndex = 4; + this.button15.Text = "MQTT服务状态"; + this.button15.UseVisualStyleBackColor = true; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label6.Location = new System.Drawing.Point(136, 10); + this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(98, 18); + this.label6.TabIndex = 1471; + this.label6.Text = "工位编号:"; + // + // button16 + // + this.button16.Location = new System.Drawing.Point(280, 28); + this.button16.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button16.Name = "button16"; + this.button16.Size = new System.Drawing.Size(93, 39); + this.button16.TabIndex = 1474; + this.button16.Text = "读取数据"; + this.button16.UseVisualStyleBackColor = true; + this.button16.Click += new System.EventHandler(this.button_ReadData_Click); + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(900, 40); + this.label7.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(44, 18); + this.label7.TabIndex = 1; + this.label7.Text = "日志"; + // + // richTextBox1 + // + this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.richTextBox1.Location = new System.Drawing.Point(886, 70); + this.richTextBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.richTextBox1.Name = "richTextBox1"; + this.richTextBox1.ReadOnly = true; + this.richTextBox1.Size = new System.Drawing.Size(654, 900); + this.richTextBox1.TabIndex = 0; + this.richTextBox1.Text = ""; + // + // groupBox3 + // + this.groupBox3.Controls.Add(this.textBox_MES_TO_WEB); + this.groupBox3.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox3.Location = new System.Drawing.Point(3, 105); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(579, 147); + this.groupBox3.TabIndex = 2; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "MES系统发送到页面信息"; + // + // textBox_MES_TO_WEB + // + this.textBox_MES_TO_WEB.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBox_MES_TO_WEB.Location = new System.Drawing.Point(3, 24); + this.textBox_MES_TO_WEB.Multiline = true; + this.textBox_MES_TO_WEB.Name = "textBox_MES_TO_WEB"; + this.textBox_MES_TO_WEB.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBox_MES_TO_WEB.Size = new System.Drawing.Size(573, 120); + this.textBox_MES_TO_WEB.TabIndex = 1; + // + // panel1 + // + this.panel1.Controls.Add(this.tableLayoutPanel3); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(588, 3); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(294, 96); + this.panel1.TabIndex = 10; + // + // tableLayoutPanel3 + // + this.tableLayoutPanel3.ColumnCount = 4; + this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); + this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); + this.tableLayoutPanel3.Controls.Add(this.checkBox_PLC_TO_MES, 0, 0); + this.tableLayoutPanel3.Controls.Add(this.button_PLC_TO_MES_Clear, 3, 0); + this.tableLayoutPanel3.Controls.Add(this.button_PLC_TO_MES_Big, 2, 0); + this.tableLayoutPanel3.Controls.Add(this.button_PLC_TO_MES_Small, 1, 0); + this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel3.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel3.Name = "tableLayoutPanel3"; + this.tableLayoutPanel3.RowCount = 2; + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 21F)); + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 21F)); + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 21F)); + this.tableLayoutPanel3.Size = new System.Drawing.Size(294, 96); + this.tableLayoutPanel3.TabIndex = 3; + // + // checkBox_PLC_TO_MES + // + this.checkBox_PLC_TO_MES.AutoSize = true; + this.checkBox_PLC_TO_MES.Dock = System.Windows.Forms.DockStyle.Fill; + this.checkBox_PLC_TO_MES.Location = new System.Drawing.Point(3, 3); + this.checkBox_PLC_TO_MES.Name = "checkBox_PLC_TO_MES"; + this.checkBox_PLC_TO_MES.Size = new System.Drawing.Size(82, 33); + this.checkBox_PLC_TO_MES.TabIndex = 0; + this.checkBox_PLC_TO_MES.Text = "监控"; + this.checkBox_PLC_TO_MES.UseVisualStyleBackColor = true; + // + // button_PLC_TO_MES_Clear + // + this.button_PLC_TO_MES_Clear.Dock = System.Windows.Forms.DockStyle.Fill; + this.button_PLC_TO_MES_Clear.Location = new System.Drawing.Point(207, 3); + this.button_PLC_TO_MES_Clear.Name = "button_PLC_TO_MES_Clear"; + this.button_PLC_TO_MES_Clear.Size = new System.Drawing.Size(84, 33); + this.button_PLC_TO_MES_Clear.TabIndex = 1; + this.button_PLC_TO_MES_Clear.Text = "清空"; + this.button_PLC_TO_MES_Clear.UseVisualStyleBackColor = true; + // + // button_PLC_TO_MES_Big + // + this.button_PLC_TO_MES_Big.Location = new System.Drawing.Point(149, 3); + this.button_PLC_TO_MES_Big.Name = "button_PLC_TO_MES_Big"; + this.button_PLC_TO_MES_Big.Size = new System.Drawing.Size(51, 30); + this.button_PLC_TO_MES_Big.TabIndex = 2; + this.button_PLC_TO_MES_Big.Text = "+"; + this.button_PLC_TO_MES_Big.UseVisualStyleBackColor = true; + // + // button_PLC_TO_MES_Small + // + this.button_PLC_TO_MES_Small.Location = new System.Drawing.Point(91, 3); + this.button_PLC_TO_MES_Small.Name = "button_PLC_TO_MES_Small"; + this.button_PLC_TO_MES_Small.Size = new System.Drawing.Size(51, 30); + this.button_PLC_TO_MES_Small.TabIndex = 2; + this.button_PLC_TO_MES_Small.Text = "-"; + this.button_PLC_TO_MES_Small.UseVisualStyleBackColor = true; + // + // panel3 + // + this.panel3.Controls.Add(this.tableLayoutPanel2); + this.panel3.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel3.Location = new System.Drawing.Point(588, 105); + this.panel3.Name = "panel3"; + this.panel3.Size = new System.Drawing.Size(294, 147); + this.panel3.TabIndex = 12; + // + // tableLayoutPanel2 + // + this.tableLayoutPanel2.ColumnCount = 4; + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); + this.tableLayoutPanel2.Controls.Add(this.dataGridView_CheckOpName, 0, 1); + this.tableLayoutPanel2.Controls.Add(this.checkBox__MES_TO_WEB, 0, 0); + this.tableLayoutPanel2.Controls.Add(this.button_MES_TO_WEB_Clear, 3, 0); + this.tableLayoutPanel2.Controls.Add(this.button_MES_TO_WEB_Small, 1, 0); + this.tableLayoutPanel2.Controls.Add(this.button_MES_TO_WEB_Big, 2, 0); + this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel2.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel2.Name = "tableLayoutPanel2"; + this.tableLayoutPanel2.RowCount = 2; + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel2.Size = new System.Drawing.Size(294, 147); + this.tableLayoutPanel2.TabIndex = 1; + // + // dataGridView_CheckOpName + // + this.dataGridView_CheckOpName.AllowUserToAddRows = false; + this.dataGridView_CheckOpName.AllowUserToDeleteRows = false; + this.dataGridView_CheckOpName.AllowUserToResizeColumns = false; + this.dataGridView_CheckOpName.AllowUserToResizeRows = false; + this.dataGridView_CheckOpName.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView_CheckOpName.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.选择, + this.工位号}); + this.tableLayoutPanel2.SetColumnSpan(this.dataGridView_CheckOpName, 4); + this.dataGridView_CheckOpName.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridView_CheckOpName.Location = new System.Drawing.Point(3, 42); + this.dataGridView_CheckOpName.MultiSelect = false; + this.dataGridView_CheckOpName.Name = "dataGridView_CheckOpName"; + this.dataGridView_CheckOpName.RowHeadersVisible = false; + this.dataGridView_CheckOpName.RowHeadersWidth = 62; + this.dataGridView_CheckOpName.RowTemplate.Height = 30; + this.dataGridView_CheckOpName.Size = new System.Drawing.Size(288, 102); + this.dataGridView_CheckOpName.TabIndex = 3; + // + // 选择 + // + this.选择.DataPropertyName = "选择"; + this.选择.HeaderText = "选择"; + this.选择.MinimumWidth = 8; + this.选择.Name = "选择"; + this.选择.Width = 60; + // + // 工位号 + // + this.工位号.DataPropertyName = "工位号"; + this.工位号.HeaderText = "工位号"; + this.工位号.MinimumWidth = 8; + this.工位号.Name = "工位号"; + this.工位号.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.工位号.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.工位号.Width = 218; + // + // checkBox__MES_TO_WEB + // + this.checkBox__MES_TO_WEB.AutoSize = true; + this.checkBox__MES_TO_WEB.Dock = System.Windows.Forms.DockStyle.Fill; + this.checkBox__MES_TO_WEB.Location = new System.Drawing.Point(3, 3); + this.checkBox__MES_TO_WEB.Name = "checkBox__MES_TO_WEB"; + this.checkBox__MES_TO_WEB.Size = new System.Drawing.Size(82, 33); + this.checkBox__MES_TO_WEB.TabIndex = 0; + this.checkBox__MES_TO_WEB.Text = "监控"; + this.checkBox__MES_TO_WEB.UseVisualStyleBackColor = true; + // + // button_MES_TO_WEB_Clear + // + this.button_MES_TO_WEB_Clear.Dock = System.Windows.Forms.DockStyle.Fill; + this.button_MES_TO_WEB_Clear.Location = new System.Drawing.Point(207, 3); + this.button_MES_TO_WEB_Clear.Name = "button_MES_TO_WEB_Clear"; + this.button_MES_TO_WEB_Clear.Size = new System.Drawing.Size(84, 33); + this.button_MES_TO_WEB_Clear.TabIndex = 2; + this.button_MES_TO_WEB_Clear.Text = "清空"; + this.button_MES_TO_WEB_Clear.UseVisualStyleBackColor = true; + // + // button_MES_TO_WEB_Small + // + this.button_MES_TO_WEB_Small.Location = new System.Drawing.Point(91, 3); + this.button_MES_TO_WEB_Small.Name = "button_MES_TO_WEB_Small"; + this.button_MES_TO_WEB_Small.Size = new System.Drawing.Size(51, 30); + this.button_MES_TO_WEB_Small.TabIndex = 4; + this.button_MES_TO_WEB_Small.Text = "-"; + this.button_MES_TO_WEB_Small.UseVisualStyleBackColor = true; + // + // button_MES_TO_WEB_Big + // + this.button_MES_TO_WEB_Big.Location = new System.Drawing.Point(149, 3); + this.button_MES_TO_WEB_Big.Name = "button_MES_TO_WEB_Big"; + this.button_MES_TO_WEB_Big.Size = new System.Drawing.Size(51, 30); + this.button_MES_TO_WEB_Big.TabIndex = 4; + this.button_MES_TO_WEB_Big.Text = "+"; + this.button_MES_TO_WEB_Big.UseVisualStyleBackColor = true; + // + // panel4 + // + this.panel4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel4.Controls.Add(this.tableLayoutPanel4); + this.panel4.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel4.Location = new System.Drawing.Point(588, 258); + this.panel4.Name = "panel4"; + this.panel4.Size = new System.Drawing.Size(294, 96); + this.panel4.TabIndex = 13; + // + // tableLayoutPanel4 + // + this.tableLayoutPanel4.ColumnCount = 4; + this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); + this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); + this.tableLayoutPanel4.Controls.Add(this.button_WEB_TO_MES_Big, 2, 0); + this.tableLayoutPanel4.Controls.Add(this.button_WEB_TO_MES_Small, 1, 0); + this.tableLayoutPanel4.Controls.Add(this.checkBox_WEB_TO_MES, 0, 0); + this.tableLayoutPanel4.Controls.Add(this.button_WEB_TO_MES_Clear, 3, 0); + this.tableLayoutPanel4.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel4.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel4.Name = "tableLayoutPanel4"; + this.tableLayoutPanel4.RowCount = 2; + this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel4.Size = new System.Drawing.Size(292, 94); + this.tableLayoutPanel4.TabIndex = 0; + // + // button_WEB_TO_MES_Big + // + this.button_WEB_TO_MES_Big.Location = new System.Drawing.Point(148, 3); + this.button_WEB_TO_MES_Big.Name = "button_WEB_TO_MES_Big"; + this.button_WEB_TO_MES_Big.Size = new System.Drawing.Size(51, 30); + this.button_WEB_TO_MES_Big.TabIndex = 6; + this.button_WEB_TO_MES_Big.Text = "+"; + this.button_WEB_TO_MES_Big.UseVisualStyleBackColor = true; + // + // button_WEB_TO_MES_Small + // + this.button_WEB_TO_MES_Small.Location = new System.Drawing.Point(90, 3); + this.button_WEB_TO_MES_Small.Name = "button_WEB_TO_MES_Small"; + this.button_WEB_TO_MES_Small.Size = new System.Drawing.Size(51, 30); + this.button_WEB_TO_MES_Small.TabIndex = 5; + this.button_WEB_TO_MES_Small.Text = "-"; + this.button_WEB_TO_MES_Small.UseVisualStyleBackColor = true; + // + // checkBox_WEB_TO_MES + // + this.checkBox_WEB_TO_MES.AutoSize = true; + this.checkBox_WEB_TO_MES.Dock = System.Windows.Forms.DockStyle.Fill; + this.checkBox_WEB_TO_MES.Location = new System.Drawing.Point(3, 3); + this.checkBox_WEB_TO_MES.Name = "checkBox_WEB_TO_MES"; + this.checkBox_WEB_TO_MES.Size = new System.Drawing.Size(81, 33); + this.checkBox_WEB_TO_MES.TabIndex = 0; + this.checkBox_WEB_TO_MES.Text = "监控"; + this.checkBox_WEB_TO_MES.UseVisualStyleBackColor = true; + // + // button_WEB_TO_MES_Clear + // + this.button_WEB_TO_MES_Clear.Dock = System.Windows.Forms.DockStyle.Fill; + this.button_WEB_TO_MES_Clear.Location = new System.Drawing.Point(206, 3); + this.button_WEB_TO_MES_Clear.Name = "button_WEB_TO_MES_Clear"; + this.button_WEB_TO_MES_Clear.Size = new System.Drawing.Size(83, 33); + this.button_WEB_TO_MES_Clear.TabIndex = 1; + this.button_WEB_TO_MES_Clear.Text = "清空"; + this.button_WEB_TO_MES_Clear.UseVisualStyleBackColor = true; + // + // panel5 + // + this.panel5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel5.Controls.Add(this.comboBox1); + this.panel5.Controls.Add(this.textBox_MqttText); + this.panel5.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel5.Location = new System.Drawing.Point(589, 360); + this.panel5.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.panel5.Name = "panel5"; + this.panel5.Size = new System.Drawing.Size(292, 149); + this.panel5.TabIndex = 14; + // + // comboBox1 + // + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Location = new System.Drawing.Point(4, 9); + this.comboBox1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(280, 26); + this.comboBox1.TabIndex = 4; + // + // textBox_MqttText + // + this.textBox_MqttText.Location = new System.Drawing.Point(4, 48); + this.textBox_MqttText.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.textBox_MqttText.Multiline = true; + this.textBox_MqttText.Name = "textBox_MqttText"; + this.textBox_MqttText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBox_MqttText.Size = new System.Drawing.Size(277, 139); + this.textBox_MqttText.TabIndex = 15; + // + // panel2 + // + this.panel2.Controls.Add(this.tableLayoutPanel5); + this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel2.Location = new System.Drawing.Point(4, 360); + this.panel2.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(577, 149); + this.panel2.TabIndex = 15; + // + // tableLayoutPanel5 + // + this.tableLayoutPanel5.ColumnCount = 2; + this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 300F)); + this.tableLayoutPanel5.Controls.Add(this.panel6, 1, 0); + this.tableLayoutPanel5.Controls.Add(this.tabControl1, 0, 0); + this.tableLayoutPanel5.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel5.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel5.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.tableLayoutPanel5.Name = "tableLayoutPanel5"; + this.tableLayoutPanel5.RowCount = 1; + this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel5.Size = new System.Drawing.Size(577, 149); + this.tableLayoutPanel5.TabIndex = 0; + // + // panel6 + // + this.panel6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel6.Controls.Add(this.button_SaveData); + this.panel6.Controls.Add(this.label1); + this.panel6.Controls.Add(this.label3); + this.panel6.Controls.Add(this.comboBox_OpNameList); + this.panel6.Controls.Add(this.label2); + this.panel6.Controls.Add(this.button_ToWEB); + this.panel6.Controls.Add(this.button_WebToMES); + this.panel6.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel6.Location = new System.Drawing.Point(281, 3); + this.panel6.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.panel6.Name = "panel6"; + this.panel6.Size = new System.Drawing.Size(292, 143); + this.panel6.TabIndex = 0; + // + // button_SaveData + // + this.button_SaveData.Location = new System.Drawing.Point(20, 142); + this.button_SaveData.Name = "button_SaveData"; + this.button_SaveData.Size = new System.Drawing.Size(84, 27); + this.button_SaveData.TabIndex = 4; + this.button_SaveData.Text = "保存质量数据"; + this.button_SaveData.UseVisualStyleBackColor = true; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(6, 9); + this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(62, 18); + this.label1.TabIndex = 2; + this.label1.Text = "工位号"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(94, 93); + this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(188, 18); + this.label3.TabIndex = 3; + this.label3.Text = "WEB|CMD|OpName|Walue"; + // + // comboBox_OpNameList + // + this.comboBox_OpNameList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBox_OpNameList.FormattingEnabled = true; + this.comboBox_OpNameList.Location = new System.Drawing.Point(76, 3); + this.comboBox_OpNameList.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.comboBox_OpNameList.Name = "comboBox_OpNameList"; + this.comboBox_OpNameList.Size = new System.Drawing.Size(208, 26); + this.comboBox_OpNameList.TabIndex = 1; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(94, 51); + this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(188, 18); + this.label2.TabIndex = 3; + this.label2.Text = "MES|CMD|OpName|Walue"; + // + // button_ToWEB + // + this.button_ToWEB.Location = new System.Drawing.Point(8, 45); + this.button_ToWEB.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.button_ToWEB.Name = "button_ToWEB"; + this.button_ToWEB.Size = new System.Drawing.Size(78, 33); + this.button_ToWEB.TabIndex = 0; + this.button_ToWEB.Text = "到页面"; + this.button_ToWEB.UseVisualStyleBackColor = true; + // + // button_WebToMES + // + this.button_WebToMES.Location = new System.Drawing.Point(9, 87); + this.button_WebToMES.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.button_WebToMES.Name = "button_WebToMES"; + this.button_WebToMES.Size = new System.Drawing.Size(76, 33); + this.button_WebToMES.TabIndex = 0; + this.button_WebToMES.Text = "到业务"; + this.button_WebToMES.UseVisualStyleBackColor = true; + // + // tabControl1 + // + this.tabControl1.Controls.Add(this.tabPage6); + this.tabControl1.Controls.Add(this.tabPage1); + this.tabControl1.Controls.Add(this.tabPage2); + this.tabControl1.Controls.Add(this.tabPage3); + this.tabControl1.Controls.Add(this.tabPage4); + this.tabControl1.Controls.Add(this.tabPage5); + this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tabControl1.Location = new System.Drawing.Point(4, 3); + this.tabControl1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(269, 143); + this.tabControl1.TabIndex = 1; + // + // tabPage6 + // + this.tabPage6.Location = new System.Drawing.Point(4, 28); + this.tabPage6.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.tabPage6.Name = "tabPage6"; + this.tabPage6.Size = new System.Drawing.Size(261, 111); + this.tabPage6.TabIndex = 5; + this.tabPage6.Text = "订单信息"; + this.tabPage6.UseVisualStyleBackColor = true; + // + // tabPage1 + // + this.tabPage1.Location = new System.Drawing.Point(4, 28); + this.tabPage1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.tabPage1.Name = "tabPage1"; + this.tabPage1.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.tabPage1.Size = new System.Drawing.Size(259, 110); + this.tabPage1.TabIndex = 0; + this.tabPage1.Text = "产品信息"; + this.tabPage1.UseVisualStyleBackColor = true; + // + // tabPage2 + // + this.tabPage2.Location = new System.Drawing.Point(4, 28); + this.tabPage2.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.tabPage2.Name = "tabPage2"; + this.tabPage2.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.tabPage2.Size = new System.Drawing.Size(259, 110); + this.tabPage2.TabIndex = 1; + this.tabPage2.Text = "工步信息"; + this.tabPage2.UseVisualStyleBackColor = true; + // + // tabPage3 + // + this.tabPage3.Location = new System.Drawing.Point(4, 28); + this.tabPage3.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.tabPage3.Name = "tabPage3"; + this.tabPage3.Size = new System.Drawing.Size(259, 110); + this.tabPage3.TabIndex = 2; + this.tabPage3.Text = "物料信息"; + this.tabPage3.UseVisualStyleBackColor = true; + // + // tabPage4 + // + this.tabPage4.Location = new System.Drawing.Point(4, 28); + this.tabPage4.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.tabPage4.Name = "tabPage4"; + this.tabPage4.Size = new System.Drawing.Size(259, 110); + this.tabPage4.TabIndex = 3; + this.tabPage4.Text = "操作图片"; + this.tabPage4.UseVisualStyleBackColor = true; + // + // tabPage5 + // + this.tabPage5.Location = new System.Drawing.Point(4, 28); + this.tabPage5.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.tabPage5.Name = "tabPage5"; + this.tabPage5.Size = new System.Drawing.Size(259, 110); + this.tabPage5.TabIndex = 4; + this.tabPage5.Text = "PLC信号"; + this.tabPage5.UseVisualStyleBackColor = true; + // + // columnHeader6 + // + this.columnHeader6.Text = "TagID"; + this.columnHeader6.Width = 70; + // + // columnHeader7 + // + this.columnHeader7.Text = "测量项目"; + this.columnHeader7.Width = 130; + // + // columnHeader8 + // + this.columnHeader8.Text = "值"; + this.columnHeader8.Width = 100; + // + // columnHeader9 + // + this.columnHeader9.Text = "工位号"; + this.columnHeader9.Width = 70; + // + // columnHeader10 + // + this.columnHeader10.Text = "地址"; + this.columnHeader10.Width = 100; + // + // panel7 + // + this.panel7.Controls.Add(this.dgv_OpName); + this.panel7.Controls.Add(this.groupBox4); + this.panel7.Controls.Add(this.panel_Signal_Conf); + this.panel7.Controls.Add(this.pb_OnLine_Print); + this.panel7.Controls.Add(this.label28); + this.panel7.Controls.Add(this.pb_OnLine_SQL); + this.panel7.Controls.Add(this.label14); + this.panel7.Controls.Add(this.pb_OnLine_MQTT); + this.panel7.Controls.Add(this.label15); + this.panel7.Controls.Add(this.groupBox2); + this.panel7.Controls.Add(this.label13); + this.panel7.Controls.Add(this.button2); + this.panel7.Controls.Add(this.label4); + this.panel7.Controls.Add(this.richTextBox1_mqtt); + this.panel7.Location = new System.Drawing.Point(14, 42); + this.panel7.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.panel7.Name = "panel7"; + this.panel7.Size = new System.Drawing.Size(1558, 956); + this.panel7.TabIndex = 5; + // + // dgv_OpName + // + this.dgv_OpName.AllowUserToAddRows = false; + this.dgv_OpName.AllowUserToDeleteRows = false; + this.dgv_OpName.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; + this.dgv_OpName.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgv_OpName.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.OpCode, + this.OpName, + this.MesDll, + this.PLC, + this.PLC代码}); + this.dgv_OpName.Location = new System.Drawing.Point(16, 99); + this.dgv_OpName.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.dgv_OpName.Name = "dgv_OpName"; + this.dgv_OpName.ReadOnly = true; + this.dgv_OpName.RowHeadersVisible = false; + this.dgv_OpName.RowHeadersWidth = 62; + this.dgv_OpName.RowTemplate.Height = 23; + this.dgv_OpName.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgv_OpName.Size = new System.Drawing.Size(314, 837); + this.dgv_OpName.TabIndex = 1488; + this.dgv_OpName.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgv_OpName_CellClick); + // + // OpCode + // + this.OpCode.DataPropertyName = "工位号"; + this.OpCode.HeaderText = "工位号"; + this.OpCode.MinimumWidth = 8; + this.OpCode.Name = "OpCode"; + this.OpCode.ReadOnly = true; + this.OpCode.Width = 80; + // + // OpName + // + this.OpName.DataPropertyName = "工位名称"; + this.OpName.HeaderText = "工位名称"; + this.OpName.MinimumWidth = 8; + this.OpName.Name = "OpName"; + this.OpName.ReadOnly = true; + this.OpName.Width = 120; + // + // MesDll + // + this.MesDll.DataPropertyName = "MesDll"; + this.MesDll.HeaderText = "MesDll"; + this.MesDll.MinimumWidth = 8; + this.MesDll.Name = "MesDll"; + this.MesDll.ReadOnly = true; + this.MesDll.Width = 90; + // + // PLC + // + this.PLC.DataPropertyName = "PLC"; + this.PLC.HeaderText = "PLC"; + this.PLC.MinimumWidth = 8; + this.PLC.Name = "PLC"; + this.PLC.ReadOnly = true; + this.PLC.Width = 150; + // + // PLC代码 + // + this.PLC代码.DataPropertyName = "PLC代码"; + this.PLC代码.HeaderText = "PLC代码"; + this.PLC代码.MinimumWidth = 8; + this.PLC代码.Name = "PLC代码"; + this.PLC代码.ReadOnly = true; + this.PLC代码.Width = 150; + // + // groupBox4 + // + this.groupBox4.Controls.Add(this.label11); + this.groupBox4.Controls.Add(this.label10); + this.groupBox4.Controls.Add(this.label12); + this.groupBox4.Controls.Add(this.button20); + this.groupBox4.Controls.Add(this.MesEngineDataWritePlc); + this.groupBox4.Controls.Add(this.button18); + this.groupBox4.Controls.Add(this.textBox1_EngineID); + this.groupBox4.Controls.Add(this.textBox2_EngineTypeID); + this.groupBox4.Controls.Add(this.textBox3_palletCode); + this.groupBox4.Controls.Add(this.button17); + this.groupBox4.Controls.Add(this.button1); + this.groupBox4.Location = new System.Drawing.Point(945, 477); + this.groupBox4.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupBox4.Name = "groupBox4"; + this.groupBox4.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupBox4.Size = new System.Drawing.Size(514, 324); + this.groupBox4.TabIndex = 1487; + this.groupBox4.TabStop = false; + this.groupBox4.Text = "调试写入"; + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label11.Location = new System.Drawing.Point(20, 32); + this.label11.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(98, 18); + this.label11.TabIndex = 1471; + this.label11.Text = "机型代码:"; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label10.Location = new System.Drawing.Point(20, 72); + this.label10.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(98, 18); + this.label10.TabIndex = 1471; + this.label10.Text = "产品编号:"; + // + // label12 + // + this.label12.AutoSize = true; + this.label12.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label12.Location = new System.Drawing.Point(20, 112); + this.label12.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(98, 18); + this.label12.TabIndex = 1471; + this.label12.Text = "托盘编号:"; + // + // button20 + // + this.button20.Location = new System.Drawing.Point(382, 56); + this.button20.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button20.Name = "button20"; + this.button20.Size = new System.Drawing.Size(117, 51); + this.button20.TabIndex = 1478; + this.button20.Text = "打印机测试"; + this.button20.UseVisualStyleBackColor = true; + this.button20.Click += new System.EventHandler(this.button20_Click); + // + // MesEngineDataWritePlc + // + this.MesEngineDataWritePlc.Location = new System.Drawing.Point(12, 184); + this.MesEngineDataWritePlc.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.MesEngineDataWritePlc.Name = "MesEngineDataWritePlc"; + this.MesEngineDataWritePlc.Size = new System.Drawing.Size(170, 34); + this.MesEngineDataWritePlc.TabIndex = 1478; + this.MesEngineDataWritePlc.Text = "MES信息回写PLC"; + this.MesEngineDataWritePlc.UseVisualStyleBackColor = true; + this.MesEngineDataWritePlc.Click += new System.EventHandler(this.MesEngineDataWritePlc_Click); + // + // button18 + // + this.button18.Location = new System.Drawing.Point(9, 147); + this.button18.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button18.Name = "button18"; + this.button18.Size = new System.Drawing.Size(172, 28); + this.button18.TabIndex = 1478; + this.button18.Text = "上述写入PLC"; + this.button18.UseVisualStyleBackColor = true; + this.button18.Click += new System.EventHandler(this.button18_Click); + // + // textBox1_EngineID + // + this.textBox1_EngineID.Location = new System.Drawing.Point(126, 68); + this.textBox1_EngineID.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.textBox1_EngineID.Name = "textBox1_EngineID"; + this.textBox1_EngineID.Size = new System.Drawing.Size(247, 28); + this.textBox1_EngineID.TabIndex = 1480; + this.textBox1_EngineID.Text = "001MBE0700000Q1590100001"; + // + // textBox2_EngineTypeID + // + this.textBox2_EngineTypeID.Location = new System.Drawing.Point(126, 21); + this.textBox2_EngineTypeID.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.textBox2_EngineTypeID.Name = "textBox2_EngineTypeID"; + this.textBox2_EngineTypeID.Size = new System.Drawing.Size(247, 28); + this.textBox2_EngineTypeID.TabIndex = 1480; + this.textBox2_EngineTypeID.Text = "1"; + // + // textBox3_palletCode + // + this.textBox3_palletCode.Location = new System.Drawing.Point(124, 108); + this.textBox3_palletCode.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.textBox3_palletCode.Name = "textBox3_palletCode"; + this.textBox3_palletCode.Size = new System.Drawing.Size(248, 28); + this.textBox3_palletCode.TabIndex = 1480; + this.textBox3_palletCode.Text = "12"; + // + // button17 + // + this.button17.Location = new System.Drawing.Point(9, 267); + this.button17.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button17.Name = "button17"; + this.button17.Size = new System.Drawing.Size(158, 48); + this.button17.TabIndex = 1478; + this.button17.Text = "模拟写入RFID"; + this.button17.UseVisualStyleBackColor = true; + this.button17.Click += new System.EventHandler(this.button17_Click); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(176, 267); + this.button1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(158, 48); + this.button1.TabIndex = 1478; + this.button1.Text = "模拟写入电芯码"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // panel_Signal_Conf + // + this.panel_Signal_Conf.Location = new System.Drawing.Point(1256, 20); + this.panel_Signal_Conf.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.panel_Signal_Conf.Name = "panel_Signal_Conf"; + this.panel_Signal_Conf.Size = new System.Drawing.Size(62, 75); + this.panel_Signal_Conf.TabIndex = 1486; + this.panel_Signal_Conf.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.panel_Signal_Conf_MouseDoubleClick); + // + // pb_OnLine_Print + // + this.pb_OnLine_Print.Image = global::MisDataFun.Properties.Resources.断开状态; + this.pb_OnLine_Print.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.pb_OnLine_Print.Location = new System.Drawing.Point(1336, 20); + this.pb_OnLine_Print.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.pb_OnLine_Print.Name = "pb_OnLine_Print"; + this.pb_OnLine_Print.Size = new System.Drawing.Size(57, 52); + this.pb_OnLine_Print.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.pb_OnLine_Print.TabIndex = 1485; + this.pb_OnLine_Print.TabStop = false; + this.pb_OnLine_Print.Visible = false; + // + // label28 + // + this.label28.AutoSize = true; + this.label28.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.label28.Location = new System.Drawing.Point(1336, 76); + this.label28.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label28.Name = "label28"; + this.label28.Size = new System.Drawing.Size(62, 18); + this.label28.TabIndex = 1484; + this.label28.Text = "打印机"; + this.label28.UseMnemonic = false; + this.label28.Visible = false; + // + // pb_OnLine_SQL + // + this.pb_OnLine_SQL.Image = global::MisDataFun.Properties.Resources.断开状态; + this.pb_OnLine_SQL.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.pb_OnLine_SQL.Location = new System.Drawing.Point(1407, 20); + this.pb_OnLine_SQL.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.pb_OnLine_SQL.Name = "pb_OnLine_SQL"; + this.pb_OnLine_SQL.Size = new System.Drawing.Size(57, 52); + this.pb_OnLine_SQL.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.pb_OnLine_SQL.TabIndex = 1485; + this.pb_OnLine_SQL.TabStop = false; + // + // label14 + // + this.label14.AutoSize = true; + this.label14.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.label14.Location = new System.Drawing.Point(1407, 76); + this.label14.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(62, 18); + this.label14.TabIndex = 1484; + this.label14.Text = "服务器"; + // + // pb_OnLine_MQTT + // + this.pb_OnLine_MQTT.Image = global::MisDataFun.Properties.Resources.断开状态; + this.pb_OnLine_MQTT.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.pb_OnLine_MQTT.Location = new System.Drawing.Point(1478, 20); + this.pb_OnLine_MQTT.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.pb_OnLine_MQTT.Name = "pb_OnLine_MQTT"; + this.pb_OnLine_MQTT.Size = new System.Drawing.Size(57, 52); + this.pb_OnLine_MQTT.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.pb_OnLine_MQTT.TabIndex = 1483; + this.pb_OnLine_MQTT.TabStop = false; + // + // label15 + // + this.label15.AutoSize = true; + this.label15.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.label15.Location = new System.Drawing.Point(1485, 76); + this.label15.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(44, 18); + this.label15.TabIndex = 1482; + this.label15.Text = "MQTT"; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.txt_PLC_39); + this.groupBox2.Controls.Add(this.txt_PLC_11); + this.groupBox2.Controls.Add(this.txt_PLC_10); + this.groupBox2.Controls.Add(this.txt_PLC_9); + this.groupBox2.Controls.Add(this.txt_Interval); + this.groupBox2.Controls.Add(this.cb_F5); + this.groupBox2.Controls.Add(this.label27); + this.groupBox2.Controls.Add(this.label26); + this.groupBox2.Controls.Add(this.label25); + this.groupBox2.Controls.Add(this.label24); + this.groupBox2.Controls.Add(this.btn_PLC_59); + this.groupBox2.Controls.Add(this.btn_PLC_2); + this.groupBox2.Controls.Add(this.btn_PLC_43); + this.groupBox2.Controls.Add(this.btn_PLC_1002); + this.groupBox2.Controls.Add(this.btn_MES_5); + this.groupBox2.Controls.Add(this.btn_PLC_1001); + this.groupBox2.Controls.Add(this.btn_PLC_44); + this.groupBox2.Controls.Add(this.btn_PLC_1000); + this.groupBox2.Controls.Add(this.btn_MES_66); + this.groupBox2.Controls.Add(this.btn_MES_7); + this.groupBox2.Controls.Add(this.btn_PLC_19); + this.groupBox2.Controls.Add(this.btn_MES_20); + this.groupBox2.Location = new System.Drawing.Point(339, 99); + this.groupBox2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupBox2.Size = new System.Drawing.Size(597, 846); + this.groupBox2.TabIndex = 1481; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "监控和调试"; + // + // txt_PLC_39 + // + this.txt_PLC_39.Location = new System.Drawing.Point(234, 220); + this.txt_PLC_39.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.txt_PLC_39.Name = "txt_PLC_39"; + this.txt_PLC_39.Size = new System.Drawing.Size(346, 28); + this.txt_PLC_39.TabIndex = 1484; + // + // txt_PLC_11 + // + this.txt_PLC_11.Location = new System.Drawing.Point(234, 180); + this.txt_PLC_11.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.txt_PLC_11.Name = "txt_PLC_11"; + this.txt_PLC_11.Size = new System.Drawing.Size(346, 28); + this.txt_PLC_11.TabIndex = 1484; + // + // txt_PLC_10 + // + this.txt_PLC_10.Location = new System.Drawing.Point(234, 144); + this.txt_PLC_10.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.txt_PLC_10.Name = "txt_PLC_10"; + this.txt_PLC_10.Size = new System.Drawing.Size(346, 28); + this.txt_PLC_10.TabIndex = 1484; + // + // txt_PLC_9 + // + this.txt_PLC_9.Location = new System.Drawing.Point(234, 110); + this.txt_PLC_9.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.txt_PLC_9.Name = "txt_PLC_9"; + this.txt_PLC_9.Size = new System.Drawing.Size(346, 28); + this.txt_PLC_9.TabIndex = 1484; + // + // txt_Interval + // + this.txt_Interval.Location = new System.Drawing.Point(12, 39); + this.txt_Interval.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.txt_Interval.Name = "txt_Interval"; + this.txt_Interval.Size = new System.Drawing.Size(98, 28); + this.txt_Interval.TabIndex = 1483; + this.txt_Interval.Text = "100"; + // + // cb_F5 + // + this.cb_F5.AutoSize = true; + this.cb_F5.Location = new System.Drawing.Point(122, 45); + this.cb_F5.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.cb_F5.Name = "cb_F5"; + this.cb_F5.Size = new System.Drawing.Size(106, 22); + this.cb_F5.TabIndex = 1482; + this.cb_F5.Text = "刷新状态"; + this.cb_F5.UseVisualStyleBackColor = true; + this.cb_F5.CheckedChanged += new System.EventHandler(this.cb_F5_CheckedChanged); + // + // label27 + // + this.label27.AutoSize = true; + this.label27.Location = new System.Drawing.Point(9, 224); + this.label27.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label27.Name = "label27"; + this.label27.Size = new System.Drawing.Size(179, 18); + this.label27.TabIndex = 1481; + this.label27.Text = "工单号(39)PLC 600"; + // + // label26 + // + this.label26.AutoSize = true; + this.label26.Location = new System.Drawing.Point(9, 183); + this.label26.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label26.Name = "label26"; + this.label26.Size = new System.Drawing.Size(197, 18); + this.label26.TabIndex = 1481; + this.label26.Text = "产品型号(11)PLC 544"; + // + // label25 + // + this.label25.AutoSize = true; + this.label25.Location = new System.Drawing.Point(9, 147); + this.label25.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label25.Name = "label25"; + this.label25.Size = new System.Drawing.Size(197, 18); + this.label25.TabIndex = 1481; + this.label25.Text = "总成编号(10)PLC 504"; + // + // label24 + // + this.label24.AutoSize = true; + this.label24.Location = new System.Drawing.Point(9, 112); + this.label24.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label24.Name = "label24"; + this.label24.Size = new System.Drawing.Size(188, 18); + this.label24.TabIndex = 1481; + this.label24.Text = "机型代码(9)PLC 502"; + // + // btn_PLC_59 + // + this.btn_PLC_59.Location = new System.Drawing.Point(297, 594); + this.btn_PLC_59.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btn_PLC_59.Name = "btn_PLC_59"; + this.btn_PLC_59.Size = new System.Drawing.Size(261, 34); + this.btn_PLC_59.TabIndex = 1479; + this.btn_PLC_59.Text = "拧紧完成(59)PLC 501.1"; + this.btn_PLC_59.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_PLC_59.UseVisualStyleBackColor = true; + this.btn_PLC_59.Click += new System.EventHandler(this.button19_Click); + // + // btn_PLC_2 + // + this.btn_PLC_2.Location = new System.Drawing.Point(12, 482); + this.btn_PLC_2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btn_PLC_2.Name = "btn_PLC_2"; + this.btn_PLC_2.Size = new System.Drawing.Size(261, 34); + this.btn_PLC_2.TabIndex = 1478; + this.btn_PLC_2.Text = "工件到位(2)PLC 500.1"; + this.btn_PLC_2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_PLC_2.UseVisualStyleBackColor = true; + this.btn_PLC_2.Click += new System.EventHandler(this.WorkStartPLC_Click); + // + // btn_PLC_43 + // + this.btn_PLC_43.Location = new System.Drawing.Point(12, 525); + this.btn_PLC_43.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btn_PLC_43.Name = "btn_PLC_43"; + this.btn_PLC_43.Size = new System.Drawing.Size(261, 34); + this.btn_PLC_43.TabIndex = 1478; + this.btn_PLC_43.Text = "申请上线(43)PLC 500.3"; + this.btn_PLC_43.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_PLC_43.UseVisualStyleBackColor = true; + this.btn_PLC_43.Click += new System.EventHandler(this.PartLoadPLC_Click); + // + // btn_PLC_1002 + // + this.btn_PLC_1002.Location = new System.Drawing.Point(297, 558); + this.btn_PLC_1002.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btn_PLC_1002.Name = "btn_PLC_1002"; + this.btn_PLC_1002.Size = new System.Drawing.Size(261, 34); + this.btn_PLC_1002.TabIndex = 1479; + this.btn_PLC_1002.Text = "机床故障(1002)PLC 587.3"; + this.btn_PLC_1002.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_PLC_1002.UseVisualStyleBackColor = true; + this.btn_PLC_1002.Click += new System.EventHandler(this.toolErrorPLC_Click); + // + // btn_MES_5 + // + this.btn_MES_5.Location = new System.Drawing.Point(12, 573); + this.btn_MES_5.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btn_MES_5.Name = "btn_MES_5"; + this.btn_MES_5.Size = new System.Drawing.Size(261, 34); + this.btn_MES_5.TabIndex = 1478; + this.btn_MES_5.Text = "传递机型(5)MES 0.1"; + this.btn_MES_5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_MES_5.UseVisualStyleBackColor = true; + this.btn_MES_5.Click += new System.EventHandler(this.EngineGetOverMES_Click); + // + // btn_PLC_1001 + // + this.btn_PLC_1001.Location = new System.Drawing.Point(297, 520); + this.btn_PLC_1001.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btn_PLC_1001.Name = "btn_PLC_1001"; + this.btn_PLC_1001.Size = new System.Drawing.Size(261, 34); + this.btn_PLC_1001.TabIndex = 1479; + this.btn_PLC_1001.Text = "循环开始(1001)PLC 587.2"; + this.btn_PLC_1001.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_PLC_1001.UseVisualStyleBackColor = true; + this.btn_PLC_1001.Click += new System.EventHandler(this.toolStartPLC_Click); + // + // btn_PLC_44 + // + this.btn_PLC_44.Location = new System.Drawing.Point(12, 618); + this.btn_PLC_44.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btn_PLC_44.Name = "btn_PLC_44"; + this.btn_PLC_44.Size = new System.Drawing.Size(261, 34); + this.btn_PLC_44.TabIndex = 1478; + this.btn_PLC_44.Text = "传递机型(44)PLC 500.4"; + this.btn_PLC_44.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_PLC_44.UseVisualStyleBackColor = true; + this.btn_PLC_44.Click += new System.EventHandler(this.EngineGetOverPLC_Click); + // + // btn_PLC_1000 + // + this.btn_PLC_1000.Location = new System.Drawing.Point(297, 484); + this.btn_PLC_1000.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btn_PLC_1000.Name = "btn_PLC_1000"; + this.btn_PLC_1000.Size = new System.Drawing.Size(261, 34); + this.btn_PLC_1000.TabIndex = 1479; + this.btn_PLC_1000.Text = "机床上电(1000)PLC 587.1"; + this.btn_PLC_1000.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_PLC_1000.UseVisualStyleBackColor = true; + this.btn_PLC_1000.Click += new System.EventHandler(this.toolPoweredPLC_Click); + // + // btn_MES_66 + // + this.btn_MES_66.Location = new System.Drawing.Point(12, 660); + this.btn_MES_66.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btn_MES_66.Name = "btn_MES_66"; + this.btn_MES_66.Size = new System.Drawing.Size(261, 34); + this.btn_MES_66.TabIndex = 1478; + this.btn_MES_66.Text = "允许工作(66)MES 1.1"; + this.btn_MES_66.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_MES_66.UseVisualStyleBackColor = true; + this.btn_MES_66.Click += new System.EventHandler(this.allowWorkMES_Click); + // + // btn_MES_7 + // + this.btn_MES_7.Location = new System.Drawing.Point(12, 788); + this.btn_MES_7.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btn_MES_7.Name = "btn_MES_7"; + this.btn_MES_7.Size = new System.Drawing.Size(261, 34); + this.btn_MES_7.TabIndex = 1478; + this.btn_MES_7.Text = "工作完成(7)MES 0.3"; + this.btn_MES_7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_MES_7.UseVisualStyleBackColor = true; + this.btn_MES_7.Click += new System.EventHandler(this.workOverMES_Click); + // + // btn_PLC_19 + // + this.btn_PLC_19.Location = new System.Drawing.Point(12, 700); + this.btn_PLC_19.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btn_PLC_19.Name = "btn_PLC_19"; + this.btn_PLC_19.Size = new System.Drawing.Size(261, 34); + this.btn_PLC_19.TabIndex = 1478; + this.btn_PLC_19.Text = "允许保存(19)PLC 587.0"; + this.btn_PLC_19.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_PLC_19.UseVisualStyleBackColor = true; + this.btn_PLC_19.Click += new System.EventHandler(this.allowSavePLC_Click); + // + // btn_MES_20 + // + this.btn_MES_20.Location = new System.Drawing.Point(12, 744); + this.btn_MES_20.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btn_MES_20.Name = "btn_MES_20"; + this.btn_MES_20.Size = new System.Drawing.Size(261, 34); + this.btn_MES_20.TabIndex = 1478; + this.btn_MES_20.Text = "保存完成(20)MES 11.3"; + this.btn_MES_20.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btn_MES_20.UseVisualStyleBackColor = true; + this.btn_MES_20.Click += new System.EventHandler(this.saveOverMES_Click); + // + // label13 + // + this.label13.AutoSize = true; + this.label13.Font = new System.Drawing.Font("宋体", 26F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label13.Location = new System.Drawing.Point(566, 8); + this.label13.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(502, 52); + this.label13.TabIndex = 1; + this.label13.Text = "GIS126数据采集程序"; + // + // button2 + // + this.button2.Location = new System.Drawing.Point(945, 816); + this.button2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(182, 58); + this.button2.TabIndex = 1477; + this.button2.Text = "初始化报警"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(900, 40); + this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(44, 18); + this.label4.TabIndex = 1; + this.label4.Text = "日志"; + // + // richTextBox1_mqtt + // + this.richTextBox1_mqtt.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.richTextBox1_mqtt.Location = new System.Drawing.Point(945, 112); + this.richTextBox1_mqtt.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.richTextBox1_mqtt.Name = "richTextBox1_mqtt"; + this.richTextBox1_mqtt.ReadOnly = true; + this.richTextBox1_mqtt.Size = new System.Drawing.Size(601, 358); + this.richTextBox1_mqtt.TabIndex = 0; + this.richTextBox1_mqtt.Text = ""; + // + // timer_Status + // + this.timer_Status.Enabled = true; + this.timer_Status.Interval = 1000; + this.timer_Status.Tick += new System.EventHandler(this.timer_Status_Tick); + // + // statusStrip1 + // + this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripStatusLabel_RunningStatu, + this.toolStripStatusLabel_RunningStatus, + this.toolStripStatusLabel2, + this.toolStripStatusLabel_StartTime, + this.toolStripStatusLabel3, + this.toolStripStatusLabel_RunTime, + this.toolStripStatusLabel1, + this.toolStripStatusLabel_WorkStationNum, + this.toolStripStatusLabel4, + this.toolStripStatusLabel_Version}); + this.statusStrip1.Location = new System.Drawing.Point(0, 1019); + this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.Padding = new System.Windows.Forms.Padding(2, 0, 21, 0); + this.statusStrip1.Size = new System.Drawing.Size(1580, 35); + this.statusStrip1.TabIndex = 1479; + this.statusStrip1.Text = "statusStrip1"; + // + // toolStripStatusLabel_RunningStatu + // + this.toolStripStatusLabel_RunningStatu.Name = "toolStripStatusLabel_RunningStatu"; + this.toolStripStatusLabel_RunningStatu.Size = new System.Drawing.Size(100, 28); + this.toolStripStatusLabel_RunningStatu.Text = "运行状态:"; + // + // toolStripStatusLabel_RunningStatus + // + this.toolStripStatusLabel_RunningStatus.ActiveLinkColor = System.Drawing.Color.Red; + this.toolStripStatusLabel_RunningStatus.AutoSize = false; + this.toolStripStatusLabel_RunningStatus.BackColor = System.Drawing.Color.Yellow; + this.toolStripStatusLabel_RunningStatus.Name = "toolStripStatusLabel_RunningStatus"; + this.toolStripStatusLabel_RunningStatus.Size = new System.Drawing.Size(62, 28); + this.toolStripStatusLabel_RunningStatus.Text = "变量模拟"; + // + // toolStripStatusLabel2 + // + this.toolStripStatusLabel2.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Left; + this.toolStripStatusLabel2.Name = "toolStripStatusLabel2"; + this.toolStripStatusLabel2.Size = new System.Drawing.Size(104, 28); + this.toolStripStatusLabel2.Text = "启动时间:"; + // + // toolStripStatusLabel_StartTime + // + this.toolStripStatusLabel_StartTime.AutoSize = false; + this.toolStripStatusLabel_StartTime.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Right; + this.toolStripStatusLabel_StartTime.Name = "toolStripStatusLabel_StartTime"; + this.toolStripStatusLabel_StartTime.Size = new System.Drawing.Size(130, 28); + this.toolStripStatusLabel_StartTime.Text = "2018/08/08 08:08:08"; + // + // toolStripStatusLabel3 + // + this.toolStripStatusLabel3.Name = "toolStripStatusLabel3"; + this.toolStripStatusLabel3.Size = new System.Drawing.Size(100, 28); + this.toolStripStatusLabel3.Text = "运行时长:"; + // + // toolStripStatusLabel_RunTime + // + this.toolStripStatusLabel_RunTime.AutoSize = false; + this.toolStripStatusLabel_RunTime.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Right; + this.toolStripStatusLabel_RunTime.Name = "toolStripStatusLabel_RunTime"; + this.toolStripStatusLabel_RunTime.Size = new System.Drawing.Size(145, 28); + this.toolStripStatusLabel_RunTime.Text = "0天0小时0分0秒"; + this.toolStripStatusLabel_RunTime.Click += new System.EventHandler(this.toolStripStatusLabel_RunTime_Click); + // + // toolStripStatusLabel1 + // + this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; + this.toolStripStatusLabel1.Size = new System.Drawing.Size(100, 28); + this.toolStripStatusLabel1.Text = "工位数量:"; + // + // toolStripStatusLabel_WorkStationNum + // + this.toolStripStatusLabel_WorkStationNum.AutoSize = false; + this.toolStripStatusLabel_WorkStationNum.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Right; + this.toolStripStatusLabel_WorkStationNum.Name = "toolStripStatusLabel_WorkStationNum"; + this.toolStripStatusLabel_WorkStationNum.Size = new System.Drawing.Size(35, 28); + this.toolStripStatusLabel_WorkStationNum.Text = "100"; + // + // toolStripStatusLabel4 + // + this.toolStripStatusLabel4.Name = "toolStripStatusLabel4"; + this.toolStripStatusLabel4.Size = new System.Drawing.Size(64, 28); + this.toolStripStatusLabel4.Text = "版本:"; + // + // toolStripStatusLabel_Version + // + this.toolStripStatusLabel_Version.Name = "toolStripStatusLabel_Version"; + this.toolStripStatusLabel_Version.Size = new System.Drawing.Size(62, 28); + this.toolStripStatusLabel_Version.Text = "8.6.12"; + // + // MesServerMisDataFun + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1580, 1054); + this.Controls.Add(this.statusStrip1); + this.Controls.Add(this.panel7); + this.Controls.Add(this.tableLayoutPanel1); + this.Controls.Add(this.menuStrip1); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MainMenuStrip = this.menuStrip1; + this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.MaximumSize = new System.Drawing.Size(2857, 1559); + this.MinimumSize = new System.Drawing.Size(1458, 1013); + this.Name = "MesServerMisDataFun"; + this.Text = "MesServer Function V2025-07-20--1150"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MisDataFun_FormClosing); + this.Load += new System.EventHandler(this.SaveData_Load); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.tableLayoutPanel1.ResumeLayout(false); + this.groupBox5.ResumeLayout(false); + this.groupBox5.PerformLayout(); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.panel8.ResumeLayout(false); + this.panel8.PerformLayout(); + this.groupBox3.ResumeLayout(false); + this.groupBox3.PerformLayout(); + this.panel1.ResumeLayout(false); + this.tableLayoutPanel3.ResumeLayout(false); + this.tableLayoutPanel3.PerformLayout(); + this.panel3.ResumeLayout(false); + this.tableLayoutPanel2.ResumeLayout(false); + this.tableLayoutPanel2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CheckOpName)).EndInit(); + this.panel4.ResumeLayout(false); + this.tableLayoutPanel4.ResumeLayout(false); + this.tableLayoutPanel4.PerformLayout(); + this.panel5.ResumeLayout(false); + this.panel5.PerformLayout(); + this.panel2.ResumeLayout(false); + this.tableLayoutPanel5.ResumeLayout(false); + this.panel6.ResumeLayout(false); + this.panel6.PerformLayout(); + this.tabControl1.ResumeLayout(false); + this.panel7.ResumeLayout(false); + this.panel7.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dgv_OpName)).EndInit(); + this.groupBox4.ResumeLayout(false); + this.groupBox4.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pb_OnLine_Print)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pb_OnLine_SQL)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pb_OnLine_MQTT)).EndInit(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.statusStrip1.ResumeLayout(false); + this.statusStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.TextBox textBox_PLC_TO_MES; + private System.Windows.Forms.Button button_WEB_TO_MES_Clear; + private System.Windows.Forms.CheckBox checkBox_WEB_TO_MES; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.TextBox textBox_MES_TO_WEB; + private System.Windows.Forms.GroupBox groupBox5; + private System.Windows.Forms.TextBox textBox_WEB_TO_MES; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3; + private System.Windows.Forms.CheckBox checkBox_PLC_TO_MES; + private System.Windows.Forms.Button button_PLC_TO_MES_Clear; + private System.Windows.Forms.Button button_PLC_TO_MES_Big; + private System.Windows.Forms.Button button_PLC_TO_MES_Small; + private System.Windows.Forms.Panel panel3; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; + private System.Windows.Forms.DataGridView dataGridView_CheckOpName; + private System.Windows.Forms.DataGridViewCheckBoxColumn 选择; + private System.Windows.Forms.DataGridViewTextBoxColumn 工位号; + private System.Windows.Forms.CheckBox checkBox__MES_TO_WEB; + private System.Windows.Forms.Button button_MES_TO_WEB_Clear; + private System.Windows.Forms.Button button_MES_TO_WEB_Small; + private System.Windows.Forms.Button button_MES_TO_WEB_Big; + private System.Windows.Forms.Panel panel4; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel4; + private System.Windows.Forms.Button button_WEB_TO_MES_Big; + private System.Windows.Forms.Button button_WEB_TO_MES_Small; + private System.Windows.Forms.Panel panel5; + private System.Windows.Forms.Button button_WebToMES; + private System.Windows.Forms.Button button_ToWEB; + private System.Windows.Forms.TextBox textBox_MqttText; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox comboBox_OpNameList; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem_PlcDebug; + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel5; + private System.Windows.Forms.Panel panel6; + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage tabPage1; + private System.Windows.Forms.TabPage tabPage2; + private System.Windows.Forms.TabPage tabPage3; + private System.Windows.Forms.TabPage tabPage4; + private System.Windows.Forms.TabPage tabPage5; + private System.Windows.Forms.TabPage tabPage6; + private System.Windows.Forms.Button button_SaveData; + private System.Windows.Forms.Panel panel7; + private System.Windows.Forms.RichTextBox richTextBox1_mqtt; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Timer timer_Status; + private System.Windows.Forms.StatusStrip statusStrip1; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel_RunningStatu; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel_RunningStatus; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel2; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel_StartTime; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel3; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel_RunTime; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel_WorkStationNum; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel4; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel_Version; + private System.Windows.Forms.ToolStripMenuItem 帮助ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem 版本信息ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem 关于迈思ToolStripMenuItem; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button btn_PLC_2; + private System.Windows.Forms.Button btn_MES_5; + private System.Windows.Forms.Button btn_MES_7; + private System.Windows.Forms.Button btn_MES_20; + private System.Windows.Forms.Button btn_PLC_19; + private System.Windows.Forms.Button btn_MES_66; + private System.Windows.Forms.Button btn_PLC_44; + private System.Windows.Forms.Button btn_PLC_43; + private System.Windows.Forms.Button btn_PLC_1001; + private System.Windows.Forms.Button btn_PLC_1000; + private System.Windows.Forms.Panel panel8; + private System.Windows.Forms.Button button4; + private System.Windows.Forms.Button button5; + private System.Windows.Forms.Button button6; + private System.Windows.Forms.Button button7; + private System.Windows.Forms.Button button8; + private System.Windows.Forms.Button button9; + private System.Windows.Forms.Button button10; + private System.Windows.Forms.Button button11; + private System.Windows.Forms.Button button12; + private System.Windows.Forms.Button button13; + private System.Windows.Forms.Button button14; + private System.Windows.Forms.CheckBox checkBox1; + private System.Windows.Forms.CheckBox checkBox2; + private System.Windows.Forms.Button button15; + private System.Windows.Forms.ColumnHeader columnHeader6; + private System.Windows.Forms.ColumnHeader columnHeader7; + private System.Windows.Forms.ColumnHeader columnHeader8; + private System.Windows.Forms.ColumnHeader columnHeader9; + private System.Windows.Forms.ColumnHeader columnHeader10; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Button button16; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.RichTextBox richTextBox1; + private System.Windows.Forms.Button btn_PLC_1002; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button17; + private System.Windows.Forms.TextBox textBox3_palletCode; + private System.Windows.Forms.TextBox textBox2_EngineTypeID; + private System.Windows.Forms.TextBox textBox1_EngineID; + private System.Windows.Forms.Button button18; + private System.Windows.Forms.Label label12; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.Button btn_PLC_59; + private System.Windows.Forms.Label label13; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.PictureBox pb_OnLine_SQL; + private System.Windows.Forms.Label label14; + private System.Windows.Forms.PictureBox pb_OnLine_MQTT; + private System.Windows.Forms.Label label15; + private System.Windows.Forms.TextBox txt_Interval; + private System.Windows.Forms.CheckBox cb_F5; + private System.Windows.Forms.Label label24; + private System.Windows.Forms.TextBox txt_PLC_9; + private System.Windows.Forms.TextBox txt_PLC_11; + private System.Windows.Forms.TextBox txt_PLC_10; + private System.Windows.Forms.Label label26; + private System.Windows.Forms.Label label25; + private System.Windows.Forms.TextBox txt_PLC_39; + private System.Windows.Forms.Label label27; + private System.Windows.Forms.Panel panel_Signal_Conf; + private System.Windows.Forms.GroupBox groupBox4; + private System.Windows.Forms.PictureBox pb_OnLine_Print; + private System.Windows.Forms.Label label28; + private System.Windows.Forms.Button button20; + private System.Windows.Forms.DataGridView dgv_OpName; + private System.Windows.Forms.Button MesEngineDataWritePlc; + private System.Windows.Forms.DataGridViewTextBoxColumn OpCode; + private System.Windows.Forms.DataGridViewTextBoxColumn OpName; + private System.Windows.Forms.DataGridViewTextBoxColumn MesDll; + private System.Windows.Forms.DataGridViewTextBoxColumn PLC; + private System.Windows.Forms.DataGridViewTextBoxColumn PLC代码; + private System.Windows.Forms.ToolStripMenuItem webApi调试ToolStripMenuItem; + } +} + diff --git a/MisDataFun/MisDataFun/MisDataFun.cs b/MisDataFun/MisDataFun/MisDataFun.cs new file mode 100644 index 0000000..4010851 --- /dev/null +++ b/MisDataFun/MisDataFun/MisDataFun.cs @@ -0,0 +1,1036 @@ +using DataLinkMesWork; +using MesDataFunction; +using MesServerWork; +using MesWork.PLC; +using MQTTnet; +using MQTTnet.Client.Connecting; +using MQTTnet.Client.Disconnecting; +using MQTTnet.Client.Receiving; +using MQTTnet.Extensions.ManagedClient; +using Newtonsoft.Json; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Data.SqlClient; +using System.Diagnostics; +using System.Threading; +using System.Windows.Forms; +using SystemFramework; +using System.IO; +using System.Net; +using System.Text; +using MesServerFunctions; +using System.Threading.Tasks; +using MesWork; +using System.Drawing; +using MES_SIGNAL_CONF; +using SlMesDbIterface; +using System.Net.NetworkInformation; +using ExternalDataSync; +using OpcBasic; +using System.Collections.Concurrent; +using MisDataFunDll; +using System.Linq; + +namespace MisDataSaveDate +{ + /// + /// + /// + public partial class MesServerMisDataFun : Form + { + public static string WebSvrUrlPort = ConfigurationManager.AppSettings["Url_WebApi"]; + public static int IsWriteMonitorLog = Convert.ToInt32(ConfigurationManager.AppSettings["IsWriteMonitorLog"]); + public static string OnlineCheckDataUrl = ConfigurationManager.AppSettings["OnlineCheckDataUrl"].ToString(); + public static string ConnectionString_MES = ConfigurationManager.AppSettings["ConnectionString_MES"]; + public static int IsDemoMesServer = Convert.ToInt32(ConfigurationManager.AppSettings["IsDemoMesServer"]); + public static string IsRecordTagStatus = ConfigurationManager.AppSettings["IsRecordTagStatus"]; + public static string BasicDataTableFile = ConfigurationManager.AppSettings["BasicDataTableFile"]; + public static string PrintURL = ConfigurationManager.AppSettings["PrintURL"]; + public static int webApiPort = Convert.ToInt32(ConfigurationManager.AppSettings["WebSvrPort"]); + public static string webapi_MesIP = ConfigurationManager.AppSettings["Webapi_MesIP"]; + + static Hashtable hashtableTopicList = new Hashtable(); + + static bool OnLineMqtt = false; + static bool OnLine_SQL = false; + static bool OnLine_Mes = false; + static bool OnLine_Mes_Cache = false; + static bool OnLine_Print = false; + static bool IsLoopReadShow = false; + + /// + /// 允许使用附加功能的变量,只有在系统开始加载Tag时,才允许读取PLC数据 + /// + public static bool AllowLoad; + /// + /// + /// + MesWork.OpcForm opcForm = null; + /// + /// + /// + public static string WorkStationNum_Now; + /// + /// + /// + DateTime StartTime; + + public static Color color_Faw = Color.FromArgb(0, 44, 101);//蓝色,大众:0,44,101 + + public static Color color_Good = Color.FromArgb(132, 185, 235);//浅蓝,自定义 + public static Color color_Wait = Color.FromArgb(240, 230, 140);//淡黄,显示等待状态 + public static Color color_Bad = SystemColors.ActiveBorder;//灰色,显示操作过程 + public static Color color_Control = SystemColors.Control;//控件默认颜色 + public static Color color_Grey = Color.FromArgb(192, 192, 192);//灰色,Table底色 + + public static Color color_Green = Color.FromArgb(22, 161, 136);//绿色 + public static Color color_Yellow = Color.FromArgb(246, 227, 74);//黄色 + public static Color color_Red = Color.FromArgb(255, 0, 0);//红色 + + [STAThread] + static void Main() + { + new System.Threading.Mutex(true, "MES_PZ126_DLQ", out bool bCanRun); + if (!bCanRun) + { + MessageBox.Show("MES中控程序 已经在运行!不可重复启动!"); + return; + } + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + //new MES_CONF().ShowDialog(); + + Application.Run(new MesServerMisDataFun()); + } + + + + public MesServerMisDataFun() + { + InitializeComponent(); + Control.CheckForIllegalCrossThreadCalls = false; + Never_Know.Hello_You_All_Never_Know = Hello_You_All_Never_Know; + + PP.ConnectionString_MES = ConnectionString_MES; + PP.PrintURL = PrintURL; + PP.IsDemoMesServer = IsDemoMesServer; + ApplicationConfig.ConnectionString_MES = ConnectionString_MES; + + CommunicationCheckOnLine(); + MisData01(); + Init_dataGridView_CheckOpName(); + MIS_BASE.InitHashtable_MesServerCode(); + InitMesSerVerCode(); + } + public void MisData01() + { + var dt_Signal = MisDataFunDll.MisDataFun.dt_Signal(); + var dt_Device = MisDataFunDll.MisDataFun.dt_Device(); + var dt_TagTypeDataType = MisDataFunDll.MisDataFun.dt_TagTypeDataType(); + + var sql = + $" SELECT [工位号],[工位名称],[PLC],[PLC代码],[MesDll]" + + $" FROM [MES_计划BOM_工位与名称] WHERE [是否启用MES] = 1" + + $" ORDER BY [工位号]"; + SqlOperation.ExecuteSql(sql, out DataTable dt_SqlOp, out string errorSqlOp); + dgv_OpName.DataSource = dt_SqlOp; + + var mp = new MesWorkPlc(); + + StartTime = Convert.ToDateTime(toolStripStatusLabel_StartTime.Text = DateTime.Now.ToString()); + Runtime_Thread(); + + if (mp.LoadOPCData(dt_Signal, dt_Device, IsDemoMesServer, IsWriteMonitorLog, true, false, out string error)) + { + MesDataFunction.LoadTagTypeCodeID.Load(dt_TagTypeDataType); + + //查询出“全部原始基本数据列表” + var drs = MesWork.PlcLinkForm.dt_BasicData.Select($"是否启用 = 1 and 变量类型代码=101 or 变量类型代码 = 102 or 变量类型代码 = 105"); + if (drs.Length > 1) + { + MIS_BASE.BasicDataTagValue = MesWork.PlcLinkForm.dt_BasicData.Select($"是否启用 = 1 and 变量类型代码=101 or 变量类型代码 = 102 or 变量类型代码 = 105").CopyToDataTable(); + if (MIS_BASE.BasicDataTagValue.Columns.Contains("上限值")) + { + MIS_BASE.BasicDataTagValue.Columns["上限值"].ColumnName = "值上限"; + } + if (MIS_BASE.BasicDataTagValue.Columns.Contains("下限值")) + { + MIS_BASE.BasicDataTagValue.Columns["下限值"].ColumnName = "值下限"; + } + } + + // BasicDataTagValue = MesWork.PlcLinkForm.dt_BasicData.Select($"是否启用 = 1 and 监控属性代码 = '{DataLinkMesWork.ApplicationConfig.MES_Code.ToString()}'").CopyToDataTable(); + //查询出“MES_基本数据_测量范围” + MesServerWork.MIS_BASE.BasicDataTagValueUpDown = MesWork.PlcLinkForm.dt_BasicData; + if (MesServerWork.MIS_BASE.BasicDataTagValueUpDown.Columns.Contains("上限值")) + { + MesServerWork.MIS_BASE.BasicDataTagValueUpDown.Columns["上限值"].ColumnName = "值上限"; + } + if (MesServerWork.MIS_BASE.BasicDataTagValueUpDown.Columns.Contains("下限值")) + { + MesServerWork.MIS_BASE.BasicDataTagValueUpDown.Columns["下限值"].ColumnName = "值下限"; + } + // 模拟时,写入质量数据 + if (IsDemoMesServer == 1) + { + InitBasicDataTagValue(); + } + + // 变量代码与其他字段的对应关系 + MesServerWork.MIS_BASE.InitHashtableTagID(); + toolStripStatusLabel_WorkStationNum.Text = MesWork.PlcLinkForm.opNameList.Count.ToString(); + + AllowLoad = true; + if (IsDemoMesServer == 1) + { + toolStripStatusLabel_RunningStatus.Text = "变量模拟"; + toolStripStatusLabel_RunningStatus.BackColor = System.Drawing.Color.Yellow; + } + else + { + toolStripStatusLabel_RunningStatus.Text = "PLC"; + toolStripStatusLabel_RunningStatus.BackColor = System.Drawing.Color.Green; + } + MesWorkPlc.D_OPCTagData_TagDataOnChangeMIS-= OPCTagData_TagDataOnChange; + MesWorkPlc.D_OPCTagData_TagDataOnChangeMIS+= OPCTagData_TagDataOnChange; + } + } + + + + public static async Task NetState_MES() + { + Ping ping = new Ping(); + try + { + PingReply reply = await ping.SendPingAsync(webapi_MesIP); + + if (reply.Status == IPStatus.Success) + { + OnLine_Mes = true; + } + else + { + OnLine_Mes = false; + } + } + catch + { + OnLine_Mes = false; + } + } + + /// + /// 获得Function调用信息 + /// + private void InitMesSerVerCode() + { + MisDataFunDll.MisDataFun.GetMesServerCodeAndMesDll(out MisDataFunDll.MisDataFun.hashtable_MesServerCode, out MisDataFunDll.MisDataFun.hashtable_MesDll); + MisDataFunDll.MisDataFun.GetBaseData_tagTable_TagName(out MisDataFunDll.MisDataFun.hashtable_TagName, out MisDataFunDll.MisDataFun.hashtable_TagTypeTagName); + + FuntionMesRead.GetAlarmInit(); + } + + public void SaveData_Load(object sender, EventArgs e) + { + MyLog4Net.MyLogHelper.LogCommit += MyLogHelper_LogCommit; + MqttLink(); + Thread.Sleep(200); + MesWorkPlc.StartServer(); //开启监控服务 + new TaskFactory().StartNew(delegate () + { + DataTable dt; + MisDataFunDll.MisDataFun.Alarm_Moby_Search(out dt); + DataTable dt1 = MisDataFunDll.MisDataFun.GetCheckOpName(); + for (int i = 0; i < dt1.Rows.Count; i++) + { + string opName = dt1.Rows[i]["工位号"].ToString(); + FuntionMesRead.Alarm_Insert_Init(opName); + } + }); + } + /// + /// 模拟时,写入质量数据 + /// + private void InitBasicDataTagValue() + { + string tagID; + double tagValue; + //写工位总合格标志 变量类型代码=21 + for (int i = 0; i < MesWork.PlcLinkForm.dt_BasicData.Rows.Count; i++) + { + if (MesWork.PlcLinkForm.dt_BasicData.Rows[i]["变量类型代码"].ToString() == "21") + { + tagID = MesWork.PlcLinkForm.dt_BasicData.Rows[i]["TagID"].ToString(); + MesServerWork.MIS_BASE.Write_TagID(tagID, 1); + } + } + if (MesServerWork.MIS_BASE.BasicDataTagValue != null) + { + for (int i = 0; i < MesServerWork.MIS_BASE.BasicDataTagValue.Rows.Count; i++) + { + try + { + switch (Convert.ToInt32(MesServerWork.MIS_BASE.BasicDataTagValue.Rows[i]["变量排序"])) + { + + case 0: + tagID = MesServerWork.MIS_BASE.BasicDataTagValue.Rows[i]["TagID"].ToString(); + MesServerWork.MIS_BASE.Write_TagID(tagID, 1); + break; + case 1: + case 2: + case 3: + tagID = MesServerWork.MIS_BASE.BasicDataTagValue.Rows[i]["TagID"].ToString(); + tagValue = Convert.ToDouble(MesServerWork.MIS_BASE.BasicDataTagValue.Rows[i]["列位置"]) * 100 + + Convert.ToDouble(MesServerWork.MIS_BASE.BasicDataTagValue.Rows[i]["变量排序"]) / 100; + MesServerWork.MIS_BASE.Write_TagID(tagID, tagValue); + break; + + } + } + catch { } + + } + } + + } + + + private void Init_dataGridView_CheckOpName() + { + try + { + var dt1 = MisDataFunDll.MisDataFun.GetCheckOpName(); + comboBox_OpNameList.DataSource = dt1; + comboBox_OpNameList.ValueMember = "工位号"; + comboBox_OpNameList.DisplayMember = "工位号"; + } + catch (Exception ex) { } + } + + + #region mqtt相关 + private async Task MqttLink() + { + List TopicFilterList = new List(); + string url; + //string topicMqttTargetTopicPLC; + //string topicMqttTargetTopicTagTypeCodeID; + string TopicList; + string[] TopicListFunItems; + string[] TopicListItems; + url = ConfigurationManager.AppSettings["MqttUrl"]; + TopicList = ConfigurationManager.AppSettings["TopicList"]; + TopicListItems = TopicList.Split('|'); + for (int i = 0; i < TopicListItems.Length; i++) + { + TopicListFunItems = TopicListItems[i].Split(','); + hashtableTopicList.Add(TopicListFunItems[0], TopicListFunItems[1]); + } + + await Mqtt.StartAsync(); + + foreach (var topic in TopicListItems) + { + TopicListFunItems = topic.Split(','); + + Mqtt.mqttClient.SubscribeAsync(new MqttTopicFilter { Topic = TopicListFunItems[0] }); + } + Mqtt.mqttClient.ConnectedHandler = new MqttClientConnectedHandlerDelegate(OnSubscriberConnected); + Mqtt.mqttClient.DisconnectedHandler = new MqttClientDisconnectedHandlerDelegate(OnSubscriberDisconnected); + Mqtt.mqttClient.ApplicationMessageReceivedHandler = new MqttApplicationMessageReceivedHandlerDelegate(OnSubscriberMessageReceived); + + } + private string Hello_You_All_Never_Know(string[] args) + { + return Guid.NewGuid().ToString() + Guid.NewGuid().ToString(); + //return string.Empty; + } + /// + /// + /// + /// + private void OnSubscriberConnected(MqttClientConnectedEventArgs x) + { + MyLog4Net.MyLogHelper.Info("Mqtt:", "Mqtt连接成功!"); + OnLineMqtt = true; + } + /// + /// + /// + /// + private void OnSubscriberDisconnected(MqttClientDisconnectedEventArgs x) + { + try + { + MyLog4Net.MyLogHelper.Error("Mqtt:", "Mqtt断开连接!Reason:" + x.Reason); + OnLineMqtt = false; + } + catch (Exception err) + { + } + } + /// + /// + /// + /// + public void OnSubscriberMessageReceived(MqttApplicationMessageReceivedEventArgs x) + { + ThreadPool.QueueUserWorkItem(MIS_Funtion_WEB, x); + } + #endregion + + /// + /// mqtt 接收web和barcode数据 + /// + /// + public void MIS_Funtion_WEB(object e) + { + try + { + MqttApplicationMessageReceivedEventArgs x = (MqttApplicationMessageReceivedEventArgs)e; + var rec = x.ApplicationMessage.ConvertPayloadToString(); + MisDataFunDll.MisDataFun.TransferInfToMES(rec); + } + catch (Exception ex) + { + //MIS_Funtion(topicFunItem, "Exception:" + ex.Message); + } + } + /// + /// 接收内部PLC数据变化 + /// + /// + public void MIS_Funtion_PLC(object e) + { + var rec = e.ToString(); + try + { + MisDataFunDll.MisDataFun.TransferInfToMES(rec); + } + catch (Exception ex) + { + //MIS_Funtion(topicFunItem, "Exception:" + ex.Message);A + } + } + + + static public void TagTypeCodeID_Insert(string opName, string TagTypeCodeID, string TagID, string TagValue, DateTime arrivedTime, DateTime leavedTime, int TimeDiff) + { + string procedureName; + procedureName = "测量数据设备状态日志_增加数据"; + SqlParameter[] thisParms = new SqlParameter[7]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@信号类型代码", TagTypeCodeID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@TagID", TagID); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@TagValue", TagValue); + thisParms[4] = new System.Data.SqlClient.SqlParameter("@到达时间", arrivedTime); + thisParms[5] = new System.Data.SqlClient.SqlParameter("@离开时间", leavedTime); + thisParms[6] = new System.Data.SqlClient.SqlParameter("@在线时间", TimeDiff); + DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms); + } + + private void MisDataFun_FormClosing(object sender, FormClosingEventArgs e) + { + if (MessageBox.Show("您确认要退出MES程序吗?该操作会停止MES进行数据处理!", "", MessageBoxButtons.OKCancel) == DialogResult.OK) + { + Process.GetCurrentProcess().Kill(); + } + else + { + e.Cancel = true; + } + } + + private void timer_Status_Tick(object sender, EventArgs e) + { + timer_Status.Enabled = false; + Show_OnLineState(); + + if (!AllowLoad) return; + Runtime_Thread(); + + timer_Status.Enabled = true; + } + + private void Show_OnLineState() + { + OnLineState_C(pb_OnLine_Print, OnLine_Print); + OnLineState_C(pb_OnLine_SQL, OnLine_SQL); + OnLineState_C(pb_OnLine_MQTT, OnLineMqtt); + } + private void CommunicationCheckOnLine() + { + + new Thread(new ThreadStart(delegate () + { + while (true) + { + try + { + OnLine_SQL = DataLinkMesWork.SQLCommon.ExecuteDataTable("select getdate()", ConnectionString_MES, out DataTable dt, out string err); + } + catch (Exception) { } + Thread.Sleep(5000); + } + })) + { IsBackground = true }.Start(); + + // 通过IP判断 目标地址是否联通 + //new Thread(new ThreadStart(delegate () + //{ + // var ip = PrintURL.Split(':')[0]; + // while (true) + // { + // try + // { + // OnLine_Print = new System.Net.NetworkInformation.Ping().Send(ip).Status == System.Net.NetworkInformation.IPStatus.Success; + // } + // catch (Exception) { } + // Thread.Sleep(5000); + // } + //})) + //{ IsBackground = true }.Start(); + + } + private void OnLineState_C(PictureBox pb, bool onLine) + { + pb.Image = onLine ? global::MisDataFun.Properties.Resources.连接状态 + : global::MisDataFun.Properties.Resources.断开状态; + } + private void MyLogHelper_LogCommit(object sender, MyLog4Net.MyLogEventArgs e) + { + var module = e.Module; + var message = e.Message; + + var log = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff") + " " + module + " " + message + "\r\n"; + if (this.InvokeRequired) + { + this.Invoke(new Action(() => + { + this.richTextBox1_mqtt.AppendText(log); + this.richTextBox1_mqtt.Focus(); + })); + } + else + { + this.richTextBox1_mqtt.AppendText(log); + this.richTextBox1_mqtt.Focus(); + } + + } + + public void OPCTagData_TagDataOnChange(DeviceDriver_BasicData. CustomeEvetnArgs e) + { + + // 处理MES业务 Function + ThreadPool.QueueUserWorkItem(TagData_MisData_TagDataOnChangeCustomeEvetnArgs, e); + // 设备状态日志 + ThreadPool.QueueUserWorkItem(TagTypeCodeID_TagDataOnChange, e); + //发送通讯服务器 MES web界面显示用 加工位号 + ThreadPool.QueueUserWorkItem(TransferInfToWebServer, e); + } + /// + /// 发送信号变化到function + /// + /// + private void TagData_MisData_TagDataOnChangeCustomeEvetnArgs(object msgEvent) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs e = (DeviceDriver_BasicData.CustomeEvetnArgs)msgEvent; + string OpName = e.OpName.ToString();//工位号 + string MesCode = e.TagType.ToString();//变量类型代码 + object tagValue = e.TagValue;//变量(0或者1) + string TagTypeCodeID = e.TagTypeCodeID.ToString();//变量类型代码 + string TagID = e.TagID.ToString(); + string cmd = ""; + cmd = MIS_BASE.hashtable_TagTypeTagName[MesCode]; + string mesServerdllName; + + mesServerdllName = GetMesServeDllByOpName(OpName); + string fun = "fun_" + cmd; + int mesServerCode; + mesServerCode = GetMesServerCodeByOpName(OpName); + string rvMsg = Newtonsoft.Json.JsonConvert.SerializeObject(e); + + string msg; + if (cmd == null) + { + cmd = MesCode; + msg = $"PLC|{cmd}|{OpName}|{rvMsg}"; + } + else + { + msg = $"PLC|{cmd}|{OpName}|{rvMsg}"; + } + try + { + if (TagTypeCodeID == "14") + { + MIS_BASE.Write_TagValueByTagTypeID(15, OpName, tagValue); + return; + } + if (TagTypeCodeID == "103") + { + DataRow errDt = FuntionMesRead.Send_AlarmMsg(TagID, Convert.ToInt32(tagValue).ToString()); + } + } + catch (Exception err) + { + ApplicationLog.WriteLog(err, "TagData_Lable_TagDataOnChange"); + return; + } + MIS_Funtion_PLC(msg); + } + catch (Exception err) + { + ApplicationLog.WriteLog(err, "TagData_Lable_TagDataOnChange"); + } + } + + /// + /// 根据工位号获取MesServerCode + /// + /// + /// + private static int GetMesServerCodeByOpName(string OpName) + { + try + { + if (MesServerWork.MIS_BASE.hashtable_MesServerCode.ContainsKey(OpName)) + { + return Convert.ToInt32(MesServerWork.MIS_BASE.hashtable_MesServerCode[OpName]); + } + return 0; + } + catch + { + return 0; + } + } + /// + /// 根据工位号获取MesServerDll + /// + /// + /// + private static string GetMesServeDllByOpName(string OpName) + { + try + { + if (MesServerWork.MIS_BASE.hashtable_MesDll.ContainsKey(OpName)) + { + return MesServerWork.MIS_BASE.hashtable_MesDll[OpName].ToString(); + } + return ""; + } + catch (Exception err) + { + ApplicationLog.WriteLog(err, "GetMesServeDllByOpName"); + return ""; + } + } + /// + /// 数据库记录信号变化 + /// + /// + private void TagTypeCodeID_TagDataOnChange(object msgEvent) + { + if (IsRecordTagStatus != "1") return; + + try + { + DeviceDriver_BasicData.CustomeEvetnArgs e = (DeviceDriver_BasicData.CustomeEvetnArgs)msgEvent; + + string tagValue; + if (e.TagValue == null) return; + + switch (e.TagValue.ToString().ToLower()) + { + case "1": + case "true": + tagValue = "1"; + break; + default: + tagValue = "0"; + break; + } + + string TagTypeCodeID; + string opName; + string TagID; + string TagValue; + DateTime arrivedTime; + DateTime leavedTime; + int TimeDiff; + opName = e.OpName.ToString(); + TagValue = tagValue; + TagTypeCodeID = e.TagTypeCodeID.ToString(); + TagID = e.TagID.ToString(); + leavedTime = Convert.ToDateTime(e.TimeStamp); + arrivedTime = Convert.ToDateTime(e.TimeStampBefore); + TimeDiff = Convert.ToInt32(e.TagKeepTime); + + if (TagTypeCodeID != "14" && TagTypeCodeID != "15") + { + TagTypeCodeID_Insert(opName, TagTypeCodeID, TagID, TagValue, arrivedTime, leavedTime, TimeDiff); + } + } + catch (Exception err) + { + ApplicationLog.WriteLog(err, "TagTypeCodeID_TagDataOnChange"); + } + + } + /// + /// 向MES通讯服务器发送消息 + /// + /// + private void TransferInfToWebServer(object msg1) + { + int tagType; + string opName; + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)msg1; + //e值不能为空 + if (msgEvent.TagValue == null) return; + tagType = Convert.ToInt32(msgEvent.TagType); + opName = msgEvent.OpName.ToString(); + + if (!MesServerWork.MIS_BASE.m_WorkStart_OpName.ContainsKey(opName)) return; //当前系统是否存在该工位 + + string cmd; + string tagValue; + string msgSvr; + try + { + switch (Convert.ToInt32(msgEvent.TagValueType)) + { + case 11: + tagValue = (Convert.ToInt32(msgEvent.TagValue)).ToString(); + break; + default: + tagValue = msgEvent.TagValue.ToString(); + break; + } + cmd = MIS_BASE.hashtable_TagTypeTagName[tagType.ToString()]; + if (Convert.ToInt32(MIS_BASE.hashtable_WebTagTypeChange[cmd]) == 0 && MIS_BASE.hashtable_WebTagTypeChange[cmd] != null) return; + + if (cmd != "" && cmd != null) + { + msgSvr = "MES|" + cmd + "|" + opName + "|" + tagValue; + } + else + { + return; + } + //MES web界面显示用 + MIS_SendMessage.asyncSendMessageQos0(msgSvr); + } + catch (Exception err) + { + ApplicationLog.WriteLog(err, "TransferInfToWebServer"); + } + } + + private void button_ReadData_Click(object sender, EventArgs e) + { + + } + + + private void ToolStripMenuItem_PlcDebug_Click(object sender, EventArgs e) + { + if (opcForm != null) + { + opcForm.Close(); + opcForm.Dispose(); + opcForm = null; + } + + opcForm = new MesWork.OpcForm(IsDemoMesServer); + opcForm.Show(); + } + /// + /// 关于迈思按钮 + /// + /// + /// + private void 关于迈思ToolStripMenuItem_Click(object sender, EventArgs e) + { + System.Diagnostics.Process.Start("http://www.meswork.com"); + } + /// + /// 版本信息按钮 + /// + /// + /// + private void 版本信息ToolStripMenuItem_Click(object sender, EventArgs e) + { + VersionsInformation VersionForm = new VersionsInformation(); + VersionForm.ShowDialog(); + } + + private void button2_Click(object sender, EventArgs e) + { + FuntionMesRead.GetAlarmInit(); + MyLog4Net.MyLogHelper.Info($"报警更新:", "报警信息更新完成!"); + } + + private void WritePLCBoolData_Click(int TagTypeCodeId) + { + string OpName = WorkStationNum_Now; + string tagValue = MIS_BASE.Read_TagValueByTagTypeID(TagTypeCodeId, OpName).ToString(); + bool tagValueBool = false; + if (tagValue.ToLower() == "true" || tagValue == "1") + { + tagValueBool = false; + } + else + { + tagValueBool = true; + } + + MIS_BASE.Write_TagValueByTagTypeID(TagTypeCodeId, OpName, tagValueBool); + } + private void WorkStartPLC_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(2); + } + + private void PartLoadPLC_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(43); + } + + private void EngineGetOverMES_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(5); + } + + private void EngineGetOverPLC_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(44); + } + + private void allowWorkMES_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(66); + } + + private void allowSavePLC_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(19); + } + + private void saveOverMES_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(20); + } + + private void workOverMES_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(7); + } + + private void toolPoweredPLC_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(1000); + } + + private void toolStartPLC_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(1001); + } + + private void toolErrorPLC_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(1002); + } + + private void button1_Click(object sender, EventArgs e) + { + MIS_BASE.Write_TagValueByTagTypeID(200, WorkStationNum_Now, "001MBE0700000QF3D0000001"); + MIS_BASE.Write_TagValueByTagTypeID(201, WorkStationNum_Now, "001MBE0700000QF3D0000002"); + MIS_BASE.Write_TagValueByTagTypeID(202, WorkStationNum_Now, "001MBE0700000QF3D0000003"); + MIS_BASE.Write_TagValueByTagTypeID(203, WorkStationNum_Now, "001MBE0700000QF3D0000004"); + MIS_BASE.Write_TagValueByTagTypeID(204, WorkStationNum_Now, "001MBE0700000QF3D0000005"); + MIS_BASE.Write_TagValueByTagTypeID(205, WorkStationNum_Now, "001MBE0700000QF3D0000006"); + MIS_BASE.Write_TagValueByTagTypeID(206, WorkStationNum_Now, "001MBE0700000QF3D0000007"); + MIS_BASE.Write_TagValueByTagTypeID(207, WorkStationNum_Now, "001MBE0700000QF3D0000008"); + } + + private void button17_Click(object sender, EventArgs e) + { + MIS_BASE.Read_EngineID_MES(WorkStationNum_Now, out string EngineID_MES); + MIS_BASE.Read_EngineTypeID_MES(WorkStationNum_Now, out int EngineTypeID_MES); + MIS_BASE.Write_TagValueByTagTypeID(10, WorkStationNum_Now, EngineID_MES); + MIS_BASE.Write_TagValueByTagTypeID(9, WorkStationNum_Now, EngineTypeID_MES); + MIS_BASE.Write_TagValueByTagTypeID(80, WorkStationNum_Now, 12); + } + + private void button18_Click(object sender, EventArgs e) + { + string EngineID = textBox1_EngineID.Text; + string EngineTypeID = textBox2_EngineTypeID.Text; + string palletCode = textBox3_palletCode.Text; + + MIS_BASE.Write_TagValueByTagTypeID(10, WorkStationNum_Now, EngineID); + MIS_BASE.Write_TagValueByTagTypeID(9, WorkStationNum_Now, EngineTypeID); + MIS_BASE.Write_TagValueByTagTypeID(80, WorkStationNum_Now, palletCode); + } + + private void button19_Click(object sender, EventArgs e) + { + WritePLCBoolData_Click(59); + } + + + /// + /// 界面上的开启时间 + /// + void Runtime_Thread() + { + try + { + DateTime Now = DateTime.Now; + TimeSpan x = Now.Subtract(StartTime); + toolStripStatusLabel_RunTime.Text = x.Days.ToString() + "天" + x.Hours.ToString("00") + "小时" + x.Minutes.ToString("00") + "分" + x.Seconds.ToString("00") + "秒"; + } + catch (Exception err) + { + ApplicationLog.WriteLog(err, err.Message); + } + } + + private void cb_F5_CheckedChanged(object sender, EventArgs e) + { + var interval = Convert.ToInt32(txt_Interval.Text); + + if (IsLoopReadShow = cb_F5.Checked) + { + var t = new Thread(new ParameterizedThreadStart(LoopReadShowTask)); + t.IsBackground = true; + t.Start(interval); + } + } + + private void toolStripStatusLabel_RunTime_Click(object sender, EventArgs e) + { + } + + public void LoopReadShowTask(object _interval) + { + var interval = (int)_interval; + while (true) + { + try + { + if (IsLoopReadShow == false) + { + return; + } + + ShowSignal(txt_PLC_9, WorkStationNum_Now); + ShowSignal(txt_PLC_10, WorkStationNum_Now); + ShowSignal(txt_PLC_11, WorkStationNum_Now); + ShowSignal(txt_PLC_39, WorkStationNum_Now); + + ShowSignal(btn_PLC_2, WorkStationNum_Now); + ShowSignal(btn_PLC_43, WorkStationNum_Now); + ShowSignal(btn_MES_5, WorkStationNum_Now); + + ShowSignal(btn_PLC_44, WorkStationNum_Now); + ShowSignal(btn_MES_66, WorkStationNum_Now); + + + ShowSignal(btn_PLC_19, WorkStationNum_Now); + ShowSignal(btn_MES_20, WorkStationNum_Now); + //ShowSignal(btn_MES_7, WorkStationNum_Now); + + ShowSignal(btn_PLC_1000, WorkStationNum_Now); + ShowSignal(btn_PLC_1001, WorkStationNum_Now); + ShowSignal(btn_PLC_1002, WorkStationNum_Now); + //ShowSignal(btn_PLC_59, WorkStationNum_Now); + + } + catch (Exception err) + { + } + Thread.Sleep(interval); + } + + } + + + public void ShowSignal(Control c,string opName) + { + var tagTypeCodeID = Convert.ToInt32(c.Name.Split('_')[2]); + if (c is TextBox) + { + try + { + c.Text = PlcLinkForm.ReadPLC(tagTypeCodeID, opName).ToString(); + + } + catch (Exception err) + { + c.Text = "不存在该信号!"; + } + } + if (c is Button) + { + try + { + c.BackColor = PlcLinkForm.ReadPLC(tagTypeCodeID, opName).ToString().ToLower() + .Replace("true", "1").Replace("false", "0") == "1" + ? color_Green : color_Bad; + } + catch (Exception err) + { + c.BackColor = color_Red; + } + } + + } + + private void panel_Signal_Conf_MouseDoubleClick(object sender, MouseEventArgs e) + { + new MES_CONF().ShowDialog(); + } + + private void button20_Click(object sender, EventArgs e) + { + PrinterCommandCenter.PrintToPrinter(textBox1_EngineID.Text); + } + + private void dgv_OpName_CellClick(object sender, DataGridViewCellEventArgs e) + { + if (e.RowIndex > -1) + { + if (AllowLoad) + { + WorkStationNum_Now = dgv_OpName.CurrentRow.Cells["OpCode"].Value.ToString(); + } + } + } + + private void webAPI接口测试ToolStripMenuItem_Click(object sender, EventArgs e) + { + } + + private void MesEngineDataWritePlc_Click(object sender, EventArgs e) + { + // 把工件编号、订单号、产品型号代码、产品型号 写入PLC + string OpName = WorkStationNum_Now; + MIS_BASE.WritePLC(9, OpName, MIS_BASE.ReadPLC(73, OpName)); // 机型标志 + MIS_BASE.WritePLC(11, OpName, MIS_BASE.ReadPLC(75, OpName)); // 产品型号 + MIS_BASE.WritePLC(39, OpName, MIS_BASE.ReadPLC(116, OpName)); // 订单号 + MIS_BASE.WritePLC(10, OpName, MIS_BASE.ReadPLC(74, OpName)); // 机型标志 + } + + } +} diff --git a/MisDataFun/MisDataFun/MisDataFun.csproj b/MisDataFun/MisDataFun/MisDataFun.csproj new file mode 100644 index 0000000..412834f --- /dev/null +++ b/MisDataFun/MisDataFun/MisDataFun.csproj @@ -0,0 +1,253 @@ + + + + + Debug + AnyCPU + {DD9131C7-BF40-45B0-827A-C5E46FC8A89E} + WinExe + MisDataFun + MisDataFun + v4.8 + 512 + true + true + + + + AnyCPU + true + full + false + ..\..\MisDataFun_Exe\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + Mes32X32.ico + + + app.manifest + + + + Form + + + MES_CONF.cs + + + + Form + + + MisDataFun.cs + + + + + + + + + MES_CONF.cs + + + MisDataFun.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + ..\..\dll_common\BasicData.dll + + + ..\..\dll_common\BouncyCastle.Crypto.dll + + + False + ..\..\dll_common\ConLink.dll + + + ..\..\dll_common\ConLink19.dll + + + ..\..\dll_common\DataLinkMesWork.dll + + + False + ..\..\dll_common\ICSharpCode.SharpZipLib.dll + + + ..\..\dll_common\MesControl.dll + + + ..\..\dll_common\MesWork.DeviceDriver.dll + + + + ..\packages\Microsoft.Owin.4.2.2\lib\net45\Microsoft.Owin.dll + + + ..\..\dll_common\Monitor.MesWork.dll + + + ..\..\dll_common\MQTTnet.dll + + + ..\..\dll_common\MQTTnet.Extensions.ManagedClient.dll + + + ..\..\dll_common\Newtonsoft.Json.dll + + + False + ..\..\dll_common\NPOI.dll + + + False + ..\..\dll_common\NPOI.OOXML.dll + + + False + ..\..\dll_common\NPOI.OpenXml4Net.dll + + + False + ..\..\dll_common\NPOI.OpenXmlFormats.dll + + + ..\..\dll_common\Opc.Ua.Client.dll + + + ..\..\dll_common\Opc.Ua.Configuration.dll + + + ..\..\dll_common\Opc.Ua.Core.dll + + + ..\..\dll_common\OpcUaHelper.dll + + + ..\packages\Owin.1.0\lib\net40\Owin.dll + + + + + + + + + + False + ..\..\dll_common\System.Net.Http.Formatting.dll + + + False + ..\..\dll_fun\System.Net.Security.dll + + + False + ..\..\dll_fun\System.Net.WebSockets.dll + + + False + ..\..\dll_fun\System.Net.WebSockets.Client.dll + + + False + ..\..\dll_fun\System.Security.Cryptography.Algorithms.dll + + + False + ..\..\dll_fun\System.Security.Cryptography.Encoding.dll + + + False + ..\..\dll_fun\System.Security.Cryptography.Primitives.dll + + + False + ..\..\dll_fun\System.Security.Cryptography.X509Certificates.dll + + + ..\..\dll_common\System.Web.Cors.dll + + + + ..\..\dll_common\System.Web.Http.dll + + + ..\..\dll_common\System.Web.Http.Cors.dll + + + ..\..\dll_common\System.Web.Http.SelfHost.dll + + + + + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 01-MesDataFunction + + + {1dc48c83-1842-4de8-acaf-26e1e7f7c58f} + 00_MyLog4Net + + + {b5a0baa3-c1a7-4aab-9486-2e650adaca7e} + Function1051 + + + {5fee5c91-8419-49ff-b2c2-47476f0b8c68} + Function1052 + + + {ca8a12c5-7bf0-4489-93fa-180b1c492bba} + Function1053 + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFun/MisDataFun/MisDataFun.resx b/MisDataFun/MisDataFun/MisDataFun.resx new file mode 100644 index 0000000..0b9bac2 --- /dev/null +++ b/MisDataFun/MisDataFun/MisDataFun.resx @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 22, 12 + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + 267, 7 + + + 137, 15 + + + 36 + + + + + AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAABAAABMLAAATCwAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMgChADIAoQIyAKEgMgChczIA + occyAKHqMgChmTIAoTwyAKEJMgChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMgChADIAoQQyAKEvMgChdzIA + odYyAKH7MgCh/zIAof8yAKH/MgCh6jIAoacyAKFJMgChEjIAoQAyAKEAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAyAKEAMgChADIAoQoyAKE+MgChkTIA + oeoyAKH+MgCh+TIAoe0yAKH+MgCh/zIAofwyAKH3MgCh/jIAofgyAKHBMgChZDIAoR4yAKEBMgChAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAyAKEAMgChATIAoRUyAKFcMgChujIA + ofEyAKH/MgCh9DIAobcyAKFPMgChfjIAof8yAKH/MgCh5TIAoVUyAKGLMgCh4jIAofwyAKH9MgCh2TIA + oYcyAKEoMgChBTIAoQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAyAKEAMgChAjIAoSYyAKF2MgCh0DIA + ofcyAKH+MgCh8zIAof8yAKGjMgChDTIAoQAyAKFpMgCh/zIAof8yAKHhMgChHjIAoQIyAKEiMgChbjIA + ocoyAKH3MgCh/jIAoeUyAKGfMgChQTIAoQsyAKEAAAAAAAAAAAAAAAAAMgChCDIAoUEyAKGXMgCh4jIA + of4yAKH/MgChzzIAoW0yAKFoMgCh+zIAoZcyAKEAMgChADIAoWkyAKH/MgCh/zIAoeEyAKEeMgChADIA + oQAyAKEBMgChETIAoVAyAKGiMgCh8DIAof8yAKH0MgChuTIAoW0yAKEVMgChADIAoQAyAKG2MgCh7TIA + of8yAKHvMgCh7jIAofgyAKFLMgChADIAoTcyAKH1MgChlzIAoQAyAKEAMgChaTIAof8yAKH/MgCh4TIA + oR4yAKEAAAAAAAAAAAAAAAAAMgChADIAoQcyAKE4MgChijIAod8yAKH9MgCh+zIAoc4yAKFdMgChADIA + of8yAKHlMgChlDIAoToyAKGgMgCh7jIAoSwyAKEAMgChFzIAodgyAKGZMgChADIAoQAyAKFpMgCh/zIA + of8yAKHxMgChfDIAoSkyAKEBMgChAAAAAAAAAAAAAAAAADIAoQAyAKECMgChITIAoW8yAKG/MgCh/zIA + oZYyAKEAMgCh/zIAoZoyAKEBMgChADIAoZkyAKHSMgChEjIAoQAyAKEGMgChujIAoZoyAKEAMgChADIA + oWkyAKH/MgCh/zIAof0yAKH+MgCh4TIAoZIyAKFEMgChDjIAoQAyAKEAAAAAAAAAAAAAAAAAMgChADIA + oUIyAKH7MgChlzIAoQAyAKH/MgChlzIAoQAyAKEAMgChmjIAobMyAKEEMgChADIAoQAyAKGcMgChmzIA + oQAyAKEAMgChaTIAof8yAKH/MgCh4zIAoZYyAKHRMgCh+zIAofQyAKHDMgChZDIAoSIyAKEBMgChAAAA + AAAyAKEAMgChPzIAofsyAKGXMgChADIAof8yAKGXMgChADIAoQAyAKGaMgChiDIAoQAAAAAAMgChADIA + oYgyAKGaMgChADIAoQAyAKFpMgCh/zIAof8yAKHhMgChIDIAoRIyAKFeMgChqzIAoe0yAKH+MgCh3jIA + oYYyAKEqMgChADIAoQAyAKE/MgCh+zIAoZcyAKEAMgCh/zIAoZcyAKEAMgChADIAoZgyAKFtMgChAAAA + AAAyAKEAMgChXDIAoZQyAKEAMgChADIAoWkyAKH/MgCh/zIAoeEyAKEeMgChADIAoQAyAKEGMgChMDIA + oX8yAKHTMgCh+jIAoWkyAKEAMgChADIAoT8yAKH7MgChlzIAoQAyAKH/MgChlzIAoQAyAKEAMgChlTIA + oWMyAKEAAAAAADIAoQAyAKE2MgChhTIAoQAyAKEAMgChaTIAof8yAKH/MgCh4TIAoR4yAKEAAAAAAAAA + AAAyAKEAMgChATIAoRUyAKFYMgChQDIAoQAyAKEAMgChPzIAofsyAKGXMgChADIAof8yAKGXMgChADIA + oQAyAKGLMgChQTIAoQAyAKEFMgChADIAoSMyAKF4MgChADIAoQAyAKFpMgCh/zIAof8yAKHhMgChHjIA + oQAAAAAAAAAAAAAAAAAAAAAAMgChADIAoQAyAKEBMgChADIAoQAyAKE/MgCh+zIAoZcyAKEAMgCh/zIA + oZcyAKEAMgChADIAoXcyAKEkMgChBzIAoUIyAKEBMgChFjIAoWUyAKEBMgChADIAoWkyAKH/MgCh/zIA + oeEyAKEeMgChADIAoQAyAKE5MgChSTIAoQ8yAKEBMgChAAAAAAAAAAAAMgChADIAoT8yAKH7MgChlzIA + oQAyAKH/MgChlzIAoQAyAKECMgChWzIAoQ8yAKEVMgChhTIAoQoyAKEHMgChMzIAoQEyAKEAMgChaTIA + of8yAKH/MgCh4TIAoR4yAKEAMgChADIAoWkyAKH1MgChyzIAoX8yAKE4MgChBTIAoQAyAKEAMgChPzIA + ofsyAKGXMgChADIAof8yAKGXMgChADIAoQMyAKFZMgChCzIAoS4yAKHDMgChGjIAoQAAAAAAAAAAADIA + oQAyAKFpMgCh/zIAof8yAKHhMgChHjIAoQAyAKEAMgChLDIAoaEyAKHkMgCh/DIAoe8yAKGrMgChUzIA + oREyAKFBMgCh+zIAoZcyAKEAMgCh/zIAoZcyAKEAMgChBzIAoVAyAKEEMgChQTIAodoyAKEjMgChAAAA + AAAAAAAAMgChADIAoWkyAKH/MgCh/zIAoeEyAKEeMgChAAAAAAAyAKEAMgChBjIAoSAyAKFyMgChwjIA + ofMyAKH4MgCh0zIAobMyAKH9MgChljIAoQAyAKH/MgChlzIAoQAyAKEBMgChBDIAoQAyAKFKMgCh7jIA + oT0yAKEAAAAAADIAoQAyAKEAMgChbDIAof8yAKH/MgCh4TIAoR8yAKEAAAAAAAAAAAAAAAAAMgChADIA + oQEyAKELMgChRzIAoZYyAKHeMgCh/TIAof8yAKGWMgChADIAof8yAKGXMgChAAAAAAAAAAAAMgChADIA + oW0yAKH/MgChZDIAoQAyAKEEMgChHDIAoWAyAKHPMgCh/zIAof8yAKH3MgChkTIAoS8yAKELMgChADIA + oQAAAAAAAAAAAAAAAAAyAKEAMgChATIAoSAyAKF2MgCh/zIAoZYyAKEAMgCh/zIAoZcyAKEAAAAAADIA + oQAyAKEAMgChljIAof8yAKGeMgChOTIAoZEyAKHcMgCh+TIAof8yAKH/MgCh/zIAof8yAKH+MgCh6jIA + obgyAKFXMgChITIAoQEyAKEAAAAAAAAAAAAAAAAAMgChADIAoT8yAKH7MgChlzIAoQAyAKH/MgChlzIA + oQAAAAAAMgChADIAoQwyAKG9MgCh/zIAofMyAKHyMgCh/jIAof8yAKH/MgCh/zIAofoyAKH3MgCh/jIA + of8yAKH/MgCh/zIAofsyAKHbMgChmzIAoUwyAKENMgChATIAoQAyAKEAMgChPzIAofsyAKGXMgChADIA + of8yAKGXMgChATIAoRkyAKFbMgChsTIAofAyAKH/MgCh/zIAof8yAKH/MgCh/DIAoeYyAKGxMgChVTIA + oUIyAKGFMgCh1TIAofUyAKH/MgCh/zIAof8yAKH/MgCh9DIAocUyAKGDMgChMDIAoQYyAKE/MgCh+zIA + oZcyAKEAMgCh/zIAocEyAKGOMgCh2TIAofcyAKH/MgCh/zIAof8yAKH/MgCh7jIAobMyAKFwMgChJjIA + oQoyAKEAMgChADIAoQEyAKEXMgChTTIAoZsyAKHYMgCh/TIAof8yAKH/MgCh/zIAof4yAKHqMgChszIA + oZgyAKH+MgChljIAoQAyAKH/MgCh/zIAof8yAKH/MgCh/zIAof8yAKH0MgChyTIAoYEyAKE/MgChBzIA + oQAAAAAAMgChADIAoSIyAKF2MgChQjIAoRIyAKEAMgChATIAoR4yAKFjMgChrjIAoecyAKH9MgCh/zIA + of8yAKH/MgCh/zIAof8yAKGWMgChADIAof8yAKH/MgCh/zIAofkyAKHWMgChmjIAoUIyAKERMgChATIA + oQAyAKEGMgChFTIAoQMyAKEAMgChKDIAoZUyAKHHMgChxjIAoXcyAKE3MgChBzIAoQAyAKEGMgChKTIA + oXYyAKHDMgCh7jIAof4yAKH/MgCh/zIAoZYyAKEAMgChrjIAoeYyAKH+MgCh0zIAoVcyAKELMgChADIA + oQAyAKEAMgChADIAoVUyAKHAMgChkjIAoVYyAKEUMgChATIAoRYyAKFhMgChqzIAodUyAKGmMgChZTIA + oR8yAKEDMgChBDIAoS0yAKGiMgCh9DIAofUyAKHGMgChWTIAoQAyAKEGMgChKjIAoWsyAKHBMgCh3DIA + ocEyAKFwMgChJTIAoQYyAKEAMgChDDIAoTgyAKF/MgChyjIAocMyAKGUMgChMzIAoQsyAKEEMgChJjIA + oWUyAKG/MgCh0TIAoaYyAKGoMgCh1TIAodYyAKGNMgChQTIAoRAyAKEAMgChAAAAAAAyAKEAMgChADIA + oQ8yAKE8MgChkDIAoc8yAKHfMgChpDIAoVIyAKEcMgChADIAoQEyAKETMgChRzIAoZ8yAKHGMgChvzIA + oWQyAKEtMgChMzIAoY8yAKHvMgCh5zIAoa8yAKFcMgChHDIAoQMyAKEAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAADIAoQAyAKECMgChFTIAoVcyAKGaMgCh3DIAodEyAKGaMgChSDIAoQsyAKEAMgChATIA + oSUyAKGGMgCh6TIAofEyAKHhMgChtzIAoXAyAKErMgChBTIAoQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMgChADIAoQIyAKElMgChXTIAobgyAKHbMgChxTIA + oYUyAKFbMgChqzIAodEyAKHLMgChhDIAoTsyAKELMgChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAyAKEAMgChCzIA + oTcyAKGTMgCh0zIAofAyAKG2MgChWjIAoRcyAKEBMgChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAA/+Af//+AB//8AAD/8AAAP8AIAA8AGDABARg+AQEYD4ERGAPxMZgAcTOY + ADEzmDAxM5g8MTKIPzEgCDDxIAgwMSB4MAEgeDgBJHg+ATxAD8E8AAHxOAAAMQAAAAEAAwABABwgAQBE + BAEBwAABAEAAA+AAAA/4AAB//wAD///gD/8= + + + \ No newline at end of file diff --git a/MisDataFun/MisDataFun/Properties/AssemblyInfo.cs b/MisDataFun/MisDataFun/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d797f42 --- /dev/null +++ b/MisDataFun/MisDataFun/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("MisDataSaveDate")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("大连迈思信息技术有限公司")] +[assembly: AssemblyProduct("MisDataSaveDate")] +[assembly: AssemblyCopyright("Copyright © 大连迈思信息技术有限公司 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("9aede061-8490-436a-b38b-9495dc908f19")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MisDataFun/MisDataFun/Properties/Resources.Designer.cs b/MisDataFun/MisDataFun/Properties/Resources.Designer.cs new file mode 100644 index 0000000..34e1c57 --- /dev/null +++ b/MisDataFun/MisDataFun/Properties/Resources.Designer.cs @@ -0,0 +1,83 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace MisDataFun.Properties { + using System; + + + /// + /// 一个强类型的资源类,用于查找本地化的字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// 返回此类使用的缓存的 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MisDataFun.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 重写当前线程的 CurrentUICulture 属性,对 + /// 使用此强类型资源类的所有资源查找执行重写。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 断开状态 { + get { + object obj = ResourceManager.GetObject("断开状态", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 连接状态 { + get { + object obj = ResourceManager.GetObject("连接状态", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/MisDataFun/MisDataFun/Properties/Resources.resx b/MisDataFun/MisDataFun/Properties/Resources.resx new file mode 100644 index 0000000..19c6ed7 --- /dev/null +++ b/MisDataFun/MisDataFun/Properties/Resources.resx @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\断开状态.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\连接状态.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/MisDataFun/MisDataFun/Properties/Settings.Designer.cs b/MisDataFun/MisDataFun/Properties/Settings.Designer.cs new file mode 100644 index 0000000..2e69221 --- /dev/null +++ b/MisDataFun/MisDataFun/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace MesServerMisDataFun.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.0.3.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/MisDataFun/MisDataFun/Properties/Settings.settings b/MisDataFun/MisDataFun/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/MisDataFun/MisDataFun/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/MisDataFun/MisDataFun/Resources/断开状态.png b/MisDataFun/MisDataFun/Resources/断开状态.png new file mode 100644 index 0000000..0ae6189 Binary files /dev/null and b/MisDataFun/MisDataFun/Resources/断开状态.png differ diff --git a/MisDataFun/MisDataFun/Resources/连接状态.png b/MisDataFun/MisDataFun/Resources/连接状态.png new file mode 100644 index 0000000..fcf9db7 Binary files /dev/null and b/MisDataFun/MisDataFun/Resources/连接状态.png differ diff --git a/MisDataFun/MisDataFun/app.manifest b/MisDataFun/MisDataFun/app.manifest new file mode 100644 index 0000000..75867c2 --- /dev/null +++ b/MisDataFun/MisDataFun/app.manifest @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MisDataFun/MisDataFun/jsconfig1.json b/MisDataFun/MisDataFun/jsconfig1.json new file mode 100644 index 0000000..afb797c --- /dev/null +++ b/MisDataFun/MisDataFun/jsconfig1.json @@ -0,0 +1,10 @@ +{ + "exclude": [ + "**/bin", + "**/bower_components", + "**/jspm_packages", + "**/node_modules", + "**/obj", + "**/platforms" + ] +} \ No newline at end of file diff --git a/MisDataFun/MisDataFun/mes_signal_conf/MES_CONF.Designer.cs b/MisDataFun/MisDataFun/mes_signal_conf/MES_CONF.Designer.cs new file mode 100644 index 0000000..4cd9051 --- /dev/null +++ b/MisDataFun/MisDataFun/mes_signal_conf/MES_CONF.Designer.cs @@ -0,0 +1,113 @@ +namespace MES_SIGNAL_CONF +{ + partial class MES_CONF + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 窗体设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.btn_ConfigToSql = new System.Windows.Forms.Button(); + this.label_ReadExcel = new System.Windows.Forms.Label(); + this.label_WriteSql = new System.Windows.Forms.Label(); + this.txt_Msg = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // btn_ConfigToSql + // + this.btn_ConfigToSql.Location = new System.Drawing.Point(487, 74); + this.btn_ConfigToSql.Name = "btn_ConfigToSql"; + this.btn_ConfigToSql.Size = new System.Drawing.Size(161, 36); + this.btn_ConfigToSql.TabIndex = 0; + this.btn_ConfigToSql.Text = "重新将配置写入数据库"; + this.btn_ConfigToSql.UseVisualStyleBackColor = true; + this.btn_ConfigToSql.Click += new System.EventHandler(this.btn_ConfigToSql_Click); + // + // label_ReadExcel + // + this.label_ReadExcel.AutoSize = true; + this.label_ReadExcel.Location = new System.Drawing.Point(12, 16); + this.label_ReadExcel.Name = "label_ReadExcel"; + this.label_ReadExcel.Size = new System.Drawing.Size(95, 12); + this.label_ReadExcel.TabIndex = 1; + this.label_ReadExcel.Text = "label_ReadExcel"; + // + // label_WriteSql + // + this.label_WriteSql.AutoSize = true; + this.label_WriteSql.Location = new System.Drawing.Point(12, 42); + this.label_WriteSql.Name = "label_WriteSql"; + this.label_WriteSql.Size = new System.Drawing.Size(89, 12); + this.label_WriteSql.TabIndex = 1; + this.label_WriteSql.Text = "label_WriteSql"; + // + // txt_Msg + // + this.txt_Msg.Location = new System.Drawing.Point(14, 116); + this.txt_Msg.Multiline = true; + this.txt_Msg.Name = "txt_Msg"; + this.txt_Msg.Size = new System.Drawing.Size(634, 316); + this.txt_Msg.TabIndex = 2; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 70); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(335, 36); + this.label1.TabIndex = 3; + this.label1.Text = "使用到数据库的表:\r\n读取:MES_计划BOM_工位与名称([是否启用MES] = 1)\r\n写入:MES_基本变量_原始数据、MES_基本变量设备类型对应表"; + this.label1.Click += new System.EventHandler(this.label1_Click); + // + // MES_CONF + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(660, 437); + this.Controls.Add(this.label1); + this.Controls.Add(this.txt_Msg); + this.Controls.Add(this.label_WriteSql); + this.Controls.Add(this.label_ReadExcel); + this.Controls.Add(this.btn_ConfigToSql); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "MES_CONF"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "MES监控系统信号配置"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button btn_ConfigToSql; + private System.Windows.Forms.Label label_ReadExcel; + private System.Windows.Forms.Label label_WriteSql; + private System.Windows.Forms.TextBox txt_Msg; + private System.Windows.Forms.Label label1; + } +} + diff --git a/MisDataFun/MisDataFun/mes_signal_conf/MES_CONF.cs b/MisDataFun/MisDataFun/mes_signal_conf/MES_CONF.cs new file mode 100644 index 0000000..b82a21e --- /dev/null +++ b/MisDataFun/MisDataFun/mes_signal_conf/MES_CONF.cs @@ -0,0 +1,421 @@ +using SlMesDbIterface; +using System; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using System.Windows.Forms; +using static System.Configuration.ConfigurationManager; + +namespace MES_SIGNAL_CONF +{ + public partial class MES_CONF : Form + { + #region 构造函数与初始化 + + public MES_CONF() + { + InitializeComponent(); + InitializeLabels(); + } + + /// + /// 初始化界面标签 + /// + private void InitializeLabels() + { + label_ReadExcel.Text = $"读取位置:{MisDataSaveDate.MesServerMisDataFun.BasicDataTableFile}"; + label_WriteSql.Text = $"写入位置:{MisDataSaveDate.MesServerMisDataFun.ConnectionString_MES}"; + } + + #endregion + + #region 事件处理 + + /// + /// 配置导入到SQL按钮点击事件 + /// + private void btn_ConfigToSql_Click(object sender, EventArgs e) + { + try + { + WriteLog("========== 开始导入配置 =========="); + LoadOpcData(); + WriteLog("========== 导入配置完成 =========="); + } + catch (Exception ex) + { + WriteLog($"✗ 导入失败:{ex.Message}"); + MessageBox.Show($"配置导入失败!\n{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void label1_Click(object sender, EventArgs e) + { + // 预留事件 + } + + #endregion + + #region 主要业务逻辑 + + /// + /// 加载OPC数据并导入数据库 + /// + private void LoadOpcData() + { + // 1. 加载基础数据 + WriteLog("正在加载Excel数据..."); + var excelData = LoadExcelData(); + + // 2. 生成标签数据 + WriteLog("正在生成标签数据..."); + DataTable dtTag = GenerateTagData(excelData); + + excelData.DeviceTable.TableName = "MES_基本变量设备类型对应表"; + + // 3. 保存到数据库 + WriteLog("正在保存到数据库..."); + SaveToDatabase(dtTag, excelData.DeviceTable); + } + + /// + /// 从Excel加载所有基础数据 + /// + private ExcelDataModel LoadExcelData() + { + string excelFile = MisDataSaveDate.MesServerMisDataFun.BasicDataTableFile; + + return new ExcelDataModel + { + StationTable = GetStationData(), + TagMesTable = LoadEnabledData(excelFile, "MES_基本变量原始数据"), + TagModelTable = LoadEnabledData(excelFile, "MES_信号表模板"), + //TagModelKwTable = LoadEnabledData(excelFile, "MES_信号表模板(库位)"), + DeviceTable = LoadEnabledData(excelFile, "设备类型对应表") + }; + } + + /// + /// 加载Excel启用数据 + /// + private DataTable LoadEnabledData(string excelFile, string sheetName) + { + var rawData = NPOITest.ExeclHelper.ExcelToDataTable(excelFile, sheetName, true); + var enabledRows = rawData.Select($"是否启用='1'"); + + return enabledRows.Length > 0 ? enabledRows.CopyToDataTable() : rawData.Clone(); + } + + /// + /// 生成标签数据 + /// + private DataTable GenerateTagData(ExcelDataModel excelData) + { + DataTable dtTag = excelData.TagModelTable.Clone(); + + // 分离库位工位和普通工位 + var stationData = SplitStationByType(excelData.StationTable, "1"); + //var stationKw = SplitStationByType(excelData.StationTable, "2"); + + // 处理普通工位 + WriteLog($"处理普通工位数据,共 {stationData.Rows.Count} 个工位"); + ProcessStations(stationData, excelData.TagModelTable, dtTag); + + //// 处理库位工位 + //WriteLog($"处理库位工位数据,共 {stationKw.Rows.Count} 个工位"); + //ProcessStations(stationKw, excelData.TagModelKwTable, dtTag); + + // 合并报警数据 + MergeAlarmData(dtTag); + + // 合并MES基本变量数据 + dtTag.Merge(excelData.TagMesTable); + + dtTag.TableName = "MES_基本变量_原始数据"; + + WriteLog($"标签数据生成完成,共 {dtTag.Rows.Count} 条记录"); + return dtTag; + } + + /// + /// 按线体类型分离工位数据 + /// + private DataTable SplitStationByType(DataTable stationTable, string lineType) + { + string filter = $"线体类型 = '{lineType}'"; + var rows = stationTable.Select(filter); + + return rows.Length > 0 ? rows.CopyToDataTable() : stationTable.Clone(); + } + + /// + /// 处理工位数据 + /// + private void ProcessStations(DataTable stations, DataTable tagModel, DataTable targetTag) + { + foreach (DataRow stationRow in stations.Rows) + { + var stationInfo = new StationInfo + { + 工位代码 = stationRow["工位代码"].ToString(), + 工位号 = stationRow["工位号"].ToString(), + 工位名称 = stationRow["工位名称"].ToString(), + PLC = stationRow["PLC"].ToString(), + PLC代码 = stationRow["PLC代码"].ToString() + }; + + DataTable tagCopy = tagModel.Copy(); + UpdateTagTableByStation(tagCopy, stationInfo); + targetTag.Merge(tagCopy); + } + } + + /// + /// 根据工位信息更新标签表 + /// + private void UpdateTagTableByStation(DataTable tagTable, StationInfo stationInfo) + { + foreach (DataRow row in tagTable.Rows) + { + // 更新TagID:将****替换为工位代码(补齐4位) + string tagId = row["TagID"].ToString(); + row["TagID"] = tagId.Replace("****", stationInfo.工位代码.PadLeft(4, '0')); + + // 更新工位相关信息 + row["工位号"] = stationInfo.工位号; + row["数据来源"] = stationInfo.工位名称; + row["IP"] = stationInfo.PLC; + row["DbName"] = stationInfo.PLC代码; + + // 更新监控组 + row["监控组"] = $"{row["监控组"]}_{stationInfo.工位号}"; + } + } + + /// + /// 合并报警数据 + /// + private void MergeAlarmData(DataTable targetTable) + { + try + { + GetAlarmTableData(out DataTable alarmTable); + if (alarmTable != null && alarmTable.Rows.Count > 0) + { + targetTable.Merge(alarmTable, false, MissingSchemaAction.Ignore); + WriteLog($"合并报警数据成功,共 {alarmTable.Rows.Count} 条记录"); + } + } + catch (DataException ex) + { + WriteLog($"⚠ 合并报警数据失败:{ex.Message}"); + throw; + } + } + + #endregion + + #region 数据库操作 + + /// + /// 使用事务安全保存数据到数据库 + /// + private void SaveToDatabase(DataTable tagTable, DataTable deviceTable) + { + using (SqlConnection conn = new SqlConnection(MisDataSaveDate.MesServerMisDataFun.ConnectionString_MES)) + { + conn.Open(); + SqlTransaction transaction = conn.BeginTransaction(); + + try + { + // 1. 创建备份 + var backupTables = CreateBackupTables(conn, transaction, tagTable.TableName, deviceTable.TableName); + + // 2. 清空原表 + ClearTables(conn, transaction, tagTable.TableName, deviceTable.TableName); + + // 3. 批量插入新数据 + BulkInsertData(conn, transaction, tagTable); + BulkInsertData(conn, transaction, deviceTable); + + // 4. 提交事务 + transaction.Commit(); + WriteLog("✓ 所有操作成功完成,事务已提交"); + + // 5. 清理备份表 + CleanupBackupTables(conn, backupTables); + } + catch (Exception ex) + { + transaction.Rollback(); + WriteLog($"✗ 操作失败,事务已回滚:{ex.Message}"); + throw; + } + } + } + + /// + /// 创建备份表 + /// + private string[] CreateBackupTables(SqlConnection conn, SqlTransaction transaction, params string[] tableNames) + { + string[] backupTables = new string[tableNames.Length]; + + for (int i = 0; i < tableNames.Length; i++) + { + backupTables[i] = $"{tableNames[i]}_Backup_{DateTime.Now:yyyyMMddHHmmss}"; + ExecuteNonQuery(conn, transaction, $"SELECT * INTO [{backupTables[i]}] FROM [{tableNames[i]}]"); + WriteLog($"已创建备份表:{backupTables[i]}"); + } + + return backupTables; + } + + /// + /// 清空表数据 + /// + private void ClearTables(SqlConnection conn, SqlTransaction transaction, params string[] tableNames) + { + foreach (var tableName in tableNames) + { + ExecuteNonQuery(conn, transaction, $"DELETE FROM [{tableName}]"); + WriteLog($"清空数据库表:{tableName}"); + } + } + + /// + /// 批量插入数据 + /// + private void BulkInsertData(SqlConnection conn, SqlTransaction transaction, DataTable dataTable) + { + using (SqlBulkCopy bulkCopy = new SqlBulkCopy(conn, SqlBulkCopyOptions.Default, transaction)) + { + bulkCopy.DestinationTableName = dataTable.TableName; + bulkCopy.BatchSize = 1000; + bulkCopy.BulkCopyTimeout = 300; + bulkCopy.WriteToServer(dataTable); + WriteLog($"写入数据库表:{dataTable.TableName},共 {dataTable.Rows.Count} 条记录"); + } + } + + /// + /// 清理备份表 + /// + private void CleanupBackupTables(SqlConnection conn, string[] backupTables) + { + try + { + foreach (var backupTable in backupTables) + { + ExecuteNonQuery(conn, null, $"DROP TABLE [{backupTable}]"); + } + WriteLog("已清理备份表"); + } + catch (Exception ex) + { + WriteLog($"⚠ 清理备份表时出错(不影响主流程):{ex.Message}"); + } + } + + /// + /// 执行SQL命令 + /// + private void ExecuteNonQuery(SqlConnection conn, SqlTransaction transaction, string sql) + { + using (SqlCommand cmd = new SqlCommand(sql, conn, transaction)) + { + cmd.ExecuteNonQuery(); + } + } + + #endregion + + #region 数据查询 + + /// + /// 获取工位数据 + /// + private DataTable GetStationData() + { + string sql = @" + SELECT * + FROM [MES_计划BOM_工位与名称] + WHERE [是否启用MES] = 1 + ORDER BY [工位号]"; + + SqlOperation.ExecuteSql(sql, out DataTable dt, out string error); + + if (!string.IsNullOrEmpty(error)) + { + WriteLog($"⚠ 查询工位数据出错:{error}"); + } + + return dt ?? new DataTable(); + } + + /// + /// 获取报警表数据 + /// + private void GetAlarmTableData(out DataTable dt) + { + string sql = @" + SELECT * + FROM [MES_基本变量_原始数据] + WHERE [type] = 9 + ORDER BY [TagID]"; + + SqlOperation.ExecuteSql(sql, out dt, out string error); + + if (!string.IsNullOrEmpty(error)) + { + WriteLog($"⚠ 查询报警数据出错:{error}"); + } + } + + #endregion + + #region 辅助方法 + + /// + /// 写入日志 + /// + public void WriteLog(string msg) + { + string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + txt_Msg.Text += $"[{timestamp}] {msg}\r\n"; + txt_Msg.SelectionStart = txt_Msg.Text.Length; + txt_Msg.ScrollToCaret(); + } + + #endregion + + #region 内部数据模型 + + /// + /// Excel数据模型 + /// + private class ExcelDataModel + { + public DataTable StationTable { get; set; } + public DataTable TagMesTable { get; set; } + public DataTable TagModelTable { get; set; } + public DataTable TagModelKwTable { get; set; } + public DataTable DeviceTable { get; set; } + } + + /// + /// 工位信息模型 + /// + private class StationInfo + { + public string 工位代码 { get; set; } + public string 工位号 { get; set; } + public string 工位名称 { get; set; } + public string PLC { get; set; } + public string PLC代码 { get; set; } + } + + #endregion + } +} diff --git a/MisDataFun/MisDataFun/mes_signal_conf/MES_CONF.resx b/MisDataFun/MisDataFun/mes_signal_conf/MES_CONF.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/MisDataFun/MisDataFun/mes_signal_conf/MES_CONF.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/MisDataFun/MisDataFun/mes_signal_conf/SqlOperation.cs b/MisDataFun/MisDataFun/mes_signal_conf/SqlOperation.cs new file mode 100644 index 0000000..47fb6ce --- /dev/null +++ b/MisDataFun/MisDataFun/mes_signal_conf/SqlOperation.cs @@ -0,0 +1,68 @@ +using System; +using System.Data; +using System.Data.SqlClient; + +namespace SlMesDbIterface +{ + public class SqlOperation + { + public static bool ExecuteStoredProcedure(string name, SqlParameter[] sqlParameters, out string errorMessage) + { + return DataLinkMesWork.SQLCommon.ExecuteStoredProcedure(name, MisDataSaveDate.MesServerMisDataFun.ConnectionString_MES, ref sqlParameters, out errorMessage); + } + public static bool ExecuteStoredProcedure(string name, SqlParameter[] sqlParameters, out DataTable dt, out string errorMessage) + { + return DataLinkMesWork.SQLCommon.ExecuteStoredProcedure(name, MisDataSaveDate.MesServerMisDataFun.ConnectionString_MES, ref sqlParameters, out dt, out errorMessage); + } + public static bool ExecuteStoredProcedure(string name, SqlParameter[] sqlParameters, out DataSet ds, out string errorMessage) + { + return DataLinkMesWork.SQLCommon.ExecuteStoredProcedure(name, MisDataSaveDate.MesServerMisDataFun.ConnectionString_MES, ref sqlParameters, out ds, out errorMessage); + } + public static bool ExecuteSql(string sql, out DataTable dt, out string errorMessage) + { + return DataLinkMesWork.SQLCommon.ExecuteSql(sql, MisDataSaveDate.MesServerMisDataFun.ConnectionString_MES, out dt, out errorMessage); + } + + public static bool ExecuteSql(string sql, out DataSet ds, out string errorMessage) + { + return DataLinkMesWork.SQLCommon.ExecuteDataset(sql, MisDataSaveDate.MesServerMisDataFun.ConnectionString_MES, out ds, out errorMessage); + } + + public static bool ExecuteSql(string sql, out string errorMessage) + { + return DataLinkMesWork.SQLCommon.ExecuteSql(sql, MisDataSaveDate.MesServerMisDataFun.ConnectionString_MES, out errorMessage); + } + + + /// + /// 通过SqlBulkCopy复制table数据到数据库 + /// + /// + public static bool SqlbulkcopyInsert(DataTable dt,out string ErrMsg) + { + bool success = false; + ErrMsg = ""; + try + { + // SqlBulkCopy sqlbulkcopy = new SqlBulkCopy(connectString, SqlBulkCopyOptions.KeepIdentity);//删除自增ID插入原始数据 + SqlBulkCopy sqlbulkcopy = new SqlBulkCopy(MisDataSaveDate.MesServerMisDataFun.ConnectionString_MES, SqlBulkCopyOptions.UseInternalTransaction);//批量事务处理 + sqlbulkcopy.DestinationTableName = dt.TableName;//数据库中的表名 + for (int i = 0; i < dt.Columns.Count; i++) + { + var columnName = dt.Columns[i].ColumnName.ToString(); + sqlbulkcopy.ColumnMappings.Add(columnName, columnName); + } + sqlbulkcopy.WriteToServer(dt); + success = true; + } + catch (Exception err) + { + ErrMsg=err.Message; + } + return success; + + } + + + } +} diff --git a/MisDataFun/MisDataFun/webApi/Analysis_MOM_Msg.cs b/MisDataFun/MisDataFun/webApi/Analysis_MOM_Msg.cs new file mode 100644 index 0000000..11ba6d8 --- /dev/null +++ b/MisDataFun/MisDataFun/webApi/Analysis_MOM_Msg.cs @@ -0,0 +1,386 @@ +using DataLinkMesWork1; +using MesServerWork; +using MisDataFunDll; +using MyLog4Net; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Net.Sockets; +using System.Reflection.Emit; +using System.Web.Http; + +namespace MisDataSaveDate +{ + public class Analysis_MOM_Msg + { + /// + /// UUID生成 + /// + /// + public static string UuidUtil() + { + string result = Guid.NewGuid().ToString(); + + return result; + } + + /// + /// 获取时间戳 + /// + /// + public static Int64 GetTimeStamp() + { + TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0); + return Convert.ToInt64(ts.TotalSeconds); + } + /// + /// 接收检测数据 + /// + /// + /// + public static string OnlineCheckData(string url, [FromBody] JObject jobj) + { + var result = new msgResHeader(); + result.MsgId = ""; + result.Message = ""; + result.Code = "200"; + result.Data = ""; + + string errorMessage = ""; + string parentID = ""; + int AID = -1; + + if (jobj == null) + { + result.Code = "500"; + result.Message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLogHelper.Info("接收检测数据_res", retString1); + return retString1; + } + int isError = 0; + string str = jobj.ToString(); + try + { + //存储日志 + var CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + //Event_MOM_Log_Insert,@创建时间,@内容 + var param = new SqlParameter[] { + new SqlParameter("@接口地址",url), + new SqlParameter("@接口类型",2), // 1. 主动调用接口 2. 被调用接口 + new SqlParameter("@请求内容",str), + new SqlParameter("@请求时间",CreateTime) + }; + DataLinkMesWork1.DataAccess.ExecuteStoredProcedure("接口_IOT接口交互日志_请求记录", ref param, out DataTable dt, out errorMessage); + + // 解析订单内容,存储数据库,根据实际业务来写 + OnlineCheckData onlineCheckData = JsonConvert.DeserializeObject(str); + if (onlineCheckData.MsgId == "") + { + throw new Exception("参数MsgId为空!"); + } + result.MsgId = onlineCheckData.MsgId; + if (onlineCheckData.OpCode == "") + { + throw new Exception("参数OpCode为空!"); + } + if (onlineCheckData.ProductionCode == "") + { + throw new Exception("参数ProductionCode为空!"); + } + string OpName = onlineCheckData.OpCode; + int Id_tagCF = 0; + SqlParameter[] param1 = new SqlParameter[6]; + param1[0] = new SqlParameter("@EngineID", onlineCheckData.ProductionCode); + param1[1] = new SqlParameter("@工位号", OpName); + param1[2] = new SqlParameter("@操作者工号", onlineCheckData.CheckPerson); + param1[3] = new SqlParameter("@扫码时间", onlineCheckData.ScanTime); + param1[4] = new SqlParameter("@合格标志", onlineCheckData.QualityMark); + param1[5] = new SqlParameter("@Id_tagCF", Id_tagCF); + param1[5].Direction = ParameterDirection.Output; + DataAccess.ExecuteStoredProcedure("测量数据合格索引_增加_测试设备", ref param1, out errorMessage); + if (errorMessage != "") + { + throw new Exception(errorMessage); + } + Id_tagCF = Convert.ToInt32(param1[5].Value.ToString()); + + List onlineCheckData_CheckDataList = onlineCheckData.CheckData; + + for (int i = 0; i < onlineCheckData_CheckDataList.Count; i++) + { + OnlineCheckData_CheckData onlineCheckData_CheckData = onlineCheckData_CheckDataList[i]; + + var param2 = new SqlParameter[] { + new SqlParameter("@Id_tagCF", Id_tagCF), + new SqlParameter("@EngineID", onlineCheckData.ProductionCode), + new SqlParameter("@TagID",onlineCheckData_CheckData.CheckCode), + new SqlParameter("@TagValue",onlineCheckData_CheckData.CheckValue), + new SqlParameter("@IsGoodBad",onlineCheckData_CheckData.QualityMark), + new SqlParameter("@工位号",OpName), + new SqlParameter("@理论值",onlineCheckData_CheckData.StandardValue), + new SqlParameter("@上限值",onlineCheckData_CheckData.MaxValue), + new SqlParameter("@下限值",onlineCheckData_CheckData.MinValue), + new SqlParameter("@测量项目",onlineCheckData_CheckData.CheckName), + new SqlParameter("@测量单位",onlineCheckData_CheckData.Unit), + }; + DataAccess.ExecuteStoredProcedure("测量数据合格_增加_测试设备", ref param2, out errorMessage); + if (errorMessage != "") + { + throw new Exception(errorMessage); + } + } + + // 查询PLC是否传递机型,保证工位有件,可以写保存完成和工作完成 + MIS_BASE.Read_EngineGetOver_PLC(OpName, out bool tagValue); + if (tagValue) + { + // 电芯段OP040流程比较特殊,无PLC保存数据的流程,可以直接写完成。 + if (OpName == "OP040") + { + //通知PLC,MES保存完成 + MIS_BASE.Write_MesReadOver(OpName, true); + //通知PLC,MES工作完成 + MIS_BASE.Write_MesWorkFinish(OpName, true); + MisDataFunDll.MisDataFun.LogRecording_OP(OpName, "INFO", "MIS", "MES保存数据完成!"); + MisDataFunDll.MisDataFun.LogRecording_OP(OpName, "INFO", "MIS", "MES工作完成!"); + } + else + { + // 查看PLC是否完成流程,如果完成的话流程结束,否则的话要等PLC完成流程(即允许保存) + DataTable dt2 = MisDataFunDll.MisDataFun.CheckAllFinish(OpName, onlineCheckData.ProductionCode, 2); + string msg1 = "查询PLC流程出错"; + if (dt2 != null && dt2.Rows.Count > 0) + { + string result1 = dt2.Rows[0]["result"].ToString(); + msg1 = dt2.Rows[0]["msg"].ToString(); + + if (result1 == "1") //已完成 + { + //通知PLC,MES保存完成 + MIS_BASE.Write_MesReadOver(OpName, true); + //通知PLC,MES工作完成 + MIS_BASE.Write_MesWorkFinish(OpName, true); + MisDataFunDll. MisDataFun.LogRecording_OP(OpName, "INFO", "MIS", msg1); + MisDataFunDll. MisDataFun.LogRecording_OP(OpName, "INFO", "MIS", "MES保存数据完成!"); + MisDataFunDll.MisDataFun.LogRecording_OP(OpName, "INFO", "MIS", "MES工作完成!"); + } + else + { + MisDataFunDll.MisDataFun.LogRecording_OP(OpName, "INFO", "MIS", msg1); + } + } + else + { + MisDataFunDll.MisDataFun.LogRecording_OP(OpName, "INFO", "MIS", msg1); + } + } + + } + } + catch (Exception err) + { + result.Code = "500"; + result.Message = err.Message; + MisDataFunDll.MisDataFun.LogRecording_OP("All", "ERROR", "MIS", err.Message); + } + string retString = JsonConvert.SerializeObject(result); + MyLogHelper.Info("接收检测数据_res", retString); + + return retString; + } + /// + /// 接收查询检测次数 + /// + /// + /// + public static string OnlineCheckDataCount(string url, [FromBody] JObject jobj) + { + var result = new msgResHeader2(); + result.MsgId = ""; + result.Message = ""; + result.Code = "200"; + result.Data = new checkCountData(); + result.Data.CheckCountOk = 0; + result.Data.CheckCountNg = 0; + string errorMessage = ""; + string parentID = ""; + int AID = -1; + + if (jobj == null) + { + result.Code = "500"; + result.Message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLogHelper.Info("接收查询检测次数_res", retString1); + return retString1; + } + int isError = 0; + string str = jobj.ToString(); + try + { + //存储日志 + var CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + //Event_MOM_Log_Insert,@创建时间,@内容 + var param = new SqlParameter[] { + new SqlParameter("@接口地址",url), + new SqlParameter("@接口类型",2), // 1. 主动调用接口 2. 被调用接口 + new SqlParameter("@请求内容",str), + new SqlParameter("@请求时间",CreateTime) + }; + DataLinkMesWork1.DataAccess.ExecuteStoredProcedure("接口_IOT接口交互日志_请求记录", ref param, out DataTable dt, out errorMessage); + + // 解析订单内容,存储数据库,根据实际业务来写 + OnlineCheckData onlineCheckData = JsonConvert.DeserializeObject(str); + if (onlineCheckData.MsgId == "") + { + throw new Exception("参数MsgId为空!"); + } + result.MsgId = onlineCheckData.MsgId; + if (onlineCheckData.OpCode == "") + { + throw new Exception("参数OpCode为空!"); + } + if (onlineCheckData.ProductionCode == "") + { + throw new Exception("参数ProductionCode为空!"); + } + + SqlParameter[] param1 = new SqlParameter[2]; + param1[0] = new SqlParameter("@EngineID", onlineCheckData.ProductionCode); + param1[1] = new SqlParameter("@工位号", onlineCheckData.OpCode); + DataLinkMesWork1.DataAccess.ExecuteStoredProcedure("CATL_测量数据合格_查询测试次数_测试设备", ref param1, out DataTable dt1, out errorMessage); + if (errorMessage != "") + { + throw new Exception(errorMessage); + } + + if (dt1 != null && dt1.Rows.Count > 0) + { + result.Data.CheckCountOk = Convert.ToInt32(dt1.Rows[0]["OK"]); + result.Data.CheckCountNg = Convert.ToInt32(dt1.Rows[0]["NG"]); + } + + } + catch (Exception err) + { + result.Code = "500"; + result.Message = err.Message; + } + string retString = JsonConvert.SerializeObject(result); + MyLogHelper.Info("接收查询检测次数_res", retString); + return retString; + } + /// + /// 接收打印任务 + /// + /// + /// + public static string ReceivePrintTask(string url, [FromBody] JObject jobj) + { + var result = new msgResHeader(); + result.MsgId = ""; + result.Message = ""; + result.Code = "200"; + result.Data = ""; + + string errorMessage = ""; + string parentID = ""; + int AID = -1; + + if (jobj == null) + { + result.Code = "500"; + result.Message = "参数格式不正确!"; + string retString1 = JsonConvert.SerializeObject(result); + MyLogHelper.Info("接收打印任务_res", retString1); + return retString1; + } + + string str = jobj.ToString(); + try + { + //存储日志 + var CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + //Event_MOM_Log_Insert,@创建时间,@内容 + var param = new SqlParameter[] { + new SqlParameter("@接口地址",url), + new SqlParameter("@接口类型",2), // 1. 主动调用接口 2. 被调用接口 + new SqlParameter("@请求内容",str), + new SqlParameter("@请求时间",CreateTime) + }; + DataLinkMesWork1.DataAccess.ExecuteStoredProcedure("接口_IOT接口交互日志_请求记录", ref param, out DataTable dt, out errorMessage); + + // 解析订单内容,存储数据库,根据实际业务来写 + PrintTaskData printTaskData = JsonConvert.DeserializeObject(str); + if (printTaskData.printTemplete == "") + { + throw new Exception("参数printTemplete为空!"); + } + + if (printTaskData.productCode == "") + { + throw new Exception("参数productCode为空!"); + } + if (printTaskData.printDate == "") + { + throw new Exception("参数printDate为空!"); + } + string msg = $"MARK|{printTaskData.printTemplete}|{printTaskData.productCode},{printTaskData.printDate}"; + + // 连接打印机 + Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + try + { + //socket.Connect(MesWorkForm.MarkingMachine_Ip, int.Parse(MesWorkForm.MarkingMachine_Port)); + } + catch (Exception err) + { + throw new Exception("连接打印机失败:" + err.Message); + } + // 发送数据 + try + { + if (socket.Connected) + { + byte[] decBytes = System.Text.Encoding.UTF8.GetBytes(msg); + //socket.Send(decBytes); + socket.Send(decBytes, 0, decBytes.Length, SocketFlags.None); + } + else + { + throw new Exception("连接打印机失败"); + } + } + catch (Exception err) + { + throw new Exception("发送打印数据失败:" + err.Message); + } + // 关闭 + try + { + if (socket.Connected) + { + socket.Shutdown(SocketShutdown.Both); + socket.Close(100); + } + } + catch (Exception ex) + { + } + } + catch (Exception err) + { + result.Code = "500"; + result.Message = err.Message; + } + string retString = JsonConvert.SerializeObject(result); + MyLogHelper.Info("接收打印任务_res", retString); + return retString; + } + + } +} diff --git a/MisDataFun/MisDataFun/webApi/Controller/ipcControll.cs b/MisDataFun/MisDataFun/webApi/Controller/ipcControll.cs new file mode 100644 index 0000000..c144448 --- /dev/null +++ b/MisDataFun/MisDataFun/webApi/Controller/ipcControll.cs @@ -0,0 +1,54 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Web; +using System.Web.Http; +using System.Collections.Concurrent; +using Newtonsoft.Json.Linq; +using System.Runtime.Remoting.Messaging; + + +namespace MisDataSaveDate +{ + + public class IpcController : ApiController + { + readonly string headUrl = "Project/"; + + [HttpPost] + [Route("OnlineCheckData")] + public HttpResponseMessage ReceiveMomPlanData([FromBody] JObject jobj) + { + + return new HttpResponseMessage + { + Content = new StringContent(Analysis_MOM_Msg.OnlineCheckData(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + + [HttpPost] + [Route("OnlineCheckDataCount")] + public HttpResponseMessage OnlineCheckDataCount([FromBody] JObject jobj) + { + + return new HttpResponseMessage + { + Content = new StringContent(Analysis_MOM_Msg.OnlineCheckDataCount(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + [HttpPost] + [Route("ReceivePrintTask")] + public HttpResponseMessage ReceivePrintTask([FromBody] JObject jobj) + { + + return new HttpResponseMessage + { + Content = new StringContent(Analysis_MOM_Msg.ReceivePrintTask(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") + }; + } + } +} diff --git a/MisDataFun/MisDataFun/webApi/InitServer.cs b/MisDataFun/MisDataFun/webApi/InitServer.cs new file mode 100644 index 0000000..7c2b03d --- /dev/null +++ b/MisDataFun/MisDataFun/webApi/InitServer.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Net.Http.Formatting; +using System.Net.Http.Headers; +using System.Web.Http; +using System.Web.Http.Cors; +using System.Web.Http.SelfHost; + +namespace MisDataSaveDate +{ + public class InitServer + { + HttpSelfHostConfiguration config = null; + HttpSelfHostServer server = null; + public InitServer(string Url_WebApi) + { + // var Url_WebApi = System.Configuration.ConfigurationManager.AppSettings["Url_WebApi"]; + Init(Url_WebApi); + } + public void Init(string url) + { + config = new HttpSelfHostConfiguration(url); + + // 启用跨域 + config.EnableCors(new EnableCorsAttribute("*", "*", "*")); + // 启用特性路由 + config.MapHttpAttributeRoutes(); + + //config.Routes.MapHttpRoute( + // name: "DefaultApi", + // routeTemplate: "api/{controller}/{id}", + // defaults: new { id = RouteParameter.Optional } + //); + + // 自定义路由匹配到action + config.Routes.MapHttpRoute( + name: "API Default", + routeTemplate: "api/{controller}/{action}/{id}", + defaults: new { id = RouteParameter.Optional } + ); + + + + server = new HttpSelfHostServer(config); + + server.OpenAsync().Wait(); + + + } + public class JsonContentNegotiator : IContentNegotiator + { + private readonly JsonMediaTypeFormatter _jsonFormatter; + + public JsonContentNegotiator(JsonMediaTypeFormatter formatter) + { + _jsonFormatter = formatter; + } + public ContentNegotiationResult Negotiate(Type type, HttpRequestMessage request, IEnumerable formatters) + { + var result = new ContentNegotiationResult(_jsonFormatter, new MediaTypeHeaderValue("application/json")); + return result; + } + } + } +} diff --git a/MisDataFun/MisDataFun/webApi/OnlineCheckData.cs b/MisDataFun/MisDataFun/webApi/OnlineCheckData.cs new file mode 100644 index 0000000..7369a65 --- /dev/null +++ b/MisDataFun/MisDataFun/webApi/OnlineCheckData.cs @@ -0,0 +1,98 @@ +using System.Collections.Generic; + +namespace MisDataSaveDate +{ + /// + /// OnlineCheckData + /// + + public class OnlineCheckData + { + /// + /// MsgId + /// + public string MsgId { get; set; } = ""; + /// + /// OpCode + /// + public string OpCode { get; set; } = ""; + /// + /// ProductionCode + /// + public string ProductionCode { get; set; } = ""; + /// + /// CheckTime + /// + public string ScanTime { get; set; } = ""; + + /// + /// CheckPerson + /// + public string CheckPerson { get; set; } = ""; + + /// + /// QualityMark + /// + public int QualityMark { get; set; } = 1; + + public List CheckData { get; set; } = new List(); + } + + public class OnlineCheckData_CheckData + { + /// + /// CheckCode + /// + public string CheckCode { get; set; } = ""; + /// + /// CheckName + /// + public string CheckName { get; set; } = ""; + /// + /// ProductionCode + /// + public string Unit { get; set; } + /// + /// StandardValue + /// + public string StandardValue { get; set; } = ""; + /// + /// MinValue + /// + public string MinValue { get; set; } = ""; + /// + /// MaxValue + /// + public string MaxValue { get; set; } = ""; + /// + /// CheckValue + /// + public string CheckValue { get; set; } = ""; + /// + /// QualityMark + /// + public int QualityMark { get; set; } = 1; + } + public class PrintTaskData + { + /// string msg = $"MARK|{printTemplete}|{productCode},{printDate}"; + + /// + /// printTemplete + /// + public string printTemplete { get; set; } = ""; + /// + /// productCode + /// + public string productCode { get; set; } = ""; + /// + /// printDate + /// + public string printDate { get; set; } = ""; + + } + + + + +} diff --git a/MisDataFun/MisDataFun/webApi/msgResHeader.cs b/MisDataFun/MisDataFun/webApi/msgResHeader.cs new file mode 100644 index 0000000..f7cacc2 --- /dev/null +++ b/MisDataFun/MisDataFun/webApi/msgResHeader.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MisDataSaveDate +{ + public class msgResHeader + { + /// + /// 任务ID + /// + public string MsgId + { + get; + set; + } + /// + /// 返回结果 + /// + public string Code + { + get; + set; + } + /// + /// 返回消息 + /// + public string Message + { + get; + set; + } + /// + /// 返回数据 + /// + public string Data + { + get; + set; + } + } + public class msgResHeader2 + { + /// + /// 任务ID + /// + public string MsgId + { + get; + set; + } + /// + /// 返回结果 + /// + public string Code + { + get; + set; + } + /// + /// 返回消息 + /// + public string Message + { + get; + set; + } + /// + /// 返回数据 + /// + public checkCountData Data + { + get; + set; + } + } + + public class checkCountData + { + /// + /// 检测次数 + /// + public int CheckCountOk + { + get; + set; + } + /// + /// 检测次数 + /// + public int CheckCountNg + { + get; + set; + } + } + +} diff --git a/MisDataFunction/Function1051/DataAccess/DataAccess.cs b/MisDataFunction/Function1051/DataAccess/DataAccess.cs new file mode 100644 index 0000000..a7f91fa --- /dev/null +++ b/MisDataFunction/Function1051/DataAccess/DataAccess.cs @@ -0,0 +1,16 @@ + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + //针对“MIS.BizFacade.Dll”中没有的存储过程,在此类中新建 + //新建原则:所有的函数用private,只允许在内部使用 + //针对单个工艺特殊,需要新建存储过程,但是存储过程不能被加入到“MIS.BizFacade.Dll”中 + + private void aa() + { + + } + } +} diff --git a/MisDataFunction/Function1051/DataAccess/vssver2.scc b/MisDataFunction/Function1051/DataAccess/vssver2.scc new file mode 100644 index 0000000..1083b3a Binary files /dev/null and b/MisDataFunction/Function1051/DataAccess/vssver2.scc differ diff --git a/MisDataFunction/Function1051/Db.cs b/MisDataFunction/Function1051/Db.cs new file mode 100644 index 0000000..a0f37b3 --- /dev/null +++ b/MisDataFunction/Function1051/Db.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + public class Db + { + + } +} diff --git a/MisDataFunction/Function1051/Function08.csproj.vspscc b/MisDataFunction/Function1051/Function08.csproj.vspscc new file mode 100644 index 0000000..82c6db2 --- /dev/null +++ b/MisDataFunction/Function1051/Function08.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:MesServer.Function\\Function08" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/MisDataFunction/Function1051/Function1051.csproj b/MisDataFunction/Function1051/Function1051.csproj new file mode 100644 index 0000000..f473946 --- /dev/null +++ b/MisDataFunction/Function1051/Function1051.csproj @@ -0,0 +1,137 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {B5A0BAA3-C1A7-4AAB-9486-2E650ADACA7E} + Library + Properties + Function1051 + Function1051 + v4.8 + 512 + + + + + + + + + + + + + + true + full + false + ..\..\MisDataFun_Exe\ + DEBUG;TRACE + prompt + 4 + AnyCPU + false + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + ..\..\dll_common\MesWork.DeviceDriver.dll + + + False + ..\..\dll_common\Newtonsoft.Json.dll + + + + + + + ..\..\DLL\System.Net.Http.dll + + + ..\..\packages\System.Net.Security.4.3.2\lib\net46\System.Net.Security.dll + + + ..\..\packages\System.Net.WebSockets.4.3.0\lib\net46\System.Net.WebSockets.dll + + + ..\..\packages\System.Net.WebSockets.Client.4.3.2\lib\net46\System.Net.WebSockets.Client.dll + + + ..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll + + + ..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 01-MesDataFunction + + + {1dc48c83-1842-4de8-acaf-26e1e7f7c58f} + 00_MyLog4Net + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1051/MesServerFunction/Function1051.cs b/MisDataFunction/Function1051/MesServerFunction/Function1051.cs new file mode 100644 index 0000000..b330d7e --- /dev/null +++ b/MisDataFunction/Function1051/MesServerFunction/Function1051.cs @@ -0,0 +1,305 @@ +using MesServerWork; +using System.Collections.Generic; +using System.Threading; +using MisDataFunDll; + + +namespace MesServerFunctions +{ + public partial class FunctionMES + { + object lockFunWork; + //public void FunWork(DeviceDriver_BasicData.CustomeEvetnArgs e) + public void FunWork(string recData) + { + + + lockFunWork = new object(); + lock (lockFunWork) + { + List dataArray = MisDataFun.GetCmdStringList(recData); + //string[] dataArray = recData.Split('|'); + //if (dataArray.Count != 4) + //return; + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 Barcode + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + DeviceDriver_BasicData.CustomeEvetnArgs e = new DeviceDriver_BasicData.CustomeEvetnArgs();// = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string tagValue; + switch (m_Source) + { + case "BarCode": + e.OpName = m_OpName; + e.TagValue = m_Value; + fun_Barcode(e); + + break; + case "WEB": + e.OpName = m_OpName; + e.TagValue = m_Command + "|" + m_Value; + fun_WebSubmit(e); + break; + case "PLC": + e = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string TagID = e.TagID.ToString(); + switch (e.TagValue.ToString().ToLower()) + { + case "false": + tagValue = "0"; + break; + case "true": + tagValue = "1"; + break; + default: + tagValue = e.TagValue.ToString(); + break; + } + e.TagValue = tagValue; + switch (e.TagTypeCodeID.ToString()) + { + //PLC 工件到位 + case "2": + fun_WorkStart(e); + break; + //PLC 允许保存质量数据 + case "19": + fun_MesRead(e); + break; + //MES 保存数据完成 + case "20": + fun_MesReadOver(e); + break; + //PLC 申请上线 + case "43": + PartLoad(e); + break; + //PLC 传递机型 + case "44": + fun_EngineTypeGetOverPLC(e); + break; + //MES 合格放行 + case "51": + fun_ConfirmOkGo(e); + break; + //MES 不合格放行 + case "8": + fun_FalseGo(e); + break; + // PLC 系统健康心跳 + case "14": + fun_HeartBeatMIS(e); + break; + //物料扫码完成 + case "49": + fun_MaterislaScanOver(e); + break; + // 写入托盘号后通知MES + case "48": + string write_Pallet_res; + MIS_BASE.Read_TagTypeID(48, m_OpName, out write_Pallet_res); + if (write_Pallet_res.ToLower() == "true" || write_Pallet_res.ToLower() == "1") + { + SendMessageFun.SendInfomation("writePallet", "1", m_OpName); + } + MIS_BASE.WritePLC(70, m_OpName, false); + break; + case "63": + fun_ReqEarlyFeeding(e); + break; + case "64": + fun_ReqTestResistor(e); + break; + } + break; + } + } + } + //public void FunWork(DeviceDriver_BasicData.CustomeEvetnArgs e) + //{ + // //lock1 = new object(); + // //lock (lock1) + // { + // switch (e.TagTypeCodeID.ToString()) + // { + // //PLC 工件到位 + // case "2": + // fun_WorkStart(e); + // break; + // //PLC 允许保存质量数据 + // case "19": + // fun_MesRead(e); + // break; + // //MES 保存数据完成 + // case "20": + // fun_MesReadOver(e); + // break; + // //PLC 传递机型 + // case "44": + // fun_EngineTypeGetOverPLC(e); + // break; + // //MES 合格放行 + // case "51": + // fun_ConfirmOkGo(e); + // break; + // //MES 不合格放行 + // case "8": + // fun_FalseGo(e); + // break; + // //MES 扫描条码 + // case "Barcode": + // fun_Barcode(e); + // break; + // //WEB 处理页面传递过来的数据 + // case "WebSubmit": + // fun_WebSubmit(e); + // break; + // } + // } + + //} + //1.工件到位后,PLC给MES传递机型(DBX0.4)(44), + //2.MES判断是否扫描完成 + //3.若扫描完成,则MES给出合格放行(DBX2.5)(51) + /// + /// 扫描条码 + /// + /// + /// + public void fun_Barcode(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(Barcode, e); + } + + + /// + /// 传递机型 + /// + /// + /// + public void fun_EngineTypeGetOverPLC(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(EngineTypeGetOver_PLC, e); + } + + /// + /// 合格放行 + /// + /// + /// + public void fun_ConfirmOkGo(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + //// ThreadPool.QueueUserWorkItem(ConfirmOkGo, e); + } + + + /// + /// 提前上料 + /// + /// + /// + public void fun_ReqEarlyFeeding(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(ReqEarlyFeeding, e); + } + + /// + /// 请求测试电阻 调用电阻仪 + /// + /// + /// + public void fun_ReqTestResistor(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem( ReqTestResistor, e); + } + + /// + /// 不合格放行 + /// + /// + /// + public void fun_FalseGo(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(FalseGO, e); + } + + + /// + /// 保存完成 20 + /// + /// + /// + public void fun_MesReadOver(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(MesReadOver, e); + } + + /// + /// 物料扫码完成 + /// + public void fun_MaterislaScanOver(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MaterialsScanOver, e); + } + + /// + /// 保存完成 19 + /// + /// + /// + public void fun_MesRead(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesRead, e); + } + + /// + /// 工件到位离开(清空所有的MES信号) + /// + /// + /// + public void fun_WorkStart(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WorkStart, e); + } + + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + public void fun_WebSubmit(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WebSubmit, e); + } + + public int fun_SubLineLoadPartCountMatch() + { + return SubLineLoadPartCountMatch; + } + + + /// + /// MES系统健康心跳监测 + /// + /// + /// + public void fun_HeartBeatMIS(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(HeartBeatMES, e); + } + /// + /// PLC系统健康心跳监测 + /// + /// + /// + public void fun_HeartBeatPLC(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + //ThreadPool.QueueUserWorkItem(HeartBeatPLC, e); + } + } +} diff --git a/MisDataFunction/Function1051/MesServerFunction/vssver2.scc b/MisDataFunction/Function1051/MesServerFunction/vssver2.scc new file mode 100644 index 0000000..775bb6c Binary files /dev/null and b/MisDataFunction/Function1051/MesServerFunction/vssver2.scc differ diff --git a/MisDataFunction/Function1051/Methods/EngineGetOverBaseWork.cs b/MisDataFunction/Function1051/Methods/EngineGetOverBaseWork.cs new file mode 100644 index 0000000..3ab6a12 --- /dev/null +++ b/MisDataFunction/Function1051/Methods/EngineGetOverBaseWork.cs @@ -0,0 +1,285 @@ +using System; +using System.Data; +using System.Threading; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 分线上总线的数量 + /// + public static int SubLineLoadPartCount = 2; + /// + /// 分线上总线已经匹配的数量 + /// + public static int SubLineLoadPartCountMatch = 0; + /// + /// 正常逻辑工作 + /// + /// + /// + /// + /// + /// + private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code,string OrderForm) + { + int IsAllowWork; + int RepairPartStatusPLC = 0; + int MES_QualityMask = 1; + + if (EngineTypeID <= 0 || EngineID.Length == 0 || EngineType.Length == 0) + { + string msg = "【" + OpName + "】" + "PLC传递机型为空!"; + MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg); + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC传递机型为空"); + return; + } + + //初始化物料临时表 + //第二步,将零件信息转移到零件_临时表中(本地BOM与订单BOM的选择显示关系) + //BaseDataSystemMES.MesServer_Process_EngineTypeOver_BQ_FirstOP(OpName); + + // 记录一下开工 + MisDataFun.OpWork_StartOrOver(OpName, EngineID, OrderForm, 1); + + //5 显示订单、机型信息 线首工位用 + SendMessage.ShowMoby_FirstOpName(OpName); + //3显示操作指导图片 PicShow_String_FirstOpName + SendMessage.PicShow_FirstOpName(OpName); + //1(直接在界面通过选择机型确认工序内容) + SendMessage.ProcessList_FirstOpName(OpName); + //界面显示物料信息 + SendMessage.MaterialList_FirstOpName(OpName); + //第四步,获取是否允许工作 + MisDataFun.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + // 暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况 + if (IsAllowWork == 1) + { + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + + } + + + /// + /// 保存MOBY信息 + /// + /// + /// + /// + /// + private void SaveMobyMessage(string OpName, int engineTypeID, string engineType, string engineID, string orderForm) + { + + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineTypeID[OpName] = engineTypeID; + } + if (MIS_BASE.hashtable_EngineGetOver_EngineType.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineType[OpName] = engineType; + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineID[OpName] = engineID; + } + if (MIS_BASE.hashtable_EngineGetOver_OrderForm.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_OrderForm[OpName] = orderForm; + } + } + + /// + /// 返修件需要工作 + /// + /// 工位号 + private void IsNeedRepaire_OK(string OpName) + { + + int isRepair; + int engineTypeID; + + string engineType = ""; + string engineID = ""; + string palletCode = ""; + string orderForm = ""; + string repairCode = ""; + //从监控系统中查询出本工位信息 + //BaseDataSystemMES.OpName_MIS_Moby_Select(OpName, + //out orderForm, out engineTypeID, out engineType, + //out engineID, out palletCode, out isRepair, out repairCode); + + //EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode),orderForm); + } + /// + /// 正常匹配分线和总线 + /// + /// + /// 总线工件号 + /// 总线工件机型代码 + /// 总线工件机型 + private void Match(string opName, string engineID, int engineTypeID, string engineType, int PartPallet_Code) + { + try + { + bool m_EngineGetOver_PLC_SubLine; + int engineTypeID_SubLine; + int partPallet_Code_SubLine; + int PalletInfo = 1;//总线托盘状态 + + string opName_SubLine = "";//分线工件信息 + string engineID_SubLine; + string engineType_SubLine; + string AlarmStr; + if (MIS_BASE.hashtable_OpNameRepair == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + //第一步:获取分线中间交互工位号 + if (MIS_BASE.hashtable_OpNameRepair.ContainsKey(opName)) + { + opName_SubLine = MIS_BASE.hashtable_OpNameRepair[opName].ToString(); + } + if (opName_SubLine == "") + { + return; + } + + //第二步:获取分线传递机型信号 + MIS_BASE.Read_EngineGetOver_PLC(opName_SubLine, out m_EngineGetOver_PLC_SubLine); + if (!m_EngineGetOver_PLC_SubLine) return;//必须工件同时到位才能进行匹配 + + //第三步:判断合格标志 + MIS_BASE.Read_PalletInfo(opName_SubLine, out PalletInfo); + if (PalletInfo == 2) return; //若不合格则返回不进行匹配 + string OrderForm; + //第四步:获取分线的信息,匹配验证 + MIS_BASE.GetEngineTypeFromPLC(opName_SubLine, out engineTypeID_SubLine, out engineType_SubLine, out engineID_SubLine, out partPallet_Code_SubLine,out OrderForm); + //判断分线数据是否合格 + //if (!BaseDataSystemMES.QulityDataVerify(opName, engineID_SubLine, out AlarmStr) && !BaseDataSystemMES.QualityVerifyStatus_Hash_Read(opName)) + //{ + // SendInfomation("LineoutAlert", AlarmStr, opName); + // return; + //} + + //if (engineTypeID_SubLine == engineTypeID) + //{ + // BaseDataSystemMES.SubLineLoadPartCountMatch_Select(opName, out SubLineLoadPartCountMatch); + // SubLineLoadPartCountMatch = SubLineLoadPartCountMatch + 1; + // BaseDataSystemMES.SubLineLoadPartCountMatch_Update(opName, SubLineLoadPartCountMatch); + + + // BaseDataSystemMES.MailLineAndSubLineData_Insert(engineID, engineTypeID, engineType, engineID_SubLine);//分线上总线数据转移 + // MIS_BASE.Write_Match(opName, true);//匹配结果 + // MIS_BASE.Write_MatchingCompleted(opName, true);//匹配完成 + // if(SubLineLoadPartCountMatch== SubLineLoadPartCount) + // { + // MIS_BASE.Write_FixAllow(opName, true); + // SubLineLoadPartCountMatch = 0; + // BaseDataSystemMES.SubLineLoadPartCountMatch_Update(opName, SubLineLoadPartCountMatch); + + // } + + // SendMessageFun.SendInfomation("MatchSuccess", "1", opName); + // SendMessageFun.SendMessage(opName, 1, "Match");//匹配结果 + //} + //else + //{ + // MIS_BASE.Write_Match(opName, false);//匹配结果 + // MIS_BASE.Write_MatchingCompleted(opName, true);//匹配完成//68:1、取消返修;2、匹配成功 自己监控发送 MES|MatchingCompleted + + // //发送匹配完成和匹配结果信息 + // SendMessageFun.AsyncSendMessage_Notice(opName,"匹配失败,工件型号不匹配!"); + // SendMessageFun.SendInfomation("MatchSuccess", "0", opName); + // SendMessageFun.SendMessage(opName, 0, "Match");//匹配结果 + //} + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog("Match:" + err.ToString()); + + } + } + + + + /// + /// 强制匹配分线和总线 + /// + /// + private void ForceMatch(string opName) + { + try + { + //bool m_EngineGetOver_PLC_SubLine; + //bool m_EngineGetOver_PLC; + + //int engineTypeID_SubLine; + //int engineTypeID; + //int partPallet_Code_SubLine; + //int partPallet_Code; + + //string opName_SubLine = "";//分线工件信息 + //string engineID_SubLine; + //string engineType_SubLine; + //string engineID; + //string engineType; + //if (MIS_BASE.hashtable_OpNameRepair == null) + //{ + // MIS_BASE.InitHashtable_MesServerCode(); + //} + ////获取分线中间交互工位号 + //if (MIS_BASE.hashtable_OpNameRepair.ContainsKey(opName)) + //{ + // opName_SubLine = MIS_BASE.hashtable_OpNameRepair[opName].ToString(); + //} + //if (opName_SubLine == "") + //{ + // return; + //} + + //MIS_BASE.Read_EngineGetOver_PLC(opName_SubLine, out m_EngineGetOver_PLC_SubLine);//1:读取分线工件到位的传递机型信号。 + + //if (!m_EngineGetOver_PLC_SubLine) return;//必须工件同时到位才能进行匹配 + + //MIS_BASE.Read_EngineGetOver_PLC(opName, out m_EngineGetOver_PLC);//2:读取总线工件到位的传递机型信号。 + + //if (!m_EngineGetOver_PLC) return;//必须工件同时到位才能进行匹配 + //string OrderForm; + //MIS_BASE.GetEngineTypeFromPLC(opName_SubLine, out engineTypeID_SubLine, out engineType_SubLine, out engineID_SubLine, out partPallet_Code_SubLine,out OrderForm);//获取分线的信息 + //MIS_BASE.GetEngineTypeFromPLC(opName, out engineTypeID, out engineType, out engineID, out partPallet_Code, out OrderForm); + + //Mis.MailLineAndSubLineData_Insert(engineID, engineTypeID, engineType, engineID_SubLine);//分线上总线数据转移 + + //MIS_BASE.Write_Match(opName, true);//匹配结果 + //MIS_BASE.Write_MatchingCompleted(opName, true);//匹配完成 + + //SendMessageFun.SendInfomation("MatchSuccess", "1", opName);//界面显示匹配成功 + + //MIS_BASE.Write_FixAllow(opName, true);//允许PLC工作 + + ////发送匹配完成和匹配结果信息 + //sendmessage(opName, 1, "MatchingComplete");//匹配完成 + //sendmessage(opName, 1, "Match");//匹配结果 + } + catch + { + + } + } + } +} diff --git a/MisDataFunction/Function1051/Methods/vssver2.scc b/MisDataFunction/Function1051/Methods/vssver2.scc new file mode 100644 index 0000000..7b1a830 Binary files /dev/null and b/MisDataFunction/Function1051/Methods/vssver2.scc differ diff --git a/MisDataFunction/Function1051/OpcServer/Barcode.cs b/MisDataFunction/Function1051/OpcServer/Barcode.cs new file mode 100644 index 0000000..d7549ae --- /dev/null +++ b/MisDataFunction/Function1051/OpcServer/Barcode.cs @@ -0,0 +1,236 @@ +using System; +using System.Threading; +using System.Xml.Linq; + +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + object lockBarcode = new object(); + + ///第一步,判断条码类型,根据条码类型,执行对应的存储过程 + ///第二步,条码类型(将扫描的条码保存到对应的表中) + ///第三步,扫描完成之后给出允许工作信号 + /// 处理页面扫描条码 + /// + /// + /// + public void Barcode(object e) + { + lock(lockBarcode) + { + try + { + //DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + //string OpName = Convert.ToString(msgEvent.OpName); + ////+*************DbName***************** + //string DbName = Convert.ToString(msgEvent.OpName); + //string barcode = Convert.ToString(msgEvent.TagValue); + + //int EngineTypeID;//机型代码 + //string EngineType;//机型 + //string EngineID;//工件编号 + + //string OrderForm; + //int Recipe1; + //int Recipe2; + + //bool IsNotRepeatedNumber = false; + ////1:获得申请上线信息后,扫描条码才处理业务 + //bool ispartload; + ////(115) + //int PTO; + ////(118)0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + //int NgearSwitch; + ////(119)0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + //int RgearSwitch; + ////(120)0=不检测;1=检测。检测线上线工位扫描总成条码,根据BOM,查出 + //int SpeedSensor; + ////(121)例如:5S 400。检测线上线工位扫描总成条码,根据BOM,查出 + //string PartTypeMid; + ////(122) 0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + //int Tcu_V; + ////判断工件是否到位 + //MIS_BASE.Read_WorkStart(OpName, out ispartload); + //if (!ispartload) + //{ + // SendMessageFun.AsyncSendMessage_Notice(OpName, "请检查设备是否到位(DBX500.1=1)"); + // return; + //} + ////判断设备是否申请上线 + //MIS_BASE.Read_PartLoad(OpName, out ispartload); + //if (!ispartload) + //{ + // SendMessageFun.AsyncSendMessage_Notice(OpName, "请检查设备是否申请上线(DBX500.3=1)"); + // return; + //} + //// 判读条码是变速器序列号条码号还是物料号 小机型*日月年* 流水号(给起始号 + 数量) + //// 选小机型 从北汽福田BOM中选 得先维护BOM + //// 变速器序列号 '1333 050 062*16012023*30000001' + + ////扫描完变速器序列号条码号 true + //bool isGetOver_PLC = false; + ////判断上线工位,MES 是否将工件流水号、机型等信息已经写入到PLC了 + // MIS_BASE.Read_EngineGetOver_PLC(OpName, out isGetOver_PLC); + + ////如果工件流水号、机型等信息没有写入PLC,扫描的条码按工件流水号进行验证 + ////否则按装配物料进行验证 + //if (!isGetOver_PLC) + //{ + + // if (barcode.Split('*').Length > 2) + // { + // //2: 判断是否重号, 从数据库获得机型、机型代码等信息 + // string partSn = barcode; + // EngineID = barcode; + + // MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineID_MES, EngineID); + + // //Db.GetEngineType( partSn, out EngineTypeID, out EngineType, out EngineID, out IsRepeatedNumber); + // //Db.GetEngineType( partSn, out EngineTypeID, out EngineType, out EngineID, out IsRepeatedNumber); + + // //IsRepeatedNumber true 不重号;false 重号; + // IsNotRepeatedNumber = BaseDataSystemMES.EngineTypeID_IsNotRepeatedNumber(partSn); + // if (IsNotRepeatedNumber) + // { + // BaseDataSystemMES.GetEngineTypeUpLoadOpName(partSn, OpName, out EngineTypeID, out EngineType, out OrderForm, out Recipe1, out Recipe2); + + // //MIS_BASE.Write_EngineID_MES(OpName, EngineID); + // //MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID); + // //MIS_BASE.Write_EngineType_MES(OpName, EngineType); + // //MIS_BASE.Write_OrderForm_MES(OpName, OrderForm); + + + // BaseDataSystemMES.UpLoadPTO(EngineType, out PTO, out NgearSwitch, out RgearSwitch, out SpeedSensor, out PartTypeMid, out Tcu_V); + // //PTO + // MIS_BASE.WritePLC(115, OpName, PTO); + // //空挡开关检测 + // MIS_BASE.WritePLC(95, OpName, NgearSwitch); + // //倒挡开关检测 + // MIS_BASE.WritePLC(96, OpName, RgearSwitch); + // //里程表检测 + // MIS_BASE.WritePLC(97, OpName, SpeedSensor); + // //大机型扩展 + // MIS_BASE.WritePLC(98, OpName, PartTypeMid); + // //TCU + // MIS_BASE.WritePLC(122, OpName, Tcu_V); + // string tagStartAdr;//= "DB411.10"; + + // // 先查询配方号 根据工位号 去moby表查配方号 + // // 根据配方号 去配方表查配方数据 + // // 写入配方数据 + // BaseDataSystemMES.PLCRcipeCurrent(OpName, out byte[] bytes, out tagStartAdr); + // DtWebApi.ReadWritePLC.Write_TagValueByTagTypeID("94", OpName, System.Text.Encoding.ASCII.GetString(bytes)); + // ////将产品信息写入PLC + // MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID); + // MIS_BASE.Write_EngineType_MES(OpName, EngineType); + // MIS_BASE.Write_EngineID_MES(OpName, EngineID); + // MIS_BASE.Write_OrderForm_MES(OpName, OrderForm); + + // //写入到数据库的[北汽福田工位状态监控MOBY]表中 + // //MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineTypeID_MES, EngineTypeID.ToString()); + // //MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineType_MES, EngineType); + // MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineID_MES, EngineID); + // //MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.OrderForm_MES, OrderForm); + + + // // 工位号],[订单号],[产品型号代码],[变速器序列号],[发动机型号],[机型基本代码],[变速器总成号] ,[托盘号] + // // [产品型号代码_MES],[变速器序列号_MES],[发动机型号_MES] + // // [机床上电],[循环开始],[机床故障],[上料无件],[下料堵塞],[工件到位] + // // [传递机型],[申请上件],[允许保存],[保存完成],[合格标志],[前序合格] + // // [工号],[班次],[是否返修件],[合格放行],[不合格放行],[扫描条码] + + // //MisDataFun.OpName_MIS_MOBY_Insert(OpName, "产品型号代码_MES", EngineTypeID.ToString()); + // //MisDataFun.OpName_MIS_MOBY_Insert(OpName, "发动机型号_MES", EngineType); + + // MIS_BASE.Write_EngineTypeGetOver_MES(OpName, true); + + // //Thread.Sleep(5000); + // //MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + + // //等待PLC将数据写入RFID;写入PLC的DB块,通知MES验证RFID机型数据是否正确传递 + + // //通知web显示 + // SendMessage.ShowMoby(OpName); + // //SendMessageFun.SendMessage("1235", "1111", OpName); + // } + // else + // { + // SendMessageFun.SendInfomation("EngineIDRepeat", "partSn", OpName); + // } + // } + // else + // { + // SendMessageFun.AsyncSendMessage_Notice(OpName, "变速器序列号格式不正确,请确认!"); + + // } + //} + //else//验证物料 + //{ + // //物料号 + // { + // //读取PLC的传递机型信号 + // bool tagValue; + // MIS_BASE.Read_EngineGetOver_PLC(OpName, out tagValue); + // if (tagValue) + // { + // //验证物料 + // BaseDataSystemMES.PartMaterial_DM_Update(OpName, barcode, out bool IsSuccess); + // if (!IsSuccess)//???? + // { + // SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认"); + // return; + // } + // else + // { + // SendMessageFun.SendMessageFun.SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息 + // } + // //判断物料是否验证完成 + // BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out int IsAllowWork); + + + // if (IsSuccess) + // { + // if (IsAllowWork == 1) + // { + // //移到允许保存信号中 + // //BaseDataSystemMES.Material_Insert(OpName, 1); + + // ////更新订单完工数量及物料 + // SendMessageFun.SendMessage("24", "11", OpName); + + // //物料验证完成,通知PLC允许工作,允许工作在保存完成时清空 + // MIS_BASE.Write_FixAllow(OpName, true); + // } + // else + // { + // SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + // } + // } + // else + // { + // SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC未传递机型"); + // } + // } + // else + // { + // SendMessage.AsyncSendMessage_Notice(OpName, "产品上线后,PLC获得变速器序列号后,再验证物料!"); + // } + + // } + //} + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:Barcode"); + } + } + + } + + + } +} diff --git a/MisDataFunction/Function1051/OpcServer/EngineGetOver.cs b/MisDataFunction/Function1051/OpcServer/EngineGetOver.cs new file mode 100644 index 0000000..cd25655 --- /dev/null +++ b/MisDataFunction/Function1051/OpcServer/EngineGetOver.cs @@ -0,0 +1,108 @@ +using System; +using System.Data; +using MesServerWork; +using MisDataFunDll; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + object lockBarcodeEngineTypeGetOver = new object(); + + + /// + /// PLC传递机型处理 + /// + /// + /// + private void EngineTypeGetOver_PLC(object e) + { + lock(lockBarcodeEngineTypeGetOver) + { + + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + //判断PLC机型与MES机型是否一致 + if (tagValue == 1) + { + bool MesRead = false; + + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + + int EngineTypeID_MES;//机型代码 + string EngineType_MES;//机型 + string EngineID_MES;//工件编号 + string OrderForm_MES; + + MIS_BASE.Read_QualityData_Read_CF(OpName, out MesRead); + //第一步,判断允许保存和保存完成信号是否全部被清空,若未清空,则通知复位MES&PLC + if (MesRead) + { + //未能清空信号,请求复位 + string msg = "【" + OpName + "】" + "未能清空MesRead信号,请求复位!"; + SendMessageFun.SendInfomation("AskReset", "1", OpName); + MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg); + return; + } + + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + MIS_BASE.GetEngineTypeFromPLC_MES(OpName, out EngineTypeID_MES, out EngineType_MES, out EngineID_MES, out OrderForm_MES); + + // 读取MES区数据 校验MES区数据是否符合 同时判断是否此工件已工作过,若已工作过则弹出弹窗提示 + if (EngineTypeID == EngineTypeID_MES & EngineID == EngineID_MES & EngineType == EngineType_MES & OrderForm == OrderForm_MES) + { + if (EngineTypeID == 0 || EngineID == "" || EngineType == "" || OrderForm == "") + { + string msg = "【" + OpName + "】" + "传递机型数据为空!"; + MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg); + SendMessage.AsyncSendMessage_Notice(OpName, msg); + return; + } + + + //写入到数据库的[北汽福田工位状态监控MOBY]表中 + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineTypeID, EngineTypeID.ToString()); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineType, EngineType); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineID, EngineID); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.OrderForm, OrderForm); + + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm); + + // 将工序数据转入临时表中 + MisDataFun.ProcessDataToTemp(OpName, EngineTypeID_MES, OrderForm_MES, EngineID_MES); + SendMessageFun.SendMessage("5123", "11111", OpName); + } + else + { + string msg = "【" + OpName + "】" + "PLC与MES信息不一致!"; + MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg); + SendMessage.AsyncSendMessage_Notice(OpName, msg); + } + + } + else + { + MIS_BASE.Write_FixAllow(OpName, false); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:EngineTypeGetOver_PLC"); + } + } + + } + + + + } +} diff --git a/MisDataFunction/Function1051/OpcServer/MaterialsScanOver.cs b/MisDataFunction/Function1051/OpcServer/MaterialsScanOver.cs new file mode 100644 index 0000000..665afe9 --- /dev/null +++ b/MisDataFunction/Function1051/OpcServer/MaterialsScanOver.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Threading; +//using SystemFramework; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 物料扫码完成 + /// + /// + /// + private void MaterialsScanOver(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + + if (tagValue == 1) + { + MIS_BASE.GetEngineTypeFromPLC(OpName, out int EngineTypeID, out string EngineType, out string EngineID, out int PartPallet_Code, out string OrderForm); + string materialsCode = MIS_BASE.ReadPLC(40, OpName).ToString(); + var dt = MisDataFun.Get_MaterialsScanOverRes(OpName, OrderForm, EngineID, materialsCode); + int result = Convert.ToInt32(dt.Rows[0]["result"]); + if (result == 1) + { + MIS_BASE.WritePLC(95, OpName, 1); + } + else if (result == 2) + { + MIS_BASE.WritePLC(95, OpName, 2); + } + } + else + { + MIS_BASE.WritePLC(96, OpName, 0); // 提前上料位置 + MIS_BASE.WritePLC(33, OpName, false); // 允许提前上料 + MIS_BASE.Write_EngineID_MES(OpName, ""); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + } +} diff --git a/MisDataFunction/Function1051/OpcServer/MesRead.cs b/MisDataFunction/Function1051/OpcServer/MesRead.cs new file mode 100644 index 0000000..e401ccc --- /dev/null +++ b/MisDataFunction/Function1051/OpcServer/MesRead.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + object lockMesRead = new object (); + /// + /// 保存完成(针对半自动和手动压装工位) + /// + /// + /// + private void MesRead(object e) + { + try + { + int EngineTypeID; + string EngineType; + string EngineID; + int PartPallet_Code; + string OrderForm; + + int EngineTypeID_MES;//机型代码 + string EngineType_MES;//机型 + string EngineID_MES;//工件编号 + string OrderForm_MES; + + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + int qualityMask; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID,out PartPallet_Code, out OrderForm); + + // 保存质量数据 + qualityMask = MisDataSaveDateMesRead.Funtion.MesRead(OpName, tagValue.ToString(), msgEvent.TagID.ToString()); + + // 保存物料数据 + MisDataFun.Material_Insert(OpName, qualityMask); + + // 保存过站信息 + MisDataFun.OpWork_StartOrOver(OpName, EngineID, OrderForm, 2); + + // 存追溯表数据 同时质量数据存入 接口表 + //MisDataFun.WorkOrderOpWorkOver(OpName, EngineID, OrderForm); + + // 推送质量数据到MES的页面 + SendMessageFun.SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName); + + //对应手动工位的 + //MIS_BASE.Write_ConfirmOkGo(OpName, true); + //通知设备,MES的质量数据(和物料数据)保存完成 + MIS_BASE.Write_MesReadOver(OpName, true); + //MIS_BASE.Write_MaterialVerifyOver(OpName, true); + //统计在线产量,在线节拍 + SendMessage.SendActuallyCount(OpName, tagValue); + } + else + { + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + } + + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + + } + } +} diff --git a/MisDataFunction/Function1051/OpcServer/MesReadOver.cs b/MisDataFunction/Function1051/OpcServer/MesReadOver.cs new file mode 100644 index 0000000..1b7206b --- /dev/null +++ b/MisDataFunction/Function1051/OpcServer/MesReadOver.cs @@ -0,0 +1,36 @@ +using System; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 保存完成(针对半自动和手动压装工位) + /// + /// + /// + private void MesReadOver(object e) + { + try + { + //DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + //string OpName = Convert.ToString(msgEvent.OpName); + //int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //if (tagValue == 1) + //{ + + // BaseDataSystemMES.Material_Insert(OpName, tagValue); + + // MIS_BASE.Write_ConfirmOkGo(OpName, true); + //} + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + } +} diff --git a/MisDataFunction/Function1051/OpcServer/PartLoad.cs b/MisDataFunction/Function1051/OpcServer/PartLoad.cs new file mode 100644 index 0000000..6a2d31d --- /dev/null +++ b/MisDataFunction/Function1051/OpcServer/PartLoad.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Threading; +//using SystemFramework; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 申请上线(针对上线工位) + /// + /// + /// + private void PartLoad(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + + if (tagValue == 1) + { + // 读取当前选择的计划中的机型,写入PLC + // 获取订单的机型 + var OrderTD = MisDataFun.GetEngineType_Order(OpName); + if (OrderTD.Rows.Count > 0) + { + string OrderForm = OrderTD.Rows[0]["制造编号"].ToString(); + string EngineID = OrderTD.Rows[0]["间隔编号"].ToString(); + string EngineType = OrderTD.Rows[0]["间隔图号"].ToString(); + int EngineTypeID = Convert.ToInt32(OrderTD.Rows[0]["产品型号代码"]); + + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineTypeID_MES, EngineTypeID.ToString()); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineType_MES, EngineType); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineID_MES, EngineID); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.OrderForm_MES, OrderForm); + + // 写入机型代码 (大机型) 机型 发动机号 订单号 + MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID); + MIS_BASE.Write_EngineType_MES(OpName, EngineType); + MIS_BASE.Write_EngineID_MES(OpName, EngineID); + MIS_BASE.Write_OrderForm_MES(OpName, OrderForm); + + // MES传递机型 + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, true); + } + else + { + string msg = "【" + OpName + "】" + "无可用生产计划 请确认!"; + // 判断到线体上有滞留工件 ,让去管理系统进行处理 + SendMessage.AsyncSendMessage_Notice(OpName, msg); + MyLog4Net.MyLogHelper.Error("PartLoad", msg); + return; + } + } + else + { + //上线工位清MES传递机型信号 + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + } +} diff --git a/MisDataFunction/Function1051/OpcServer/ReqEarlyFeeding.cs b/MisDataFunction/Function1051/OpcServer/ReqEarlyFeeding.cs new file mode 100644 index 0000000..729f519 --- /dev/null +++ b/MisDataFunction/Function1051/OpcServer/ReqEarlyFeeding.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Threading; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 申请提前上料 + /// + /// + /// + private void ReqEarlyFeeding(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + + if (tagValue == 1) + { + var dt = MisDataFun.Get_ReqEarlyFeedingData(OpName); + int result = Convert.ToInt32(dt.Rows[0]["result"]); + string msg = dt.Rows[0]["msg"].ToString(); + int EngineTypeID = Convert.ToInt32(dt.Rows[0]["产品型号代码"]); + if (result == 1) + { + MIS_BASE.WritePLC(96, OpName, EngineTypeID); // 产品型号 + MIS_BASE.Write_EngineID_MES(OpName, dt.Rows[0]["工件编号"].ToString()); + int ReadEngineID = Convert.ToInt32(MIS_BASE.ReadPLC(96, OpName)); + if (EngineTypeID != ReadEngineID) + { + MyLog4Net.MyLogHelper.Error("ReqEarlyFeeding", $"写入提前上料机型{EngineTypeID.ToString()} 与 读取到的{ReadEngineID.ToString()}不一致"); + return; + } + if (EngineTypeID == 0 || ReadEngineID == 0) + { + MyLog4Net.MyLogHelper.Error("ReqEarlyFeeding", $"写入提前上料机型{EngineTypeID.ToString()} 与 读取到的{ReadEngineID.ToString()} 其中存在空值"); + return; + } + MIS_BASE.WritePLC(33, OpName, true); // 允许提前上料 + + } + else if (result == 2) + { + MIS_BASE.WritePLC(33, OpName, false); + string msg2 = "【" + OpName + "】" + msg; + MyLog4Net.MyLogHelper.Error("ReqEarlyFeeding", msg2); + SendMessage.AsyncSendMessage_Notice(OpName, msg); + return; + } + } + else + { + MIS_BASE.WritePLC(96, OpName, 0); // 提前上料位置 + MIS_BASE.WritePLC(33, OpName, false); // 允许提前上料 + MIS_BASE.Write_EngineID_MES(OpName, ""); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + } +} diff --git a/MisDataFunction/Function1051/OpcServer/ReqTestResistor.cs b/MisDataFunction/Function1051/OpcServer/ReqTestResistor.cs new file mode 100644 index 0000000..7418852 --- /dev/null +++ b/MisDataFunction/Function1051/OpcServer/ReqTestResistor.cs @@ -0,0 +1,238 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Net.Http; +using System.Net.Sockets; +using System.Text; +using System.Threading; +using MesServerWork; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + private readonly object _lockObject = new object(); + private volatile bool _isTestOk = false; + private string _opName; + private const int DEFAULT_TIMEOUT = 7000; // 默认超时时间(毫秒) + private const int MAX_RETRY_COUNT = 10; // 最大重试次数 + private const int RESULT_LENGTH = 113; // 预期结果长度 + + /// + /// 电阻测试 + /// + private void ReqTestResistor(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + _opName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + TestResistor().GetAwaiter().GetResult(); + } + else + { + ResetPLCValues(); + } + } + catch (Exception err) + { + MyLog4Net.MyLogHelper.Error("电阻测试", $"测试过程发生错误: {err.Message}"); + ErrPLCValues(); + } + } + + /// + /// 执行电阻测试 + /// + private async Task TestResistor() + { + TcpClient tcpClient = null; + try + { + string IP = ConfigurationManager.AppSettings["ResistorDeviceIP_"+_opName]; + string Port = ConfigurationManager.AppSettings["ResistorDevicePort"]; + + using (tcpClient = new TcpClient()) + { + var connectTask = tcpClient.ConnectAsync(IP, Convert.ToInt32(Port)); + if (await Task.WhenAny(connectTask, Task.Delay(DEFAULT_TIMEOUT)) != connectTask) + { + throw new TimeoutException(_opName+"连接电阻仪超时"); + } + + if (tcpClient.Connected) + { + MyLog4Net.MyLogHelper.Info(_opName + "电阻测试", "电阻仪链接成功!"); + await SendCommand(tcpClient, "01 09 64 00 05 00 00 00 00 00 73"); + + await Task.Delay(DEFAULT_TIMEOUT); + + var readTask = Task.Run(() => Read(tcpClient)); + + int count = 0; + while (!_isTestOk && count < MAX_RETRY_COUNT) + { + await Task.Delay(1000); + await SendCommand(tcpClient, "03 01 04"); + count++; + } + + if (count >= MAX_RETRY_COUNT && !_isTestOk) + { + MyLog4Net.MyLogHelper.Error(_opName + "电阻测试", "测试超时,未收到有效结果"); + ErrPLCValues(); + } + } + } + } + catch (Exception ex) + { + MyLog4Net.MyLogHelper.Error(_opName + "电阻测试", $"测试过程发生错误: {ex.Message}"); + ErrPLCValues(); + } + finally + { + if (tcpClient != null) + { + tcpClient.Close(); + MyLog4Net.MyLogHelper.Info(_opName + "电阻测试", "电阻仪链接关闭"); + } + } + } + + private void ResetPLCValues() + { + lock (_lockObject) + { + MIS_BASE.WritePLC(202, _opName, 0); + MIS_BASE.WritePLC(203, _opName, 0); + MIS_BASE.WritePLC(204, _opName, 0); + MIS_BASE.WritePLC(34, _opName, false); + } + } + + private void ErrPLCValues() + { + lock (_lockObject) + { + MIS_BASE.WritePLC(202, _opName, 0); + MIS_BASE.WritePLC(203, _opName, 0); + MIS_BASE.WritePLC(204, _opName, 0); + MIS_BASE.WritePLC(34, _opName, true); + } + } + + /// + /// 发送命令到电阻仪 + /// + private async Task SendCommand(TcpClient tcpClient, string command) + { + try + { + // 将空格分隔的HEX字符串转换为字节数组 + string[] hexValues = command.Split(' '); + byte[] commandbyte = new byte[hexValues.Length]; + + for (int i = 0; i < hexValues.Length; i++) + { + commandbyte[i] = Convert.ToByte(hexValues[i], 16); + } + + // 发送HEX格式的数据 + await tcpClient.Client.SendAsync(new ArraySegment(commandbyte), SocketFlags.None); + + // 记录发送的命令 + MyLog4Net.MyLogHelper.Info(_opName + "电阻测试Send", $"发送命令: {command}"); + } + catch (Exception err) + { + MyLog4Net.MyLogHelper.Error(_opName + "电阻测试Send", $"发送命令失败: {err.Message}"); + throw; + } + } + + private void Read(TcpClient tcpClient) + { + try + { + while (!_isTestOk) + { + if (tcpClient != null && tcpClient.Connected) + { + byte[] byteCommand = new byte[1024]; + int icommand = tcpClient.Client.Receive(byteCommand); + string hexString = BitConverter.ToString(byteCommand, 0, icommand).Replace("-", " "); + + if (hexString.Length == RESULT_LENGTH) + { + DataAnalysis(hexString); + } + } + } + } + catch (Exception err) + { + MyLog4Net.MyLogHelper.Error(_opName + "电阻测试Read", err.Message); + } + } + + private void DataAnalysis(string hexString) + { + try + { + var byteArray = HexStringToByteArray(hexString.Replace(" ", "")); + var start = 2; + + var 状态 = BitConverter.ToInt32(byteArray.Skip(start + 0).Take(4).ToArray(), 0); + if (状态 != 2) return; + var 电压V = BitConverter.ToDouble(byteArray.Skip(start + 4).Take(8).ToArray(), 0); + var 电流A = BitConverter.ToDouble(byteArray.Skip(start + 12).Take(8).ToArray(), 0); + var 电阻uΩ = BitConverter.ToDouble(byteArray.Skip(start + 20).Take(8).ToArray(), 0) * 1000000; + var yyyy = BitConverter.ToUInt16(byteArray.Skip(start + 28).Take(2).ToArray(), 0); + var MM = byteArray[start + 30]; + var dd = byteArray[start + 31]; + var HH = byteArray[start + 32]; + var mm = byteArray[start + 33]; + var ss = byteArray[start + 34]; + var datetime = $"{yyyy}-{MM}-{dd} {HH}:{mm}:{ss}"; + + lock (_lockObject) + { + MIS_BASE.WritePLC(202, _opName, 电压V); + MIS_BASE.WritePLC(203, _opName, 电流A); + MIS_BASE.WritePLC(204, _opName, 电阻uΩ); + MIS_BASE.WritePLC(34, _opName, true); + _isTestOk = true; + } + + MyLog4Net.MyLogHelper.Info(_opName + "电阻测试", $"电阻结果写入完毕 【电压】{电压V}【电流】{电流A}【电阻】{电阻uΩ}"); + } + catch (Exception ex) + { + MyLog4Net.MyLogHelper.Error(_opName + "电阻测试DataAnalysis", $"数据分析错误: {ex.Message}"); + } + } + + public static byte[] HexStringToByteArray(string hex) + { + if (hex.Length % 2 != 0) + { + throw new ArgumentException("十六进制字符串长度必须是偶数"); + } + + byte[] bytes = new byte[hex.Length / 2]; + for (int i = 0; i < hex.Length; i += 2) + { + bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16); + } + return bytes; + } + } +} \ No newline at end of file diff --git a/MisDataFunction/Function1051/OpcServer/WebSubmit.cs b/MisDataFunction/Function1051/OpcServer/WebSubmit.cs new file mode 100644 index 0000000..71febbc --- /dev/null +++ b/MisDataFunction/Function1051/OpcServer/WebSubmit.cs @@ -0,0 +1,410 @@ +using System; +using MesServerWork; +using System.Threading; +using MisDataSaveDate; +using System.Collections; +using MisDataFunDll; +//using SystemFramework; + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + private void WebSubmit(object e) + { + try + { + var msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string Content = Convert.ToString(msgEvent.TagValue); + + string opName_SubLine = ""; + string engineID = "";//工件信息 + string[] dataArray = Content.Split('|'); + + if (dataArray.Length != 2) + return; + + + string m_Command = dataArray[0].ToString();//消息类型 + string m_Value = dataArray[1].ToString();//消息参数 + string[] m_Value_array = m_Value.Split('&');//消息参数数量 + int m_Value_length = m_Value_array.Length; //消息参数长度 + + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + engineID = MIS_BASE.hashtable_EngineGetOver_EngineID[OpName].ToString(); + } + if (MIS_BASE.hashtable_OpNameRepair == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + DeviceDriver_BasicData.CustomeEvetnArgs _e = new DeviceDriver_BasicData.CustomeEvetnArgs(); + _e.OpName = OpName; + _e.TagValue = m_Value; + string msg; + bool bolVal; + + //根据请求的命令处理逻辑 + switch (m_Command) + { + case "Barcode": + if (m_Value_length > 1) return; + fun_Barcode(_e); + break; + case "ConfirmOkGo"://合格放行 + //修改托盘状态 + + //MisDataFun.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_ConfirmOkGo(OpName, true); + MIS_BASE.Write_FalseGO(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + break; + case "FalseGO"://返修放行 + //修改托盘状态 + //BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "NgGO"://不合格放行 + //修改托盘状态 + //保存不合格信息(必须保存不合格放行信息,由于B5A的Moby没有不合格标志位) + //BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Insert(OpName, engineID, "", ""); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "OnLineState"://在线0、离线1、屏蔽2 + try + { + if (m_Value_length > 1) return; + int a = Convert.ToInt32(m_Value); + if (a <= 2) + { + //BaseDataSystemMES.IsOnLine_Update(OpName, m_Value.ToString()); + MIS_BASE.Write_OnLineState(OpName, Convert.ToInt32(m_Value)); + + if (a == 2) SendMessage.AsyncSendMessage_Notice(OpName, "屏蔽MES!"); + if (a == 0) SendMessage.AsyncSendMessage_Notice(OpName, "启用MES!"); + } + } + catch + { + + } + break; + + case "NullWorkGo"://空托盘放行 0不放行 1放行 + try + { + int a = Convert.ToInt32(m_Value); + //修改地址值 + MIS_BASE.Write_PartPalletGoOver(OpName, a); + if (a == 1) + { + SendMessage.AsyncSendMessage_Notice(OpName, "开启空托盘放行!"); + } + else + { + SendMessage.AsyncSendMessage_Notice(OpName, "关闭空托盘放行!"); + } + } + catch + { + + } + break; + case "Reset"://复位,将MES所有的信息都复位了 + SetMoby(OpName);//将MES所有信号清空 + + break; + case "FixAllow"://重新拧紧 + break; + case "IsAutoGetEngineID"://自动手动申请编号(线首) + if (m_Value_length > 1) return; + MIS_BASE.Write_IsAutoGetEngineID(OpName, Convert.ToInt32(m_Value)); + break; + case "PartPalletGoOver"://空托盘放行 + MIS_BASE.Write_RepairUpline_MES(opName_SubLine, true); + //MIS_BASE.Write_PalletInfo(opName_SubLine, 4); + //MIS_BASE.Write_UpdatePalletOK(opName_SubLine, true); + MIS_BASE.Write_MaterialVerifyOver(opName_SubLine, true); + break; + case "SetMoby"://清空托盘(线首) + SetMoby(OpName);//将MES所有信号清空 + break; + case "RepairUplineMES"://返修上线 + MIS_BASE.Write_RepairUpline_MES(OpName, true); + break; + case "CancelRepair"://将返修件置为正常件 + + break; + case "PartPalletCode"://申请写入托盘号 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "WritePartPalletCode"://写入托盘号 + if (m_Value_length > 1) return; + MIS_BASE.WritePLC(113, OpName, Convert.ToInt32(m_Value)); + Thread.Sleep(500); + MIS_BASE.WritePLC(70, OpName, true); + break; + case "Normal"://启用正常拧紧工位 + MIS_BASE.Write_Normal(OpName, 1); + MIS_BASE.Write_UnNormal(OpName, 0); + break; + case "UnNormal"://启用备用拧紧工位 + MIS_BASE.Write_Normal(OpName, 0); + MIS_BASE.Write_UnNormal(OpName, 1); + break; + case "ResetDevice"://复位设备 + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + break; + case "IsNeedRepaire"://返修上线(返修上线点) + if (Convert.ToInt32(m_Value) == 1) + { + //修改托盘状态 + MIS_BASE.Write_PalletInfo(OpName, 3); + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + IsNeedRepaire_OK(OpName); + } + else if (Convert.ToInt32(m_Value) == 0) + { + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + break; + //强制匹配 + case "ForceMatch": + if (Convert.ToInt32(m_Value) == 1) + { + ForceMatch(OpName); + } + break; + case "PalletGO": + + if (Convert.ToInt32(m_Value) == 1) + { + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(opName_SubLine, true); + } + break; + case "ContinueMatch": + //BaseDataSystemMES.QualityVerifyStatus_Hash_Write(OpName, true); + fun_EngineTypeGetOverPLC(_e); + break; + //初始化网页信号 + case "IniSingalToWeb": + InitializeSingalToWeb(OpName); + break; + // 检查项 检查完成 + case "checkWorkOver": + MIS_BASE.WritePLC(30, OpName,1); + msg = "MES|checkWorkOverIsShow|" + OpName + "|" + 0; + SendMessage.AsyncSendMessage(msg); + break; + // 重新申请上线 + case "againPartLoad": + // 判断是否有工件到位 + MIS_BASE.Read_WorkStart(OpName, out bolVal); + if (bolVal) + { + MIS_BASE.WritePLC(35, OpName, 1); + msg = "【" + OpName + "】" + "重新申请上线完成!"; + SendMessage.AsyncSendMessage_Notice(OpName, msg); + } + else + { + msg = "【" + OpName + "】" + "当前无工件到位信号,请确认是否存在工件!"; + SendMessage.AsyncSendMessage_Notice(OpName, msg); + } + break; + // 跳过交互 + case "skipWork": + // 判断是否有工件到位 + MIS_BASE.Read_WorkStart(OpName, out bolVal); + if (bolVal) + { + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, true); // 传递机型 + MIS_BASE.Write_FixAllow(OpName,true); // 允许工作 + MIS_BASE.WritePLC(30, OpName, 1); // 检查完成 + MIS_BASE.Write_MesReadOver(OpName, true); // 保存完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); // 工作完成 + msg = "【" + OpName + "】" + "跳过交互完成!"; + SendMessage.AsyncSendMessage_Notice(OpName, msg); + } + else + { + msg = "【" + OpName + "】" + "当前无工件到位信号,请确认是否存在工件!"; + SendMessage.AsyncSendMessage_Notice(OpName, msg); + } + break; + default: break; + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:WebSubmit"); + } + } + + private void SetMoby(string OpName) + { + try + { + //清空Moby时,需要将MES信号清空 + MIS_BASE.Write_ClearMesMoby(OpName); + + //BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName); + + SendMessageFun.SendMessage("5123", "1111", OpName); + + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + } + catch + { + + } + } + + + /// + /// 网页重现登录,恢复关闭前的页面状态 + /// + /// 工位号 + private void InitializeSingalToWeb(string Opname) + { + InitOpPosion(Opname); + + //3显示操作指导图片 PicShow_String_FirstOpName + SendMessage.PicShow_FirstOpName(Opname); + //1(直接在界面通过选择机型确认工序内容) + SendMessage.ProcessList_FirstOpName(Opname); + // MOBY数据 + SendMessageFun.SendMessage("5", "1", Opname); + //SendMessageFun.SendMessage("5123", "1111", Opname); + // 物料信息 物料信息 + SendMessage.MaterialList(Opname); + + // 新增查询PLC直通状态 网页显示 + //MIS_BASE.Read_TagTypeID(63, Opname, out S_plcStatus); + InitAlarm(Opname); + } + + //分线发送工件到位信号函数 + private void sendmessage(string OpName, int tagValue, string Command) + { + string SendMessage; + SendMessage = "MES|" + Command + "|" + OpName + "|" + tagValue; + SendMessageFun.AsyncSendMessage(SendMessage); + + } + private void InitAlarm(string Opname) + { + FuntionMesRead.Alarm_InitAlarm_Send(Opname, out Hashtable ht); + foreach (DictionaryEntry kv in ht) + { + var TagID = kv.Key.ToString(); + var TagValue = kv.Value.ToString(); + FuntionMesRead.Send_AlarmMsg(TagID, TagValue); + } + + } + + private void InitOpPosion(string Opname) + { + int S_WorkCheckOver = Convert.ToInt32(MIS_BASE.ReadPLC(30, Opname)); + string S_WorkCheckOver_Msg = "MES|checkWorkOverIsShow|" + Opname + "|" + S_WorkCheckOver; + SendMessage.AsyncSendMessage(S_WorkCheckOver_Msg); + + bool S_WorkStart;//工件到位 DBX0.1 + MIS_BASE.Read_WorkStart(Opname, out S_WorkStart); + if (S_WorkStart == true) + { + SendMessageFun.SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname); + } + //---------------------------------------------------- + bool S_PartLoad;//申请上线 + MIS_BASE.Read_PartLoad(Opname, out S_PartLoad); + if (S_PartLoad == true) + { + SendMessageFun.SendInfomation("PartLoad", Convert.ToString(Convert.ToInt32(S_PartLoad)), Opname); + } + //---------------------------------------------------- + bool S_EngineGetOver;//传递机型 DBX0.4 + MIS_BASE.Read_EngineGetOver_PLC(Opname, out S_EngineGetOver); + if (S_EngineGetOver == true) + { + SendMessageFun.SendInfomation("EngineTypeGetOverPLC", Convert.ToString(Convert.ToInt32(S_EngineGetOver)), Opname); + + //5 显示订单、机型信息 线首工位用 + SendMessage.ShowMoby_FirstOpName(Opname); + //界面显示物料信息 + SendMessage.MaterialList_FirstOpName(Opname); + } + //---------------------------------------------------- + bool S_FixAllow;//允许工作 DBX3.1 + MIS_BASE.Read_FixAllow(Opname, out S_FixAllow); + if (S_FixAllow == true) + { + SendMessageFun.SendInfomation("FixAllow", Convert.ToString(Convert.ToInt32(S_FixAllow)), Opname); + } + //---------------------------------------------------- + bool S_MesRead;//允许保存 DBX3.1 + MIS_BASE.Read_QualityData_Read_CF(Opname, out S_MesRead); + if (S_MesRead == true) + { + SendMessageFun.SendInfomation("MesRead", Convert.ToString(Convert.ToInt32(S_MesRead)), Opname); + } + //---------------------------------------------------- + bool S_ReadOver;//保存完成 + MIS_BASE.Read_MesReadOver(Opname, out S_ReadOver); + if (S_ReadOver == true) + { + SendMessageFun.SendInfomation("MesReadOver", Convert.ToString(Convert.ToInt32(S_ReadOver)), Opname); + } + //---------------------------------------------------- + bool S_MaterialVerifyOver;//工作完成 DBX0.3 + MIS_BASE.Read_MaterialVerifyOver(Opname, out S_MaterialVerifyOver); + if (S_MaterialVerifyOver == true) + { + SendMessageFun.SendInfomation("MaterialVerifyOver", Convert.ToString(Convert.ToInt32(S_MaterialVerifyOver)), Opname); + } + //---------------------------------------------------- + int S_QualityMask;//合格标志 DBX588 + MIS_BASE.Read_QualityMask(Opname, out S_QualityMask); + if (S_QualityMask == 1) + { + SendMessageFun.SendInfomation("QualityMask", Convert.ToString(Convert.ToInt32(S_QualityMask)), Opname); + } + //---------------------------------------------------- + string S_plcStatus = "false";//DBX501.5 PLC直通,1 强制放行 0 正常循环 + if (S_plcStatus.ToLower() == "false") + { + SendMessageFun.SendInfomation("PlcStatus", "0", Opname); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", Opname); + } + } + } +} diff --git a/MisDataFunction/Function1051/OpcServer/WorkStart.cs b/MisDataFunction/Function1051/OpcServer/WorkStart.cs new file mode 100644 index 0000000..91e7893 --- /dev/null +++ b/MisDataFunction/Function1051/OpcServer/WorkStart.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using MesServerWork; +using MisDataFunDll; +//using SystemFramework; + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工件到位与离开时,清空MES自身信号 + /// + /// + /// + private void WorkStart(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //线首显示订单信息 + + if (tagValue == 1) + { + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.WorkStartIn, DateTime.Now.ToString()); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.WorkStart, tagValue.ToString()); + } + else + { + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.WorkStartOut, DateTime.Now.ToString()); + + // 清除工位数据 + MIS_BASE.Write_EngineTypeID_MES(OpName, 0); + MIS_BASE.Write_EngineType_MES(OpName, ""); + MIS_BASE.Write_EngineID_MES(OpName, ""); + MIS_BASE.Write_OrderForm_MES(OpName, ""); + + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + + MIS_BASE.WritePLC(115, OpName, 0); // 清除小机型 + + // 检查项完成 + MIS_BASE.Write_TagTypeID(30, OpName,0); + string message = "MES|checkWorkOverIsShow|" + OpName + "|" + 0; + SendMessage.AsyncSendMessage(message); + + // 重新申请上线 + MIS_BASE.WritePLC(35, OpName, 0); + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:WorkStart"); + } + } + } +} diff --git a/MisDataFunction/Function1051/OpcServer/vssver2.scc b/MisDataFunction/Function1051/OpcServer/vssver2.scc new file mode 100644 index 0000000..e8dac03 Binary files /dev/null and b/MisDataFunction/Function1051/OpcServer/vssver2.scc differ diff --git a/MisDataFunction/Function1051/Properties/AssemblyInfo.cs b/MisDataFunction/Function1051/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f3608c0 --- /dev/null +++ b/MisDataFunction/Function1051/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Function08")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("苏州宏软信息技术有限公司")] +[assembly: AssemblyProduct("Function08")] +[assembly: AssemblyCopyright("Copyright © 苏州宏软信息技术有限公司 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("47710f2c-e141-4252-8d13-701bf4c1c027")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MisDataFunction/Function1051/Properties/vssver2.scc b/MisDataFunction/Function1051/Properties/vssver2.scc new file mode 100644 index 0000000..87eebff Binary files /dev/null and b/MisDataFunction/Function1051/Properties/vssver2.scc differ diff --git a/MisDataFunction/Function1051/mssccprj.scc b/MisDataFunction/Function1051/mssccprj.scc new file mode 100644 index 0000000..f184c61 --- /dev/null +++ b/MisDataFunction/Function1051/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[Function08.csproj] +SCC_Aux_Path = "\\192.168.0.100\vss\MES4.0" +SCC_Project_Name = "$/MisData/MisData/MisData/MesServer.Function/Function08", KRHAAAAA diff --git a/MisDataFunction/Function1051/packages.config b/MisDataFunction/Function1051/packages.config new file mode 100644 index 0000000..b3e1761 --- /dev/null +++ b/MisDataFunction/Function1051/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1051/vssver2.scc b/MisDataFunction/Function1051/vssver2.scc new file mode 100644 index 0000000..93af295 Binary files /dev/null and b/MisDataFunction/Function1051/vssver2.scc differ diff --git a/MisDataFunction/Function1052/DataAccess/DataAccess.cs b/MisDataFunction/Function1052/DataAccess/DataAccess.cs new file mode 100644 index 0000000..574d619 --- /dev/null +++ b/MisDataFunction/Function1052/DataAccess/DataAccess.cs @@ -0,0 +1,15 @@ + +namespace MesServerFunctions +{ + partial class Function1052 + { + //针对“MIS.BizFacade.Dll”中没有的存储过程,在此类中新建 + //新建原则:所有的函数用private,只允许在内部使用 + //针对单个工艺特殊,需要新建存储过程,但是存储过程不能被加入到“MIS.BizFacade.Dll”中 + + private void aa() + { + + } + } +} diff --git a/MisDataFunction/Function1052/DataAccess/vssver2.scc b/MisDataFunction/Function1052/DataAccess/vssver2.scc new file mode 100644 index 0000000..d045c26 Binary files /dev/null and b/MisDataFunction/Function1052/DataAccess/vssver2.scc differ diff --git a/MisDataFunction/Function1052/Function02.csproj.vspscc b/MisDataFunction/Function1052/Function02.csproj.vspscc new file mode 100644 index 0000000..0f0f36c --- /dev/null +++ b/MisDataFunction/Function1052/Function02.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:MesServer.Function\\Function02" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/MisDataFunction/Function1052/Function1052.csproj b/MisDataFunction/Function1052/Function1052.csproj new file mode 100644 index 0000000..097bfab --- /dev/null +++ b/MisDataFunction/Function1052/Function1052.csproj @@ -0,0 +1,170 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {5FEE5C91-8419-49FF-B2C2-47476F0B8C68} + Library + Properties + Function1052 + Function1052 + v4.8 + 512 + + + + + + + + + + + + + + true + full + false + ..\..\MisDataFun_Exe\ + DEBUG;TRACE + prompt + 4 + false + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + ..\..\dll_common\MesWork.DeviceDriver.dll + + + ..\..\..\Common\dll\MQTTnet.dll + + + ..\..\..\Common\dll\MQTTnet.Extensions.ManagedClient.dll + + + False + ..\..\dll_common\Newtonsoft.Json.dll + + + + + + + ..\..\DLL\System.Net.Http.dll + + + ..\..\packages\System.Net.Security.4.3.2\lib\net46\System.Net.Security.dll + + + ..\..\packages\System.Net.WebSockets.4.3.0\lib\net46\System.Net.WebSockets.dll + + + ..\..\packages\System.Net.WebSockets.Client.4.3.2\lib\net46\System.Net.WebSockets.Client.dll + + + ..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll + + + ..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {f55da1a0-a982-4479-8c47-0d9a5aaf3e18} + 00MesWorkMqtt + + + {0d1af432-439a-4920-8692-43ae139f5530} + 01_01DoWhatPlc + + + {f434e066-4c59-47c8-aa82-6f48cc84501a} + 04-DataBaseAccess + + + {f0a0c525-03fd-428a-9b17-7f54aa0e4475} + 07BusinessFacade + + + {d98be764-adeb-488d-9714-61e308aa8201} + 08-WebFun_base + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 09-MesDataFunction + + + {e4eb6420-906d-4672-947a-ca33ddcdadfc} + 12SendMessageToWeb + + + {55b510c1-59e9-4bfd-ae84-d76d46f6e365} + 02-13.3MIS_FuntionSaveData + + + {1dc48c83-1842-4de8-acaf-26e1e7f7c58f} + 00_MyLog4Net + + + + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1052/MesServerFunction/Fun_1052.cs b/MisDataFunction/Function1052/MesServerFunction/Fun_1052.cs new file mode 100644 index 0000000..78466e6 --- /dev/null +++ b/MisDataFunction/Function1052/MesServerFunction/Fun_1052.cs @@ -0,0 +1,250 @@ +using MesServerWork; +using System.Collections.Generic; +using System.Threading; +using MisDataFunDll; + +namespace MesServerFunctions +{ + public partial class FunctionMES + { + object lockFunWork; + //public void FunWork(DeviceDriver_BasicData.CustomeEvetnArgs e) + public void FunWork(string recData) + { + + + lockFunWork = new object(); + lock (lockFunWork) + { + List dataArray = MisDataFun.GetCmdStringList(recData); + //string[] dataArray = recData.Split('|'); + //if (dataArray.Count != 4) + //return; + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 Barcode + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + DeviceDriver_BasicData.CustomeEvetnArgs e = new DeviceDriver_BasicData.CustomeEvetnArgs();// = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string tagValue; + + switch (m_Source) + { + case "BarCode": + e.OpName = m_OpName; + e.TagValue = m_Value; + fun_Barcode(e); + break; + case "WEB": + e.OpName = m_OpName; + e.TagValue = m_Command + "|" + m_Value; + fun_WebSubmit(e); + break; + case "PLC": + e = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string TagID = e.TagID.ToString(); + switch (e.TagValue.ToString().ToLower()) + { + case "false": + tagValue = "0"; + break; + case "true": + tagValue = "1"; + break; + default: + tagValue = e.TagValue.ToString(); + break; + } + e.TagValue = tagValue; + switch (e.TagTypeCodeID.ToString()) + { + //PLC 工件到位 + case "2": + fun_WorkStart(e); + break; + //PLC 允许保存质量数据 + case "19": + fun_MesRead(e); + break; + //MES 保存数据完成 + case "20": + fun_MesReadOver(e); + break; + //PLC 传递机型 + case "44": + fun_EngineTypeGetOverPLC(e); + break; + //MES 合格放行 + case "51": + fun_ConfirmOkGo(e); + break; + //MES 不合格放行 + case "8": + fun_FalseGo(e); + break; + //PLC 工位合格标志 + case "21": + fun_IsOk(e); + break; + //MES保存实时质量数据 + case "65": + fun_MesSaveNowData(e); + break; + //MES 系统健康心跳 + case "14": + fun_HeartBeatMIS(e); + break; + case "63": + fun_ReqEarlyFeeding(e); + break; + case "64": + fun_ReqTestResistor(e); + break; + } + break; + } + } + } + + //1.工件到位后,PLC给MES传递机型(DBX0.4)(44), + //MES判断条码是否全部扫描完成 + //PLC给出允许保存(DBX100.2)(19),MES见到(DBX100.2)(19)为1后给出保存完成(DBX102.2)(20), + //PLC见到保存完成(DBX102.2)(20)为1后,清空允许保存(DBX100.2)(19), + //MES见到允许保存(DBX100.2)(19)为0后,清空保存完成(DBX102.2)(20) + //MES判断总合格标志(INT104)(21)为1后,给出合格放行(DBX2.5)(51) + /// + /// 扫描条码 + /// + /// + /// + public void fun_Barcode(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(Barcode, e); + } + + /// + /// 传递机型 + /// + /// + /// + public void fun_EngineTypeGetOverPLC(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(EngineTypeGetOver_PLC, e); + } + + /// + /// 合格放行 + /// + /// + /// + public void fun_ConfirmOkGo(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(ConfirmOkGo, e); + } + + /// + /// 不合格放行 + /// + /// + /// + public void fun_FalseGo(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(FalseGO, e); + } + + /// + /// 允许保存 + /// + /// + /// + public void fun_MesRead(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesRead, e); + } + + /// + /// 提前上料 + /// + /// + /// + public void fun_ReqEarlyFeeding(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(ReqEarlyFeeding, e); + } + + /// + /// 请求测试电阻 调用电阻仪 + /// + /// + /// + public void fun_ReqTestResistor(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(ReqTestResistor, e); + } + + /// + /// 保存完成 + /// + /// + /// + public void fun_MesReadOver(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(MesReadOver, e); + } + + /// + /// 工件到位离开(清空所有的MES信号) + /// + /// + /// + public void fun_WorkStart(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WorkStart, e); + } + + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + public void fun_WebSubmit(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WebSubmit, e); + } + + + /// + /// 工位是否合格 + /// + /// + /// + public void fun_IsOk(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(IsOk, e); + } + + /// + /// 系统健康心跳监测 + /// + /// + /// + public void fun_HeartBeatMIS(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(HeartBeat, e); + } + + /// + /// MES实时保存质量数据 + /// + /// + /// + public void fun_MesSaveNowData(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(MesSaveNowData, e); + } + } +} diff --git a/MisDataFunction/Function1052/MesServerFunction/vssver2.scc b/MisDataFunction/Function1052/MesServerFunction/vssver2.scc new file mode 100644 index 0000000..a246f67 Binary files /dev/null and b/MisDataFunction/Function1052/MesServerFunction/vssver2.scc differ diff --git a/MisDataFunction/Function1052/Methods/EngineGetOverBaseWork.cs b/MisDataFunction/Function1052/Methods/EngineGetOverBaseWork.cs new file mode 100644 index 0000000..5767df1 --- /dev/null +++ b/MisDataFunction/Function1052/Methods/EngineGetOverBaseWork.cs @@ -0,0 +1,106 @@ +using System; +using System.Data; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 正常逻辑工作(传递机型) + /// + /// + /// + /// + /// + /// + private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code, string OrderForm) + { + int IsAllowWork; + int RepairPartStatusPLC = 0; + int MES_QualityMask = 1; + + if (EngineTypeID <= 0 || EngineID.Length == 0 || EngineType.Length == 0) + { + string msg = "【" + OpName + "】" + "PLC传递机型为空!"; + MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg); + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC传递机型为空"); + return; + } + + //电子看板_装配零件_临时表_增加_北汽 + //第二步,将零件信息转移到零件_临时表中 + MisDataFun.MesServer_Process_EngineTypeOverBQ(OpName); + + //通知web显示 + SendMessageFun.SendMessage("123", "111", OpName); + //MIS_BASE.Read_PalletInfo(OpName, out MES_QualityMask);//合格标志 合格标志暂时改为即时响应式的 + MIS_BASE.Read_RepairStatus_PLC(OpName, out RepairPartStatusPLC);//返修标志 + //SendMessageFun.SendInfomation("QualityMask", Convert.ToString(MES_QualityMask), OpName);//显示合格标志 + SendMessageFun.SendInfomation("RepairPartStatusPLC", Convert.ToString(RepairPartStatusPLC), OpName);//显示返修标志 + + //第四步,获取是否允许工作 + MisDataFun.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + //暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况 + if (IsAllowWork == 1) + { + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + + } + + /// + /// 二次工作 + /// + /// + private void EngineTypeGetOver_PLC_Work_two(string OpName) + { + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, Convert.ToInt32(PartPallet_Code), OrderForm); + + } + /// + /// 跳过二次工作 + /// + /// + private void EngineTypeGetOver_PLC_Work_Skip(string OpName) + { + //MIS_BASE.Write_MesReadOver(OpName, true); + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + + /// + /// 返修件需要工作 + /// + /// 工位号 + private void IsNeedRepaire_OK(string OpName) + { + string orderForm = ""; + int engineTypeID; + string engineType = ""; + string engineID = ""; + string palletCode = ""; + int isRepair; + string repairCode = ""; + //从监控系统中查询出本工位信息 + //MisDataFun.OpName_MIS_Moby_Select(OpName, + //out orderForm, out engineTypeID, out engineType, + //out engineID, out palletCode, out isRepair, out repairCode); + + //EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode), orderForm); + } + } +} diff --git a/MisDataFunction/Function1052/Methods/vssver2.scc b/MisDataFunction/Function1052/Methods/vssver2.scc new file mode 100644 index 0000000..7782f6f Binary files /dev/null and b/MisDataFunction/Function1052/Methods/vssver2.scc differ diff --git a/MisDataFunction/Function1052/OpcServer/Barcode.cs b/MisDataFunction/Function1052/OpcServer/Barcode.cs new file mode 100644 index 0000000..6d2013c --- /dev/null +++ b/MisDataFunction/Function1052/OpcServer/Barcode.cs @@ -0,0 +1,89 @@ +using System; +using System.Windows.Forms; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + ///1.扫描配送单号,用于接收物料,扫描单号的时候,将接收的物料信息显示在“物料拉动”Tab区域 + ///2.扫描料箱标签/看板卡,用于追溯物料批次信息 + ///3.扫描零件条码,根据零件图号进行防错 + ///第一步,判断条码类型,根据条码类型,执行对应的存储过程 + ///第二步,条码类型(将扫描的条码保存到对应的表中) + ///第三步,扫描完成之后给出允许工作信号 + /// 处理页面扫描条码 + /// + /// + /// + public void Barcode(object e) + { + + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string barcode = Convert.ToString(msgEvent.TagValue); + string AlarmStr = ""; + + int IsAllowWork; + bool IsSuccess = false; + bool EngineGetOver_PLC_NextWorkStep; + //传递机型是否到位 + MIS_BASE.Read_EngineGetOver_PLC(OpName, out EngineGetOver_PLC_NextWorkStep); + if (!EngineGetOver_PLC_NextWorkStep) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC未传递机型"); + return; + } + //物料验证 + MisDataFun.PartMaterial_DM_Update(OpName, barcode, out IsSuccess); + if (!IsSuccess) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认"); + return; + } + else + { + SendMessageFun.SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息 + } + + + + + //获取是否允许工作 + MisDataFun.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + //此处逻辑有问题 需要考虑到批次扫描 提示PLC未传递机型的情况 + if (IsAllowWork == 1) + { + //BaseDataSystemMES.Material_Insert(OpName, 1); + + //更新订单完工数量及物料 + SendMessageFun.SendMessage("24", "11", OpName); + + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:Barcode"); + } + + } + + } + + + } +} diff --git a/MisDataFunction/Function1052/OpcServer/EngineGetOver.cs b/MisDataFunction/Function1052/OpcServer/EngineGetOver.cs new file mode 100644 index 0000000..4cac79f --- /dev/null +++ b/MisDataFunction/Function1052/OpcServer/EngineGetOver.cs @@ -0,0 +1,114 @@ +using System; +using System.Data; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// PLC传递机型处理 + /// + /// + /// + private void EngineTypeGetOver_PLC(object e) + { + + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + //判断PLC机型与MES机型是否一致 + if (tagValue == 1) + { + bool MesRead = false; + + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + string EngineType;//机型 + string EngineID;//工件编号 + + //上线工位清MES传递机型信号 + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + + MIS_BASE.Read_QualityData_Read_CF(OpName, out MesRead); + //第一步,判断允许保存和保存完成信号是否全部被清空,若未清空,则通知复位MES&PLC + if (MesRead) + { + //未能清空信号,请求复位 + string msg = "【" + OpName + "】" + "未能清空MesRead信号,请求复位!"; + SendMessageFun.SendInfomation("AskReset", "1", OpName); + MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg); + return; + } + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + + // 读取MES区数据 校验MES区数据是否符合 同时判断是否此工件已工作过,若已工作过则弹出弹窗提示 + if (EngineTypeID != 0 & EngineID != "" & EngineType != "" & OrderForm != "") + { + DataTable checkTable = MisDataFun.WorkOrderCheck(OpName, EngineID, OrderForm, EngineType); + int result = Convert.ToInt32(checkTable.Rows[0]["result"]); + //int result = 1; + string resultMsg = "";// checkTable.Rows[0]["msg"].ToString(); + if (result != 2) + { + if (result == 3) + { + string msg = "【" + OpName + "】" + resultMsg; + MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg); + SendMessage.AsyncSendMessage_Notice(OpName, msg); + } + int parType = Convert.ToInt32(checkTable.Rows[0]["小机型"]); + MIS_BASE.WritePLC(115, OpName, parType); // 托盘类型 1 静 2 动 3 拐 + + //写入到数据库的[北汽福田工位状态监控MOBY]表中 + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineTypeID, EngineTypeID.ToString()); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineType, EngineType); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineID, EngineID); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.OrderForm, OrderForm); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.PartPallet_Code, PartPallet_Code.ToString()); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineTypeID_MES, EngineTypeID.ToString()); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineType_MES, EngineType); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineID_MES, EngineID); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.OrderForm_MES, OrderForm); + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm); + SendMessage.ShowMoby(OpName); + SendMessageFun.SendMessage("5123", "1111", OpName); + } + else + { + string msg = "【" + OpName + "】" + resultMsg; + MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg); + SendMessage.AsyncSendMessage_Notice(OpName, msg); + } + + return; + } + else + { + string msg = "【" + OpName + "】" + "读取信息存在空值!"; + MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg); + SendMessage.AsyncSendMessage_Notice(OpName, msg); + } + + } + else + { + MIS_BASE.Write_FixAllow(OpName, false); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:EngineTypeGetOver_PLC"); + } + } + + + } + + } +} diff --git a/MisDataFunction/Function1052/OpcServer/MesRead.cs b/MisDataFunction/Function1052/OpcServer/MesRead.cs new file mode 100644 index 0000000..11357b7 --- /dev/null +++ b/MisDataFunction/Function1052/OpcServer/MesRead.cs @@ -0,0 +1,86 @@ +using MesServerWork; +using MisDataFunDll; +using System; +using System.Collections.Generic; +using System.Threading; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 允许保存(针对半自动和手动压装工位) + /// + /// + /// + private void MesRead(object e) + { + { + try + { + int EngineTypeID; + string EngineType; + string EngineID; + int PartPallet_Code; + string OrderForm; + + int EngineTypeID_MES;//机型代码 + string EngineType_MES;//机型 + string EngineID_MES;//工件编号 + string OrderForm_MES; + + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + int qualityMask; + + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + //MIS_BASE.GetEngineTypeFromPLC_MES(OpName, out EngineTypeID_MES, out EngineType_MES, out EngineID_MES, out OrderForm_MES); + //保存数据到线首表 先保存到 北汽福田变速器序列号总线上线 用于之前判断是否重号 + // 保存质量数据 + qualityMask = MisDataSaveDateMesRead.Funtion.MesRead(OpName, tagValue.ToString(), msgEvent.TagID.ToString()); + + // 保存物料数据 + MisDataFun.Material_Insert(OpName, qualityMask); + + // 测量数据发动机在线状态 + MisDataFun.WorkStartInsert(OpName, qualityMask); + + // 存追溯表数据 + MisDataFun.WorkOrderOpWorkOver(OpName, EngineID, OrderForm); + + // 推送质量数据到MES的页面 + SendMessageFun.SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName); + + //对应手动工位的 + //MIS_BASE.Write_ConfirmOkGo(OpName, true); + //通知设备,MES的质量数据(和物料数据)保存完成 + MIS_BASE.Write_MesReadOver(OpName, true); + //MIS_BASE.Write_MaterialVerifyOver(OpName, true); + //统计在线产量,在线节拍 + SendMessage.SendActuallyCount(OpName, tagValue); + } + else + { + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + } + + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + + } + + } +} diff --git a/MisDataFunction/Function1052/OpcServer/ReqEarlyFeeding.cs b/MisDataFunction/Function1052/OpcServer/ReqEarlyFeeding.cs new file mode 100644 index 0000000..eb15c8c --- /dev/null +++ b/MisDataFunction/Function1052/OpcServer/ReqEarlyFeeding.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Threading; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 申请提前上料 + /// + /// + /// + private void ReqEarlyFeeding(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + + if (tagValue == 1) + { + var dt = MisDataFun.Get_ReqEarlyFeedingData(OpName); + int result = Convert.ToInt32(dt.Rows[0]["result"]); + string msg = dt.Rows[0]["msg"].ToString(); + int EngineTypeID = Convert.ToInt32(dt.Rows[0]["产品型号代码"]); + if (result == 1) + { + MIS_BASE.WritePLC(96, OpName, EngineTypeID); // 产品型号 + MIS_BASE.Write_EngineID_MES(OpName, dt.Rows[0]["工件编号"].ToString()); + int ReadEngineID = Convert.ToInt32(MIS_BASE.ReadPLC(96, OpName)); + if (EngineTypeID != ReadEngineID) + { + MyLog4Net.MyLogHelper.Error("ReqEarlyFeeding", $"写入提前上料机型{EngineTypeID.ToString()} 与 读取到的{ReadEngineID.ToString()}不一致"); + return; + } + if (EngineTypeID == 0 || ReadEngineID == 0) + { + MyLog4Net.MyLogHelper.Error("ReqEarlyFeeding", $"写入提前上料机型{EngineTypeID.ToString()} 与 读取到的{ReadEngineID.ToString()} 其中存在空值"); + return; + } + MIS_BASE.WritePLC(33, OpName, true); // 允许提前上料 + + } + else if (result == 2) + { + MIS_BASE.WritePLC(33, OpName, false); + string msg2 = "【" + OpName + "】" + msg; + MyLog4Net.MyLogHelper.Error("ReqEarlyFeeding", msg2); + SendMessage.AsyncSendMessage_Notice(OpName, msg); + return; + } + } + else + { + MIS_BASE.WritePLC(96, OpName, 0); // 提前上料位置 + MIS_BASE.WritePLC(33, OpName, false); // 允许提前上料 + MIS_BASE.Write_EngineID_MES(OpName, ""); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + } +} diff --git a/MisDataFunction/Function1052/OpcServer/ReqTestResistor.cs b/MisDataFunction/Function1052/OpcServer/ReqTestResistor.cs new file mode 100644 index 0000000..e3e0b82 --- /dev/null +++ b/MisDataFunction/Function1052/OpcServer/ReqTestResistor.cs @@ -0,0 +1,238 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Net.Http; +using System.Net.Sockets; +using System.Text; +using System.Threading; +using MesServerWork; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + private readonly object _lockObject = new object(); + private volatile bool _isTestOk = false; + private string _opName; + private const int DEFAULT_TIMEOUT = 7000; // 默认超时时间(毫秒) + private const int MAX_RETRY_COUNT = 10; // 最大重试次数 + private const int RESULT_LENGTH = 113; // 预期结果长度 + + /// + /// 电阻测试 + /// + private void ReqTestResistor(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + _opName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + TestResistor().GetAwaiter().GetResult(); + } + else + { + ResetPLCValues(); + } + } + catch (Exception err) + { + MyLog4Net.MyLogHelper.Error("电阻测试", $"测试过程发生错误: {err.Message}"); + ErrPLCValues(); + } + } + + /// + /// 执行电阻测试 + /// + private async Task TestResistor() + { + TcpClient tcpClient = null; + try + { + string IP = ConfigurationManager.AppSettings["ResistorDeviceIP_" + _opName]; + string Port = ConfigurationManager.AppSettings["ResistorDevicePort"]; + + using (tcpClient = new TcpClient()) + { + var connectTask = tcpClient.ConnectAsync(IP, Convert.ToInt32(Port)); + if (await Task.WhenAny(connectTask, Task.Delay(DEFAULT_TIMEOUT)) != connectTask) + { + throw new TimeoutException("连接电阻仪超时"); + } + + if (tcpClient.Connected) + { + MyLog4Net.MyLogHelper.Info("电阻测试", "电阻仪链接成功!"); + await SendCommand(tcpClient, "01 09 64 00 05 00 00 00 00 00 73"); + + await Task.Delay(DEFAULT_TIMEOUT); + + var readTask = Task.Run(() => Read(tcpClient)); + + int count = 0; + while (!_isTestOk && count < MAX_RETRY_COUNT) + { + await Task.Delay(1000); + await SendCommand(tcpClient, "03 01 04"); + count++; + } + + if (count >= MAX_RETRY_COUNT && !_isTestOk) + { + MyLog4Net.MyLogHelper.Error("电阻测试", "测试超时,未收到有效结果"); + ErrPLCValues(); + } + } + } + } + catch (Exception ex) + { + MyLog4Net.MyLogHelper.Error("电阻测试", $"测试过程发生错误: {ex.Message}"); + ErrPLCValues(); + } + finally + { + if (tcpClient != null) + { + tcpClient.Close(); + MyLog4Net.MyLogHelper.Info("电阻测试", "电阻仪链接关闭"); + } + } + } + + private void ResetPLCValues() + { + lock (_lockObject) + { + MIS_BASE.WritePLC(202, _opName, 0); + MIS_BASE.WritePLC(203, _opName, 0); + MIS_BASE.WritePLC(204, _opName, 0); + MIS_BASE.WritePLC(34, _opName, false); + } + } + + private void ErrPLCValues() + { + lock (_lockObject) + { + MIS_BASE.WritePLC(202, _opName, 0); + MIS_BASE.WritePLC(203, _opName, 0); + MIS_BASE.WritePLC(204, _opName, 0); + MIS_BASE.WritePLC(34, _opName, true); + } + } + + /// + /// 发送命令到电阻仪 + /// + private async Task SendCommand(TcpClient tcpClient, string command) + { + try + { + // 将空格分隔的HEX字符串转换为字节数组 + string[] hexValues = command.Split(' '); + byte[] commandbyte = new byte[hexValues.Length]; + + for (int i = 0; i < hexValues.Length; i++) + { + commandbyte[i] = Convert.ToByte(hexValues[i], 16); + } + + // 发送HEX格式的数据 + await tcpClient.Client.SendAsync(new ArraySegment(commandbyte), SocketFlags.None); + + // 记录发送的命令 + MyLog4Net.MyLogHelper.Info("电阻测试Send", $"发送命令: {command}"); + } + catch (Exception err) + { + MyLog4Net.MyLogHelper.Error("电阻测试Send", $"发送命令失败: {err.Message}"); + throw; + } + } + + private void Read(TcpClient tcpClient) + { + try + { + while (!_isTestOk) + { + if (tcpClient != null && tcpClient.Connected) + { + byte[] byteCommand = new byte[1024]; + int icommand = tcpClient.Client.Receive(byteCommand); + string hexString = BitConverter.ToString(byteCommand, 0, icommand).Replace("-", " "); + + if (hexString.Length == RESULT_LENGTH) + { + DataAnalysis(hexString); + } + } + } + } + catch (Exception err) + { + MyLog4Net.MyLogHelper.Error("电阻测试Read", err.Message); + } + } + + private void DataAnalysis(string hexString) + { + try + { + var byteArray = HexStringToByteArray(hexString.Replace(" ", "")); + var start = 2; + + var 状态 = BitConverter.ToInt32(byteArray.Skip(start + 0).Take(4).ToArray(), 0); + if (状态 != 2) return; + var 电压V = BitConverter.ToDouble(byteArray.Skip(start + 4).Take(8).ToArray(), 0); + var 电流A = BitConverter.ToDouble(byteArray.Skip(start + 12).Take(8).ToArray(), 0); + var 电阻uΩ = BitConverter.ToDouble(byteArray.Skip(start + 20).Take(8).ToArray(), 0) * 1000000; + var yyyy = BitConverter.ToUInt16(byteArray.Skip(start + 28).Take(2).ToArray(), 0); + var MM = byteArray[start + 30]; + var dd = byteArray[start + 31]; + var HH = byteArray[start + 32]; + var mm = byteArray[start + 33]; + var ss = byteArray[start + 34]; + var datetime = $"{yyyy}-{MM}-{dd} {HH}:{mm}:{ss}"; + + lock (_lockObject) + { + MIS_BASE.WritePLC(202, _opName, 电压V); + MIS_BASE.WritePLC(203, _opName, 电流A); + MIS_BASE.WritePLC(204, _opName, 电阻uΩ); + MIS_BASE.WritePLC(34, _opName, true); + _isTestOk = true; + } + + MyLog4Net.MyLogHelper.Info("电阻测试", $"电阻结果写入完毕 【电压】{电压V}【电流】{电流A}【电阻】{电阻uΩ}"); + } + catch (Exception ex) + { + MyLog4Net.MyLogHelper.Error("电阻测试DataAnalysis", $"数据分析错误: {ex.Message}"); + } + } + + public static byte[] HexStringToByteArray(string hex) + { + if (hex.Length % 2 != 0) + { + throw new ArgumentException("十六进制字符串长度必须是偶数"); + } + + byte[] bytes = new byte[hex.Length / 2]; + for (int i = 0; i < hex.Length; i += 2) + { + bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16); + } + return bytes; + } + } +} \ No newline at end of file diff --git a/MisDataFunction/Function1052/OpcServer/WebSubmit.cs b/MisDataFunction/Function1052/OpcServer/WebSubmit.cs new file mode 100644 index 0000000..cd3512e --- /dev/null +++ b/MisDataFunction/Function1052/OpcServer/WebSubmit.cs @@ -0,0 +1,352 @@ +using System; +using MesServerWork; +using MisDataSaveDate; +using System.Collections; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + private void WebSubmit(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName=Convert.ToString(msgEvent.OpName); + string Content = Convert.ToString(msgEvent.TagValue); + + string[] dataArray = Content.Split('|'); + if (dataArray.Length != 2) + return; + //消息类型 + string m_Command = dataArray[0].ToString(); + //消息参数 + string m_Value = dataArray[1].ToString(); + //消息参数数量 + string[] m_Value_array = m_Value.Split('&'); + //消息参数长度 + int m_Value_length = m_Value_array.Length; + + //工件信息 + string engineID = ""; + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + return; + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + engineID = MIS_BASE.hashtable_EngineGetOver_EngineID[OpName].ToString(); + } + + DeviceDriver_BasicData.CustomeEvetnArgs _e = new DeviceDriver_BasicData.CustomeEvetnArgs(); + _e.OpName = OpName; + _e.TagValue = m_Value; + + string msg; + bool bolVal; + + //根据请求的命令处理逻辑 + switch (m_Command) + { + case "Barcode": + if (m_Value_length > 1) return; + fun_Barcode(_e); + break; + case "OnLineState"://在线0、离线1、屏蔽2 + try + { + if (m_Value_length > 1) return; + int a = Convert.ToInt32(m_Value); + if (a <= 2) + { + //MisDataFun.IsOnLine_Update(OpName, m_Value.ToString()); + MIS_BASE.Write_OnLineState(OpName, Convert.ToInt32(m_Value)); + if (a == 2) SendMessage.AsyncSendMessage_Notice(OpName, "屏蔽MES!"); + if (a == 0) SendMessage.AsyncSendMessage_Notice(OpName, "启用MES!"); + } + } + catch + { + + } + break; + case "Reset"://复位,将MES所有的信息都复位了 + SetMoby(OpName);//将MES所有信号清空 + break; + case "FixAllow"://重新拧紧 + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_FixAllow(OpName, true); + break; + case "IsAutoGetEngineID"://自动手动申请编号(线首) + if (m_Value_length > 1) return; + MIS_BASE.Write_IsAutoGetEngineID(OpName, Convert.ToInt32(m_Value)); + break; + case "PartPalletGoOver"://空托盘放行 + int Is_PartPalletGoOver; + MIS_BASE.Read_PartPalletGoOver(OpName, out Is_PartPalletGoOver); + if (Is_PartPalletGoOver == 1) + { + MIS_BASE.Write_PartPalletGoOver(OpName, 1); + } + else + { + MIS_BASE.Write_PartPalletGoOver(OpName,0); + } + break; + case "SetMoby"://清空托盘(线首) + SetMoby(OpName);//将MES所有信号清空 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "RepairUplineMES"://返修上线 + MIS_BASE.Write_RepairUpline_MES(OpName, true); + break; + case "CancelRepair"://将返修件置为正常件 + + break; + case "PartPalletCode"://申请写入托盘号 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "WritePartPalletCode"://写入托盘号 + if (m_Value_length > 1) return; + MIS_BASE.Write_PalletCode(OpName, Convert.ToInt32(m_Value)); + break; + case "Normal"://启用正常拧紧工位 + MIS_BASE.Write_Normal(OpName, 1); + MIS_BASE.Write_UnNormal(OpName, 0); + break; + case "UnNormal"://启用备用拧紧工位 + MIS_BASE.Write_Normal(OpName, 0); + MIS_BASE.Write_UnNormal(OpName, 1); + break; + case "ResetDevice"://复位设备 + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + break; + case "IsNeedRepaire"://返修上线(返修上线点) + if (Convert.ToInt32(m_Value) == 1) + { + //修改托盘状态 + MIS_BASE.Write_PalletInfo(OpName, 3); + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + IsNeedRepaire_OK(OpName); + + } + else if (Convert.ToInt32(m_Value) == 0) + { + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + else + { } + + break; + case "ContinueMatch": + //BaseDataSystemMES.QualityVerifyStatus_Hash_Write(OpName, true); + break; + //初始化网页信号 + case "IniSingalToWeb": + InitializeSingalToWeb(OpName); + break; + case "Reset_Engine"://返修上线(返修上线点) + SetMoby(OpName);//将MES所有信号清空 + //fun_EngineTypeGetOverPLC(OpName, 0); + //fun_EngineTypeGetOverPLC(OpName, 1); + break; + case "twoWorkSkip"://重新工作工件跳过工作(重新工作工件) + //工作完成 + EngineTypeGetOver_PLC_Work_Skip(OpName); + break; + case "twoWork"://重新工作工件重新工作(重新工作工件) + //允许工作 + EngineTypeGetOver_PLC_Work_two(OpName); + break; + // 检查项 检查完成 + case "checkWorkOver": + MIS_BASE.WritePLC(30, OpName, 1); + string message = "MES|checkWorkOverIsShow|" + OpName + "|" + 0; + SendMessage.AsyncSendMessage(message); + break; + // 跳过交互 + case "skipWork": + // 判断是否有工件到位 + MIS_BASE.Read_WorkStart(OpName, out bolVal); + if (bolVal) + { + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, true); // 传递机型 + MIS_BASE.Write_FixAllow(OpName, true); // 允许工作 + MIS_BASE.WritePLC(30, OpName, 1); // 检查完成 + MIS_BASE.Write_MesReadOver(OpName, true); // 保存完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); // 工作完成 + msg = "【" + OpName + "】" + "跳过交互完成!"; + SendMessage.AsyncSendMessage_Notice(OpName, msg); + } + else + { + msg = "【" + OpName + "】" + "当前无工件到位信号,请确认是否存在工件!"; + SendMessage.AsyncSendMessage_Notice(OpName, msg); + } + break; + default: break; + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WebSubmit"); + } + } + private void SetMoby(string OpName) + { + try + { + //清空Moby时,需要将MES信号清空 + MIS_BASE.Write_ClearMesMoby(OpName); + + MisDataFun.MesServer_Process_EngineTypeOver(OpName); + + SendMessageFun.SendMessage("5123", "1111", OpName); + + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + } + catch + { + + } + } + + private void sendmessage(string OpName, int tagValue, string Command) + { + string SendMessage; + SendMessage = "MES|" + Command + "|" + OpName + "|" + tagValue; + SendMessageFun.AsyncSendMessage(SendMessage); + + } + + /// 网页重现登录,恢复关闭前的页面状态 + /// + /// 工位号 + private void InitializeSingalToWeb(string Opname) + { + + InitOpPosion(Opname); + + //3显示操作指导图片 PicShow_String_FirstOpName + SendMessage.PicShow_FirstOpName(Opname); + //1(直接在界面通过选择机型确认工序内容) + SendMessage.ProcessList_FirstOpName(Opname); + // MOBY数据 + SendMessageFun.SendMessage("5", "1", Opname); + // 物料信息 物料信息 + SendMessage.MaterialList(Opname); + + // 新增查询PLC直通状态 网页显示 + //MIS_BASE.Read_TagTypeID(63, Opname, out S_plcStatus); + InitAlarm(Opname); + } + + private void InitAlarm(string Opname) + { + FuntionMesRead.Alarm_InitAlarm_Send(Opname, out Hashtable ht); + foreach (DictionaryEntry kv in ht) + { + var TagID = kv.Key.ToString(); + var TagValue = kv.Value.ToString(); + FuntionMesRead.Send_AlarmMsg(TagID, TagValue); + } + + } + + private void InitOpPosion(string Opname) + { + int S_WorkCheckOver = Convert.ToInt32(MIS_BASE.ReadPLC(30, Opname)); + string S_WorkCheckOver_Msg = "MES|checkWorkOverIsShow|" + Opname + "|" + S_WorkCheckOver; + SendMessage.AsyncSendMessage(S_WorkCheckOver_Msg); + + bool S_WorkStart;//工件到位 DBX0.1 + MIS_BASE.Read_WorkStart(Opname, out S_WorkStart); + if (S_WorkStart == true) + { + SendMessageFun.SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname); + } + //---------------------------------------------------- + bool S_PartLoad;//申请上线 + MIS_BASE.Read_PartLoad(Opname, out S_PartLoad); + if (S_PartLoad == true) + { + SendMessageFun.SendInfomation("PartLoad", Convert.ToString(Convert.ToInt32(S_PartLoad)), Opname); + } + //---------------------------------------------------- + bool S_EngineGetOver;//传递机型 DBX0.4 + MIS_BASE.Read_EngineGetOver_PLC(Opname, out S_EngineGetOver); + if (S_EngineGetOver == true) + { + SendMessageFun.SendInfomation("EngineTypeGetOverPLC", Convert.ToString(Convert.ToInt32(S_EngineGetOver)), Opname); + + //5 显示订单、机型信息 线首工位用 + SendMessage.ShowMoby_FirstOpName(Opname); + //界面显示物料信息 + SendMessage.MaterialList_FirstOpName(Opname); + } + //---------------------------------------------------- + bool S_FixAllow;//允许工作 DBX3.1 + MIS_BASE.Read_FixAllow(Opname, out S_FixAllow); + if (S_FixAllow == true) + { + SendMessageFun.SendInfomation("FixAllow", Convert.ToString(Convert.ToInt32(S_FixAllow)), Opname); + } + //---------------------------------------------------- + bool S_MesRead;//允许保存 DBX3.1 + MIS_BASE.Read_QualityData_Read_CF(Opname, out S_MesRead); + if (S_MesRead == true) + { + SendMessageFun.SendInfomation("MesRead", Convert.ToString(Convert.ToInt32(S_MesRead)), Opname); + } + //---------------------------------------------------- + bool S_ReadOver;//保存完成 + MIS_BASE.Read_MesReadOver(Opname, out S_ReadOver); + if (S_ReadOver == true) + { + SendMessageFun.SendInfomation("MesReadOver", Convert.ToString(Convert.ToInt32(S_ReadOver)), Opname); + } + //---------------------------------------------------- + bool S_MaterialVerifyOver;//工作完成 DBX2.3 + MIS_BASE.Read_MaterialVerifyOver(Opname, out S_MaterialVerifyOver); + if (S_MaterialVerifyOver == true) + { + SendMessageFun.SendInfomation("MaterialVerifyOver", Convert.ToString(Convert.ToInt32(S_MaterialVerifyOver)), Opname); + } + //---------------------------------------------------- + int S_QualityMask;//合格标志 DBX588 + MIS_BASE.Read_QualityMask(Opname, out S_QualityMask); + if (S_QualityMask == 1) + { + SendMessageFun.SendInfomation("QualityMask", Convert.ToString(Convert.ToInt32(S_QualityMask)), Opname); + } + //---------------------------------------------------- + string S_plcStatus = "false";//DBX501.5 PLC直通,1 强制放行 0 正常循环 + if (S_plcStatus.ToLower() == "false") + { + SendMessageFun.SendInfomation("PlcStatus", "0", Opname); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", Opname); + } + } + } +} diff --git a/MisDataFunction/Function1052/OpcServer/WorkIsOk.cs b/MisDataFunction/Function1052/OpcServer/WorkIsOk.cs new file mode 100644 index 0000000..3149bce --- /dev/null +++ b/MisDataFunction/Function1052/OpcServer/WorkIsOk.cs @@ -0,0 +1,44 @@ +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工位合格标志 + /// + /// + /// + private void IsOk(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + int qualityMask; + MIS_BASE.Read_QualityMask(OpName, out qualityMask); + //判断是否合格 + if (qualityMask == 1) + { + qualityMask = 1; + } else { + qualityMask = 0; + } + //通知WEB修改状态 + string message = "MES|QualityMask|" + OpName + "|" + qualityMask.ToString(); + SendMessage.AsyncSendMessage(message); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1052/OpcServer/WorkStart.cs b/MisDataFunction/Function1052/OpcServer/WorkStart.cs new file mode 100644 index 0000000..7fc448c --- /dev/null +++ b/MisDataFunction/Function1052/OpcServer/WorkStart.cs @@ -0,0 +1,57 @@ +using MesServerWork; +using MisDataFunDll; +using System; +using System.Threading; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工件到位与离开时,清空MES自身信号 + /// + /// + /// + private void WorkStart(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + if (tagValue > 0) + { + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.WorkStartIn, DateTime.Now.ToString()); + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.WorkStart, tagValue.ToString()); + } + else + { + MIS_BASE.Write_EngineTypeID_MES(OpName, 0); + MIS_BASE.Write_EngineType_MES(OpName, ""); + MIS_BASE.Write_EngineID_MES(OpName, ""); + MIS_BASE.Write_OrderForm_MES(OpName, ""); + + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.WorkStartOut, DateTime.Now.ToString()); + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + + // 检查项完成 + MIS_BASE.Write_TagTypeID(30, OpName, 0); + string message = "MES|checkWorkOverIsShow|" + OpName + "|" + 0; + SendMessage.AsyncSendMessage(message); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WorkStart"); + } + } + + } +} diff --git a/MisDataFunction/Function1052/OpcServer/vssver2.scc b/MisDataFunction/Function1052/OpcServer/vssver2.scc new file mode 100644 index 0000000..b884d13 Binary files /dev/null and b/MisDataFunction/Function1052/OpcServer/vssver2.scc differ diff --git a/MisDataFunction/Function1052/Properties/AssemblyInfo.cs b/MisDataFunction/Function1052/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0bb79c4 --- /dev/null +++ b/MisDataFunction/Function1052/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Function02")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("苏州宏软信息技术有限公司")] +[assembly: AssemblyProduct("Function02")] +[assembly: AssemblyCopyright("Copyright © 苏州宏软信息技术有限公司 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("47710f2c-e141-4252-8d13-701bf4c1c027")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MisDataFunction/Function1052/Properties/vssver2.scc b/MisDataFunction/Function1052/Properties/vssver2.scc new file mode 100644 index 0000000..14e543b Binary files /dev/null and b/MisDataFunction/Function1052/Properties/vssver2.scc differ diff --git a/MisDataFunction/Function1052/mssccprj.scc b/MisDataFunction/Function1052/mssccprj.scc new file mode 100644 index 0000000..119193d --- /dev/null +++ b/MisDataFunction/Function1052/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[Function02.csproj] +SCC_Aux_Path = "\\192.168.0.100\vss\MES4.0" +SCC_Project_Name = "$/MisData/MisData/MisData/MesServer.Function/Function02", ILHAAAAA diff --git a/MisDataFunction/Function1052/packages.config b/MisDataFunction/Function1052/packages.config new file mode 100644 index 0000000..b3e1761 --- /dev/null +++ b/MisDataFunction/Function1052/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1052/vssver2.scc b/MisDataFunction/Function1052/vssver2.scc new file mode 100644 index 0000000..c770e28 Binary files /dev/null and b/MisDataFunction/Function1052/vssver2.scc differ diff --git a/MisDataFunction/Function1053/DataAccess/DataAccess.cs b/MisDataFunction/Function1053/DataAccess/DataAccess.cs new file mode 100644 index 0000000..cd36930 --- /dev/null +++ b/MisDataFunction/Function1053/DataAccess/DataAccess.cs @@ -0,0 +1,15 @@ + +namespace MesServerFunctions +{ + partial class Function1053 + { + //针对“MIS.BizFacade.Dll”中没有的存储过程,在此类中新建 + //新建原则:所有的函数用private,只允许在内部使用 + //针对单个工艺特殊,需要新建存储过程,但是存储过程不能被加入到“MIS.BizFacade.Dll”中 + + private void aa() + { + + } + } +} diff --git a/MisDataFunction/Function1053/DataAccess/vssver2.scc b/MisDataFunction/Function1053/DataAccess/vssver2.scc new file mode 100644 index 0000000..d045c26 Binary files /dev/null and b/MisDataFunction/Function1053/DataAccess/vssver2.scc differ diff --git a/MisDataFunction/Function1053/Db.cs b/MisDataFunction/Function1053/Db.cs new file mode 100644 index 0000000..cce85a9 --- /dev/null +++ b/MisDataFunction/Function1053/Db.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + public class Db + { + + + } +} diff --git a/MisDataFunction/Function1053/Function02.csproj.vspscc b/MisDataFunction/Function1053/Function02.csproj.vspscc new file mode 100644 index 0000000..0f0f36c --- /dev/null +++ b/MisDataFunction/Function1053/Function02.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:MesServer.Function\\Function02" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/MisDataFunction/Function1053/Function1053.csproj b/MisDataFunction/Function1053/Function1053.csproj new file mode 100644 index 0000000..b07ecd1 --- /dev/null +++ b/MisDataFunction/Function1053/Function1053.csproj @@ -0,0 +1,167 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {CA8A12C5-7BF0-4489-93FA-180B1C492BBA} + Library + Properties + Function1053 + Function1053 + v4.8 + 512 + + + + + + + + + + + + + + true + full + false + ..\..\MisDataFun_Exe\ + DEBUG;TRACE + prompt + 4 + false + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + ..\..\dll_common\MesWork.DeviceDriver.dll + + + ..\..\..\Common\dll\MQTTnet.dll + + + ..\..\..\Common\dll\MQTTnet.Extensions.ManagedClient.dll + + + False + ..\..\dll_common\Newtonsoft.Json.dll + + + + + + ..\..\DLL\System.Net.Http.dll + + + ..\..\packages\System.Net.Security.4.3.2\lib\net46\System.Net.Security.dll + + + ..\..\packages\System.Net.WebSockets.4.3.0\lib\net46\System.Net.WebSockets.dll + + + ..\..\packages\System.Net.WebSockets.Client.4.3.2\lib\net46\System.Net.WebSockets.Client.dll + + + ..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll + + + ..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {f55da1a0-a982-4479-8c47-0d9a5aaf3e18} + 00MesWorkMqtt + + + {0d1af432-439a-4920-8692-43ae139f5530} + 01_01DoWhatPlc + + + {f434e066-4c59-47c8-aa82-6f48cc84501a} + 04-DataBaseAccess + + + {f0a0c525-03fd-428a-9b17-7f54aa0e4475} + 07BusinessFacade + + + {d98be764-adeb-488d-9714-61e308aa8201} + 08-WebFun_base + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 09-MesDataFunction + + + {e4eb6420-906d-4672-947a-ca33ddcdadfc} + 12SendMessageToWeb + + + {55b510c1-59e9-4bfd-ae84-d76d46f6e365} + 02-13.3MIS_FuntionSaveData + + + {1dc48c83-1842-4de8-acaf-26e1e7f7c58f} + 00_MyLog4Net + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1053/MesServerFunction/Fun_1053.cs b/MisDataFunction/Function1053/MesServerFunction/Fun_1053.cs new file mode 100644 index 0000000..0ba7185 --- /dev/null +++ b/MisDataFunction/Function1053/MesServerFunction/Fun_1053.cs @@ -0,0 +1,262 @@ +using MesServerWork; +using MisDataFunDll; +using MisDataSaveDate; +using System.Collections.Generic; +using System.Threading; +using System.Xml.Linq; + +namespace MesServerFunctions +{ + public partial class FunctionMES + { + object lockFunWork; + //public void FunWork(DeviceDriver_BasicData.CustomeEvetnArgs e) + public void FunWork(string recData) + { + + + lockFunWork = new object(); + lock (lockFunWork) + { + List dataArray = MisDataFun.GetCmdStringList(recData); + //string[] dataArray = recData.Split('|'); + //if (dataArray.Count != 4) + //return; + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 Barcode + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + DeviceDriver_BasicData.CustomeEvetnArgs e = new DeviceDriver_BasicData.CustomeEvetnArgs();// = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string tagValue; + + switch (m_Source) + { + case "BarCode": + e.OpName = m_OpName; + e.TagValue = m_Value; + fun_Barcode(e); + break; + case "WEB": + e.OpName = m_OpName; + e.TagValue = m_Command + "|" + m_Value; + fun_WebSubmit(e); + break; + case "PLC": + e = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string TagID = e.TagID.ToString(); + switch (e.TagValue.ToString().ToLower()) + { + case "false": + tagValue = "0"; + break; + case "true": + tagValue = "1"; + break; + default: + tagValue = e.TagValue.ToString(); + break; + } + e.TagValue = tagValue; + switch (e.TagTypeCodeID.ToString()) + { + //PLC 工件到位 + case "2": + fun_WorkStart(e); + break; + //PLC 允许保存质量数据 + case "19": + fun_MesRead(e); + break; + //MES 保存数据完成 + case "20": + fun_MesReadOver(e); + break; + //PLC 申请上线 + case "43": + PartLoad(e); + break; + //PLC 传递机型 + case "44": + fun_EngineTypeGetOverPLC(e); + break; + //MES 合格放行 + case "51": + fun_ConfirmOkGo(e); + break; + //MES 不合格放行 + case "8": + fun_FalseGo(e); + break; + //PLC 工位合格标志 + case "21": + fun_IsOk(e); + break; + //MES保存实时质量数据 + case "65": + fun_MesSaveNowData(e); + break; + //MES 系统健康心跳 + case "14": + fun_HeartBeatMIS(e); + break; + //空料握手plc + case "49": + fun_Handshake(e); + break; + //待上料数量plc + case "38": + UpdateWait_NUM_PLC(e); + break; + case "63": + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + MIS_BASE.Read_TagTypeID(63, m_OpName, out S_plcStatus); + if (S_plcStatus.ToLower() != "true" || S_plcStatus.ToLower() == "1") + { + SendMessageFun.SendInfomation("PlcStatus", "0", m_OpName); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", m_OpName); + } + break; + } + break; + } + } + } + + //1.工件到位后,PLC给MES传递机型(DBX0.4)(44), + //MES判断条码是否全部扫描完成 + //PLC给出允许保存(DBX100.2)(19),MES见到(DBX100.2)(19)为1后给出保存完成(DBX102.2)(20), + //PLC见到保存完成(DBX102.2)(20)为1后,清空允许保存(DBX100.2)(19), + //MES见到允许保存(DBX100.2)(19)为0后,清空保存完成(DBX102.2)(20) + //MES判断总合格标志(INT104)(21)为1后,给出合格放行(DBX2.5)(51) + /// + /// 扫描条码 + /// + /// + /// + public void fun_Barcode(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(Barcode, e); + } + + /// + /// 传递机型 + /// + /// + /// + public void fun_EngineTypeGetOverPLC(DeviceDriver_BasicData .CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(EngineTypeGetOver_PLC, e); + } + + /// + /// 合格放行 + /// + /// + /// + public void fun_ConfirmOkGo(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(ConfirmOkGo, e); + } + + /// + /// 不合格放行 + /// + /// + /// + public void fun_FalseGo(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(FalseGO, e); + } + + /// + /// 允许保存 + /// + /// + /// + public void fun_MesRead(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesRead, e); + } + + /// + /// 保存完成 + /// + /// + /// + public void fun_MesReadOver(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(MesReadOver, e); + } + + /// + /// 工件到位离开(清空所有的MES信号) + /// + /// + /// + public void fun_WorkStart(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WorkStart, e); + } + + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + public void fun_WebSubmit(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WebSubmit, e); + } + + + /// + /// 工位是否合格 + /// + /// + /// + public void fun_IsOk(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(IsOk, e); + } + + /// + /// 系统健康心跳监测 + /// + /// + /// + public void fun_HeartBeatMIS(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(HeartBeat, e); + } + + + /// + /// 空料握手plc + /// + public void fun_Handshake(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + //ThreadPool.QueueUserWorkItem(Handshake_Fun, e); + } + + + /// + /// MES实时保存质量数据 + /// + /// + /// + public void fun_MesSaveNowData(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + // ThreadPool.QueueUserWorkItem(MesSaveNowData, e); + } + + + } +} diff --git a/MisDataFunction/Function1053/MesServerFunction/vssver2.scc b/MisDataFunction/Function1053/MesServerFunction/vssver2.scc new file mode 100644 index 0000000..a246f67 Binary files /dev/null and b/MisDataFunction/Function1053/MesServerFunction/vssver2.scc differ diff --git a/MisDataFunction/Function1053/Methods/EngineGetOverBaseWork.cs b/MisDataFunction/Function1053/Methods/EngineGetOverBaseWork.cs new file mode 100644 index 0000000..46e4f96 --- /dev/null +++ b/MisDataFunction/Function1053/Methods/EngineGetOverBaseWork.cs @@ -0,0 +1,115 @@ +using System; +using System.Data; +using System.Threading; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 正常逻辑工作(传递机型) + /// + /// + /// + /// + /// + /// + private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code, string OrderForm) + { + int IsAllowWork; + int RepairPartStatusPLC = 0; + + if (EngineTypeID <= 0 || EngineID.Length == 0 || EngineType.Length == 0) + { + string msg = "【" + OpName + "】" + "PLC传递机型为空!"; + MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg); + SendMessageFun.AsyncSendMessage_Notice(OpName, msg); + return; + } + + //电子看板_装配零件_临时表_增加_北汽 + //第二步,将零件信息转移到零件_临时表中 + MisDataFun.MesServer_Process_EngineTypeOverBQ(OpName); + + //通知web显示 + //MIS_BASE.Read_PalletInfo(OpName, out MES_QualityMask);//合格标志 合格标志暂时改为即时响应式的 + MIS_BASE.Read_RepairStatus_PLC(OpName, out RepairPartStatusPLC);//返修标志 + //SendMessageFun.SendInfomation("QualityMask", Convert.ToString(MES_QualityMask), OpName);//显示合格标志 + SendMessageFun.SendInfomation("RepairPartStatusPLC", Convert.ToString(RepairPartStatusPLC), OpName);//显示返修标志 + + //第四步,获取是否允许工作 + MisDataFun.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + //暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况 + if (IsAllowWork == 1) + { + MIS_BASE.Write_WorkStart(OpName, true); + MIS_BASE.Write_FixAllow(OpName, true); + MIS_BASE.Write_EngineTypeGetOver_PLC(OpName, true); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.FixAllow, "1"); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + SendMessageFun.SendMessage("1235", "1111", OpName); + } + + /// + /// 二次工作 + /// + /// + private void EngineTypeGetOver_PLC_Work_two(string OpName) + { + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, Convert.ToInt32(PartPallet_Code), OrderForm); + + } + /// + /// 跳过二次工作 + /// + /// + private void EngineTypeGetOver_PLC_Work_Skip(string OpName) + { + //MIS_BASE.Write_MesReadOver(OpName, true); + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + + /// + /// 返修件需要工作 + /// + /// 工位号 + private void IsNeedRepaire_OK(string OpName) + { + //string orderForm = ""; + //int engineTypeID; + //string engineType = ""; + //string engineID = ""; + //string palletCode = ""; + //int isRepair; + //string repairCode = ""; + ////从监控系统中查询出本工位信息 + //MisDataFun.OpName_MIS_Moby_Select(OpName, + //out orderForm, out engineTypeID, out engineType, + //out engineID, out palletCode, out isRepair, out repairCode); + + //EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode), orderForm); + } + + /// + /// 更新待上料数量 + /// + /// + private void UpdateWait_NUM_PLC(object e) + { + } + } +} diff --git a/MisDataFunction/Function1053/Methods/vssver2.scc b/MisDataFunction/Function1053/Methods/vssver2.scc new file mode 100644 index 0000000..7782f6f Binary files /dev/null and b/MisDataFunction/Function1053/Methods/vssver2.scc differ diff --git a/MisDataFunction/Function1053/OpcServer/Barcode.cs b/MisDataFunction/Function1053/OpcServer/Barcode.cs new file mode 100644 index 0000000..24a7187 --- /dev/null +++ b/MisDataFunction/Function1053/OpcServer/Barcode.cs @@ -0,0 +1,79 @@ +using System; +using System.Data; +using System.Windows.Forms; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + ///1.扫描配送单号,用于接收物料,扫描单号的时候,将接收的物料信息显示在“物料拉动”Tab区域 + ///2.扫描料箱标签/看板卡,用于追溯物料批次信息 + ///3.扫描零件条码,根据零件图号进行防错 + ///第一步,判断条码类型,根据条码类型,执行对应的存储过程 + ///第二步,条码类型(将扫描的条码保存到对应的表中) + ///第三步,扫描完成之后给出允许工作信号 + /// 处理页面扫描条码 + /// + /// + /// + public void Barcode(object e) + { + + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string barcode = Convert.ToString(msgEvent.TagValue); + string AlarmStr = ""; + + int IsAllowWork; + bool IsSuccess = false; + + MisDataFun.PartMaterial_DM_Update(OpName, barcode, out IsSuccess); + if (!IsSuccess) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认!"); + return; + } + else + { + SendMessageFun.SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息 + } + + //获取是否允许工作 + MisDataFun.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + if (IsAllowWork == 1) + { + // 保存物料信息 + MisDataFun.Material_Insert(OpName, 1); + + SendMessageFun.SendMessage("24", "11", OpName); + + // 物料验证完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认!"); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:Barcode"); + } + + } + + } + + + } +} diff --git a/MisDataFunction/Function1053/OpcServer/EngineGetOver.cs b/MisDataFunction/Function1053/OpcServer/EngineGetOver.cs new file mode 100644 index 0000000..f46a8c4 --- /dev/null +++ b/MisDataFunction/Function1053/OpcServer/EngineGetOver.cs @@ -0,0 +1,72 @@ +using System; +using System.Data; +using System.Windows.Forms; +using System.Xml.Linq; +//using SystemFramework; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// PLC传递机型处理 + /// + /// + /// + private void EngineTypeGetOver_PLC(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + //int tagValue = Convert.ToInt32(msgEvent.TagValue); + if(msgEvent.TagValueUp.ToString() == "6") + { + MIS_BASE.Write_FixAllow(OpName, false); + string Program_No = ""; + MisDataFun.GetEngineType_Order(OpName, Program_No, out int EngineTypeID, out string EngineType, out string EngineID, out string OrderForm, out int isCheckOk, out int planCount, out int haveUplaodCount, out int remainingQuantity, out string msg2); + if (isCheckOk == 2) + { + string msg = "【" + OpName + "】" + msg2; + SendMessage.AsyncSendMessage_Notice(OpName, msg); + MyLog4Net.MyLogHelper.Error("PartLoad", msg); + return; + } + else + { + MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID); + MIS_BASE.Write_EngineType_MES(OpName, EngineType); + MIS_BASE.Write_EngineID_MES(OpName, EngineID); + MIS_BASE.Write_OrderForm_MES(OpName, OrderForm); + + MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.WorkStartIn, DateTime.Now.ToString()); + MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineTypeID, EngineTypeID.ToString()); + MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineType, EngineType); + MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineID, EngineID); + MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.OrderForm, OrderForm); + MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineTypeID_MES, EngineTypeID.ToString()); + MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineType_MES, EngineType); + MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.EngineID_MES, EngineID); + MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.OrderForm_MES, OrderForm); + + MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID); + MIS_BASE.Write_EngineType_MES(OpName, EngineType); + MIS_BASE.Write_EngineID_MES(OpName, EngineID); + MIS_BASE.Write_OrderForm_MES(OpName, OrderForm); + + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, 0, OrderForm); + } + } + } + catch (Exception err) + { + // 保存出错日志 1.申请上线 2.传递机型 3.允许保存 4.扫码 + MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(System.Reflection.MethodBase.GetCurrentMethod().Name, e, "Fun1053", err); + ////ApplicationLog.WriteLog(err, "Function02:EngineTypeGetOver_PLC"); + } + } + + } +} diff --git a/MisDataFunction/Function1053/OpcServer/HeartBeat.cs b/MisDataFunction/Function1053/OpcServer/HeartBeat.cs new file mode 100644 index 0000000..b94f253 --- /dev/null +++ b/MisDataFunction/Function1053/OpcServer/HeartBeat.cs @@ -0,0 +1,34 @@ +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// MES与PLC心跳监听 + /// + /// + /// + private void HeartBeat(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //返写在MES心跳中 + MIS_BASE.WritePLC(15, OpName, tagValue); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1053/OpcServer/MesRead.cs b/MisDataFunction/Function1053/OpcServer/MesRead.cs new file mode 100644 index 0000000..af14ba5 --- /dev/null +++ b/MisDataFunction/Function1053/OpcServer/MesRead.cs @@ -0,0 +1,88 @@ +using MesServerWork; +using MesWork; +using MisDataFunDll; +using System; +using System.Data; +using System.Threading; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 允许保存(针对半自动和手动压装工位) + /// + /// + /// + private void MesRead(object e) + { + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + int EngineTypeID_MES;//机型代码 + string EngineType_MES;//机型 + string EngineID_MES;//工件编号 + string OrderForm_MES; + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.MesRead, "0"); + Thread.Sleep(500); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.MesRead, "1"); + if (tagValue == 1) + { + bool isEngineGetOver; + DataRow mobyData = MisDataFun.GetMobyTableByOpName(OpName).Rows[0]; + EngineTypeID_MES = Convert.ToInt32(mobyData["产品型号代码_MES"]); + EngineType_MES = mobyData["发动机型号_MES"].ToString(); + EngineID_MES = mobyData["变速器序列号_MES"].ToString(); + OrderForm_MES = mobyData["订单号_MES"].ToString(); + isEngineGetOver = Convert.ToBoolean(mobyData["允许工作"]); + + if (!isEngineGetOver) + { + string msg2 = "【" + OpName + "】" + "请先开始订单生产后再进行保存,当前未允许工作!"; + SendMessage.AsyncSendMessage_Notice(OpName, msg2); + return; + } + + // 存追溯表数据 + MisDataFun.WorkOrderOpWorkOver(OpName, EngineID_MES, OrderForm_MES); + + // 保存物料数据 + MisDataFun.Material_Insert(OpName, 1); + + // 测量数据发动机在线状态 + MisDataFun.WorkStartInsert(OpName, 1); + + //通知设备,MES的质量数据(和物料数据)保存完成 + //统计在线产量,在线节拍 + SendMessage.SendActuallyCount(OpName, tagValue); + + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.MesReadOver, "1"); + Thread.Sleep(1000 * 1); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.WorkStart, "0"); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.EngineTypeGetOverPLC, "0"); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.PartLoad, "0"); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.MesRead, "0"); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.MesReadOver, "0"); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.FixAllow, "0"); + + + string msg = "【" + OpName + "】" + "工件数据保存完成!"; + SendMessage.AsyncSendMessage_Notice(OpName, msg); + } + } + catch (Exception err) + { + // 保存出错日志 1.申请上线 2.传递机型 3.允许保存 4.扫码 + MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(System.Reflection.MethodBase.GetCurrentMethod().Name, e, "Fun1053", err); + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + + } + + } +} diff --git a/MisDataFunction/Function1053/OpcServer/PartLoad.cs b/MisDataFunction/Function1053/OpcServer/PartLoad.cs new file mode 100644 index 0000000..b51c56a --- /dev/null +++ b/MisDataFunction/Function1053/OpcServer/PartLoad.cs @@ -0,0 +1,55 @@ +using System; +using System.Threading; +//using SystemFramework; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 申请上线(针对上线工位) + /// + /// + /// + private void PartLoad(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + // 清空MOBY表中所有数据 + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.WorkStart, "0"); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.EngineTypeGetOverPLC, "0"); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.PartLoad, "0"); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.MesRead, "0"); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.MesReadOver, "0"); + MisDataFun.MobySendWebAndSaveData(OpName, MisDataFun.MobyTagType.FixAllow, "0"); + Thread.Sleep(500); + // 按照生产排序顺序获取订单相关数据 + // 获取到数据 显示 申请上线、传递机型、允许工作三个点位 + // 显示对应物料信息、 + + if (tagValue == 1) + { + + } + else + { + ////上线工位清MES传递机型信号 + //MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + //// 清除报警 + } + } + catch (Exception err) + { + // 保存出错日志 1.申请上线 2.传递机型 3.允许保存 4.扫码 + MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(System.Reflection.MethodBase.GetCurrentMethod().Name, e, "Fun1053", err); + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + } +} diff --git a/MisDataFunction/Function1053/OpcServer/WebSubmit.cs b/MisDataFunction/Function1053/OpcServer/WebSubmit.cs new file mode 100644 index 0000000..242f6fa --- /dev/null +++ b/MisDataFunction/Function1053/OpcServer/WebSubmit.cs @@ -0,0 +1,336 @@ +using System; +using MesServerWork; +using System.Threading; +using MisDataSaveDate; +using System.Collections; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + private void WebSubmit(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName=Convert.ToString(msgEvent.OpName); + string Content = Convert.ToString(msgEvent.TagValue); + + string[] dataArray = Content.Split('|'); + if (dataArray.Length != 2) + return; + //消息类型 + string m_Command = dataArray[0].ToString(); + //消息参数 + string m_Value = dataArray[1].ToString(); + //消息参数数量 + string[] m_Value_array = m_Value.Split('&'); + //消息参数长度 + int m_Value_length = m_Value_array.Length; + + //工件信息 + string engineID = ""; + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + return; + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + engineID = MIS_BASE.hashtable_EngineGetOver_EngineID[OpName].ToString(); + } + + DeviceDriver_BasicData.CustomeEvetnArgs _e = new DeviceDriver_BasicData.CustomeEvetnArgs(); + _e.OpName = OpName; + _e.TagValue = m_Value; + + //根据请求的命令处理逻辑 + switch (m_Command) + { + case "Barcode": + if (m_Value_length > 1) return; + fun_Barcode(_e); + break; + case "OnLineState"://在线0、离线1、屏蔽2 + try + { + if (m_Value_length > 1) return; + int a = Convert.ToInt32(m_Value); + if (a <= 2) + { + //BaseDataSystemMES.IsOnLine_Update(OpName, m_Value.ToString()); + MIS_BASE.Write_OnLineState(OpName, Convert.ToInt32(m_Value)); + if (a == 2) SendMessage.AsyncSendMessage_Notice(OpName, "屏蔽MES!"); + if (a == 0) SendMessage.AsyncSendMessage_Notice(OpName, "启用MES!"); + } + } + catch + { + + } + break; + case "Reset"://复位,将MES所有的信息都复位了 + SetMoby(OpName);//将MES所有信号清空 + break; + case "FixAllow"://重新拧紧 + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_FixAllow(OpName, true); + break; + case "IsAutoGetEngineID"://自动手动申请编号(线首) + if (m_Value_length > 1) return; + MIS_BASE.Write_IsAutoGetEngineID(OpName, Convert.ToInt32(m_Value)); + break; + case "PartPalletGoOver"://空托盘放行 + int Is_PartPalletGoOver; + MIS_BASE.Read_PartPalletGoOver(OpName, out Is_PartPalletGoOver); + if (Is_PartPalletGoOver == 1) + { + MIS_BASE.Write_PartPalletGoOver(OpName, 1); + } + else + { + MIS_BASE.Write_PartPalletGoOver(OpName,0); + } + break; + case "SetMoby"://清空托盘(线首) + SetMoby(OpName);//将MES所有信号清空 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "RepairUplineMES"://返修上线 + MIS_BASE.Write_RepairUpline_MES(OpName, true); + break; + case "CancelRepair"://将返修件置为正常件 + + break; + case "PartPalletCode"://申请写入托盘号 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "WritePartPalletCode"://写入托盘号 + if (m_Value_length > 1) return; + MIS_BASE.Write_PalletCode(OpName, Convert.ToInt32(m_Value)); + break; + case "Normal"://启用正常拧紧工位 + MIS_BASE.Write_Normal(OpName, 1); + MIS_BASE.Write_UnNormal(OpName, 0); + break; + case "UnNormal"://启用备用拧紧工位 + MIS_BASE.Write_Normal(OpName, 0); + MIS_BASE.Write_UnNormal(OpName, 1); + break; + case "ResetDevice"://复位设备 + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + break; + case "IsNeedRepaire"://返修上线(返修上线点) + if (Convert.ToInt32(m_Value) == 1) + { + //修改托盘状态 + MIS_BASE.Write_PalletInfo(OpName, 3); + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + IsNeedRepaire_OK(OpName); + + } + else if (Convert.ToInt32(m_Value) == 0) + { + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + else + { } + + break; + case "ContinueMatch": + //BaseDataSystemMES.QualityVerifyStatus_Hash_Write(OpName, true); + break; + //初始化网页信号 + case "IniSingalToWeb": + InitializeSingalToWeb(OpName); + break; + case "Reset_Engine"://返修上线(返修上线点) + SetMoby(OpName);//将MES所有信号清空 + //fun_EngineTypeGetOverPLC(OpName, 0); + //fun_EngineTypeGetOverPLC(OpName, 1); + break; + + case "twoWorkSkip"://重新工作工件跳过工作(重新工作工件) + //工作完成 + EngineTypeGetOver_PLC_Work_Skip(OpName); + break; + case "twoWork"://重新工作工件重新工作(重新工作工件) + //允许工作 + EngineTypeGetOver_PLC_Work_two(OpName); + break; + case "SelectOrderForm"://分线接受前端模拟传递机型 + _e.TagValueUp = "6"; + EngineTypeGetOver_PLC(_e); + break; + case "outLineOpNameWorkOver"://分线接受前端模拟工作完成 + _e.TagValueUp = "6"; + _e.TagValue = 1; + MesRead(_e); + break; + default: break; + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WebSubmit"); + } + } + private void SetMoby(string OpName) + { + try + { + //清空Moby时,需要将MES信号清空 + MIS_BASE.Write_ClearMesMoby(OpName); + + //BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName); + + SendMessageFun.SendMessage("5123", "1111", OpName); + + + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + } + catch + { + + } + } + /// + /// 网页重现登录,恢复关闭前的页面状态 + /// + /// 工位号 + private void InitializeSingalToWeb(string OpName) + { + InitOpPosion(OpName); + + ////3显示操作指导图片 PicShow_String_FirstOpName + //SendMessage.PicShow_FirstOpName(OpOpNamename); + ////1(直接在界面通过选择机型确认工序内容) + //SendMessage.ProcessList_FirstOpName(OpName); + //// MOBY数据 + //SendMessageFun.SendMessage("5", "1", OpName); + //// 物料信息 物料信息 + //SendMessage.MaterialList(OpName); + + SendMessageFun.SendMessage("315", "111", OpName); + + // 新增查询PLC直通状态 网页显示 + //MIS_BASE.Read_TagTypeID(63, Opname, out S_plcStatus); + InitAlarm(OpName); + } + + //分线发送工件到位信号函数 + private void sendmessage(string OpName, int tagValue, string Command) + { + string SendMessage; + SendMessage = "MES|" + Command + "|" + OpName + "|" + tagValue; + SendMessageFun.AsyncSendMessage(SendMessage); + + } + private void InitAlarm(string Opname) + { + FuntionMesRead.Alarm_InitAlarm_Send(Opname, out Hashtable ht); + foreach (DictionaryEntry kv in ht) + { + var TagID = kv.Key.ToString(); + var TagValue = kv.Value.ToString(); + FuntionMesRead.Send_AlarmMsg(TagID, TagValue); + } + + } + + private void InitOpPosion(string Opname) + { + int S_WorkCheckOver = Convert.ToInt32(MIS_BASE.ReadPLC(30, Opname)); + string S_WorkCheckOver_Msg = "MES|checkWorkOverIsShow|" + Opname + "|" + S_WorkCheckOver; + SendMessage.AsyncSendMessage(S_WorkCheckOver_Msg); + + bool S_WorkStart;//工件到位 DBX0.1 + MIS_BASE.Read_WorkStart(Opname, out S_WorkStart); + if (S_WorkStart == true) + { + SendMessageFun.SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname); + } + //---------------------------------------------------- + bool S_PartLoad;//申请上线 + MIS_BASE.Read_PartLoad(Opname, out S_PartLoad); + if (S_PartLoad == true) + { + SendMessageFun.SendInfomation("PartLoad", Convert.ToString(Convert.ToInt32(S_PartLoad)), Opname); + } + //---------------------------------------------------- + bool S_EngineGetOver;//传递机型 DBX0.4 + MIS_BASE.Read_EngineGetOver_PLC(Opname, out S_EngineGetOver); + if (S_EngineGetOver == true) + { + SendMessageFun.SendInfomation("EngineTypeGetOverPLC", Convert.ToString(Convert.ToInt32(S_EngineGetOver)), Opname); + + //5 显示订单、机型信息 线首工位用 + SendMessage.ShowMoby_FirstOpName(Opname); + //界面显示物料信息 + SendMessage.MaterialList_FirstOpName(Opname); + } + //---------------------------------------------------- + bool S_FixAllow;//允许工作 DBX3.1 + MIS_BASE.Read_FixAllow(Opname, out S_FixAllow); + if (S_FixAllow == true) + { + SendMessageFun.SendInfomation("FixAllow", Convert.ToString(Convert.ToInt32(S_FixAllow)), Opname); + } + //---------------------------------------------------- + bool S_MesRead;//允许保存 DBX3.1 + MIS_BASE.Read_QualityData_Read_CF(Opname, out S_MesRead); + if (S_MesRead == true) + { + SendMessageFun.SendInfomation("MesRead", Convert.ToString(Convert.ToInt32(S_MesRead)), Opname); + } + //---------------------------------------------------- + bool S_ReadOver;//保存完成 + MIS_BASE.Read_MesReadOver(Opname, out S_ReadOver); + if (S_ReadOver == true) + { + SendMessageFun.SendInfomation("MesReadOver", Convert.ToString(Convert.ToInt32(S_ReadOver)), Opname); + } + //---------------------------------------------------- + bool S_MaterialVerifyOver;//工作完成 DBX2.3 + MIS_BASE.Read_MaterialVerifyOver(Opname, out S_MaterialVerifyOver); + if (S_MaterialVerifyOver == true) + { + SendMessageFun.SendInfomation("MaterialVerifyOver", Convert.ToString(Convert.ToInt32(S_MaterialVerifyOver)), Opname); + } + //---------------------------------------------------- + int S_QualityMask;//合格标志 DBX588 + MIS_BASE.Read_QualityMask(Opname, out S_QualityMask); + if (S_QualityMask == 1) + { + SendMessageFun.SendInfomation("QualityMask", Convert.ToString(Convert.ToInt32(S_QualityMask)), Opname); + } + //---------------------------------------------------- + string S_plcStatus = "false";//DBX501.5 PLC直通,1 强制放行 0 正常循环 + if (S_plcStatus.ToLower() == "false") + { + SendMessageFun.SendInfomation("PlcStatus", "0", Opname); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", Opname); + } + } + } +} diff --git a/MisDataFunction/Function1053/OpcServer/WorkIsOk.cs b/MisDataFunction/Function1053/OpcServer/WorkIsOk.cs new file mode 100644 index 0000000..3149bce --- /dev/null +++ b/MisDataFunction/Function1053/OpcServer/WorkIsOk.cs @@ -0,0 +1,44 @@ +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工位合格标志 + /// + /// + /// + private void IsOk(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + int qualityMask; + MIS_BASE.Read_QualityMask(OpName, out qualityMask); + //判断是否合格 + if (qualityMask == 1) + { + qualityMask = 1; + } else { + qualityMask = 0; + } + //通知WEB修改状态 + string message = "MES|QualityMask|" + OpName + "|" + qualityMask.ToString(); + SendMessage.AsyncSendMessage(message); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1053/OpcServer/WorkStart.cs b/MisDataFunction/Function1053/OpcServer/WorkStart.cs new file mode 100644 index 0000000..c634017 --- /dev/null +++ b/MisDataFunction/Function1053/OpcServer/WorkStart.cs @@ -0,0 +1,49 @@ +using MesServerWork; +using System; +using System.Threading; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工件到位与离开时,清空MES自身信号 + /// + /// + /// + private void WorkStart(object e) + { + try + { + DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + //if (tagValue > 0) + //{ + // MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.WorkStartIn, DateTime.Now.ToString()); + // MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.WorkStart, tagValue.ToString()); + //} + //else + //{ + // MisDataFun.OpName_MIS_MOBY_Insert(OpName,MisDataFun.MobyTagType.WorkStartOut, DateTime.Now.ToString()); + // MIS_BASE.Write_MesReadOver(OpName, false); + // MIS_BASE.Write_ConfirmOkGo(OpName, false); + // MIS_BASE.Write_FixAllow(OpName, false); + // MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + // //工作完成 + // MIS_BASE.Write_MaterialVerifyOver(OpName, false); + // MIS_BASE.Write_EngineTypeID_MES(OpName, 0); + // MIS_BASE.Write_EngineType_MES(OpName, ""); + // MIS_BASE.Write_EngineID_MES(OpName, ""); + // MIS_BASE.Write_OrderForm_MES(OpName, ""); + //} + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WorkStart"); + } + } + + } +} diff --git a/MisDataFunction/Function1053/OpcServer/vssver2.scc b/MisDataFunction/Function1053/OpcServer/vssver2.scc new file mode 100644 index 0000000..b884d13 Binary files /dev/null and b/MisDataFunction/Function1053/OpcServer/vssver2.scc differ diff --git a/MisDataFunction/Function1053/Properties/AssemblyInfo.cs b/MisDataFunction/Function1053/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0bb79c4 --- /dev/null +++ b/MisDataFunction/Function1053/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Function02")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("苏州宏软信息技术有限公司")] +[assembly: AssemblyProduct("Function02")] +[assembly: AssemblyCopyright("Copyright © 苏州宏软信息技术有限公司 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("47710f2c-e141-4252-8d13-701bf4c1c027")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MisDataFunction/Function1053/Properties/vssver2.scc b/MisDataFunction/Function1053/Properties/vssver2.scc new file mode 100644 index 0000000..14e543b Binary files /dev/null and b/MisDataFunction/Function1053/Properties/vssver2.scc differ diff --git a/MisDataFunction/Function1053/mssccprj.scc b/MisDataFunction/Function1053/mssccprj.scc new file mode 100644 index 0000000..119193d --- /dev/null +++ b/MisDataFunction/Function1053/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[Function02.csproj] +SCC_Aux_Path = "\\192.168.0.100\vss\MES4.0" +SCC_Project_Name = "$/MisData/MisData/MisData/MesServer.Function/Function02", ILHAAAAA diff --git a/MisDataFunction/Function1053/packages.config b/MisDataFunction/Function1053/packages.config new file mode 100644 index 0000000..b3e1761 --- /dev/null +++ b/MisDataFunction/Function1053/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1053/vssver2.scc b/MisDataFunction/Function1053/vssver2.scc new file mode 100644 index 0000000..c770e28 Binary files /dev/null and b/MisDataFunction/Function1053/vssver2.scc differ diff --git a/MisDataFunction/Function1054/DataAccess/DataAccess.cs b/MisDataFunction/Function1054/DataAccess/DataAccess.cs new file mode 100644 index 0000000..574d619 --- /dev/null +++ b/MisDataFunction/Function1054/DataAccess/DataAccess.cs @@ -0,0 +1,15 @@ + +namespace MesServerFunctions +{ + partial class Function1052 + { + //针对“MIS.BizFacade.Dll”中没有的存储过程,在此类中新建 + //新建原则:所有的函数用private,只允许在内部使用 + //针对单个工艺特殊,需要新建存储过程,但是存储过程不能被加入到“MIS.BizFacade.Dll”中 + + private void aa() + { + + } + } +} diff --git a/MisDataFunction/Function1054/DataAccess/vssver2.scc b/MisDataFunction/Function1054/DataAccess/vssver2.scc new file mode 100644 index 0000000..d045c26 Binary files /dev/null and b/MisDataFunction/Function1054/DataAccess/vssver2.scc differ diff --git a/MisDataFunction/Function1054/Db.cs b/MisDataFunction/Function1054/Db.cs new file mode 100644 index 0000000..1190bb0 --- /dev/null +++ b/MisDataFunction/Function1054/Db.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + public class Db + { + + } +} diff --git a/MisDataFunction/Function1054/Function02.csproj.vspscc b/MisDataFunction/Function1054/Function02.csproj.vspscc new file mode 100644 index 0000000..0f0f36c --- /dev/null +++ b/MisDataFunction/Function1054/Function02.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:MesServer.Function\\Function02" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/MisDataFunction/Function1054/Function1054.csproj b/MisDataFunction/Function1054/Function1054.csproj new file mode 100644 index 0000000..e4bcfac --- /dev/null +++ b/MisDataFunction/Function1054/Function1054.csproj @@ -0,0 +1,167 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {CC45D613-11B9-48AF-B073-6523D6273525} + Library + Properties + Function1054 + Function1054 + v4.8 + 512 + + + + + + + + + + + + + + true + full + false + ..\..\MisDataFun_Exe\ + DEBUG;TRACE + prompt + 4 + false + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + ..\..\dll_common\MesWork.DeviceDriver.dll + + + ..\..\..\Common\dll\MQTTnet.dll + + + ..\..\..\Common\dll\MQTTnet.Extensions.ManagedClient.dll + + + False + ..\..\dll_common\Newtonsoft.Json.dll + + + + + + + ..\..\DLL\System.Net.Http.dll + + + ..\..\packages\System.Net.Security.4.3.2\lib\net46\System.Net.Security.dll + + + ..\..\packages\System.Net.WebSockets.4.3.0\lib\net46\System.Net.WebSockets.dll + + + ..\..\packages\System.Net.WebSockets.Client.4.3.2\lib\net46\System.Net.WebSockets.Client.dll + + + ..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll + + + ..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + + + + + + + + + + + + + + + + + + + + + + {f55da1a0-a982-4479-8c47-0d9a5aaf3e18} + 00MesWorkMqtt + + + {0d1af432-439a-4920-8692-43ae139f5530} + 01_01DoWhatPlc + + + {3e6d1dd5-01c9-435f-9941-61f906ce35bb} + 02_02WebApiCallPLC + + + {f434e066-4c59-47c8-aa82-6f48cc84501a} + 04-DataBaseAccess + + + {f0a0c525-03fd-428a-9b17-7f54aa0e4475} + 07BusinessFacade + + + {d98be764-adeb-488d-9714-61e308aa8201} + 08-WebFun_base + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 09-MesDataFunction + + + {1dc48c83-1842-4de8-acaf-26e1e7f7c58f} + 00_MyLog4Net + + + {e4eb6420-906d-4672-947a-ca33ddcdadfc} + 12SendMessageToWeb + + + {55b510c1-59e9-4bfd-ae84-d76d46f6e365} + 02-13.3MIS_FuntionSaveData + + + + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1054/MesServerFunction/Fun_1054.cs b/MisDataFunction/Function1054/MesServerFunction/Fun_1054.cs new file mode 100644 index 0000000..b133096 --- /dev/null +++ b/MisDataFunction/Function1054/MesServerFunction/Fun_1054.cs @@ -0,0 +1,235 @@ +using MesServerWork; +using MisDataFunDll; +using System.Collections.Generic; +using System.Threading; +using System.Xml.Linq; + +namespace MesServerFunctions +{ + public partial class FunctionMES + { + object lockFunWork; + //public void FunWork(DeviceDriver_BasicData.CustomeEvetnArgs e) + public void FunWork(string recData) + { + + + lockFunWork = new object(); + lock (lockFunWork) + { + List dataArray = MisDataFun.GetCmdStringList(recData); + //string[] dataArray = recData.Split('|'); + //if (dataArray.Count != 4) + //return; + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 Barcode + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + DeviceDriver_BasicData.CustomeEvetnArgs e = new DeviceDriver_BasicData.CustomeEvetnArgs();// = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string tagValue; + + switch (m_Source) + { + case "PLC": + e = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + switch (e.TagValue.ToString().ToLower()) + { + case "false": + tagValue = "0"; + break; + case "true": + tagValue = "1"; + break; + default: + tagValue = e.TagValue.ToString(); + break; + } + e.TagValue = tagValue; + switch (e.TagTypeCodeID.ToString()) + { + // AGV相关变量类型代码处理说明: + // 301:AGV请求进入 + // 302:AGV器具放置完毕 + // 303:AGV退出光栅 + // 304:送料信息验证完成 + // 305:送料信息验证结果 + // 305:任务发送状态 0 没有 1 发送 2 失败 + // 311:请求叫料 + // 312:请求退空 + // 313:请求退料 + // 314:允许AGV进入 + // 315:允许AGV离开 + // 316:器具码扫描完毕 + // 317:退回并重新配送 + // 318:器具号 + // 319:请求上料机型 + // 320:收到状态反馈点 + // 321:转序 + // 322:下空托盘 + // 323:上空托盘 + // 324:点对点 + + // 请求叫料 + case "311": + fun_CallMaterials(e); + break; + // 请求退空 + case "312": + fun_RequestReturns(e); + break; + // 请求退料 + case "313": + fun_RequestReturnMaterial(e); + break; + // 允许AGV进入 + case "314": + fun_AllowAGVEnter(e); + break; + // 允许AGV离开 + case "315": + fun_AllowAGVLeave(e); + break; + // 器具码扫描完毕 + case "316": + fun_ToolCodeScanOver(e); + break; + // 退回并重新配送 + case "317": + fun_ReturnAndRedispatch(e); + break; + // 收到任务状态握手 + case "320": + //MIS_BASE.WritePLC(306, m_OpName, 0); + break; + // 转序 + case "321": + fun_TransferSequence(e); + break; + // 下空托盘 + case "322": + fun_UnloadEmptyTray(e); + break; + // 上空托盘 + case "323": + fun_LoadEmptyTray(e); + break; + // 点对点 + case "324": + fun_PointToPoint(e); + break; + } + break; + } + } + } + + // 叫料流程 + // 1.请求叫料 收到请求叫料后 调用叫料接口 后续收到AGV的 + // 2.收到工厂 请求进入接口(工厂未开发 跳过) 发给PLC AGV请求进入 + // 3.收到允许AGV进入 调用接口(未开发 跳过) 允许进入 + // 4.收到 器具码扫码完成 根据318器具号 调用器具号查询接口 得出校验结果 + // 5.若器具码校验通过 调用 确认物料配送接口 调用成功后 给PLC发送 送料信息验证结果(1 合格 2 不合格) 和 送料信息验证完成 + // 6.收到AGV请求离开接口后(未开发 跳过) 发送给PLC请求离开点位 + // 7.收到PLC允许离开信号后 调用AGV允许离开接口(未开发 跳过) + + // 退空托流程 + // 1.收到请求退空 调用退空托接口 + // 2.如叫料AGV请求进入 请求离开。。。。 只不过不需要扫描器具码部分 + + + // AGV相关方法声明(PLC触发的信号) + /// + /// 请求叫料 + /// + public void fun_CallMaterials(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(CallMaterials, e); + } + + /// + /// 请求退空 + /// + public void fun_RequestReturns(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(RequestReturns, e); + } + + /// + /// 请求退料 + /// + public void fun_RequestReturnMaterial(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(RequestReturnMaterial, e); + } + + /// + /// 允许AGV进入 + /// + public void fun_AllowAGVEnter(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(AllowAGVEnter, e); + } + + /// + /// 允许AGV离开 + /// + public void fun_AllowAGVLeave(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(AllowAGVLeave, e); + } + + /// + /// 器具码扫描完毕 + /// + public void fun_ToolCodeScanOver(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(ToolCodeScanOver, e); + } + + /// + /// 退回并重新配送 + /// + public void fun_ReturnAndRedispatch(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(ReturnAndRedispatch, e); + } + + /// + /// 转序 + /// + public void fun_TransferSequence(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(TransferSequence, e); + } + + /// + /// 下空托盘 + /// + public void fun_UnloadEmptyTray(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(UnloadEmptyTray, e); + } + + /// + /// 上空托盘 + /// + public void fun_LoadEmptyTray(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(LoadEmptyTray, e); + } + + /// + /// 点对点 + /// + public void fun_PointToPoint(DeviceDriver_BasicData.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(PointToPoint, e); + } + + } +} diff --git a/MisDataFunction/Function1054/MesServerFunction/vssver2.scc b/MisDataFunction/Function1054/MesServerFunction/vssver2.scc new file mode 100644 index 0000000..a246f67 Binary files /dev/null and b/MisDataFunction/Function1054/MesServerFunction/vssver2.scc differ diff --git a/MisDataFunction/Function1054/Methods/EngineGetOverBaseWork.cs b/MisDataFunction/Function1054/Methods/EngineGetOverBaseWork.cs new file mode 100644 index 0000000..3d43608 --- /dev/null +++ b/MisDataFunction/Function1054/Methods/EngineGetOverBaseWork.cs @@ -0,0 +1,177 @@ +using System; +using System.Data; +using MesServerWork; +using MisDataFunDll; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 正常逻辑工作(传递机型) + /// + /// + /// + /// + /// + /// + private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code, string OrderForm) + { + //int IsAllowWork; + //int RepairPartStatusPLC = 0; + //int MES_QualityMask = 1; + + + + ////电子看板_装配零件_临时表_增加_北汽 + ////第二步,将零件信息转移到零件_临时表中 + //BaseDataSystemMES.MesServer_Process_EngineTypeOverBQ(OpName); + + ////通知web显示 + //SendMessageFun.SendMessage("123", "111", OpName); + ////MIS_BASE.Read_PalletInfo(OpName, out MES_QualityMask);//合格标志 合格标志暂时改为即时响应式的 + ////MIS_BASE.Read_RepairStatus_PLC(OpName, out RepairPartStatusPLC);//返修标志 + ////SendMessageFun.SendInfomation("QualityMask", Convert.ToString(MES_QualityMask), OpName);//显示合格标志 + ////SendMessageFun.SendInfomation("RepairPartStatusPLC", Convert.ToString(RepairPartStatusPLC), OpName);//显示返修标志 + //MIS_BASE.Read_TagTypeID(201, OpName, out string EngineTypeID_QiaoKe); + + //Db.OP50_OPA90_MatchResult(EngineTypeID, Convert.ToInt32(EngineTypeID_QiaoKe), EngineID, OrderForm, out int MatchResult, out string MatchResultStr); + //if (MatchResult == 1) + //{ + // // 轮毂线 + // MIS_BASE.Write_Match(OpName, true);// 匹配结果 + // MIS_BASE.Write_MatchingCompleted(OpName, true);// 匹配完成 + // MIS_BASE.Write_FixAllow(OpName, true); // 允许工作 + // return; + //} + //else if (MatchResult == 2) // 分等待状态 与 报警状态 等待的话就等A60 工作完成时判断清除等待 写入A90 的匹配结果 匹配完成 允许工作 + //{ + // MIS_BASE.WritePLC(29, OpName, true); // 开始等待 通知A60 保存完成时更新下等待状态与匹配状态 + // return; + //} + //else + //{ + // // 将根据轮毂号 工位号 时间 报错内容 存储到数据库中供查询 + // BaseDataSystemMES.HeLi_OoNameAlarmRecord_Add(OpName, EngineID, MatchResultStr); + // // 匹配结果不成功 + // MIS_BASE.Write_Match(OpName, false);// 匹配结果 + // MIS_BASE.Write_MatchingCompleted(OpName, true);// 匹配完成 + // return; + //} + + + + + + //// 判断分线是否 传递机型 + //if (EngineGetOver_SubLine) + //{ + // string EngineTypeID_MainLine; + // int EngineTypeID_MainLineQiaoKe; + // // 读取主线桥壳机型 + // MIS_BASE.Read_EngineTypeID(OpName_MainLine, out EngineTypeID_MainLineQiaoKe); + // // 读取分线存储的桥壳机型 + // MIS_BASE.Read_TagTypeID(38, OpName_SubLine, out EngineTypeID_MainLine); + + // if (Convert.ToInt32(EngineTypeID_MainLine) == EngineTypeID) + // { + // Db.OP50_OPA90_MatchResult(EngineTypeID, Convert.ToInt32(EngineTypeID_MainLine), EngineTypeID_MainLineQiaoKe, out int MatchResult); + + // if (MatchResult == 0) // 不匹配 + // { + // // 主线 + // MIS_BASE.Write_Match(OpName_MainLine, false);// 匹配结果 + // MIS_BASE.Write_MatchingCompleted(OpName_MainLine, false);// 匹配完成 + // MIS_BASE.Write_FixAllow(OpName_MainLine, false); // 允许工作 + // // 分线 + // MIS_BASE.Write_Match(OpName_SubLine, false);// 匹配结果 + // MIS_BASE.Write_MatchingCompleted(OpName_SubLine, false);// 匹配完成 + // MIS_BASE.Write_FixAllow(OpName_SubLine, false); // 允许工作 + + // // 写入分线 等待 0 + // MIS_BASE.WritePLC(29, OpName_SubLine, "0"); + // } + // if (MatchResult == 1) // 允许抓 + // { + // // 主线 + // MIS_BASE.Write_Match(OpName_MainLine, true);// 匹配结果 + // MIS_BASE.Write_MatchingCompleted(OpName_MainLine, true);// 匹配完成 + // // 分线 + // MIS_BASE.Write_Match(OpName_SubLine, true);// 匹配结果 + // MIS_BASE.Write_MatchingCompleted(OpName_SubLine, true);// 匹配完成 + // MIS_BASE.Write_FixAllow(OpName_MainLine, true); // 允许工作 + + // // 写入分线 等待 0 + // MIS_BASE.WritePLC(29, OpName_SubLine, "0"); + // } + // if (MatchResult == 2) // 等待 + // { + // // 写入分线 等待 1 + // MIS_BASE.WritePLC(29, OpName_SubLine, "1"); + // } + // } + // else // 不匹配 + // { + // // 主线 + // MIS_BASE.Write_Match(OpName_MainLine, false);// 匹配结果 + // MIS_BASE.Write_MatchingCompleted(OpName_MainLine, false);// 匹配完成 + // MIS_BASE.Write_FixAllow(OpName_MainLine, false); // 允许工作 + // // 分线 + // MIS_BASE.Write_Match(OpName_SubLine, false);// 匹配结果 + // MIS_BASE.Write_MatchingCompleted(OpName_SubLine, false);// 匹配完成 + // MIS_BASE.Write_FixAllow(OpName_SubLine, false); // 允许工作 + + // // 写入分线 等待 0 + // MIS_BASE.WritePLC(29, OpName_SubLine, "0"); + // } + //} + } + + /// + /// 二次工作 + /// + /// + private void EngineTypeGetOver_PLC_Work_two(string OpName) + { + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, Convert.ToInt32(PartPallet_Code), OrderForm); + + } + /// + /// 跳过二次工作 + /// + /// + private void EngineTypeGetOver_PLC_Work_Skip(string OpName) + { + MIS_BASE.Write_MesReadOver(OpName, true); + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + + /// + /// 返修件需要工作 + /// + /// 工位号 + private void IsNeedRepaire_OK(string OpName) + { + string orderForm = ""; + int engineTypeID; + string engineType = ""; + string engineID = ""; + string palletCode = ""; + int isRepair; + string repairCode = ""; + //从监控系统中查询出本工位信息 + //MisDataFun.OpName_MIS_Moby_Select(OpName, + //out orderForm, out engineTypeID, out engineType, + //out engineID, out palletCode, out isRepair, out repairCode); + + //EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode), orderForm); + } + } +} diff --git a/MisDataFunction/Function1054/Methods/vssver2.scc b/MisDataFunction/Function1054/Methods/vssver2.scc new file mode 100644 index 0000000..7782f6f Binary files /dev/null and b/MisDataFunction/Function1054/Methods/vssver2.scc differ diff --git a/MisDataFunction/Function1054/OpcServer/vssver2.scc b/MisDataFunction/Function1054/OpcServer/vssver2.scc new file mode 100644 index 0000000..b884d13 Binary files /dev/null and b/MisDataFunction/Function1054/OpcServer/vssver2.scc differ diff --git a/MisDataFunction/Function1054/Properties/AssemblyInfo.cs b/MisDataFunction/Function1054/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0bb79c4 --- /dev/null +++ b/MisDataFunction/Function1054/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Function02")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("苏州宏软信息技术有限公司")] +[assembly: AssemblyProduct("Function02")] +[assembly: AssemblyCopyright("Copyright © 苏州宏软信息技术有限公司 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("47710f2c-e141-4252-8d13-701bf4c1c027")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MisDataFunction/Function1054/Properties/vssver2.scc b/MisDataFunction/Function1054/Properties/vssver2.scc new file mode 100644 index 0000000..14e543b Binary files /dev/null and b/MisDataFunction/Function1054/Properties/vssver2.scc differ diff --git a/MisDataFunction/Function1054/mssccprj.scc b/MisDataFunction/Function1054/mssccprj.scc new file mode 100644 index 0000000..119193d --- /dev/null +++ b/MisDataFunction/Function1054/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[Function02.csproj] +SCC_Aux_Path = "\\192.168.0.100\vss\MES4.0" +SCC_Project_Name = "$/MisData/MisData/MisData/MesServer.Function/Function02", ILHAAAAA diff --git a/MisDataFunction/Function1054/packages.config b/MisDataFunction/Function1054/packages.config new file mode 100644 index 0000000..b3e1761 --- /dev/null +++ b/MisDataFunction/Function1054/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1054/vssver2.scc b/MisDataFunction/Function1054/vssver2.scc new file mode 100644 index 0000000..c770e28 Binary files /dev/null and b/MisDataFunction/Function1054/vssver2.scc differ diff --git a/MisDataFunction/Function1055/DataAccess/DataAccess.cs b/MisDataFunction/Function1055/DataAccess/DataAccess.cs new file mode 100644 index 0000000..68cdca4 --- /dev/null +++ b/MisDataFunction/Function1055/DataAccess/DataAccess.cs @@ -0,0 +1,15 @@ + +namespace MesServerFunctions +{ + partial class FunctionMES + { + //针对“MIS.BizFacade.Dll”中没有的存储过程,在此类中新建 + //新建原则:所有的函数用private,只允许在内部使用 + //针对单个工艺特殊,需要新建存储过程,但是存储过程不能被加入到“MIS.BizFacade.Dll”中 + + private void aa() + { + + } + } +} diff --git a/MisDataFunction/Function1055/DataAccess/vssver2.scc b/MisDataFunction/Function1055/DataAccess/vssver2.scc new file mode 100644 index 0000000..d045c26 Binary files /dev/null and b/MisDataFunction/Function1055/DataAccess/vssver2.scc differ diff --git a/MisDataFunction/Function1055/Db.cs b/MisDataFunction/Function1055/Db.cs new file mode 100644 index 0000000..03abc44 --- /dev/null +++ b/MisDataFunction/Function1055/Db.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DataLinkMesWork; +using System.Net.NetworkInformation; + +namespace MesServerFunctions +{ + public class Db + { + public static bool OP051_OP050_NeedWork(string EngineID, string opName,string orderForm, out int MatchResult) + { + DataTable dt = new DataTable(); + MatchResult = 0; + string produceName = "合力_OP050前停判断_下工位是否需要工作"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@桥壳总成号", EngineID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@订单号", orderForm); + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt)) + { + if (dt.Rows.Count > 0) + { + MatchResult = Convert.ToInt32(dt.Rows[0]["是否需要工作"]); + return true; + } + } + return false; + } + public static bool OP051_OP050_NeedWork_Save(string EngineID, int MatchResult) + { + + string produceName = "合力_OP050是否需要工作_插入"; + SqlParameter[] thisParms = new SqlParameter[2]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@桥壳总成号", EngineID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@是否需要工作", MatchResult); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + public static bool OPA90_TO_OP50_CheckTwoFinish(out int MainLineAllowWork) + { + DataTable dt; + MainLineAllowWork = 2; + string produceName = "合力_OP050是否允许工作_判断"; + SqlParameter[] thisParms = new SqlParameter[0]; + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt)) + { + if (dt.Rows.Count > 0) + { + MainLineAllowWork = Convert.ToInt32(dt.Rows[0]["是否允许工作"]); + return true; + } + } + return false; + } + } +} diff --git a/MisDataFunction/Function1055/Function02.csproj.vspscc b/MisDataFunction/Function1055/Function02.csproj.vspscc new file mode 100644 index 0000000..0f0f36c --- /dev/null +++ b/MisDataFunction/Function1055/Function02.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:MesServer.Function\\Function02" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/MisDataFunction/Function1055/Function1055.csproj b/MisDataFunction/Function1055/Function1055.csproj new file mode 100644 index 0000000..6ab4d10 --- /dev/null +++ b/MisDataFunction/Function1055/Function1055.csproj @@ -0,0 +1,169 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {86DF6A20-91FC-4B62-AABF-116F933E31AA} + Library + Properties + Function1055 + Function1055 + v4.8 + 512 + + + + + + + + + + + + + + true + full + false + ..\..\MisDataFun_Exe\ + DEBUG;TRACE + prompt + 4 + false + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + ..\..\..\Common\dll\MQTTnet.dll + + + ..\..\..\Common\dll\MQTTnet.Extensions.ManagedClient.dll + + + False + ..\..\..\Common\dll\Newtonsoft.Json.dll + + + + + + ..\..\DLL\System.Net.Http.dll + + + ..\..\packages\System.Net.Security.4.3.2\lib\net46\System.Net.Security.dll + + + ..\..\packages\System.Net.WebSockets.4.3.0\lib\net46\System.Net.WebSockets.dll + + + ..\..\packages\System.Net.WebSockets.Client.4.3.2\lib\net46\System.Net.WebSockets.Client.dll + + + ..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll + + + ..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {f55da1a0-a982-4479-8c47-0d9a5aaf3e18} + 00MesWorkMqtt + + + {0d1af432-439a-4920-8692-43ae139f5530} + 01_01DoWhatPlc + + + {3e6d1dd5-01c9-435f-9941-61f906ce35bb} + 02_02WebApiCallPLC + + + {f434e066-4c59-47c8-aa82-6f48cc84501a} + 04-DataBaseAccess + + + {f0a0c525-03fd-428a-9b17-7f54aa0e4475} + 07BusinessFacade + + + {d98be764-adeb-488d-9714-61e308aa8201} + 08-WebFun_base + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 09-MesDataFunction + + + {e4eb6420-906d-4672-947a-ca33ddcdadfc} + 12SendMessageToWeb + + + {55b510c1-59e9-4bfd-ae84-d76d46f6e365} + 02-13.3MIS_FuntionSaveData + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1055/MesServerFunction/Fun_1055.cs b/MisDataFunction/Function1055/MesServerFunction/Fun_1055.cs new file mode 100644 index 0000000..bd3e090 --- /dev/null +++ b/MisDataFunction/Function1055/MesServerFunction/Fun_1055.cs @@ -0,0 +1,242 @@ +using MesServerWork; +using System.Collections.Generic; +using System.Threading; +using System.Xml.Linq; + +namespace MesServerFunctions +{ + public partial class FunctionMES + { + object lockFunWork; + //public void FunWork(DoWhatPlc.CustomeEvetnArgs e) + public void FunWork(string recData) + { + + + lockFunWork = new object(); + lock (lockFunWork) + { + List dataArray = DoWhatPlc.MessageText.GetCmdStringList(recData); + //string[] dataArray = recData.Split('|'); + //if (dataArray.Count != 4) + //return; + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 Barcode + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + DoWhatPlc.CustomeEvetnArgs e = new DoWhatPlc.CustomeEvetnArgs();// = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string tagValue; + + switch (m_Source) + { + case "BarCode": + e.OpName = m_OpName; + e.TagValue = m_Value; + fun_Barcode(e); + break; + case "WEB": + e.OpName = m_OpName; + e.TagValue = m_Command + "|" + m_Value; + fun_WebSubmit(e); + break; + case "PLC": + e = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + switch (e.TagValue.ToString().ToLower()) + { + case "false": + tagValue = "0"; + break; + case "true": + tagValue = "1"; + break; + default: + tagValue = e.TagValue.ToString(); + break; + } + e.TagValue = tagValue; + switch (e.TagTypeCodeID.ToString()) + { + //PLC 工件到位 + case "2": + fun_WorkStart(e); + break; + //PLC 允许保存质量数据 + case "19": + fun_MesRead(e); + break; + //MES 保存数据完成 + case "20": + fun_MesReadOver(e); + break; + //PLC 传递机型 + case "44": + fun_EngineTypeGetOverPLC(e); + break; + //MES 合格放行 + case "51": + fun_ConfirmOkGo(e); + break; + //MES 不合格放行 + case "8": + fun_FalseGo(e); + break; + //PLC 工位合格标志 + case "21": + fun_IsOk(e); + break; + //MES保存实时质量数据 + case "65": + fun_MesSaveNowData(e); + break; + //MES 系统健康心跳 + case "14": + fun_HeartBeatMIS(e); + break; + case "63": + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + MIS_BASE.Read_TagTypeID(63, m_OpName, out S_plcStatus); + if (S_plcStatus.ToLower() != "true" || S_plcStatus.ToLower() == "1") + { + SendMessageFun.SendInfomation("PlcStatus", "0", m_OpName); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", m_OpName); + } + break; + //MES 将MES传递的数据回传到这个变量,如果是人为修改的,也需要更新到这个变量 (DBX589 37) + case "37": + MIS_BASE.WritePLC(77, m_OpName, m_Value); // 回写到MES托盘状态 + MIS_BASE.Write_FixAllow(m_OpName, true); // 允许工作 + break; + } + break; + } + } + } + + //1.工件到位后,PLC给MES传递机型(DBX0.4)(44), + //MES判断条码是否全部扫描完成 + //PLC给出允许保存(DBX100.2)(19),MES见到(DBX100.2)(19)为1后给出保存完成(DBX102.2)(20), + //PLC见到保存完成(DBX102.2)(20)为1后,清空允许保存(DBX100.2)(19), + //MES见到允许保存(DBX100.2)(19)为0后,清空保存完成(DBX102.2)(20) + //MES判断总合格标志(INT104)(21)为1后,给出合格放行(DBX2.5)(51) + /// + /// 扫描条码 + /// + /// + /// + public void fun_Barcode(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(Barcode, e); + } + + /// + /// 传递机型 + /// + /// + /// + public void fun_EngineTypeGetOverPLC(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(EngineTypeGetOver_PLC, e); + } + + /// + /// 合格放行 + /// + /// + /// + public void fun_ConfirmOkGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(ConfirmOkGo, e); + } + + /// + /// 不合格放行 + /// + /// + /// + public void fun_FalseGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(FalseGO, e); + } + + /// + /// 允许保存 + /// + /// + /// + public void fun_MesRead(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesRead, e); + } + + /// + /// 保存完成 + /// + /// + /// + public void fun_MesReadOver(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesReadOver, e); + } + + /// + /// 工件到位离开(清空所有的MES信号) + /// + /// + /// + public void fun_WorkStart(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WorkStart, e); + } + + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + public void fun_WebSubmit(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WebSubmit, e); + } + + + /// + /// 工位是否合格 + /// + /// + /// + public void fun_IsOk(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(IsOk, e); + } + + /// + /// 系统健康心跳监测 + /// + /// + /// + public void fun_HeartBeatMIS(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(HeartBeat, e); + } + + /// + /// MES实时保存质量数据 + /// + /// + /// + public void fun_MesSaveNowData(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesSaveNowData, e); + } + + + } +} diff --git a/MisDataFunction/Function1055/MesServerFunction/vssver2.scc b/MisDataFunction/Function1055/MesServerFunction/vssver2.scc new file mode 100644 index 0000000..a246f67 Binary files /dev/null and b/MisDataFunction/Function1055/MesServerFunction/vssver2.scc differ diff --git a/MisDataFunction/Function1055/Methods/EngineGetOverBaseWork.cs b/MisDataFunction/Function1055/Methods/EngineGetOverBaseWork.cs new file mode 100644 index 0000000..ab76f41 --- /dev/null +++ b/MisDataFunction/Function1055/Methods/EngineGetOverBaseWork.cs @@ -0,0 +1,120 @@ +using System; +using System.Data; +using bizFacade; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 正常逻辑工作(传递机型) + /// + /// + /// + /// + /// + /// + private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code, string OrderForm) + { + int IsAllowWork; + int RepairPartStatusPLC = 0; + int MES_QualityMask = 1; + + //电子看板_装配零件_临时表_增加_北汽 + //第二步,将零件信息转移到零件_临时表中 + BaseDataSystemMES.MesServer_Process_EngineTypeOverBQ(OpName); + + //通知web显示 + SendMessageFun.SendMessage("123", "111", OpName); + //MIS_BASE.Read_PalletInfo(OpName, out MES_QualityMask);//合格标志 合格标志暂时改为即时响应式的 + //MIS_BASE.Read_RepairStatus_PLC(OpName, out RepairPartStatusPLC);//返修标志 + //SendMessageFun.SendInfomation("QualityMask", Convert.ToString(MES_QualityMask), OpName);//显示合格标志 + //SendMessageFun.SendInfomation("RepairPartStatusPLC", Convert.ToString(RepairPartStatusPLC), OpName);//显示返修标志 + + if (MES_QualityMask == 2) + { + // 暂时先屏蔽掉 + ////工作完成 + //MIS_BASE.Write_MaterialVerifyOver(OpName, true); + //SendMessageFun.SendInfomation("NgGO", "1", OpName);//显示不合格标志 + //return; + } + + //第三步,用于工件离开后完工数量统计及工件编号追溯 + //BaseDataSystemMES.MaterialPush_EngineIDStatus_Insert(OpName);//更新订单产量 + //MIS_BASE.Read_TagTypeID(201, OpName, out string EngineTypeID_QiaoKe); + Db.OP051_OP050_NeedWork(EngineID, OpName, OrderForm, out int MatchResult); + + if (MatchResult == 2) // 不匹配 没有需要装配的轮毂了 + { + MIS_BASE.Write_Match(OpName, false);// 匹配结果 + MIS_BASE.Write_MatchingCompleted(OpName, false);// 匹配完成 + MIS_BASE.WritePLC(77, OpName, "2"); ;// 托盘是否需要工作 1:需要工作 2:不需要工作 + + } + else if (MatchResult == 1) //匹配 有需要装配的轮毂 + { + MIS_BASE.Write_Match(OpName, true);// 匹配结果 + MIS_BASE.Write_MatchingCompleted(OpName, true);// 匹配完成 + MIS_BASE.WritePLC(77, OpName, "1");// 托盘是否需要工作 1:需要工作 2:不需要工作 + MIS_BASE.Write_FixAllow(OpName, true); // 允许工作 + } + else + { + MIS_BASE.WritePLC(29, OpName, true); // 开始等待 通知A60 保存完成时更新下等待状态与匹配状态 + } + } + + /// + /// 二次工作 + /// + /// + private void EngineTypeGetOver_PLC_Work_two(string OpName) + { + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, Convert.ToInt32(PartPallet_Code), OrderForm); + + } + /// + /// 跳过二次工作 + /// + /// + private void EngineTypeGetOver_PLC_Work_Skip(string OpName) + { + MIS_BASE.Write_MesReadOver(OpName, true); + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + + /// + /// 返修件需要工作 + /// + /// 工位号 + private void IsNeedRepaire_OK(string OpName) + { + string orderForm = ""; + int engineTypeID; + string engineType = ""; + string engineID = ""; + string palletCode = ""; + int isRepair; + string repairCode = ""; + //从监控系统中查询出本工位信息 + BaseDataSystemMES.OpName_MIS_Moby_Select(OpName, + out orderForm, out engineTypeID, out engineType, + out engineID, out palletCode, out isRepair, out repairCode); + + EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode), orderForm); + } + + + + + } +} diff --git a/MisDataFunction/Function1055/Methods/SubmitToMisweb.cs b/MisDataFunction/Function1055/Methods/SubmitToMisweb.cs new file mode 100644 index 0000000..52ce16f --- /dev/null +++ b/MisDataFunction/Function1055/Methods/SubmitToMisweb.cs @@ -0,0 +1,127 @@ +using System; +using bizFacade; +//using SystemFramework; + +namespace MesServerFunctions +{ + + /// + /// 此类用于向WEB发送各种类型消息 + /// + partial class FunctionMES + { + + /// + /// 批量发送WEB消息(Value为BOOL值) + /// + /// 消息编号组合 + /// 消息值组合 + /// 工位号 + void Sendmessage(string MessageNumm,string Value, string OpName) + { + for (int i=0;i + /// 选择发送给WEB的消息 + /// + /// 消息类型 + /// 消息工位 + string Sendmessage(char Num,string Value, string OpName) + { + string SendMessage; + string result = ""; + switch (Num) + { + case '1': + //1(直接在界面通过选择机型确认工序内容) + SendMessage = "MES|ProcessList|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '2': + //2显示物料 + SendMessage = "MES|MaterialList|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '3': + //3显示操作指导图片 + SendMessage = "MES|PicShow|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '4': + //4订单完工模块刷新完成数量 + SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '5': + SendMessage = "MES|ShowMoby|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '6': + SendMessage = "MES|MaterialCheckPosition|" + OpName + "|" +Value; + result = AsyncSendMessage(SendMessage); + break; + case '7': + SendMessage = "MES|WorkStart|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '8'://清除MES生成编号 + + break; + case '9': + SendMessage = "MES|ConfirmOkGo|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case 'a': + SendMessage = "MES|FixAllow|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + } + return result; + } + /// + /// 向WEB发送信息(value为字符串) + /// + /// 消息种类 + /// 消息内容 + /// 工位号 + string SendInfomation(string Command, string Value, string OpName) + { + string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value; + return AsyncSendMessage(SendMessage); + } + + + /// + /// 发送在线产量、在线节拍 + /// + /// + /// + private void SendActuallyCount(string OpName, int tagValue) + { + //当工件离开时,更新在线产量、在线节拍 + if (tagValue == 0) + { + try + { + int opNameCount = 0;//在线产量 + int opNameCountTime = 0;//在线节拍 + //基本数据_工作日历_班次产量查询_New + BaseDataSystemMES.OpNameCount_New(OpName, out opNameCount, out opNameCountTime); + string SendMessage; + SendMessage = "MES|ActuallyCount|" + OpName + "|" + opNameCount.ToString() + "&" + opNameCountTime.ToString(); + AsyncSendMessage(SendMessage); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:SendActuallyCount"); + } + } + } + + + } +} diff --git a/MisDataFunction/Function1055/Methods/UDP.Send.cs b/MisDataFunction/Function1055/Methods/UDP.Send.cs new file mode 100644 index 0000000..aed7cc3 --- /dev/null +++ b/MisDataFunction/Function1055/Methods/UDP.Send.cs @@ -0,0 +1,53 @@ +using bizFacade; +//using SystemFramework; +using MesServerWork; +using DataLinkMesWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 发送信息到MES通讯服务器或者其他的 + /// + /// + private string AsyncSendMessage(string Message) + { + return MIS_BASE.asyncSendMessage(Message); + } + + /// + /// 发送提示消息 + /// + /// + private void AsyncSendMessage_Notice(string opname, string notice) + { + //通知Web界面 + BaseDataSystemMES.Web_Notice_Insert(opname, notice); + string SendMessage = "MES|Notice|" + opname + "|" + "1"; + MIS_BASE.asyncSendMessage(SendMessage); + } + + /// + /// 发送信息到打印机 + /// + /// + private void asyncSendMessageToMark(string Message) + { + string messageSend = (string)Message; + //UDPClientSend.Send_ALL(ApplicationConfig.MES_MarkPortNum, messageSend); + } + + /// + /// 发送信息到LED + /// + /// + private void asyncSendMessageLED(string OpName) + { + //发送到大屏幕显示 41104 + string strMessage = "MIS|" + OpName + "|" + "0" + "|" + "1"; + //UDPClientSend.Send_ALL(ApplicationConfig.Port_ShowLED_ProductCount, strMessage); + + } + } +} diff --git a/MisDataFunction/Function1055/Methods/vssver2.scc b/MisDataFunction/Function1055/Methods/vssver2.scc new file mode 100644 index 0000000..7782f6f Binary files /dev/null and b/MisDataFunction/Function1055/Methods/vssver2.scc differ diff --git a/MisDataFunction/Function1055/OpcServer/Barcode.cs b/MisDataFunction/Function1055/OpcServer/Barcode.cs new file mode 100644 index 0000000..1f9ea05 --- /dev/null +++ b/MisDataFunction/Function1055/OpcServer/Barcode.cs @@ -0,0 +1,90 @@ +using System; +using System.Windows.Forms; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + ///1.扫描配送单号,用于接收物料,扫描单号的时候,将接收的物料信息显示在“物料拉动”Tab区域 + ///2.扫描料箱标签/看板卡,用于追溯物料批次信息 + ///3.扫描零件条码,根据零件图号进行防错 + ///第一步,判断条码类型,根据条码类型,执行对应的存储过程 + ///第二步,条码类型(将扫描的条码保存到对应的表中) + ///第三步,扫描完成之后给出允许工作信号 + /// 处理页面扫描条码 + /// + /// + /// + public void Barcode(object e) + { + + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string barcode = Convert.ToString(msgEvent.TagValue); + string AlarmStr = ""; + + int IsAllowWork; + bool IsSuccess = false; + bool EngineGetOver_PLC_NextWorkStep; + //传递机型是否到位 + MIS_BASE.Read_EngineGetOver_PLC(OpName, out EngineGetOver_PLC_NextWorkStep); + if (!EngineGetOver_PLC_NextWorkStep) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC未传递机型"); + return; + } + //物料验证 + BaseDataSystemMES.PartMaterial_DM_Update(OpName, barcode, out IsSuccess); + if (!IsSuccess) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认"); + return; + } + else + { + SendMessageFun.SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息 + } + + + + + //获取是否允许工作 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + //此处逻辑有问题 需要考虑到批次扫描 提示PLC未传递机型的情况 + if (IsAllowWork == 1) + { + //BaseDataSystemMES.Material_Insert(OpName, 1); + + //更新订单完工数量及物料 + SendMessageFun.SendMessage("24", "11", OpName); + + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:Barcode"); + } + + } + + } + + + } +} diff --git a/MisDataFunction/Function1055/OpcServer/ConfirmOkGo.cs b/MisDataFunction/Function1055/OpcServer/ConfirmOkGo.cs new file mode 100644 index 0000000..06e6b33 --- /dev/null +++ b/MisDataFunction/Function1055/OpcServer/ConfirmOkGo.cs @@ -0,0 +1,41 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 合格放行 + /// + /// + /// + private void ConfirmOkGo(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + + BaseDataSystemMES.Material_Insert(OpName, 1); + + //更新订单完工数量及物料 + Sendmessage("24", "11", OpName); + + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:ConfirmOkGo"); + } + } + } +} diff --git a/MisDataFunction/Function1055/OpcServer/EngineGetOver.cs b/MisDataFunction/Function1055/OpcServer/EngineGetOver.cs new file mode 100644 index 0000000..59d2445 --- /dev/null +++ b/MisDataFunction/Function1055/OpcServer/EngineGetOver.cs @@ -0,0 +1,79 @@ +using System; +using System.Data; +using System.Windows.Forms; +using System.Xml.Linq; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// PLC传递机型处理 + /// + /// + /// + private void EngineTypeGetOver_PLC(object e) + { + + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + + if (EngineTypeID <= 0 || EngineID.Length == 0 || EngineType.Length == 0) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC传递机型为空"); + return; + } + + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineTypeID, EngineTypeID.ToString()); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineType, EngineType); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID, EngineID); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.OrderForm, OrderForm); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.PartPallet_Code, PartPallet_Code.ToString()); + + //显示当前订单信息 + SendMessage.ShowMoby(OpName); + //判断该订单数据是否已经工作过,有的话则在WEB跳出弹窗选择 并同时禁止工作 + //DataTable dt2 = BaseDataSystemMES.EngineIsTwoWork(OpName, OrderForm, EngineID); + //if (dt2.Rows[0]["result"].ToString() == "1") //已完成 + //{ + // //不允许工作 + // MIS_BASE.Write_FixAllow(OpName, false); + // //通知WEB校验重新工作还是跳过 点重新工作给允许工作,点跳过给工作完成 + // string message = "MES|Engine_Is_TwoWork|" + OpName + "|1"; + // SendMessage.AsyncSendMessage(message); + //} + //else + //{ + // EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm); + //} + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:EngineTypeGetOver_PLC"); + } + } + + + } + + } +} diff --git a/MisDataFunction/Function1055/OpcServer/FalseGO.cs b/MisDataFunction/Function1055/OpcServer/FalseGO.cs new file mode 100644 index 0000000..14b5771 --- /dev/null +++ b/MisDataFunction/Function1055/OpcServer/FalseGO.cs @@ -0,0 +1,46 @@ +using System; +using System.Data; +using System.Windows.Forms; +using System.Xml.Linq; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 不合格放行 + /// + /// + /// + private void FalseGO(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + //不合格放行信号 + //MIS_BASE.Write_FalseGO(OpName, true); + //总合格标志2(不合格) + + BaseDataSystemMES.Material_Insert_NG(OpName, 2); + + Sendmessage("24", "11", OpName); + + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1055/OpcServer/HeartBeat.cs b/MisDataFunction/Function1055/OpcServer/HeartBeat.cs new file mode 100644 index 0000000..93affd3 --- /dev/null +++ b/MisDataFunction/Function1055/OpcServer/HeartBeat.cs @@ -0,0 +1,35 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// MES与PLC心跳监听 + /// + /// + /// + private void HeartBeat(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //返写在MES心跳中 + MIS_BASE.WritePLC(15, OpName, tagValue); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1055/OpcServer/MesRead.cs b/MisDataFunction/Function1055/OpcServer/MesRead.cs new file mode 100644 index 0000000..5fe6452 --- /dev/null +++ b/MisDataFunction/Function1055/OpcServer/MesRead.cs @@ -0,0 +1,77 @@ +using bizFacade; +using MesServerWork; +using System; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 允许保存(针对半自动和手动压装工位) + /// + /// + /// + private void MesRead(object e) + { + { + try + { + + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + string NeedWork; + + if (tagValue == 1) + { + // 记录050前停工位的是否需要工作 + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + MIS_BASE.Read_TagTypeID(37, OpName, out NeedWork); + Db.OP051_OP050_NeedWork_Save(EngineID, Convert.ToInt32(NeedWork)); + + int qualityMask; + // 保存质量数据 + qualityMask = MisDataSaveDateMesRead.Funtion.MesRead(OpName, tagValue.ToString(), msgEvent.TagID.ToString()); + // 保存物料数据 + BaseDataSystemMES.Material_Insert(OpName, qualityMask); + + // 测量数据发动机在线状态 + BaseDataSystemMES.WorkStartInsert(OpName, qualityMask); + + // 推送质量数据到MES的页面 + SendMessageFun.SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName); + + //对应手动工位的 + //MIS_BASE.Write_ConfirmOkGo(OpName, true); + //通知设备,MES的质量数据(和物料数据)保存完成 + MIS_BASE.Write_MesReadOver(OpName, true); + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + //统计在线产量,在线节拍 + //SendMessage.SendActuallyCount(OpName, tagValue); + var result = MesFunctions.EnginePart_OutStation(OpName, EngineID, qualityMask); + } + else + { + MIS_BASE.Write_MesReadOver(OpName, false); + + } + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + + } + } +} diff --git a/MisDataFunction/Function1055/OpcServer/MesReadOver.cs b/MisDataFunction/Function1055/OpcServer/MesReadOver.cs new file mode 100644 index 0000000..f96a7d3 --- /dev/null +++ b/MisDataFunction/Function1055/OpcServer/MesReadOver.cs @@ -0,0 +1,55 @@ +using System; +//using SystemFramework; +using MesServerWork; +using bizFacade; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 保存完成(针对半自动和手动压装工位) + /// + /// + /// + private void MesReadOver(object e) + { + //try + //{ + // DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + // string OpName = Convert.ToString(msgEvent.OpName); + // var tagValue = msgEvent.TagValue.ToString (); + + // if (tagValue == "1" | tagValue.ToLower () == "true") + // { + // int qualityMask; + // MIS_BASE.Read_QualityMask(OpName, out qualityMask); + + // SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName);//发给Web页面显示质量数据 + + // if (qualityMask == 1)//全部OK,给出合格放行 + // { + // //如果存在线外扫描工位,根据扫描条码绑定线外数据 需要时解除禁用 + // //BaseDataSystemMES.TransLaunchDataByMainMaterial(OpName, EngineType, EngineID, EngineTypeID); + + // //如果存在线外排队工位,根据排队编号绑定线外数据 需要时解除禁用 + // ////BaseDataSystemMES.MailLineAndSubLineData_InsertByEngineID_Subline(OpName,EngineID, EngineTypeID, EngineType); + + // MIS_BASE.Write_ConfirmOkGo(OpName, true); + // //MIS_BASE.Write_FalseGO(OpName, false); + // } + // else + // { + // //MIS_BASE.Write_ConfirmOkGo(OpName, false); + // MIS_BASE.Write_FalseGO(OpName, true); + // } + + // } + //} + //catch (Exception err) + //{ + // ////ApplicationLog.WriteLog(err, "Function02:MesReadOver"); + //} + } + } +} diff --git a/MisDataFunction/Function1055/OpcServer/MesSaveNowData.cs b/MisDataFunction/Function1055/OpcServer/MesSaveNowData.cs new file mode 100644 index 0000000..63c11b3 --- /dev/null +++ b/MisDataFunction/Function1055/OpcServer/MesSaveNowData.cs @@ -0,0 +1,40 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using static System.Net.Mime.MediaTypeNames; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// MES保存实时质量数据 + /// + /// + /// + private void MesSaveNowData(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + // 直接发送实时的 质量数据 + string message = MisDataSaveDateMesRead.Funtion.GetRealTimeQualityData(OpName); + //推送质量数据到MES的页面 + SendMessage.AsyncSendMessage("MES|ShowTimelyQuality_Resources|" + OpName + "|" + message); + //SendMessageFun.SendMessageMESToWEB("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1055/OpcServer/WebSubmit.cs b/MisDataFunction/Function1055/OpcServer/WebSubmit.cs new file mode 100644 index 0000000..d7ca28c --- /dev/null +++ b/MisDataFunction/Function1055/OpcServer/WebSubmit.cs @@ -0,0 +1,304 @@ +using System; +using MesServerWork; +using bizFacade; +using System.Threading; +using MisDataSaveDate; +using System.Collections; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + private void WebSubmit(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName=Convert.ToString(msgEvent.OpName); + string Content = Convert.ToString(msgEvent.TagValue); + + string[] dataArray = Content.Split('|'); + if (dataArray.Length != 2) + return; + //消息类型 + string m_Command = dataArray[0].ToString(); + //消息参数 + string m_Value = dataArray[1].ToString(); + //消息参数数量 + string[] m_Value_array = m_Value.Split('&'); + //消息参数长度 + int m_Value_length = m_Value_array.Length; + + //工件信息 + string engineID = ""; + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + return; + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + engineID = MIS_BASE.hashtable_EngineGetOver_EngineID[OpName].ToString(); + } + + DoWhatPlc.CustomeEvetnArgs _e = new DoWhatPlc.CustomeEvetnArgs(); + _e.OpName = OpName; + _e.TagValue = m_Value; + + //根据请求的命令处理逻辑 + switch (m_Command) + { + case "Barcode": + if (m_Value_length > 1) return; + fun_Barcode(_e); + break; + case "ConfirmOkGo"://合格放行 + //删除不合格放行记录 + //修改托盘状态 + //Update_PalletStatus(OpName, 1, false); + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_ConfirmOkGo(OpName, true); + MIS_BASE.Write_FalseGO(OpName, false); + + Thread.Sleep(1000); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + break; + case "FalseGO"://返修放行 + //修改托盘状态 + //Update_PalletStatus(OpName, 3, false); + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "NgGO"://不合格放行 + //修改托盘状态 + //Update_PalletStatus(OpName, 2, false); + //保存不合格信息(必须保存不合格放行信息,由于B5A的Moby没有不合格标志位) + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Insert(OpName, engineID, "", ""); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "OnLineState"://在线0、离线1、屏蔽2 + try + { + if (m_Value_length > 1) return; + int a = Convert.ToInt32(m_Value); + if (a <= 2) + { + BaseDataSystemMES.IsOnLine_Update(OpName, m_Value.ToString()); + MIS_BASE.Write_OnLineState(OpName, Convert.ToInt32(m_Value)); + if (a == 2) SendMessage.AsyncSendMessage_Notice(OpName, "屏蔽MES!"); + if (a == 0) SendMessage.AsyncSendMessage_Notice(OpName, "启用MES!"); + } + } + catch + { + + } + break; + case "Reset"://复位,将MES所有的信息都复位了 + SetMoby(OpName);//将MES所有信号清空 + break; + case "FixAllow"://重新拧紧 + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_FixAllow(OpName, true); + break; + case "IsAutoGetEngineID"://自动手动申请编号(线首) + if (m_Value_length > 1) return; + MIS_BASE.Write_IsAutoGetEngineID(OpName, Convert.ToInt32(m_Value)); + break; + case "PartPalletGoOver"://空托盘放行 + int Is_PartPalletGoOver; + MIS_BASE.Read_PartPalletGoOver(OpName, out Is_PartPalletGoOver); + if (Is_PartPalletGoOver == 1) + { + MIS_BASE.Write_PartPalletGoOver(OpName, 1); + } + else + { + MIS_BASE.Write_PartPalletGoOver(OpName,0); + } + break; + case "SetMoby"://清空托盘(线首) + SetMoby(OpName);//将MES所有信号清空 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "RepairUplineMES"://返修上线 + MIS_BASE.Write_RepairUpline_MES(OpName, true); + break; + case "CancelRepair"://将返修件置为正常件 + + break; + case "PartPalletCode"://申请写入托盘号 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "WritePartPalletCode"://写入托盘号 + if (m_Value_length > 1) return; + MIS_BASE.Write_PalletCode(OpName, Convert.ToInt32(m_Value)); + break; + case "Normal"://启用正常拧紧工位 + MIS_BASE.Write_Normal(OpName, 1); + MIS_BASE.Write_UnNormal(OpName, 0); + break; + case "UnNormal"://启用备用拧紧工位 + MIS_BASE.Write_Normal(OpName, 0); + MIS_BASE.Write_UnNormal(OpName, 1); + break; + case "ResetDevice"://复位设备 + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + break; + case "IsNeedRepaire"://返修上线(返修上线点) + if (Convert.ToInt32(m_Value) == 1) + { + //修改托盘状态 + MIS_BASE.Write_PalletInfo(OpName, 3); + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + IsNeedRepaire_OK(OpName); + + } + else if (Convert.ToInt32(m_Value) == 0) + { + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + else + { } + + break; + case "ContinueMatch": + BaseDataSystemMES.QualityVerifyStatus_Hash_Write(OpName, true); + break; + //初始化网页信号 + case "IniSingalToWeb": + InitializeSingalToWeb(OpName); + break; + case "Reset_Engine"://返修上线(返修上线点) + SetMoby(OpName);//将MES所有信号清空 + //fun_EngineTypeGetOverPLC(OpName, 0); + //fun_EngineTypeGetOverPLC(OpName, 1); + break; + + case "twoWorkSkip"://重新工作工件跳过工作(重新工作工件) + //工作完成 + EngineTypeGetOver_PLC_Work_Skip(OpName); + break; + case "twoWork"://重新工作工件重新工作(重新工作工件) + //允许工作 + EngineTypeGetOver_PLC_Work_two(OpName); + break; + + default: break; + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WebSubmit"); + } + } + private void SetMoby(string OpName) + { + try + { + //清空Moby时,需要将MES信号清空 + MIS_BASE.Write_ClearMesMoby(OpName); + + BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName); + + Sendmessage("5123", "1111", OpName); + + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + } + catch + { + + } + } + /// 网页重现登录,恢复关闭前的页面状态 + /// + /// 工位号 + private void InitializeSingalToWeb(string Opname) + { + + //工件到位 DBX0.1 + bool S_WorkStart; + bool S_FixAllow; + bool S_EngineGetOver; + bool S_MaterialVerifyOver; + + MIS_BASE.Read_WorkStart(Opname, out S_WorkStart); + MIS_BASE.Read_FixAllow(Opname, out S_FixAllow); + MIS_BASE.Read_EngineGetOver_PLC(Opname, out S_EngineGetOver); + MIS_BASE.Read_MaterialVerifyOver(Opname, out S_MaterialVerifyOver); + + Sendmessage("13", "1111", Opname); + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + // 新增查询PLC直通状态 网页显示 + MIS_BASE.Read_TagTypeID(63, Opname, out S_plcStatus); + if (S_plcStatus.ToLower() == "false") + { + SendMessageFun.SendInfomation("PlcStatus", "0", Opname); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", Opname); + } + + if (S_WorkStart == true) + { + SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname); + } + if (S_FixAllow == true) + { + SendInfomation("FixAllow", Convert.ToString(Convert.ToInt32(S_FixAllow)), Opname); + } + if (S_MaterialVerifyOver == true) + { + SendInfomation("MaterialVerifyOver", Convert.ToString(Convert.ToInt32(S_MaterialVerifyOver)), Opname); + } + if (S_EngineGetOver == true) + { + SendInfomation("EngineTypeGetOverPLC", Convert.ToString(Convert.ToInt32(S_EngineGetOver)), Opname); + Sendmessage("2", "1111", Opname); + SendMessage.ShowMoby(Opname); + // 直接发送实时的 质量数据 + string message = MisDataSaveDateMesRead.Funtion.GetRealTimeQualityData(Opname); + //推送质量数据到MES的页面 + SendMessage.AsyncSendMessage("MES|ShowTimelyQuality_Resources|" + Opname + "|" + message); + } + InitAlarm(Opname); + } + + private void InitAlarm(string Opname) + { + FuntionMesRead.Alarm_InitAlarm_Send(Opname, out Hashtable ht); + foreach (DictionaryEntry kv in ht) + { + var TagID = kv.Key.ToString(); + var TagValue = kv.Value.ToString(); + FuntionMesRead.Send_AlarmMsg(TagID, TagValue); + } + + } + } +} diff --git a/MisDataFunction/Function1055/OpcServer/WorkIsOk.cs b/MisDataFunction/Function1055/OpcServer/WorkIsOk.cs new file mode 100644 index 0000000..08819e3 --- /dev/null +++ b/MisDataFunction/Function1055/OpcServer/WorkIsOk.cs @@ -0,0 +1,45 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工位合格标志 + /// + /// + /// + private void IsOk(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + int qualityMask; + MIS_BASE.Read_QualityMask(OpName, out qualityMask); + //判断是否合格 + if (qualityMask == 1) + { + qualityMask = 1; + } else { + qualityMask = 0; + } + //通知WEB修改状态 + string message = "MES|QualityMask|" + OpName + "|" + qualityMask.ToString(); + SendMessage.AsyncSendMessage(message); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1055/OpcServer/WorkStart.cs b/MisDataFunction/Function1055/OpcServer/WorkStart.cs new file mode 100644 index 0000000..a0905d5 --- /dev/null +++ b/MisDataFunction/Function1055/OpcServer/WorkStart.cs @@ -0,0 +1,53 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Threading; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工件到位与离开时,清空MES自身信号 + /// + /// + /// + private void WorkStart(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + if (tagValue == 1) + { + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartIn, DateTime.Now.ToString()); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStart, tagValue.ToString()); + } + else + { + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartOut, DateTime.Now.ToString()); + Thread.Sleep(500); + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + + MIS_BASE.Write_MatchingCompleted(OpName, false);// 匹配完成 + MIS_BASE.Write_Match(OpName, false);// 匹配结果 + MIS_BASE.WritePLC(77, OpName, "0"); ;// 托盘是否需要工作 1:需要工作 2:不需要工作 + + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WorkStart"); + } + } + + } +} diff --git a/MisDataFunction/Function1055/OpcServer/vssver2.scc b/MisDataFunction/Function1055/OpcServer/vssver2.scc new file mode 100644 index 0000000..b884d13 Binary files /dev/null and b/MisDataFunction/Function1055/OpcServer/vssver2.scc differ diff --git a/MisDataFunction/Function1055/Properties/AssemblyInfo.cs b/MisDataFunction/Function1055/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0bb79c4 --- /dev/null +++ b/MisDataFunction/Function1055/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Function02")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("苏州宏软信息技术有限公司")] +[assembly: AssemblyProduct("Function02")] +[assembly: AssemblyCopyright("Copyright © 苏州宏软信息技术有限公司 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("47710f2c-e141-4252-8d13-701bf4c1c027")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MisDataFunction/Function1055/Properties/vssver2.scc b/MisDataFunction/Function1055/Properties/vssver2.scc new file mode 100644 index 0000000..14e543b Binary files /dev/null and b/MisDataFunction/Function1055/Properties/vssver2.scc differ diff --git a/MisDataFunction/Function1055/mssccprj.scc b/MisDataFunction/Function1055/mssccprj.scc new file mode 100644 index 0000000..119193d --- /dev/null +++ b/MisDataFunction/Function1055/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[Function02.csproj] +SCC_Aux_Path = "\\192.168.0.100\vss\MES4.0" +SCC_Project_Name = "$/MisData/MisData/MisData/MesServer.Function/Function02", ILHAAAAA diff --git a/MisDataFunction/Function1055/packages.config b/MisDataFunction/Function1055/packages.config new file mode 100644 index 0000000..b3e1761 --- /dev/null +++ b/MisDataFunction/Function1055/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1055/vssver2.scc b/MisDataFunction/Function1055/vssver2.scc new file mode 100644 index 0000000..c770e28 Binary files /dev/null and b/MisDataFunction/Function1055/vssver2.scc differ diff --git a/MisDataFunction/Function1056/DataAccess/DataAccess.cs b/MisDataFunction/Function1056/DataAccess/DataAccess.cs new file mode 100644 index 0000000..68cdca4 --- /dev/null +++ b/MisDataFunction/Function1056/DataAccess/DataAccess.cs @@ -0,0 +1,15 @@ + +namespace MesServerFunctions +{ + partial class FunctionMES + { + //针对“MIS.BizFacade.Dll”中没有的存储过程,在此类中新建 + //新建原则:所有的函数用private,只允许在内部使用 + //针对单个工艺特殊,需要新建存储过程,但是存储过程不能被加入到“MIS.BizFacade.Dll”中 + + private void aa() + { + + } + } +} diff --git a/MisDataFunction/Function1056/DataAccess/vssver2.scc b/MisDataFunction/Function1056/DataAccess/vssver2.scc new file mode 100644 index 0000000..d045c26 Binary files /dev/null and b/MisDataFunction/Function1056/DataAccess/vssver2.scc differ diff --git a/MisDataFunction/Function1056/Db.cs b/MisDataFunction/Function1056/Db.cs new file mode 100644 index 0000000..23ab541 --- /dev/null +++ b/MisDataFunction/Function1056/Db.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DataLinkMesWork; + +namespace MesServerFunctions +{ + public class Db + { + /// + /// 合力_转线_A92判断工件状态 + /// + /// + /// + /// + /// + /// + /// + /// + public static bool OPA92_EngineGetOverCheckWorkType(string EngineID, out int MatchResult, out string MatchResultStr) + { + DataTable dt = new DataTable(); + MatchResult = 2;// 默认是报警 程序出错 + MatchResultStr = "默认是报警 程序出错";// 默认是报警 程序出错 + string produceName = "合力_转线_A92判断工件状态"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@轮毂总成号", EngineID); + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt)) + { + if (dt.Rows.Count > 0) + { + MatchResult = Convert.ToInt32(dt.Rows[0]["result"]); + MatchResultStr = dt.Rows[0]["msg"].ToString(); + return true; + } + } + return false; + } + + /// + /// 合力_转线_删除记录数据 同时保存 轮毂 桥壳 关系 + /// + /// + public static void OPA92_DeleteLineData(string EngineID_QiaoKe) + { + DataTable dt = new DataTable(); + string produceName = "合力_转线_删除记录数据"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@桥壳总成号", EngineID_QiaoKe); + DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt); + } + } +} diff --git a/MisDataFunction/Function1056/Function02.csproj.vspscc b/MisDataFunction/Function1056/Function02.csproj.vspscc new file mode 100644 index 0000000..0f0f36c --- /dev/null +++ b/MisDataFunction/Function1056/Function02.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:MesServer.Function\\Function02" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/MisDataFunction/Function1056/Function1056.csproj b/MisDataFunction/Function1056/Function1056.csproj new file mode 100644 index 0000000..75060ae --- /dev/null +++ b/MisDataFunction/Function1056/Function1056.csproj @@ -0,0 +1,169 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {191419A0-CCEB-4816-BEDC-C39ABF2981A7} + Library + Properties + Function1056 + Function1056 + v4.8 + 512 + + + + + + + + + + + + + + true + full + false + ..\..\MisDataFun_Exe\ + DEBUG;TRACE + prompt + 4 + false + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + ..\..\..\Common\dll\MQTTnet.dll + + + ..\..\..\Common\dll\MQTTnet.Extensions.ManagedClient.dll + + + False + ..\..\..\Common\dll\Newtonsoft.Json.dll + + + + + + ..\..\DLL\System.Net.Http.dll + + + ..\..\packages\System.Net.Security.4.3.2\lib\net46\System.Net.Security.dll + + + ..\..\packages\System.Net.WebSockets.4.3.0\lib\net46\System.Net.WebSockets.dll + + + ..\..\packages\System.Net.WebSockets.Client.4.3.2\lib\net46\System.Net.WebSockets.Client.dll + + + ..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll + + + ..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {f55da1a0-a982-4479-8c47-0d9a5aaf3e18} + 00MesWorkMqtt + + + {0d1af432-439a-4920-8692-43ae139f5530} + 01_01DoWhatPlc + + + {3e6d1dd5-01c9-435f-9941-61f906ce35bb} + 02_02WebApiCallPLC + + + {f434e066-4c59-47c8-aa82-6f48cc84501a} + 04-DataBaseAccess + + + {f0a0c525-03fd-428a-9b17-7f54aa0e4475} + 07BusinessFacade + + + {d98be764-adeb-488d-9714-61e308aa8201} + 08-WebFun_base + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 09-MesDataFunction + + + {e4eb6420-906d-4672-947a-ca33ddcdadfc} + 12SendMessageToWeb + + + {55b510c1-59e9-4bfd-ae84-d76d46f6e365} + 02-13.3MIS_FuntionSaveData + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1056/MesServerFunction/Fun_1056.cs b/MisDataFunction/Function1056/MesServerFunction/Fun_1056.cs new file mode 100644 index 0000000..a6ed400 --- /dev/null +++ b/MisDataFunction/Function1056/MesServerFunction/Fun_1056.cs @@ -0,0 +1,223 @@ +using MesServerWork; +using System.Collections.Generic; +using System.Threading; + +namespace MesServerFunctions +{ + public partial class FunctionMES + { + object lockFunWork; + //public void FunWork(DoWhatPlc.CustomeEvetnArgs e) + public void FunWork(string recData) + { + + + lockFunWork = new object(); + lock (lockFunWork) + { + List dataArray = DoWhatPlc.MessageText.GetCmdStringList(recData); + //string[] dataArray = recData.Split('|'); + //if (dataArray.Count != 4) + //return; + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 Barcode + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + DoWhatPlc.CustomeEvetnArgs e = new DoWhatPlc.CustomeEvetnArgs();// = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string tagValue; + + switch (m_Source) + { + case "BarCode": + e.OpName = m_OpName; + e.TagValue = m_Value; + fun_Barcode(e); + break; + case "WEB": + e.OpName = m_OpName; + e.TagValue = m_Command + "|" + m_Value; + fun_WebSubmit(e); + break; + // case "MES": + case "PLC": + e = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + switch (e.TagValue.ToString().ToLower()) + { + case "false": + tagValue = "0"; + break; + case "true": + tagValue = "1"; + break; + default: + tagValue = e.TagValue.ToString(); + break; + } + e.TagValue = tagValue; + switch (e.TagTypeCodeID.ToString()) + { + //PLC 工件到位 + case "2": + fun_WorkStart(e); + break; + //PLC 允许保存质量数据 + case "19": + fun_MesRead(e); + break; + //MES 保存数据完成 + case "20": + fun_MesReadOver(e); + break; + //PLC 传递机型 + case "44": + fun_EngineTypeGetOverPLC(e); + break; + //MES 合格放行 + case "51": + fun_ConfirmOkGo(e); + break; + //MES 不合格放行 + case "8": + fun_FalseGo(e); + break; + //MES保存实时质量数据 + case "65": + fun_MesSaveNowData(e); + break; + //MES 系统健康心跳 + case "15": + fun_HeartBeatMIS(e); + break; + case "63": + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + MIS_BASE.Read_TagTypeID(63, m_OpName, out S_plcStatus); + if (S_plcStatus.ToLower() != "true" || S_plcStatus.ToLower() == "1") + { + SendMessageFun.SendInfomation("PlcStatus", "0", m_OpName); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", m_OpName); + } + break; + } + break; + } + } + } + + //1.工件到位后,PLC给MES传递机型(DBX0.4)(44), + //MES判断条码是否全部扫描完成 + //PLC给出允许保存(DBX100.2)(19),MES见到(DBX100.2)(19)为1后给出保存完成(DBX102.2)(20), + //PLC见到保存完成(DBX102.2)(20)为1后,清空允许保存(DBX100.2)(19), + //MES见到允许保存(DBX100.2)(19)为0后,清空保存完成(DBX102.2)(20) + //MES判断总合格标志(INT104)(21)为1后,给出合格放行(DBX2.5)(51) + /// + /// 扫描条码 + /// + /// + /// + public void fun_Barcode(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(Barcode, e); + } + /// + /// 系统健康心跳监测 + /// + /// + /// + public void fun_HeartBeatMIS(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(HeartBeat, e); + } + public void fun_WritePLC(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WritePLC, e); + } + /// + /// 传递机型 + /// + /// + /// + public void fun_EngineTypeGetOverPLC(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(EngineTypeGetOver_PLC, e); + } + + /// + /// 合格放行 + /// + /// + /// + public void fun_ConfirmOkGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(ConfirmOkGo, e); + } + + /// + /// 不合格放行 + /// + /// + /// + public void fun_FalseGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(FalseGO, e); + } + + /// + /// 允许保存 + /// + /// + /// + public void fun_MesRead(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesRead, e); + } + + /// + /// 保存完成 + /// + /// + /// + public void fun_MesReadOver(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesReadOver, e); + } + + /// + /// 工件到位离开(清空所有的MES信号) + /// + /// + /// + public void fun_WorkStart(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WorkStart, e); + } + + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + public void fun_WebSubmit(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WebSubmit, e); + } + + /// + /// MES实时保存质量数据 + /// + /// + /// + public void fun_MesSaveNowData(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesSaveNowData, e); + } + + } +} diff --git a/MisDataFunction/Function1056/MesServerFunction/vssver2.scc b/MisDataFunction/Function1056/MesServerFunction/vssver2.scc new file mode 100644 index 0000000..a246f67 Binary files /dev/null and b/MisDataFunction/Function1056/MesServerFunction/vssver2.scc differ diff --git a/MisDataFunction/Function1056/Methods/EngineGetOverBaseWork.cs b/MisDataFunction/Function1056/Methods/EngineGetOverBaseWork.cs new file mode 100644 index 0000000..bd32165 --- /dev/null +++ b/MisDataFunction/Function1056/Methods/EngineGetOverBaseWork.cs @@ -0,0 +1,109 @@ +using System; +using System.Data; +using bizFacade; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 正常逻辑工作(传递机型) + /// + /// + /// + /// + /// + /// + private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code,string OrderForm) + { + int IsAllowWork; + int RepairPartStatusPLC = 0; + int MES_QualityMask = 1; + DataTable dt; + dt = BaseDataSystemMES.EngineTypeChange(OpName, EngineType); + + //通知web显示 + SendMessageFun.SendMessage("123", "111", OpName); + MIS_BASE.Read_PalletInfo(OpName, out MES_QualityMask);//合格标志 + SendMessageFun.SendInfomation("QualityMask", Convert.ToString(MES_QualityMask), OpName);//显示合格标志 + + MIS_BASE.Write_FixAllow(OpName, true); + + // 当A92 到位时表示当前一定是第二个件 先判断当前工件是否为已匹配的第二个工件 是的话是工作,不是报警 + Db.OPA92_EngineGetOverCheckWorkType(EngineID, out int MatchResult, out string MatchResultStr); + if (MatchResult == 1) + { + // 轮毂线 + MIS_BASE.Write_Match(OpName, true);// 匹配结果 + MIS_BASE.Write_MatchingCompleted(OpName, true);// 匹配完成 + MIS_BASE.Write_FixAllow(OpName, true); // 允许工作 + + return; + } + else + { + // 将根据轮毂号 工位号 时间 报错内容 存储到数据库中供查询 + // 匹配结果不成功 + MIS_BASE.Write_Match(OpName, false);// 匹配结果 + MIS_BASE.Write_MatchingCompleted(OpName, true);// 匹配完成 + return; + } + + //if (MES_QualityMask == 2) + //{ + // //工作完成 + // //MIS_BASE.Write_MaterialVerifyOver(OpName, true); + // //SendMessageFun.SendInfomation("NgGO", "1", OpName);//显示不合格标志 + // //return; + //} + + + //第三步,用于工件离开后完工数量统计及工件编号追溯 + //BaseDataSystemMES.MaterialPush_EngineIDStatus_Insert(OpName);//更新订单产量 + + ////第四步,获取是否允许工作 + //BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + ////暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况 + //if (IsAllowWork == 1) + //{ + // //通知PLC允许工作,允许工作在保存完成时清空 + // MIS_BASE.Write_FixAllow(OpName, true); + //} + //else + //{ + // SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + //} + + + + } + + + /// + /// 返修件需要工作 + /// + /// 工位号 + private void IsNeedRepaire_OK(string OpName) + { + string orderForm = ""; + int engineTypeID; + string engineType = ""; + string engineID = ""; + string palletCode = ""; + int isRepair; + string repairCode = ""; + //从监控系统中查询出本工位信息 + BaseDataSystemMES.OpName_MIS_Moby_Select(OpName, + out orderForm, out engineTypeID, out engineType, + out engineID, out palletCode, out isRepair, out repairCode); + + EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode),orderForm); + } + + + + + } +} diff --git a/MisDataFunction/Function1056/Methods/SubmitToMisweb.cs b/MisDataFunction/Function1056/Methods/SubmitToMisweb.cs new file mode 100644 index 0000000..52ce16f --- /dev/null +++ b/MisDataFunction/Function1056/Methods/SubmitToMisweb.cs @@ -0,0 +1,127 @@ +using System; +using bizFacade; +//using SystemFramework; + +namespace MesServerFunctions +{ + + /// + /// 此类用于向WEB发送各种类型消息 + /// + partial class FunctionMES + { + + /// + /// 批量发送WEB消息(Value为BOOL值) + /// + /// 消息编号组合 + /// 消息值组合 + /// 工位号 + void Sendmessage(string MessageNumm,string Value, string OpName) + { + for (int i=0;i + /// 选择发送给WEB的消息 + /// + /// 消息类型 + /// 消息工位 + string Sendmessage(char Num,string Value, string OpName) + { + string SendMessage; + string result = ""; + switch (Num) + { + case '1': + //1(直接在界面通过选择机型确认工序内容) + SendMessage = "MES|ProcessList|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '2': + //2显示物料 + SendMessage = "MES|MaterialList|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '3': + //3显示操作指导图片 + SendMessage = "MES|PicShow|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '4': + //4订单完工模块刷新完成数量 + SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '5': + SendMessage = "MES|ShowMoby|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '6': + SendMessage = "MES|MaterialCheckPosition|" + OpName + "|" +Value; + result = AsyncSendMessage(SendMessage); + break; + case '7': + SendMessage = "MES|WorkStart|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '8'://清除MES生成编号 + + break; + case '9': + SendMessage = "MES|ConfirmOkGo|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case 'a': + SendMessage = "MES|FixAllow|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + } + return result; + } + /// + /// 向WEB发送信息(value为字符串) + /// + /// 消息种类 + /// 消息内容 + /// 工位号 + string SendInfomation(string Command, string Value, string OpName) + { + string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value; + return AsyncSendMessage(SendMessage); + } + + + /// + /// 发送在线产量、在线节拍 + /// + /// + /// + private void SendActuallyCount(string OpName, int tagValue) + { + //当工件离开时,更新在线产量、在线节拍 + if (tagValue == 0) + { + try + { + int opNameCount = 0;//在线产量 + int opNameCountTime = 0;//在线节拍 + //基本数据_工作日历_班次产量查询_New + BaseDataSystemMES.OpNameCount_New(OpName, out opNameCount, out opNameCountTime); + string SendMessage; + SendMessage = "MES|ActuallyCount|" + OpName + "|" + opNameCount.ToString() + "&" + opNameCountTime.ToString(); + AsyncSendMessage(SendMessage); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:SendActuallyCount"); + } + } + } + + + } +} diff --git a/MisDataFunction/Function1056/Methods/UDP.Send.cs b/MisDataFunction/Function1056/Methods/UDP.Send.cs new file mode 100644 index 0000000..aed7cc3 --- /dev/null +++ b/MisDataFunction/Function1056/Methods/UDP.Send.cs @@ -0,0 +1,53 @@ +using bizFacade; +//using SystemFramework; +using MesServerWork; +using DataLinkMesWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 发送信息到MES通讯服务器或者其他的 + /// + /// + private string AsyncSendMessage(string Message) + { + return MIS_BASE.asyncSendMessage(Message); + } + + /// + /// 发送提示消息 + /// + /// + private void AsyncSendMessage_Notice(string opname, string notice) + { + //通知Web界面 + BaseDataSystemMES.Web_Notice_Insert(opname, notice); + string SendMessage = "MES|Notice|" + opname + "|" + "1"; + MIS_BASE.asyncSendMessage(SendMessage); + } + + /// + /// 发送信息到打印机 + /// + /// + private void asyncSendMessageToMark(string Message) + { + string messageSend = (string)Message; + //UDPClientSend.Send_ALL(ApplicationConfig.MES_MarkPortNum, messageSend); + } + + /// + /// 发送信息到LED + /// + /// + private void asyncSendMessageLED(string OpName) + { + //发送到大屏幕显示 41104 + string strMessage = "MIS|" + OpName + "|" + "0" + "|" + "1"; + //UDPClientSend.Send_ALL(ApplicationConfig.Port_ShowLED_ProductCount, strMessage); + + } + } +} diff --git a/MisDataFunction/Function1056/Methods/vssver2.scc b/MisDataFunction/Function1056/Methods/vssver2.scc new file mode 100644 index 0000000..7782f6f Binary files /dev/null and b/MisDataFunction/Function1056/Methods/vssver2.scc differ diff --git a/MisDataFunction/Function1056/OpcServer/Barcode.cs b/MisDataFunction/Function1056/OpcServer/Barcode.cs new file mode 100644 index 0000000..10a0ee6 --- /dev/null +++ b/MisDataFunction/Function1056/OpcServer/Barcode.cs @@ -0,0 +1,98 @@ +using System; +using System.Windows.Forms; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + ///1.扫描配送单号,用于接收物料,扫描单号的时候,将接收的物料信息显示在“物料拉动”Tab区域 + ///2.扫描料箱标签/看板卡,用于追溯物料批次信息 + ///3.扫描零件条码,根据零件图号进行防错 + ///第一步,判断条码类型,根据条码类型,执行对应的存储过程 + ///第二步,条码类型(将扫描的条码保存到对应的表中) + ///第三步,扫描完成之后给出允许工作信号 + /// 处理页面扫描条码 + /// + /// + /// + public void Barcode(object e) + { + + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string barcode = Convert.ToString(msgEvent.TagValue); + string AlarmStr = ""; + + int IsAllowWork; + bool IsSuccess = false; + bool EngineGetOver_PLC_NextWorkStep; + //传递机型是否到位 + MIS_BASE.Read_EngineGetOver_PLC(OpName, out EngineGetOver_PLC_NextWorkStep); + if (!EngineGetOver_PLC_NextWorkStep) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC未传递机型"); + return; + } + //物料验证 + BaseDataSystemMES.PartMaterial_DM_Update(OpName, barcode, out IsSuccess); + if (!IsSuccess) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认"); + return; + } + else + { + SendMessageFun.SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息 + } + + //获取是否允许工作 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + //此处逻辑有问题 需要考虑到批次扫描 提示PLC未传递机型的情况 + if (IsAllowWork == 1) + { + //BaseDataSystemMES.Material_Insert(OpName, 1); + + //更新订单完工数量及物料 + SendMessageFun.SendMessage("24", "11", OpName); + + //工作完成 + //MIS_BASE.Write_MaterialVerifyOver(OpName, true); + //if (!BaseDataSystemMES.QualityVerifyStatusOutline(OpName, out AlarmStr)) + //{ + // SendInfomation("LineoutAlert", AlarmStr, OpName); + // return; + //} + //通知PLC允许工作,允许工作在保存完成时清空 + + //将机型信息传递给刷写站工控机 + + + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:Barcode"); + } + + } + + } + + + } +} diff --git a/MisDataFunction/Function1056/OpcServer/ConfirmOkGo.cs b/MisDataFunction/Function1056/OpcServer/ConfirmOkGo.cs new file mode 100644 index 0000000..06e6b33 --- /dev/null +++ b/MisDataFunction/Function1056/OpcServer/ConfirmOkGo.cs @@ -0,0 +1,41 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 合格放行 + /// + /// + /// + private void ConfirmOkGo(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + + BaseDataSystemMES.Material_Insert(OpName, 1); + + //更新订单完工数量及物料 + Sendmessage("24", "11", OpName); + + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:ConfirmOkGo"); + } + } + } +} diff --git a/MisDataFunction/Function1056/OpcServer/EngineGetOver.cs b/MisDataFunction/Function1056/OpcServer/EngineGetOver.cs new file mode 100644 index 0000000..c5b6d6f --- /dev/null +++ b/MisDataFunction/Function1056/OpcServer/EngineGetOver.cs @@ -0,0 +1,67 @@ +using System; +using System.Data; +using System.Windows.Forms; +using System.Xml.Linq; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// PLC传递机型处理 + /// + /// + /// + private void EngineTypeGetOver_PLC(object e) + { + + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + + if (EngineTypeID <= 0 || EngineID.Length == 0 || EngineType.Length == 0 || OrderForm.Length == 0) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC传递机型为空"); + return; + } + + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineTypeID, EngineTypeID.ToString()); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineType, EngineType); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID, EngineID); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.OrderForm, OrderForm); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.PartPallet_Code, PartPallet_Code.ToString()); + //显示当前订单信息 + SendMessage.ShowMoby(OpName); + + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm); + + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:EngineTypeGetOver_PLC"); + } + } + + + } + + + } +} diff --git a/MisDataFunction/Function1056/OpcServer/FalseGO.cs b/MisDataFunction/Function1056/OpcServer/FalseGO.cs new file mode 100644 index 0000000..4ad2665 --- /dev/null +++ b/MisDataFunction/Function1056/OpcServer/FalseGO.cs @@ -0,0 +1,41 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 不合格放行 + /// + /// + /// + private void FalseGO(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + //总合格标志2(不合格) + + BaseDataSystemMES.Material_Insert_NG(OpName, 2); + + Sendmessage("24", "11", OpName); + + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1056/OpcServer/HeartBeat.cs b/MisDataFunction/Function1056/OpcServer/HeartBeat.cs new file mode 100644 index 0000000..93affd3 --- /dev/null +++ b/MisDataFunction/Function1056/OpcServer/HeartBeat.cs @@ -0,0 +1,35 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// MES与PLC心跳监听 + /// + /// + /// + private void HeartBeat(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //返写在MES心跳中 + MIS_BASE.WritePLC(15, OpName, tagValue); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1056/OpcServer/MesRead.cs b/MisDataFunction/Function1056/OpcServer/MesRead.cs new file mode 100644 index 0000000..a577ea9 --- /dev/null +++ b/MisDataFunction/Function1056/OpcServer/MesRead.cs @@ -0,0 +1,92 @@ +using bizFacade; +using MesServerWork; +using System; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 允许保存(针对半自动和手动压装工位) + /// + /// + /// + private void MesRead(object e) + { + { + try + { + + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + int qualityMask; + + //保存质量数据 + qualityMask = MisDataSaveDateMesRead.Funtion.MesRead(OpName, tagValue.ToString(), msgEvent.TagID.ToString()); + //保存物料数据 + BaseDataSystemMES.Material_Insert(OpName, qualityMask); + + //测量数据发动机在线状态 + BaseDataSystemMES.WorkStartInsert(OpName, qualityMask); + + //推送质量数据到MES的页面 + SendMessageFun.SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName); + + + //对应手动工位的 + //MIS_BASE.Write_ConfirmOkGo(OpName, true); + + + //MIS_BASE.Write_FixAllow(OpName, false); + + //MIS_BASE.Write_ConfirmOkGo(OpName, false); + + + //MIS_BASE.Write_FixOver(OpName, false); + //MIS_BASE.Write_MaterialVerifyOver(OpName, false); + + + //统计在线产量,在线节拍 + // SendMessage.SendActuallyCount(OpName, tagValue); + + // 判断050 工位是否有传递机型 有的话 允许050工作 同时删除记录表中轮毂号 + MIS_BASE.Read_EngineGetOver_PLC("OP050", out bool EngineGetOver_PLC_NextWorkStep); + if (EngineGetOver_PLC_NextWorkStep) + { + MIS_BASE.Write_FixAllow("OP050", true); + // 查询050 工位当前到位的工件编号 + MIS_BASE.Read_EngineID("OP050", out string OP050_EngineID); + // 绑定关系 同时 删除记录 + Db.OPA92_DeleteLineData(OP050_EngineID); + } + + //通知设备,MES的质量数据(和物料数据)保存完成 + MIS_BASE.Write_MesReadOver(OpName, true); + } + else + { + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + } + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + + } + } +} diff --git a/MisDataFunction/Function1056/OpcServer/MesReadOver.cs b/MisDataFunction/Function1056/OpcServer/MesReadOver.cs new file mode 100644 index 0000000..f96a7d3 --- /dev/null +++ b/MisDataFunction/Function1056/OpcServer/MesReadOver.cs @@ -0,0 +1,55 @@ +using System; +//using SystemFramework; +using MesServerWork; +using bizFacade; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 保存完成(针对半自动和手动压装工位) + /// + /// + /// + private void MesReadOver(object e) + { + //try + //{ + // DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + // string OpName = Convert.ToString(msgEvent.OpName); + // var tagValue = msgEvent.TagValue.ToString (); + + // if (tagValue == "1" | tagValue.ToLower () == "true") + // { + // int qualityMask; + // MIS_BASE.Read_QualityMask(OpName, out qualityMask); + + // SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName);//发给Web页面显示质量数据 + + // if (qualityMask == 1)//全部OK,给出合格放行 + // { + // //如果存在线外扫描工位,根据扫描条码绑定线外数据 需要时解除禁用 + // //BaseDataSystemMES.TransLaunchDataByMainMaterial(OpName, EngineType, EngineID, EngineTypeID); + + // //如果存在线外排队工位,根据排队编号绑定线外数据 需要时解除禁用 + // ////BaseDataSystemMES.MailLineAndSubLineData_InsertByEngineID_Subline(OpName,EngineID, EngineTypeID, EngineType); + + // MIS_BASE.Write_ConfirmOkGo(OpName, true); + // //MIS_BASE.Write_FalseGO(OpName, false); + // } + // else + // { + // //MIS_BASE.Write_ConfirmOkGo(OpName, false); + // MIS_BASE.Write_FalseGO(OpName, true); + // } + + // } + //} + //catch (Exception err) + //{ + // ////ApplicationLog.WriteLog(err, "Function02:MesReadOver"); + //} + } + } +} diff --git a/MisDataFunction/Function1056/OpcServer/MesSaveNowData.cs b/MisDataFunction/Function1056/OpcServer/MesSaveNowData.cs new file mode 100644 index 0000000..63c11b3 --- /dev/null +++ b/MisDataFunction/Function1056/OpcServer/MesSaveNowData.cs @@ -0,0 +1,40 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using static System.Net.Mime.MediaTypeNames; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// MES保存实时质量数据 + /// + /// + /// + private void MesSaveNowData(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + // 直接发送实时的 质量数据 + string message = MisDataSaveDateMesRead.Funtion.GetRealTimeQualityData(OpName); + //推送质量数据到MES的页面 + SendMessage.AsyncSendMessage("MES|ShowTimelyQuality_Resources|" + OpName + "|" + message); + //SendMessageFun.SendMessageMESToWEB("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1056/OpcServer/WebSubmit.cs b/MisDataFunction/Function1056/OpcServer/WebSubmit.cs new file mode 100644 index 0000000..6a088b5 --- /dev/null +++ b/MisDataFunction/Function1056/OpcServer/WebSubmit.cs @@ -0,0 +1,294 @@ +using System; +using MesServerWork; +using bizFacade; +using System.Threading; +using MisDataSaveDate; +using System.Collections; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + private void WebSubmit(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName=Convert.ToString(msgEvent.OpName); + string Content = Convert.ToString(msgEvent.TagValue); + + string[] dataArray = Content.Split('|'); + if (dataArray.Length != 2) + return; + //消息类型 + string m_Command = dataArray[0].ToString(); + //消息参数 + string m_Value = dataArray[1].ToString(); + //消息参数数量 + string[] m_Value_array = m_Value.Split('&'); + //消息参数长度 + int m_Value_length = m_Value_array.Length; + + //工件信息 + string engineID = ""; + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + engineID = MIS_BASE.hashtable_EngineGetOver_EngineID[OpName].ToString(); + } + + DoWhatPlc.CustomeEvetnArgs _e = new DoWhatPlc.CustomeEvetnArgs(); + _e.OpName = OpName; + _e.TagValue = m_Value; + + //根据请求的命令处理逻辑 + switch (m_Command) + { + case "WritePLC": + if (m_Value_length > 1) return; + fun_WritePLC(_e); + break; + case "Barcode": + if (m_Value_length > 1) return; + fun_Barcode(_e); + break; + case "ConfirmOkGo"://合格放行 + //删除不合格放行记录 + //修改托盘状态 + //Update_PalletStatus(OpName, 1, false); + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_ConfirmOkGo(OpName, true); + MIS_BASE.Write_FalseGO(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + break; + case "FalseGO"://返修放行 + //修改托盘状态 + //Update_PalletStatus(OpName, 3, false); + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "NgGO"://不合格放行 + //修改托盘状态 + //Update_PalletStatus(OpName, 2, false); + //保存不合格信息(必须保存不合格放行信息,由于B5A的Moby没有不合格标志位) + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Insert(OpName, engineID, "", ""); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "OnLineState"://在线0、离线1、屏蔽2 + try + { + if (m_Value_length > 1) return; + int a = Convert.ToInt32(m_Value); + if (a <= 2) + { + BaseDataSystemMES.IsOnLine_Update(OpName, m_Value.ToString()); + MIS_BASE.Write_OnLineState(OpName, Convert.ToInt32(m_Value)); + if (a == 2) SendMessage.AsyncSendMessage_Notice(OpName, "屏蔽MES!"); + if (a == 0) SendMessage.AsyncSendMessage_Notice(OpName, "启用MES!"); + } + } + catch + { + + } + break; + case "Reset"://复位,将MES所有的信息都复位了 + SetMoby(OpName);//将MES所有信号清空 + break; + case "FixAllow"://重新拧紧 + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_FixAllow(OpName, true); + break; + case "IsAutoGetEngineID"://自动手动申请编号(线首) + if (m_Value_length > 1) return; + MIS_BASE.Write_IsAutoGetEngineID(OpName, Convert.ToInt32(m_Value)); + break; + case "PartPalletGoOver"://空托盘放行 + int Is_PartPalletGoOver; + MIS_BASE.Read_PartPalletGoOver(OpName, out Is_PartPalletGoOver); + if (Is_PartPalletGoOver == 1) + { + MIS_BASE.Write_PartPalletGoOver(OpName, 1); + } + else + { + MIS_BASE.Write_PartPalletGoOver(OpName,0); + } + break; + case "SetMoby"://清空托盘(线首) + SetMoby(OpName);//将MES所有信号清空 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "RepairUplineMES"://返修上线 + MIS_BASE.Write_RepairUpline_MES(OpName, true); + break; + case "CancelRepair"://将返修件置为正常件 + + break; + case "PartPalletCode"://申请写入托盘号 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "WritePartPalletCode"://写入托盘号 + if (m_Value_length > 1) return; + MIS_BASE.Write_PalletCode(OpName, Convert.ToInt32(m_Value)); + break; + case "Normal"://启用正常拧紧工位 + MIS_BASE.Write_Normal(OpName, 1); + MIS_BASE.Write_UnNormal(OpName, 0); + break; + case "UnNormal"://启用备用拧紧工位 + MIS_BASE.Write_Normal(OpName, 0); + MIS_BASE.Write_UnNormal(OpName, 1); + break; + case "ResetDevice"://复位设备 + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + break; + case "IsNeedRepaire"://返修上线(返修上线点) + if (Convert.ToInt32(m_Value) == 1) + { + //修改托盘状态 + MIS_BASE.Write_PalletInfo(OpName, 3); + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + IsNeedRepaire_OK(OpName); + + } + else if (Convert.ToInt32(m_Value) == 0) + { + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + else + { } + + break; + case "ContinueMatch": + BaseDataSystemMES.QualityVerifyStatus_Hash_Write(OpName, true); + break; + //初始化网页信号 + case "IniSingalToWeb": + InitializeSingalToWeb(OpName); + break; + case "Reset_Engine"://返修上线(返修上线点) + SetMoby(OpName);//将MES所有信号清空 + //fun_EngineTypeGetOverPLC(OpName, 0); + //fun_EngineTypeGetOverPLC(OpName, 1); + break; + + + default: break; + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WebSubmit"); + } + } + private void SetMoby(string OpName) + { + try + { + //清空Moby时,需要将MES信号清空 + MIS_BASE.Write_ClearMesMoby(OpName); + + BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName); + + Sendmessage("5123", "1111", OpName); + + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + } + catch + { + + } + } + /// 网页重现登录,恢复关闭前的页面状态 + /// + /// 工位号 + private void InitializeSingalToWeb(string Opname) + { + + //工件到位 DBX0.1 + bool S_WorkStart; + bool S_FixAllow; + bool S_EngineGetOver; + bool S_MaterialVerifyOver; + + MIS_BASE.Read_WorkStart(Opname, out S_WorkStart); + MIS_BASE.Read_FixAllow(Opname, out S_FixAllow); + MIS_BASE.Read_EngineGetOver_PLC(Opname, out S_EngineGetOver); + MIS_BASE.Read_MaterialVerifyOver(Opname, out S_MaterialVerifyOver); + + Sendmessage("13", "1111", Opname); + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + // 新增查询PLC直通状态 网页显示 + MIS_BASE.Read_TagTypeID(63, Opname, out S_plcStatus); + if (S_plcStatus.ToLower() == "false") + { + SendMessageFun.SendInfomation("PlcStatus", "0", Opname); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", Opname); + } + + if (S_WorkStart == true) + { + SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname); + } + + if (S_FixAllow == true) + { + SendInfomation("FixAllow", Convert.ToString(Convert.ToInt32(S_FixAllow)), Opname); + } + if (S_MaterialVerifyOver == true) + { + SendInfomation("MaterialVerifyOver", Convert.ToString(Convert.ToInt32(S_MaterialVerifyOver)), Opname); + } + if (S_EngineGetOver == true) + { + SendInfomation("EngineTypeGetOverPLC", Convert.ToString(Convert.ToInt32(S_EngineGetOver)), Opname); + Sendmessage("2", "1111", Opname); + SendMessage.ShowMoby(Opname); + // 直接发送实时的 质量数据 + string message = MisDataSaveDateMesRead.Funtion.GetRealTimeQualityData(Opname); + //推送质量数据到MES的页面 + SendMessage.AsyncSendMessage("MES|ShowTimelyQuality_Resources|" + Opname + "|" + message); + } + InitAlarm(Opname); + } + private void InitAlarm(string Opname) + { + FuntionMesRead.Alarm_InitAlarm_Send(Opname, out Hashtable ht); + foreach (DictionaryEntry kv in ht) + { + var TagID = kv.Key.ToString(); + var TagValue = kv.Value.ToString(); + FuntionMesRead.Send_AlarmMsg(TagID, TagValue); + } + + } + } +} diff --git a/MisDataFunction/Function1056/OpcServer/WorkStart.cs b/MisDataFunction/Function1056/OpcServer/WorkStart.cs new file mode 100644 index 0000000..da1ef0a --- /dev/null +++ b/MisDataFunction/Function1056/OpcServer/WorkStart.cs @@ -0,0 +1,46 @@ +using bizFacade; +using MesServerWork; +using System; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工件到位与离开时,清空MES自身信号 + /// + /// + /// + private void WorkStart(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + if (tagValue > 0) + { + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartIn, DateTime.Now.ToString()); + } + else + { + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartOut, DateTime.Now.ToString()); + //后加,清空信号 + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WorkStart"); + } + } + + } +} diff --git a/MisDataFunction/Function1056/OpcServer/WritePLC.cs b/MisDataFunction/Function1056/OpcServer/WritePLC.cs new file mode 100644 index 0000000..83ede7c --- /dev/null +++ b/MisDataFunction/Function1056/OpcServer/WritePLC.cs @@ -0,0 +1,41 @@ +using System; +using System.Windows.Forms; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + ///1.扫描配送单号,用于接收物料,扫描单号的时候,将接收的物料信息显示在“物料拉动”Tab区域 + ///2.扫描料箱标签/看板卡,用于追溯物料批次信息 + ///3.扫描零件条码,根据零件图号进行防错 + ///第一步,判断条码类型,根据条码类型,执行对应的存储过程 + ///第二步,条码类型(将扫描的条码保存到对应的表中) + ///第三步,扫描完成之后给出允许工作信号 + /// 处理页面扫描条码 + /// + /// + /// + public void WritePLC(object e) + { + + { + try + { + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:Barcode"); + } + + } + + } + + + } +} diff --git a/MisDataFunction/Function1056/OpcServer/vssver2.scc b/MisDataFunction/Function1056/OpcServer/vssver2.scc new file mode 100644 index 0000000..b884d13 Binary files /dev/null and b/MisDataFunction/Function1056/OpcServer/vssver2.scc differ diff --git a/MisDataFunction/Function1056/Properties/AssemblyInfo.cs b/MisDataFunction/Function1056/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0bb79c4 --- /dev/null +++ b/MisDataFunction/Function1056/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Function02")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("苏州宏软信息技术有限公司")] +[assembly: AssemblyProduct("Function02")] +[assembly: AssemblyCopyright("Copyright © 苏州宏软信息技术有限公司 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("47710f2c-e141-4252-8d13-701bf4c1c027")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MisDataFunction/Function1056/Properties/vssver2.scc b/MisDataFunction/Function1056/Properties/vssver2.scc new file mode 100644 index 0000000..14e543b Binary files /dev/null and b/MisDataFunction/Function1056/Properties/vssver2.scc differ diff --git a/MisDataFunction/Function1056/mssccprj.scc b/MisDataFunction/Function1056/mssccprj.scc new file mode 100644 index 0000000..119193d --- /dev/null +++ b/MisDataFunction/Function1056/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[Function02.csproj] +SCC_Aux_Path = "\\192.168.0.100\vss\MES4.0" +SCC_Project_Name = "$/MisData/MisData/MisData/MesServer.Function/Function02", ILHAAAAA diff --git a/MisDataFunction/Function1056/packages.config b/MisDataFunction/Function1056/packages.config new file mode 100644 index 0000000..b3e1761 --- /dev/null +++ b/MisDataFunction/Function1056/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1056/vssver2.scc b/MisDataFunction/Function1056/vssver2.scc new file mode 100644 index 0000000..c770e28 Binary files /dev/null and b/MisDataFunction/Function1056/vssver2.scc differ diff --git a/MisDataFunction/Function1057/DataAccess/DataAccess.cs b/MisDataFunction/Function1057/DataAccess/DataAccess.cs new file mode 100644 index 0000000..574d619 --- /dev/null +++ b/MisDataFunction/Function1057/DataAccess/DataAccess.cs @@ -0,0 +1,15 @@ + +namespace MesServerFunctions +{ + partial class Function1052 + { + //针对“MIS.BizFacade.Dll”中没有的存储过程,在此类中新建 + //新建原则:所有的函数用private,只允许在内部使用 + //针对单个工艺特殊,需要新建存储过程,但是存储过程不能被加入到“MIS.BizFacade.Dll”中 + + private void aa() + { + + } + } +} diff --git a/MisDataFunction/Function1057/DataAccess/vssver2.scc b/MisDataFunction/Function1057/DataAccess/vssver2.scc new file mode 100644 index 0000000..d045c26 Binary files /dev/null and b/MisDataFunction/Function1057/DataAccess/vssver2.scc differ diff --git a/MisDataFunction/Function1057/Db.cs b/MisDataFunction/Function1057/Db.cs new file mode 100644 index 0000000..0e1fdc9 --- /dev/null +++ b/MisDataFunction/Function1057/Db.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DataLinkMesWork; + +namespace MesServerFunctions +{ + public class Db + { + /// + /// 合力_OPA90是否允许工作_判断 如果允许工作则将两个轮毂状态设为待匹配 + /// + /// + /// + /// + /// + /// + /// + /// + public static bool OP50_OPA90_MatchResult(int EngineTypeID, int EngineTypeID_QiaoKe, string EngineID, string OrderForm, out int MatchResult, out string MatchResultStr) + { + DataTable dt = new DataTable(); + MatchResult = 3;// 默认是报警 程序出错 + MatchResultStr = "默认是报警 程序出错";// 默认是报警 程序出错 + string produceName = "合力_OPA90是否允许工作_判断"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@轮毂机型", EngineTypeID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@轮毂总成号", EngineID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@桥壳_机型", EngineTypeID_QiaoKe); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@订单号", OrderForm); + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt)) + { + if (dt.Rows.Count > 0) + { + MatchResult = Convert.ToInt32(dt.Rows[0]["最终结果"]); + MatchResultStr = dt.Rows[0]["最终结果说明"].ToString(); + return true; + } + } + return false; + } + + public static bool OP051_OP050_NeedWork(string EngineID, string opName, string orderForm, out int MatchResult) + { + DataTable dt = new DataTable(); + MatchResult = 0; + string produceName = "合力_OP050前停判断_下工位是否需要工作"; + SqlParameter[] thisParms = new SqlParameter[3]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@桥壳总成号", EngineID); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位号", opName); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@订单号", orderForm); + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt)) + { + if (dt.Rows.Count > 0) + { + MatchResult = Convert.ToInt32(dt.Rows[0]["是否需要工作"]); + return true; + } + } + return false; + } + } +} diff --git a/MisDataFunction/Function1057/Function02.csproj.vspscc b/MisDataFunction/Function1057/Function02.csproj.vspscc new file mode 100644 index 0000000..0f0f36c --- /dev/null +++ b/MisDataFunction/Function1057/Function02.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:MesServer.Function\\Function02" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/MisDataFunction/Function1057/Function1057.csproj b/MisDataFunction/Function1057/Function1057.csproj new file mode 100644 index 0000000..142cf1b --- /dev/null +++ b/MisDataFunction/Function1057/Function1057.csproj @@ -0,0 +1,167 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {9377BB04-B518-4E77-8B90-E56FE7980204} + Library + Properties + Function1057 + Function1057 + v4.8 + 512 + + + + + + + + + + + + + + true + full + false + ..\..\MisDataFun_Exe\ + DEBUG;TRACE + prompt + 4 + false + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + ..\..\..\Common\dll\MQTTnet.dll + + + ..\..\..\Common\dll\MQTTnet.Extensions.ManagedClient.dll + + + False + ..\..\..\Common\dll\Newtonsoft.Json.dll + + + + + + ..\..\DLL\System.Net.Http.dll + + + ..\..\packages\System.Net.Security.4.3.2\lib\net46\System.Net.Security.dll + + + ..\..\packages\System.Net.WebSockets.4.3.0\lib\net46\System.Net.WebSockets.dll + + + ..\..\packages\System.Net.WebSockets.Client.4.3.2\lib\net46\System.Net.WebSockets.Client.dll + + + ..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll + + + ..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {f55da1a0-a982-4479-8c47-0d9a5aaf3e18} + 00MesWorkMqtt + + + {0d1af432-439a-4920-8692-43ae139f5530} + 01_01DoWhatPlc + + + {3e6d1dd5-01c9-435f-9941-61f906ce35bb} + 02_02WebApiCallPLC + + + {f434e066-4c59-47c8-aa82-6f48cc84501a} + 04-DataBaseAccess + + + {f0a0c525-03fd-428a-9b17-7f54aa0e4475} + 07BusinessFacade + + + {d98be764-adeb-488d-9714-61e308aa8201} + 08-WebFun_base + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 09-MesDataFunction + + + {e4eb6420-906d-4672-947a-ca33ddcdadfc} + 12SendMessageToWeb + + + {55b510c1-59e9-4bfd-ae84-d76d46f6e365} + 02-13.3MIS_FuntionSaveData + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1057/MesServerFunction/Fun_1057.cs b/MisDataFunction/Function1057/MesServerFunction/Fun_1057.cs new file mode 100644 index 0000000..6a943b5 --- /dev/null +++ b/MisDataFunction/Function1057/MesServerFunction/Fun_1057.cs @@ -0,0 +1,206 @@ +using MesServerWork; +using System.Collections.Generic; +using System.Threading; +using System.Xml.Linq; + +namespace MesServerFunctions +{ + public partial class FunctionMES + { + object lockFunWork; + //public void FunWork(DoWhatPlc.CustomeEvetnArgs e) + public void FunWork(string recData) + { + + + lockFunWork = new object(); + lock (lockFunWork) + { + List dataArray = DoWhatPlc.MessageText.GetCmdStringList(recData); + //string[] dataArray = recData.Split('|'); + //if (dataArray.Count != 4) + //return; + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 Barcode + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + DoWhatPlc.CustomeEvetnArgs e = new DoWhatPlc.CustomeEvetnArgs();// = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string tagValue; + + switch (m_Source) + { + case "BarCode": + e.OpName = m_OpName; + e.TagValue = m_Value; + fun_Barcode(e); + break; + case "WEB": + e.OpName = m_OpName; + e.TagValue = m_Command + "|" + m_Value; + fun_WebSubmit(e); + break; + case "PLC": + e = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + switch (e.TagValue.ToString().ToLower()) + { + case "false": + tagValue = "0"; + break; + case "true": + tagValue = "1"; + break; + default: + tagValue = e.TagValue.ToString(); + break; + } + e.TagValue = tagValue; + switch (e.TagTypeCodeID.ToString()) + { + //PLC 工件到位 + case "2": + fun_WorkStart(e); + break; + //PLC 允许保存质量数据 + case "19": + fun_MesRead(e); + break; + //MES 保存数据完成 + case "20": + fun_MesReadOver(e); + break; + //PLC 传递机型 + case "44": + fun_EngineTypeGetOverPLC(e); + break; + //MES 合格放行 + case "51": + fun_ConfirmOkGo(e); + break; + //MES 不合格放行 + case "8": + fun_FalseGo(e); + break; + //MES 系统健康心跳 + case "14": + fun_HeartBeatMIS(e); + break; + case "63": + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + MIS_BASE.Read_TagTypeID(63, m_OpName, out S_plcStatus); + if (S_plcStatus.ToLower() != "true" || S_plcStatus.ToLower() == "1") + { + SendMessageFun.SendInfomation("PlcStatus", "0", m_OpName); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", m_OpName); + } + break; + } + break; + } + } + } + + //1.工件到位后,PLC给MES传递机型(DBX0.4)(44), + //MES判断条码是否全部扫描完成 + //PLC给出允许保存(DBX100.2)(19),MES见到(DBX100.2)(19)为1后给出保存完成(DBX102.2)(20), + //PLC见到保存完成(DBX102.2)(20)为1后,清空允许保存(DBX100.2)(19), + //MES见到允许保存(DBX100.2)(19)为0后,清空保存完成(DBX102.2)(20) + //MES判断总合格标志(INT104)(21)为1后,给出合格放行(DBX2.5)(51) + /// + /// 扫描条码 + /// + /// + /// + public void fun_Barcode(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(Barcode, e); + } + + /// + /// 传递机型 + /// + /// + /// + public void fun_EngineTypeGetOverPLC(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(EngineTypeGetOver_PLC, e); + } + /// + /// 系统健康心跳监测 + /// + /// + /// + public void fun_HeartBeatMIS(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(HeartBeat, e); + } + /// + /// 合格放行 + /// + /// + /// + public void fun_ConfirmOkGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(ConfirmOkGo, e); + } + + /// + /// 不合格放行 + /// + /// + /// + public void fun_FalseGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(FalseGO, e); + } + + /// + /// 允许保存 + /// + /// + /// + public void fun_MesRead(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesRead, e); + } + + /// + /// 保存完成 + /// + /// + /// + public void fun_MesReadOver(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesReadOver, e); + } + + /// + /// 工件到位离开(清空所有的MES信号) + /// + /// + /// + public void fun_WorkStart(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WorkStart, e); + } + + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + public void fun_WebSubmit(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WebSubmit, e); + } + + + } +} diff --git a/MisDataFunction/Function1057/MesServerFunction/vssver2.scc b/MisDataFunction/Function1057/MesServerFunction/vssver2.scc new file mode 100644 index 0000000..a246f67 Binary files /dev/null and b/MisDataFunction/Function1057/MesServerFunction/vssver2.scc differ diff --git a/MisDataFunction/Function1057/Methods/EngineGetOverBaseWork.cs b/MisDataFunction/Function1057/Methods/EngineGetOverBaseWork.cs new file mode 100644 index 0000000..edaa222 --- /dev/null +++ b/MisDataFunction/Function1057/Methods/EngineGetOverBaseWork.cs @@ -0,0 +1,98 @@ +using System; +using System.Data; +using bizFacade; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 正常逻辑工作(传递机型) + /// + /// + /// + /// + /// + /// + private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code,string OrderForm) + { + int IsAllowWork; + int RepairPartStatusPLC = 0; + int MES_QualityMask = 1; + DataTable dt; + dt = BaseDataSystemMES.EngineTypeChange(OpName, EngineType); + //提示机型发生变化 + if (dt.Rows.Count > 0) + { + string mesValue = Newtonsoft.Json.JsonConvert.SerializeObject(dt);//(recData); + string message = "MES|MaterialList_Dif_Resources|" + OpName + "|" + mesValue; + SendMessage.AsyncSendMessage(message); + } + + //电子看板_装配零件_临时表_增加_北汽 + //第二步,将零件信息转移到零件_临时表中 + BaseDataSystemMES.MesServer_Process_EngineTypeOverBQ(OpName); + + //通知web显示 + SendMessageFun.SendMessage("123", "111", OpName); + MIS_BASE.Read_PalletInfo(OpName, out MES_QualityMask);//合格标志 + MIS_BASE.Read_RepairStatus_PLC(OpName, out RepairPartStatusPLC);//返修标志 + SendMessageFun.SendInfomation("QualityMask", Convert.ToString(MES_QualityMask), OpName);//显示合格标志 + SendMessageFun.SendInfomation("RepairPartStatusPLC", Convert.ToString(RepairPartStatusPLC), OpName);//显示返修标志 + + if (MES_QualityMask == 2) + { + ////工作完成 + //MIS_BASE.Write_MaterialVerifyOver(OpName, true); + //SendMessageFun.SendInfomation("NgGO", "1", OpName);//显示不合格标志 + //return; + } + + + //第三步,用于工件离开后完工数量统计及工件编号追溯 + //BaseDataSystemMES.MaterialPush_EngineIDStatus_Insert(OpName);//更新订单产量 + + //第四步,获取是否允许工作 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + //暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况 + if (IsAllowWork == 1) + { + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + + } + + + /// + /// 返修件需要工作 + /// + /// 工位号 + private void IsNeedRepaire_OK(string OpName) + { + string orderForm = ""; + int engineTypeID; + string engineType = ""; + string engineID = ""; + string palletCode = ""; + int isRepair; + string repairCode = ""; + //从监控系统中查询出本工位信息 + BaseDataSystemMES.OpName_MIS_Moby_Select(OpName, + out orderForm, out engineTypeID, out engineType, + out engineID, out palletCode, out isRepair, out repairCode); + + EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode),orderForm); + } + + + + + } +} diff --git a/MisDataFunction/Function1057/Methods/SubmitToMisweb.cs b/MisDataFunction/Function1057/Methods/SubmitToMisweb.cs new file mode 100644 index 0000000..52ce16f --- /dev/null +++ b/MisDataFunction/Function1057/Methods/SubmitToMisweb.cs @@ -0,0 +1,127 @@ +using System; +using bizFacade; +//using SystemFramework; + +namespace MesServerFunctions +{ + + /// + /// 此类用于向WEB发送各种类型消息 + /// + partial class FunctionMES + { + + /// + /// 批量发送WEB消息(Value为BOOL值) + /// + /// 消息编号组合 + /// 消息值组合 + /// 工位号 + void Sendmessage(string MessageNumm,string Value, string OpName) + { + for (int i=0;i + /// 选择发送给WEB的消息 + /// + /// 消息类型 + /// 消息工位 + string Sendmessage(char Num,string Value, string OpName) + { + string SendMessage; + string result = ""; + switch (Num) + { + case '1': + //1(直接在界面通过选择机型确认工序内容) + SendMessage = "MES|ProcessList|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '2': + //2显示物料 + SendMessage = "MES|MaterialList|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '3': + //3显示操作指导图片 + SendMessage = "MES|PicShow|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '4': + //4订单完工模块刷新完成数量 + SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '5': + SendMessage = "MES|ShowMoby|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '6': + SendMessage = "MES|MaterialCheckPosition|" + OpName + "|" +Value; + result = AsyncSendMessage(SendMessage); + break; + case '7': + SendMessage = "MES|WorkStart|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '8'://清除MES生成编号 + + break; + case '9': + SendMessage = "MES|ConfirmOkGo|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case 'a': + SendMessage = "MES|FixAllow|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + } + return result; + } + /// + /// 向WEB发送信息(value为字符串) + /// + /// 消息种类 + /// 消息内容 + /// 工位号 + string SendInfomation(string Command, string Value, string OpName) + { + string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value; + return AsyncSendMessage(SendMessage); + } + + + /// + /// 发送在线产量、在线节拍 + /// + /// + /// + private void SendActuallyCount(string OpName, int tagValue) + { + //当工件离开时,更新在线产量、在线节拍 + if (tagValue == 0) + { + try + { + int opNameCount = 0;//在线产量 + int opNameCountTime = 0;//在线节拍 + //基本数据_工作日历_班次产量查询_New + BaseDataSystemMES.OpNameCount_New(OpName, out opNameCount, out opNameCountTime); + string SendMessage; + SendMessage = "MES|ActuallyCount|" + OpName + "|" + opNameCount.ToString() + "&" + opNameCountTime.ToString(); + AsyncSendMessage(SendMessage); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:SendActuallyCount"); + } + } + } + + + } +} diff --git a/MisDataFunction/Function1057/Methods/UDP.Send.cs b/MisDataFunction/Function1057/Methods/UDP.Send.cs new file mode 100644 index 0000000..aed7cc3 --- /dev/null +++ b/MisDataFunction/Function1057/Methods/UDP.Send.cs @@ -0,0 +1,53 @@ +using bizFacade; +//using SystemFramework; +using MesServerWork; +using DataLinkMesWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 发送信息到MES通讯服务器或者其他的 + /// + /// + private string AsyncSendMessage(string Message) + { + return MIS_BASE.asyncSendMessage(Message); + } + + /// + /// 发送提示消息 + /// + /// + private void AsyncSendMessage_Notice(string opname, string notice) + { + //通知Web界面 + BaseDataSystemMES.Web_Notice_Insert(opname, notice); + string SendMessage = "MES|Notice|" + opname + "|" + "1"; + MIS_BASE.asyncSendMessage(SendMessage); + } + + /// + /// 发送信息到打印机 + /// + /// + private void asyncSendMessageToMark(string Message) + { + string messageSend = (string)Message; + //UDPClientSend.Send_ALL(ApplicationConfig.MES_MarkPortNum, messageSend); + } + + /// + /// 发送信息到LED + /// + /// + private void asyncSendMessageLED(string OpName) + { + //发送到大屏幕显示 41104 + string strMessage = "MIS|" + OpName + "|" + "0" + "|" + "1"; + //UDPClientSend.Send_ALL(ApplicationConfig.Port_ShowLED_ProductCount, strMessage); + + } + } +} diff --git a/MisDataFunction/Function1057/Methods/vssver2.scc b/MisDataFunction/Function1057/Methods/vssver2.scc new file mode 100644 index 0000000..7782f6f Binary files /dev/null and b/MisDataFunction/Function1057/Methods/vssver2.scc differ diff --git a/MisDataFunction/Function1057/OpcServer/Barcode.cs b/MisDataFunction/Function1057/OpcServer/Barcode.cs new file mode 100644 index 0000000..d9f59f8 --- /dev/null +++ b/MisDataFunction/Function1057/OpcServer/Barcode.cs @@ -0,0 +1,228 @@ +using System; +using System.Threading; +using System.Windows.Forms; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + ///1.扫描配送单号,用于接收物料,扫描单号的时候,将接收的物料信息显示在“物料拉动”Tab区域 + ///2.扫描料箱标签/看板卡,用于追溯物料批次信息 + ///3.扫描零件条码,根据零件图号进行防错 + ///第一步,判断条码类型,根据条码类型,执行对应的存储过程 + ///第二步,条码类型(将扫描的条码保存到对应的表中) + ///第三步,扫描完成之后给出允许工作信号 + /// 处理页面扫描条码 + /// + /// + /// + public void Barcode(object e) + { + + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string barcode = Convert.ToString(msgEvent.TagValue); + + int EngineTypeID;//机型代码 + string EngineType;//机型 + string EngineID;//工件编号 + + string OrderForm; + int Recipe1; + int Recipe2; + + bool IsNotRepeatedNumber = false; + //1:获得申请上线信息后,扫描条码才处理业务 + bool ispartload; + //(115) + int PTO; + //(118)0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + int NgearSwitch; + //(119)0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + int RgearSwitch; + //(120)0=不检测;1=检测。检测线上线工位扫描总成条码,根据BOM,查出 + int SpeedSensor; + //(121)例如:5S 400。检测线上线工位扫描总成条码,根据BOM,查出 + string PartTypeMid; + //(122) 0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + int Tcu_V; + + //判断是否开启线外上线 + if (!Convert.ToBoolean(MIS_BASE.ReadPLC(64, OpName))) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "若转线上线工件请在系统选择转线工件选项"); + return; + } + + //判断工件是否到位 + MIS_BASE.Read_WorkStart(OpName, out ispartload); + if (!ispartload) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请检查设备是否到位(DBX500.1=1)"); + return; + } + //判断设备是否申请上线 + MIS_BASE.Read_UpdatePalletOK(OpName, out ispartload); + if (!ispartload) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请检查设备是否申请上线(DBX500.3=1)"); + return; + } + // 判读条码是变速器序列号条码号还是物料号 小机型*日月年* 流水号(给起始号 + 数量) + // 选小机型 从北汽福田BOM中选 得先维护BOM + // 变速器序列号 '1333 050 062*16012023*30000001' + + //扫描完变速器序列号条码号 true + bool isGetOver_PLC = false; + //判断上线工位,MES 是否将工件流水号、机型等信息已经写入到PLC了 + MIS_BASE.Read_EngineGetOver_PLC(OpName, out isGetOver_PLC); + //如果工件流水号、机型等信息没有写入PLC,扫描的条码按工件流水号进行验证 + //否则按装配物料进行验证 + if (!isGetOver_PLC) + { + + if (barcode.Split('*').Length > 2) + { + //2: 判断是否重号, 从数据库获得机型、机型代码等信息 + string partSn = barcode; + EngineID = barcode; + + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID_MES, EngineID); + + //IsRepeatedNumber true 不重号;false 重号; + IsNotRepeatedNumber = BaseDataSystemMES.EngineTypeID_IsNotRepeatedNumber(partSn); + if (IsNotRepeatedNumber) + { + BaseDataSystemMES.GetEngineTypeUpLoadOpName(partSn, OpName, out EngineTypeID, out EngineType, out OrderForm, out Recipe1, out Recipe2); + + + BaseDataSystemMES.UpLoadPTO(EngineType, out PTO, out NgearSwitch, out RgearSwitch, out SpeedSensor, out PartTypeMid, out Tcu_V); + //PTO + MIS_BASE.WritePLC(115, OpName, PTO); + //空挡开关检测 + MIS_BASE.WritePLC(95, OpName, NgearSwitch); + //倒挡开关检测 + MIS_BASE.WritePLC(96, OpName, RgearSwitch); + //里程表检测 + MIS_BASE.WritePLC(97, OpName, SpeedSensor); + //大机型扩展 + MIS_BASE.WritePLC(98, OpName, PartTypeMid); + //TCU + MIS_BASE.WritePLC(122, OpName, Tcu_V); + string tagStartAdr;//= "DB411.10"; + + // 先查询配方号 根据工位号 去moby表查配方号 + // 根据配方号 去配方表查配方数据 + // 写入配方数据 + BaseDataSystemMES.PLCRcipeCurrent(OpName, out byte[] bytes, out tagStartAdr); + DtWebApi.ReadWritePLC.Write_TagValueByTagTypeID("94", OpName, System.Text.Encoding.ASCII.GetString(bytes)); + ////将产品信息写入PLC + MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID); + MIS_BASE.Write_EngineType_MES(OpName, EngineType); + MIS_BASE.Write_EngineID_MES(OpName, EngineID); + MIS_BASE.Write_OrderForm_MES(OpName, OrderForm); + + //写入到数据库的[北汽福田工位状态监控MOBY]表中 + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineTypeID_MES, EngineTypeID.ToString()); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineType_MES, EngineType); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID_MES, EngineID); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.OrderForm_MES, OrderForm); + + //通知web显示 + SendMessage.ShowMoby(OpName); + //在PLC传递机型后进行允许工作 + //MIS_BASE.Write_FixAllow(OpName, true); + SendMessageFun.AsyncSendMessage_Notice(OpName, "扫码成功,请开始工作!"); + //SendMessageFun.SendMessage("1235", "1111", OpName); + + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, true); + //Thread.Sleep(1000); + //MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "变速器序列号 重号,请确认!"); + } + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "变速器序列号格式不正确,请确认!"); + + } + } + else//验证物料 + { + //物料号 + { + //读取PLC的传递机型信号 + bool tagValue; + MIS_BASE.Read_EngineGetOver_PLC(OpName, out tagValue); + if (tagValue) + { + //验证物料 + BaseDataSystemMES.PartMaterial_DM_Update(OpName, barcode, out bool IsSuccess); + if (!IsSuccess)//???? + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认"); + return; + } + else + { + SendMessageFun.SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息 + } + //判断物料是否验证完成 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out int IsAllowWork); + + + if (IsSuccess) + { + if (IsAllowWork == 1) + { + //移到允许保存信号中 + //BaseDataSystemMES.Material_Insert(OpName, 1); + + ////更新订单完工数量及物料 + SendMessageFun.SendMessage("24", "11", OpName); + + //物料验证完成,通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC未传递机型"); + } + } + else + { + SendMessage.AsyncSendMessage_Notice(OpName, "产品上线后,PLC获得变速器序列号后,再验证物料!"); + } + + } + } + + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:Barcode"); + } + + } + + } + + + } +} diff --git a/MisDataFunction/Function1057/OpcServer/ConfirmOkGo.cs b/MisDataFunction/Function1057/OpcServer/ConfirmOkGo.cs new file mode 100644 index 0000000..06e6b33 --- /dev/null +++ b/MisDataFunction/Function1057/OpcServer/ConfirmOkGo.cs @@ -0,0 +1,41 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 合格放行 + /// + /// + /// + private void ConfirmOkGo(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + + BaseDataSystemMES.Material_Insert(OpName, 1); + + //更新订单完工数量及物料 + Sendmessage("24", "11", OpName); + + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:ConfirmOkGo"); + } + } + } +} diff --git a/MisDataFunction/Function1057/OpcServer/EngineGetOver.cs b/MisDataFunction/Function1057/OpcServer/EngineGetOver.cs new file mode 100644 index 0000000..fd4ae58 --- /dev/null +++ b/MisDataFunction/Function1057/OpcServer/EngineGetOver.cs @@ -0,0 +1,79 @@ +using System; +using System.Data; +using System.Windows.Forms; +using System.Xml.Linq; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// PLC传递机型处理 + /// + /// + /// + private void EngineTypeGetOver_PLC(object e) + { + + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + + if (EngineTypeID <= 0 || EngineID.Length == 0 || EngineType.Length == 0 || OrderForm.Length == 0) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC传递机型为空"); + return; + } + + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineTypeID, EngineTypeID.ToString()); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineType, EngineType); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID, EngineID); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.OrderForm, OrderForm); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.PartPallet_Code, PartPallet_Code.ToString()); + //显示当前订单信息 + SendMessage.ShowMoby(OpName); + //判断该订单数据是否已经工作过,有的话则在WEB跳出弹窗选择 并同时禁止工作 + //DataTable dt2 = BaseDataSystemMES.EngineIsTwoWork(OpName, OrderForm, EngineID); + //if (dt2.Rows[0]["result"].ToString() == "1") //已完成 + //{ + // //不允许工作 + // MIS_BASE.Write_FixAllow(OpName, false); + // //通知WEB校验重新工作还是跳过 点重新工作给允许工作,点跳过给工作完成 + // string message = "MES|Engine_Is_TwoWork|" + OpName + "|1"; + // SendMessage.AsyncSendMessage(message); + //} + //else + //{ + // EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm); + //} + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:EngineTypeGetOver_PLC"); + } + } + + + } + + + } +} diff --git a/MisDataFunction/Function1057/OpcServer/FalseGO.cs b/MisDataFunction/Function1057/OpcServer/FalseGO.cs new file mode 100644 index 0000000..4ad2665 --- /dev/null +++ b/MisDataFunction/Function1057/OpcServer/FalseGO.cs @@ -0,0 +1,41 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 不合格放行 + /// + /// + /// + private void FalseGO(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + //总合格标志2(不合格) + + BaseDataSystemMES.Material_Insert_NG(OpName, 2); + + Sendmessage("24", "11", OpName); + + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1057/OpcServer/HeartBeat.cs b/MisDataFunction/Function1057/OpcServer/HeartBeat.cs new file mode 100644 index 0000000..93affd3 --- /dev/null +++ b/MisDataFunction/Function1057/OpcServer/HeartBeat.cs @@ -0,0 +1,35 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// MES与PLC心跳监听 + /// + /// + /// + private void HeartBeat(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //返写在MES心跳中 + MIS_BASE.WritePLC(15, OpName, tagValue); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1057/OpcServer/MesRead.cs b/MisDataFunction/Function1057/OpcServer/MesRead.cs new file mode 100644 index 0000000..2496314 --- /dev/null +++ b/MisDataFunction/Function1057/OpcServer/MesRead.cs @@ -0,0 +1,123 @@ +using bizFacade; +using MesServerWork; +using System; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 允许保存(针对半自动和手动压装工位) + /// + /// + /// + private void MesRead(object e) + { + { + try + { + + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + int qualityMask; + + //保存质量数据 + qualityMask = MisDataSaveDateMesRead.Funtion.MesRead_J07MA150(OpName, tagValue.ToString(), msgEvent.TagID.ToString()); + //保存物料数据 + BaseDataSystemMES.Material_Insert(OpName, qualityMask); + + //测量数据发动机在线状态 + BaseDataSystemMES.WorkStartInsert(OpName, qualityMask); + + //推送质量数据到MES的页面d + SendMessageFun.SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName); + + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + string SLResult = MIS_BASE.ReadPLC(41, OpName).ToString(); //试漏结果 + int TurnLineWork = Convert.ToInt32(MIS_BASE.ReadPLC(64, OpName)); //是否转线 + // 保存150工位试漏结果 + BaseDataSystemMES.SLResult_Add( SLResult, EngineID, EngineType, EngineTypeID, TurnLineWork); + + //通知设备,MES的质量数据(和物料数据)保存完成 + MIS_BASE.Write_MesReadOver(OpName, true); + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + + //统计在线产量,在线节拍 + SendMessage.SendActuallyCount(OpName, tagValue); + + string awaitOpName = "OPA90"; + // 读取A90 是否在等待 + int isAwait = Convert.ToInt32(MIS_BASE.ReadPLC(29, awaitOpName)); + // 如果是OPA60 的话去再次判断工件匹配状态 + if (isAwait == 1) + { + MIS_BASE.Read_TagTypeID(201, awaitOpName, out string EngineTypeID_QiaoKe); + + string await_EngineID = MIS_BASE.ReadPLC(10, awaitOpName).ToString(); // 读取A90等待工件的工件编号 + int await_EngineTypeID = Convert.ToInt32(MIS_BASE.ReadPLC(9, awaitOpName)); // 读取A90等待工件的机型编号 + string await_OrderForm = MIS_BASE.ReadPLC(39, awaitOpName).ToString(); // 读取A90等待工件的订单号 + Db.OP50_OPA90_MatchResult(await_EngineTypeID, Convert.ToInt32(EngineTypeID_QiaoKe), await_EngineID, await_OrderForm, out int MatchResult, out string MatchResultStr); + if (MatchResult == 1) + { + // 轮毂线 + MIS_BASE.Write_Match(awaitOpName, true);// 匹配结果 + MIS_BASE.Write_MatchingCompleted(awaitOpName, true);// 匹配完成 + MIS_BASE.Write_FixAllow(awaitOpName, true); // 允许工作 + MIS_BASE.WritePLC(29, awaitOpName, false); // 取消等待 + return; + } + } + + string awaitOpName2 = "OP051"; + // 读取A90 是否在等待 + int isAwait2 = Convert.ToInt32(MIS_BASE.ReadPLC(29, awaitOpName2)); + if (isAwait2 == 1 && OpName == "OPA60") + { + string await2_EngineID = MIS_BASE.ReadPLC(10, awaitOpName2).ToString(); // 读取051等待工件的工件编号 + string await2_OrderForm = MIS_BASE.ReadPLC(39, awaitOpName2).ToString(); // 读取051等待工件的订单号 + + + Db.OP051_OP050_NeedWork(await2_EngineID, awaitOpName2, await2_OrderForm, out int MatchResult); + + if (MatchResult == 1) //匹配 有需要装配的轮毂 + { + MIS_BASE.Write_Match(awaitOpName2, true);// 匹配结果 + MIS_BASE.Write_MatchingCompleted(awaitOpName2, true);// 匹配完成 + MIS_BASE.WritePLC(77, awaitOpName2, "1");// 托盘是否需要工作 1:需要工作 2:不需要工作 + MIS_BASE.Write_FixAllow(awaitOpName2, true); // 允许工作 + MIS_BASE.WritePLC(29, awaitOpName2, false); // 取消等待 + } + } + } + else + { + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + } + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + + } + } +} diff --git a/MisDataFunction/Function1057/OpcServer/MesReadOver.cs b/MisDataFunction/Function1057/OpcServer/MesReadOver.cs new file mode 100644 index 0000000..f96a7d3 --- /dev/null +++ b/MisDataFunction/Function1057/OpcServer/MesReadOver.cs @@ -0,0 +1,55 @@ +using System; +//using SystemFramework; +using MesServerWork; +using bizFacade; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 保存完成(针对半自动和手动压装工位) + /// + /// + /// + private void MesReadOver(object e) + { + //try + //{ + // DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + // string OpName = Convert.ToString(msgEvent.OpName); + // var tagValue = msgEvent.TagValue.ToString (); + + // if (tagValue == "1" | tagValue.ToLower () == "true") + // { + // int qualityMask; + // MIS_BASE.Read_QualityMask(OpName, out qualityMask); + + // SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName);//发给Web页面显示质量数据 + + // if (qualityMask == 1)//全部OK,给出合格放行 + // { + // //如果存在线外扫描工位,根据扫描条码绑定线外数据 需要时解除禁用 + // //BaseDataSystemMES.TransLaunchDataByMainMaterial(OpName, EngineType, EngineID, EngineTypeID); + + // //如果存在线外排队工位,根据排队编号绑定线外数据 需要时解除禁用 + // ////BaseDataSystemMES.MailLineAndSubLineData_InsertByEngineID_Subline(OpName,EngineID, EngineTypeID, EngineType); + + // MIS_BASE.Write_ConfirmOkGo(OpName, true); + // //MIS_BASE.Write_FalseGO(OpName, false); + // } + // else + // { + // //MIS_BASE.Write_ConfirmOkGo(OpName, false); + // MIS_BASE.Write_FalseGO(OpName, true); + // } + + // } + //} + //catch (Exception err) + //{ + // ////ApplicationLog.WriteLog(err, "Function02:MesReadOver"); + //} + } + } +} diff --git a/MisDataFunction/Function1057/OpcServer/WebSubmit.cs b/MisDataFunction/Function1057/OpcServer/WebSubmit.cs new file mode 100644 index 0000000..fc79ae5 --- /dev/null +++ b/MisDataFunction/Function1057/OpcServer/WebSubmit.cs @@ -0,0 +1,307 @@ +using System; +using MesServerWork; +using bizFacade; +using System.Threading; +using MisDataSaveDate; +using System.Collections; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + private void WebSubmit(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName=Convert.ToString(msgEvent.OpName); + string Content = Convert.ToString(msgEvent.TagValue); + + string[] dataArray = Content.Split('|'); + if (dataArray.Length != 2) + return; + //消息类型 + string m_Command = dataArray[0].ToString(); + //消息参数 + string m_Value = dataArray[1].ToString(); + //消息参数数量 + string[] m_Value_array = m_Value.Split('&'); + //消息参数长度 + int m_Value_length = m_Value_array.Length; + + //工件信息 + string engineID = ""; + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + engineID = MIS_BASE.hashtable_EngineGetOver_EngineID[OpName].ToString(); + } + + DoWhatPlc.CustomeEvetnArgs _e = new DoWhatPlc.CustomeEvetnArgs(); + _e.OpName = OpName; + _e.TagValue = m_Value; + + //根据请求的命令处理逻辑 + switch (m_Command) + { + case "Barcode": + if (m_Value_length > 1) return; + fun_Barcode(_e); + break; + case "ConfirmOkGo"://合格放行 + //删除不合格放行记录 + //修改托盘状态 + //Update_PalletStatus(OpName, 1, false); + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_ConfirmOkGo(OpName, true); + MIS_BASE.Write_FalseGO(OpName, false); + + Thread.Sleep(1000); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + break; + case "FalseGO"://返修放行 + //修改托盘状态 + //Update_PalletStatus(OpName, 3, false); + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "NgGO"://不合格放行 + //修改托盘状态 + //Update_PalletStatus(OpName, 2, false); + //保存不合格信息(必须保存不合格放行信息,由于B5A的Moby没有不合格标志位) + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Insert(OpName, engineID, "", ""); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "OnLineState"://在线0、离线1、屏蔽2 + try + { + if (m_Value_length > 1) return; + int a = Convert.ToInt32(m_Value); + if (a <= 2) + { + BaseDataSystemMES.IsOnLine_Update(OpName, m_Value.ToString()); + MIS_BASE.Write_OnLineState(OpName, Convert.ToInt32(m_Value)); + if (a == 2) SendMessage.AsyncSendMessage_Notice(OpName, "屏蔽MES!"); + if (a == 0) SendMessage.AsyncSendMessage_Notice(OpName, "启用MES!"); + } + } + catch + { + + } + break; + case "Reset"://复位,将MES所有的信息都复位了 + SetMoby(OpName);//将MES所有信号清空 + break; + case "TurnLineWork"://150工位独有,转线上线标志 + SendMessage.AsyncSendMessage_Notice(OpName, "切换成功!"); + if (Convert.ToInt32(m_Value) == 1) //(0 正常工件 ,1 转线工件) + { + //写入转线标识点 (64)501.6 + MIS_BASE.WritePLC(64, OpName, true); + } + else + { + MIS_BASE.WritePLC(64, OpName, false); + } + break; + case "FixAllow"://重新拧紧 + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_FixAllow(OpName, true); + break; + case "IsAutoGetEngineID"://自动手动申请编号(线首) + if (m_Value_length > 1) return; + MIS_BASE.Write_IsAutoGetEngineID(OpName, Convert.ToInt32(m_Value)); + break; + case "PartPalletGoOver"://空托盘放行 + int Is_PartPalletGoOver; + MIS_BASE.Read_PartPalletGoOver(OpName, out Is_PartPalletGoOver); + if (Is_PartPalletGoOver == 1) + { + MIS_BASE.Write_PartPalletGoOver(OpName, 1); + } + else + { + MIS_BASE.Write_PartPalletGoOver(OpName,0); + } + break; + case "SetMoby"://清空托盘(线首) + SetMoby(OpName);//将MES所有信号清空 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "RepairUplineMES"://返修上线 + MIS_BASE.Write_RepairUpline_MES(OpName, true); + break; + case "CancelRepair"://将返修件置为正常件 + + break; + case "PartPalletCode"://申请写入托盘号 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "WritePartPalletCode"://写入托盘号 + if (m_Value_length > 1) return; + MIS_BASE.Write_PalletCode(OpName, Convert.ToInt32(m_Value)); + break; + case "Normal"://启用正常拧紧工位 + MIS_BASE.Write_Normal(OpName, 1); + MIS_BASE.Write_UnNormal(OpName, 0); + break; + case "UnNormal"://启用备用拧紧工位 + MIS_BASE.Write_Normal(OpName, 0); + MIS_BASE.Write_UnNormal(OpName, 1); + break; + case "ResetDevice"://复位设备 + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + break; + case "IsNeedRepaire"://返修上线(返修上线点) + if (Convert.ToInt32(m_Value) == 1) + { + //修改托盘状态 + MIS_BASE.Write_PalletInfo(OpName, 3); + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + IsNeedRepaire_OK(OpName); + + } + else if (Convert.ToInt32(m_Value) == 0) + { + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + else + { } + + break; + case "ContinueMatch": + BaseDataSystemMES.QualityVerifyStatus_Hash_Write(OpName, true); + break; + //初始化网页信号 + case "IniSingalToWeb": + InitializeSingalToWeb(OpName); + break; + case "Reset_Engine"://返修上线(返修上线点) + SetMoby(OpName);//将MES所有信号清空 + //fun_EngineTypeGetOverPLC(OpName, 0); + //fun_EngineTypeGetOverPLC(OpName, 1); + break; + + + default: break; + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WebSubmit"); + } + } + private void SetMoby(string OpName) + { + try + { + //清空Moby时,需要将MES信号清空 + MIS_BASE.Write_ClearMesMoby(OpName); + + BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName); + + Sendmessage("5123", "1111", OpName); + + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + } + catch + { + + } + } + /// 网页重现登录,恢复关闭前的页面状态 + /// + /// 工位号 + private void InitializeSingalToWeb(string Opname) + { + try + { + //工件到位 DBX0.1 + bool S_WorkStart; + bool S_FixAllow; + bool S_EngineGetOver; + bool S_MaterialVerifyOver; + + MIS_BASE.Read_WorkStart(Opname, out S_WorkStart); + MIS_BASE.Read_FixAllow(Opname, out S_FixAllow); + MIS_BASE.Read_EngineGetOver_PLC(Opname, out S_EngineGetOver); + MIS_BASE.Read_MaterialVerifyOver(Opname, out S_MaterialVerifyOver); + + Sendmessage("13", "1111", Opname); + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + // 新增查询PLC直通状态 网页显示 + MIS_BASE.Read_TagTypeID(63, Opname, out S_plcStatus); + if (S_plcStatus.ToLower() == "false") + { + SendMessageFun.SendInfomation("PlcStatus", "0", Opname); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", Opname); + } + + if (S_WorkStart == true) + { + SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname); + } + + if (S_EngineGetOver == true) + { + SendInfomation("EngineTypeGetOverPLC", Convert.ToString(Convert.ToInt32(S_EngineGetOver)), Opname); + Sendmessage("2", "1111", Opname); + SendMessage.ShowMoby(Opname); + } + if (S_FixAllow == true) + { + SendInfomation("FixAllow", Convert.ToString(Convert.ToInt32(S_FixAllow)), Opname); + } + if (S_MaterialVerifyOver == true) + { + SendInfomation("MaterialVerifyOver", Convert.ToString(Convert.ToInt32(S_MaterialVerifyOver)), Opname); + } + InitAlarm(Opname); + } + catch (Exception err) + { + + } + + } + private void InitAlarm(string Opname) + { + FuntionMesRead.Alarm_InitAlarm_Send(Opname, out Hashtable ht); + foreach (DictionaryEntry kv in ht) + { + var TagID = kv.Key.ToString(); + var TagValue = kv.Value.ToString(); + FuntionMesRead.Send_AlarmMsg(TagID, TagValue); + } + + } + } +} diff --git a/MisDataFunction/Function1057/OpcServer/WorkStart.cs b/MisDataFunction/Function1057/OpcServer/WorkStart.cs new file mode 100644 index 0000000..5739456 --- /dev/null +++ b/MisDataFunction/Function1057/OpcServer/WorkStart.cs @@ -0,0 +1,44 @@ +using bizFacade; +using MesServerWork; +using System; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工件到位与离开时,清空MES自身信号 + /// + /// + /// + private void WorkStart(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + if (tagValue > 0) + { + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartIn, DateTime.Now.ToString()); + } + else + { + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartOut, DateTime.Now.ToString()); + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WorkStart"); + } + } + + } +} diff --git a/MisDataFunction/Function1057/OpcServer/vssver2.scc b/MisDataFunction/Function1057/OpcServer/vssver2.scc new file mode 100644 index 0000000..b884d13 Binary files /dev/null and b/MisDataFunction/Function1057/OpcServer/vssver2.scc differ diff --git a/MisDataFunction/Function1057/Properties/AssemblyInfo.cs b/MisDataFunction/Function1057/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0bb79c4 --- /dev/null +++ b/MisDataFunction/Function1057/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Function02")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("苏州宏软信息技术有限公司")] +[assembly: AssemblyProduct("Function02")] +[assembly: AssemblyCopyright("Copyright © 苏州宏软信息技术有限公司 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("47710f2c-e141-4252-8d13-701bf4c1c027")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MisDataFunction/Function1057/Properties/vssver2.scc b/MisDataFunction/Function1057/Properties/vssver2.scc new file mode 100644 index 0000000..14e543b Binary files /dev/null and b/MisDataFunction/Function1057/Properties/vssver2.scc differ diff --git a/MisDataFunction/Function1057/mssccprj.scc b/MisDataFunction/Function1057/mssccprj.scc new file mode 100644 index 0000000..119193d --- /dev/null +++ b/MisDataFunction/Function1057/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[Function02.csproj] +SCC_Aux_Path = "\\192.168.0.100\vss\MES4.0" +SCC_Project_Name = "$/MisData/MisData/MisData/MesServer.Function/Function02", ILHAAAAA diff --git a/MisDataFunction/Function1057/packages.config b/MisDataFunction/Function1057/packages.config new file mode 100644 index 0000000..b3e1761 --- /dev/null +++ b/MisDataFunction/Function1057/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1057/vssver2.scc b/MisDataFunction/Function1057/vssver2.scc new file mode 100644 index 0000000..c770e28 Binary files /dev/null and b/MisDataFunction/Function1057/vssver2.scc differ diff --git a/MisDataFunction/Function1058/DataAccess/DataAccess.cs b/MisDataFunction/Function1058/DataAccess/DataAccess.cs new file mode 100644 index 0000000..a7f91fa --- /dev/null +++ b/MisDataFunction/Function1058/DataAccess/DataAccess.cs @@ -0,0 +1,16 @@ + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + //针对“MIS.BizFacade.Dll”中没有的存储过程,在此类中新建 + //新建原则:所有的函数用private,只允许在内部使用 + //针对单个工艺特殊,需要新建存储过程,但是存储过程不能被加入到“MIS.BizFacade.Dll”中 + + private void aa() + { + + } + } +} diff --git a/MisDataFunction/Function1058/DataAccess/vssver2.scc b/MisDataFunction/Function1058/DataAccess/vssver2.scc new file mode 100644 index 0000000..1083b3a Binary files /dev/null and b/MisDataFunction/Function1058/DataAccess/vssver2.scc differ diff --git a/MisDataFunction/Function1058/Db.cs b/MisDataFunction/Function1058/Db.cs new file mode 100644 index 0000000..64286ed --- /dev/null +++ b/MisDataFunction/Function1058/Db.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DataLinkMesWork; + +namespace MesServerFunctions +{ + public class Db + { + /// + /// 北汽福田变速器序列号总线上线_获得机型信息 + /// + /// + /// + /// + /// + /// 0 不重号;1 重号;2:失败 + /// + public static bool GetEngineType(string partSn, out int EngineTypeID, out string EngineType, out string EngineID,out int IsRepeatedNumber) + { + DataTable dt = new DataTable(); + EngineTypeID = 0; + EngineType = ""; + EngineID = ""; + IsRepeatedNumber = 2; + string produceName = "北汽福田变速器序列号总线上线_获得机型信息"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@变速器序列号", partSn); + + thisParms[2].Direction = ParameterDirection.Output; + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms,out dt)) + { + if(dt.Rows.Count > 0) + { + IsRepeatedNumber = Convert.ToInt32( dt.Rows[0]["IsRepeatedNumber"]); + EngineTypeID = Convert.ToInt32(dt.Rows[0]["EngineTypeID"]); + EngineType = dt.Rows[0]["EngineType"].ToString(); + EngineID = partSn; + return true; + } + } + return false; + } + /// + /// 北汽福田变速器序列号总线上线_增加 + /// + /// + /// + /// + /// + /// + public static bool UpLoadOpNameInsert(string partSn, int EngineTypeID, string EngineType, string OpName) + { + + string produceName = "北汽福田变速器序列号总线上线_增加"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@变速器序列号", partSn); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@基本型号代码", EngineTypeID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@基本型号", EngineType); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@工位号", OpName); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + // ALTER PROCEDURE[dbo].[北汽福田变速器序列号总线上线_增加] + // @变速器序列号 nvarchar(50)='1333 050 062 0001*146012023*12345678',--'1333 050 062 0001' + //@基本型号代码 int=1, + //@基本型号 nvarchar(50)='1333 050 062 0001', + //@工位号 nvarchar(50) = 'J05PA010' + } +} diff --git a/MisDataFunction/Function1058/Function08.csproj.vspscc b/MisDataFunction/Function1058/Function08.csproj.vspscc new file mode 100644 index 0000000..82c6db2 --- /dev/null +++ b/MisDataFunction/Function1058/Function08.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:MesServer.Function\\Function08" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/MisDataFunction/Function1058/Function1058.csproj b/MisDataFunction/Function1058/Function1058.csproj new file mode 100644 index 0000000..8be72b1 --- /dev/null +++ b/MisDataFunction/Function1058/Function1058.csproj @@ -0,0 +1,168 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {FC07F99C-0C97-4FEF-9A0E-CA4883400464} + Library + Properties + Function1058 + Function1058 + v4.8 + 512 + + + + + + + + + + + + + + true + full + false + ..\..\MisDataFun_Exe\ + DEBUG;TRACE + prompt + 4 + AnyCPU + false + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + ..\..\..\Common\dll\MQTTnet.dll + + + ..\..\..\Common\dll\MQTTnet.Extensions.ManagedClient.dll + + + False + ..\..\..\Common\dll\Newtonsoft.Json.dll + + + + + + ..\..\DLL\System.Net.Http.dll + + + ..\..\packages\System.Net.Security.4.3.2\lib\net46\System.Net.Security.dll + + + ..\..\packages\System.Net.WebSockets.4.3.0\lib\net46\System.Net.WebSockets.dll + + + ..\..\packages\System.Net.WebSockets.Client.4.3.2\lib\net46\System.Net.WebSockets.Client.dll + + + ..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll + + + ..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {f55da1a0-a982-4479-8c47-0d9a5aaf3e18} + 00MesWorkMqtt + + + {0d1af432-439a-4920-8692-43ae139f5530} + 01_01DoWhatPlc + + + {3e6d1dd5-01c9-435f-9941-61f906ce35bb} + 02_02WebApiCallPLC + + + {f434e066-4c59-47c8-aa82-6f48cc84501a} + 04-DataBaseAccess + + + {f0a0c525-03fd-428a-9b17-7f54aa0e4475} + 07BusinessFacade + + + {d98be764-adeb-488d-9714-61e308aa8201} + 08-WebFun_base + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 09-MesDataFunction + + + {e4eb6420-906d-4672-947a-ca33ddcdadfc} + 12SendMessageToWeb + + + {55b510c1-59e9-4bfd-ae84-d76d46f6e365} + 02-13.3MIS_FuntionSaveData + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1058/MesServerFunction/Function1058.cs b/MisDataFunction/Function1058/MesServerFunction/Function1058.cs new file mode 100644 index 0000000..1c5713d --- /dev/null +++ b/MisDataFunction/Function1058/MesServerFunction/Function1058.cs @@ -0,0 +1,253 @@ + +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Threading; + +namespace MesServerFunctions +{ + public partial class FunctionMES + { + object lockFunWork; + //public void FunWork(DoWhatPlc.CustomeEvetnArgs e) + public void FunWork(string recData) + { + + + lockFunWork = new object(); + lock (lockFunWork) + { + List dataArray = DoWhatPlc.MessageText.GetCmdStringList(recData); + //string[] dataArray = recData.Split('|'); + //if (dataArray.Count != 4) + //return; + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 Barcode + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + DoWhatPlc.CustomeEvetnArgs e =new DoWhatPlc.CustomeEvetnArgs();// = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string tagValue; + + switch (m_Source) + { + case "BarCode": + e.OpName = m_OpName; + e.TagValue = m_Value; + fun_Barcode(e); + + break; + case "WEB": + e.OpName = m_OpName; + e.TagValue = m_Command + "|" + m_Value; + fun_WebSubmit(e); + break; + case "PLC": + e = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + switch (e.TagValue.ToString().ToLower()) + { + case "false": + tagValue = "0"; + break; + case "true": + tagValue = "1"; + break; + default: + tagValue = e.TagValue.ToString(); + break; + } + e.TagValue = tagValue; + switch (e.TagTypeCodeID.ToString()) + { + //PLC 工件到位 + case "2": + fun_WorkStart(e); + break; + //PLC 允许保存质量数据 + case "19": + fun_MesRead(e); + break; + //MES 保存数据完成 + case "20": + fun_MesReadOver(e); + break; + //PLC 传递机型 + case "44": + fun_EngineTypeGetOverPLC(e); + break; + //MES 合格放行 + case "51": + fun_ConfirmOkGo(e); + break; + //MES 不合格放行 + case "8": + fun_FalseGo(e); + break; + //MES 系统健康心跳 + case "14": + fun_HeartBeatMIS(e); + break; + case "63": + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + MIS_BASE.Read_TagTypeID(63, m_OpName, out S_plcStatus); + if (S_plcStatus.ToLower() != "true" || S_plcStatus.ToLower() == "1") + { + SendMessageFun.SendInfomation("PlcStatus", "0", m_OpName); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", m_OpName); + } + break; + } + break; + } + } + } + //public void FunWork(DoWhatPlc.CustomeEvetnArgs e) + //{ + // //lock1 = new object(); + // //lock (lock1) + // { + // switch (e.TagTypeCodeID.ToString()) + // { + // //PLC 工件到位 + // case "2": + // fun_WorkStart(e); + // break; + // //PLC 允许保存质量数据 + // case "19": + // fun_MesRead(e); + // break; + // //MES 保存数据完成 + // case "20": + // fun_MesReadOver(e); + // break; + // //PLC 传递机型 + // case "44": + // fun_EngineTypeGetOverPLC(e); + // break; + // //MES 合格放行 + // case "51": + // fun_ConfirmOkGo(e); + // break; + // //MES 不合格放行 + // case "8": + // fun_FalseGo(e); + // break; + // //MES 扫描条码 + // case "Barcode": + // fun_Barcode(e); + // break; + // //WEB 处理页面传递过来的数据 + // case "WebSubmit": + // fun_WebSubmit(e); + // break; + // } + // } + + //} + //1.工件到位后,PLC给MES传递机型(DBX0.4)(44), + //2.MES判断是否扫描完成 + //3.若扫描完成,则MES给出合格放行(DBX2.5)(51) + /// + /// 扫描条码 + /// + /// + /// + public void fun_Barcode(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(Barcode, e); + } + + + /// + /// 传递机型 + /// + /// + /// + public void fun_EngineTypeGetOverPLC(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(EngineTypeGetOver_PLC, e); + } + + /// + /// 合格放行 + /// + /// + /// + public void fun_ConfirmOkGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(ConfirmOkGo, e); + } + /// + /// 系统健康心跳监测 + /// + /// + /// + public void fun_HeartBeatMIS(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(HeartBeat, e); + } + /// + /// 不合格放行 + /// + /// + /// + public void fun_FalseGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(FalseGO, e); + } + + + /// + /// 保存完成 20 + /// + /// + /// + public void fun_MesReadOver(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesReadOver, e); + } + + /// + /// 保存完成 19 + /// + /// + /// + public void fun_MesRead(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesRead, e); + } + + /// + /// 工件到位离开(清空所有的MES信号) + /// + /// + /// + public void fun_WorkStart(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WorkStart, e); + } + + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + public void fun_WebSubmit(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WebSubmit, e); + } + + public int fun_SubLineLoadPartCountMatch() + { + return SubLineLoadPartCountMatch; + } + + } +} diff --git a/MisDataFunction/Function1058/MesServerFunction/vssver2.scc b/MisDataFunction/Function1058/MesServerFunction/vssver2.scc new file mode 100644 index 0000000..775bb6c Binary files /dev/null and b/MisDataFunction/Function1058/MesServerFunction/vssver2.scc differ diff --git a/MisDataFunction/Function1058/Methods/EngineGetOverBaseWork.cs b/MisDataFunction/Function1058/Methods/EngineGetOverBaseWork.cs new file mode 100644 index 0000000..5c44814 --- /dev/null +++ b/MisDataFunction/Function1058/Methods/EngineGetOverBaseWork.cs @@ -0,0 +1,288 @@ +using System; +using System.Data; +using bizFacade; +using MesServerWork; +//using SystemFramework; + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 分线上总线的数量 + /// + public static int SubLineLoadPartCount = 2; + /// + /// 分线上总线已经匹配的数量 + /// + public static int SubLineLoadPartCountMatch = 0; + /// + /// 正常逻辑工作 + /// + /// + /// + /// + /// + /// + private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code,string OrderForm) + { + int IsAllowWork; + int RepairPartStatusPLC = 0; + int MES_QualityMask = 1; + + if (EngineTypeID <= 0 || EngineID.Length == 0 || EngineType.Length == 0 || OrderForm.Length == 0) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC传递机型为空"); + return; + } + + //初始化物料临时表 + //第二步,将零件信息转移到零件_临时表中(本地BOM与订单BOM的选择显示关系) + BaseDataSystemMES.MesServer_Process_EngineTypeOver_BQ_FirstOP(OpName); + + //5 显示订单、机型信息 线首工位用 + SendMessage.ShowMoby_FirstOpName(OpName); + //3显示操作指导图片 PicShow_String_FirstOpName + SendMessage.PicShow_FirstOpName(OpName); + //1(直接在界面通过选择机型确认工序内容) + SendMessage.ProcessList_FirstOpName(OpName); + //界面显示物料信息 + SendMessage.MaterialList_FirstOpName(OpName); + + //电子看板_装配零件_临时表_增加_北汽 + //第二步,将零件信息转移到零件_临时表中 + // BaseDataSystemMES.MesServer_Process_EngineTypeOverBQ(OpName); + + //通知web显示 + //SendMessageFun.SendMessage("123", "111", OpName); + + //第四步,获取是否允许工作 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + // 暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况 + if (IsAllowWork == 1) + { + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + } + + + /// + /// 保存MOBY信息 + /// + /// + /// + /// + /// + private void SaveMobyMessage(string OpName, int engineTypeID, string engineType, string engineID, string orderForm) + { + + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineTypeID[OpName] = engineTypeID; + } + if (MIS_BASE.hashtable_EngineGetOver_EngineType.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineType[OpName] = engineType; + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineID[OpName] = engineID; + } + if (MIS_BASE.hashtable_EngineGetOver_OrderForm.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_OrderForm[OpName] = orderForm; + } + } + + /// + /// 返修件需要工作 + /// + /// 工位号 + private void IsNeedRepaire_OK(string OpName) + { + + int isRepair; + int engineTypeID; + + string engineType = ""; + string engineID = ""; + string palletCode = ""; + string orderForm = ""; + string repairCode = ""; + //从监控系统中查询出本工位信息 + BaseDataSystemMES.OpName_MIS_Moby_Select(OpName, + out orderForm, out engineTypeID, out engineType, + out engineID, out palletCode, out isRepair, out repairCode); + + EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode),orderForm); + } + /// + /// 正常匹配分线和总线 + /// + /// + /// 总线工件号 + /// 总线工件机型代码 + /// 总线工件机型 + private void Match(string opName, string engineID, int engineTypeID, string engineType, int PartPallet_Code) + { + try + { + bool m_EngineGetOver_PLC_SubLine; + int engineTypeID_SubLine; + int partPallet_Code_SubLine; + int PalletInfo = 1;//总线托盘状态 + + string opName_SubLine = "";//分线工件信息 + string engineID_SubLine; + string engineType_SubLine; + string AlarmStr; + if (MIS_BASE.hashtable_OpNameRepair == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + //第一步:获取分线中间交互工位号 + if (MIS_BASE.hashtable_OpNameRepair.ContainsKey(opName)) + { + opName_SubLine = MIS_BASE.hashtable_OpNameRepair[opName].ToString(); + } + if (opName_SubLine == "") + { + return; + } + + //第二步:获取分线传递机型信号 + MIS_BASE.Read_EngineGetOver_PLC(opName_SubLine, out m_EngineGetOver_PLC_SubLine); + if (!m_EngineGetOver_PLC_SubLine) return;//必须工件同时到位才能进行匹配 + + //第三步:判断合格标志 + MIS_BASE.Read_PalletInfo(opName_SubLine, out PalletInfo); + if (PalletInfo == 2) return; //若不合格则返回不进行匹配 + string OrderForm; + //第四步:获取分线的信息,匹配验证 + MIS_BASE.GetEngineTypeFromPLC(opName_SubLine, out engineTypeID_SubLine, out engineType_SubLine, out engineID_SubLine, out partPallet_Code_SubLine,out OrderForm); + //判断分线数据是否合格 + //if (!BaseDataSystemMES.QulityDataVerify(opName, engineID_SubLine, out AlarmStr) && !BaseDataSystemMES.QualityVerifyStatus_Hash_Read(opName)) + //{ + // SendInfomation("LineoutAlert", AlarmStr, opName); + // return; + //} + + if (engineTypeID_SubLine == engineTypeID) + { + BaseDataSystemMES.SubLineLoadPartCountMatch_Select(opName, out SubLineLoadPartCountMatch); + SubLineLoadPartCountMatch = SubLineLoadPartCountMatch + 1; + BaseDataSystemMES.SubLineLoadPartCountMatch_Update(opName, SubLineLoadPartCountMatch); + + + BaseDataSystemMES.MailLineAndSubLineData_Insert(engineID, engineTypeID, engineType, engineID_SubLine);//分线上总线数据转移 + MIS_BASE.Write_Match(opName, true);//匹配结果 + MIS_BASE.Write_MatchingCompleted(opName, true);//匹配完成 + if(SubLineLoadPartCountMatch== SubLineLoadPartCount) + { + MIS_BASE.Write_FixAllow(opName, true); + SubLineLoadPartCountMatch = 0; + BaseDataSystemMES.SubLineLoadPartCountMatch_Update(opName, SubLineLoadPartCountMatch); + + } + + SendMessageFun.SendInfomation("MatchSuccess", "1", opName); + sendmessage(opName, 1, "Match");//匹配结果 + } + else + { + MIS_BASE.Write_Match(opName, false);//匹配结果 + MIS_BASE.Write_MatchingCompleted(opName, true);//匹配完成//68:1、取消返修;2、匹配成功 自己监控发送 MES|MatchingCompleted + + //发送匹配完成和匹配结果信息 + SendMessageFun.AsyncSendMessage_Notice(opName,"匹配失败,工件型号不匹配!"); + SendMessageFun.SendInfomation("MatchSuccess", "0", opName); + sendmessage(opName, 0, "Match");//匹配结果 + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog("Match:" + err.ToString()); + + } + } + + + + /// + /// 强制匹配分线和总线 + /// + /// + private void ForceMatch(string opName) + { + try + { + bool m_EngineGetOver_PLC_SubLine; + bool m_EngineGetOver_PLC; + + int engineTypeID_SubLine; + int engineTypeID; + int partPallet_Code_SubLine; + int partPallet_Code; + + string opName_SubLine = "";//分线工件信息 + string engineID_SubLine; + string engineType_SubLine; + string engineID; + string engineType; + if (MIS_BASE.hashtable_OpNameRepair == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + //获取分线中间交互工位号 + if (MIS_BASE.hashtable_OpNameRepair.ContainsKey(opName)) + { + opName_SubLine = MIS_BASE.hashtable_OpNameRepair[opName].ToString(); + } + if (opName_SubLine == "") + { + return; + } + + MIS_BASE.Read_EngineGetOver_PLC(opName_SubLine, out m_EngineGetOver_PLC_SubLine);//1:读取分线工件到位的传递机型信号。 + + if (!m_EngineGetOver_PLC_SubLine) return;//必须工件同时到位才能进行匹配 + + MIS_BASE.Read_EngineGetOver_PLC(opName, out m_EngineGetOver_PLC);//2:读取总线工件到位的传递机型信号。 + + if (!m_EngineGetOver_PLC) return;//必须工件同时到位才能进行匹配 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(opName_SubLine, out engineTypeID_SubLine, out engineType_SubLine, out engineID_SubLine, out partPallet_Code_SubLine,out OrderForm);//获取分线的信息 + MIS_BASE.GetEngineTypeFromPLC(opName, out engineTypeID, out engineType, out engineID, out partPallet_Code, out OrderForm); + + BaseDataSystemMES.MailLineAndSubLineData_Insert(engineID, engineTypeID, engineType, engineID_SubLine);//分线上总线数据转移 + + MIS_BASE.Write_Match(opName, true);//匹配结果 + MIS_BASE.Write_MatchingCompleted(opName, true);//匹配完成 + + SendMessageFun.SendInfomation("MatchSuccess", "1", opName);//界面显示匹配成功 + + MIS_BASE.Write_FixAllow(opName, true);//允许PLC工作 + + //发送匹配完成和匹配结果信息 + sendmessage(opName, 1, "MatchingComplete");//匹配完成 + sendmessage(opName, 1, "Match");//匹配结果 + } + catch + { + + } + } + } +} diff --git a/MisDataFunction/Function1058/Methods/SubmitToMisweb.cs b/MisDataFunction/Function1058/Methods/SubmitToMisweb.cs new file mode 100644 index 0000000..8d84430 --- /dev/null +++ b/MisDataFunction/Function1058/Methods/SubmitToMisweb.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using bizFacade; +//using SystemFramework; + +namespace MesServerFunctions +{ + + /// + /// 此类用于向WEB发送各种类型消息 + /// + partial class FunctionMES + { + + + // /// + // /// 批量发送WEB消息(Value为BOOL值) + // /// + // /// 消息编号组合 + // /// 消息值组合 + // /// 工位号 + // void Sendmessage(string MessageNumm,string Value, string OpName) + //{ + // for (int i=0;i + // /// 选择发送给WEB的消息 + // /// + // /// 消息类型 + // /// 消息工位 + //void Sendmessage(char Num,string Value, string OpName) + //{ + // string SendMessage; + // switch (Num) + // { + // case '1': + // //1(直接在界面通过选择机型确认工序内容) + // SendMessage = "MES|ProcessList|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + + // case '2': + // //2显示物料 + // SendMessage = "MES|MaterialList|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + + // case '3': + + // //3显示操作指导图片 + // SendMessage = "MES|PicShow|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case '4': + // //3显示操作指导图片 + // SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + + // case '5': + // SendMessage = "MES|ShowMoby|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case '6': + // SendMessage = "MES|MaterialCheckPosition|" + OpName + "|" +Value; + // AsyncSendMessage(SendMessage); + // break; + // case '7': + // SendMessage = "MES|WorkStart|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case '8': + // SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case '9': + // SendMessage = "MES|ConfirmOkGo|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case 'a': + // SendMessage = "MES|FixAllow|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case 'b': + // SendMessage = "MES|ShaftPosition|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case 'c': + // SendMessage = "MES|ShowQuality|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // } + //} + + /// + /// 向WEB发送信息(value为字符串) + /// + /// 消息种类 + /// 消息内容 + /// 工位号 + //void SendInfomation(string Command, string Value, string OpName) + //{ + + // string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + //} + + + ///// + ///// 发送在线产量、在线节拍 + ///// + ///// + ///// + //private void SendActuallyCount(string OpName, int tagValue) + //{ + // //当工件离开时,更新在线产量、在线节拍 + // if (tagValue == 0) + // { + // try + // { + // int opNameCount = 0;//在线产量 + // int opNameCountTime = 0;//在线节拍 + + // BaseDataSystemMES.OpNameCount_New(OpName, out opNameCount, out opNameCountTime); //基本数据_工作日历_班次产量查询_New + + // SendInfomation("ActuallyCount", opNameCount.ToString() + "&" + opNameCountTime.ToString(), OpName); + + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "Function01:SendActuallyCount"); + // } + // } + //} + + + } +} diff --git a/MisDataFunction/Function1058/Methods/UDP.Send.cs b/MisDataFunction/Function1058/Methods/UDP.Send.cs new file mode 100644 index 0000000..26acece --- /dev/null +++ b/MisDataFunction/Function1058/Methods/UDP.Send.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using MesServerWork; +//using BasicData; +using System.Collections; +using bizFacade; +//using SystemFramework; +using System.Data; +using System.Threading; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + ///// + ///// 发送信息到MES通讯服务器或者其他的 + ///// + ///// + //private void AsyncSendMessage(string Message) + //{ + // MIS_BASE.asyncSendMessage(Message); + //} + + /// + /// 发送提示消息 + /// + /// + //private void AsyncSendMessage_Notice(string opname, string notice) + //{ + // //通知Web界面 + // BaseDataSystemMES.Web_Notice_Insert(opname, notice); + // string SendMessage = "MES|Notice|" + opname + "|" + "1"; + // MIS_BASE.asyncSendMessage(SendMessage); + //} + + /// + /// 发送信息到打印机 + /// + /// + private void asyncSendMessageToMark(string Message) + { + string messageSend = (string)Message; + //UDPClientSend.Send_ALL(ApplicationConfig.MES_MarkPortNum, messageSend); + } + + /// + /// 发送信息到LED + /// + /// + private void asyncSendMessageLED(string OpName) + { + + //发送到大屏幕显示 41104 + string strMessage = "MIS|" + OpName + "|" + "0" + "|" + "1"; + //UDPClientSend.Send_ALL(ApplicationConfig.Port_ShowLED_ProductCount, strMessage); + + } + + } +} diff --git a/MisDataFunction/Function1058/Methods/vssver2.scc b/MisDataFunction/Function1058/Methods/vssver2.scc new file mode 100644 index 0000000..7b1a830 Binary files /dev/null and b/MisDataFunction/Function1058/Methods/vssver2.scc differ diff --git a/MisDataFunction/Function1058/OpcServer/Barcode.cs b/MisDataFunction/Function1058/OpcServer/Barcode.cs new file mode 100644 index 0000000..f70a8bc --- /dev/null +++ b/MisDataFunction/Function1058/OpcServer/Barcode.cs @@ -0,0 +1,220 @@ +using System; +using System.Threading; +using System.Xml.Linq; +using bizFacade; + +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + object lockBarcode = new object(); + + ///第一步,判断条码类型,根据条码类型,执行对应的存储过程 + ///第二步,条码类型(将扫描的条码保存到对应的表中) + ///第三步,扫描完成之后给出允许工作信号 + /// 处理页面扫描条码 + /// + /// + /// + public void Barcode(object e) + { + lock(lockBarcode) + { + try + { + + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string barcode = Convert.ToString(msgEvent.TagValue); + + int EngineTypeID;//机型代码 + string EngineType;//机型 + string EngineID;//工件编号 + + string OrderForm; + int Recipe1; + int Recipe2; + + bool IsNotRepeatedNumber = false; + //1:获得申请上线信息后,扫描条码才处理业务 + bool ispartload; + //(115) + int PTO; + //(118)0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + int NgearSwitch; + //(119)0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + int RgearSwitch; + //(120)0=不检测;1=检测。检测线上线工位扫描总成条码,根据BOM,查出 + int SpeedSensor; + //(121)例如:5S 400。检测线上线工位扫描总成条码,根据BOM,查出 + string PartTypeMid; + //(122) 0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + int Tcu_V; + //判断工件是否到位 + MIS_BASE.Read_WorkStart(OpName, out ispartload); + if (!ispartload) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请检查设备是否到位(DBX500.1=1)"); + return; + } + //判断设备是否申请上线 + MIS_BASE.Read_UpdatePalletOK(OpName, out ispartload); + if (!ispartload) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请检查设备是否申请上线(DBX500.3=1)"); + return; + } + // 判读条码是变速器序列号条码号还是物料号 小机型*日月年* 流水号(给起始号 + 数量) + // 选小机型 从北汽福田BOM中选 得先维护BOM + // 变速器序列号 '1333 050 062*16012023*30000001' + + //扫描完变速器序列号条码号 true + bool isGetOver_MES = false; + //判断上线工位,MES 是否将工件流水号、机型等信息已经写入到PLC了 + //MIS_BASE.Read_EngineTypeGetOver_MES(OpName, out isGetOver_MES); + MIS_BASE.Read_EngineGetOver_PLC(OpName, out isGetOver_MES); + //如果工件流水号、机型等信息没有写入PLC,扫描的条码按工件流水号进行验证 + //否则按装配物料进行验证 + if (!isGetOver_MES) + { + + if (barcode.Split(';').Length > 2 || barcode.Split('*').Length > 2) + { + + string partSn = barcode; + EngineID = barcode; + + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID_MES, EngineID); + SendMessage.ShowMoby(OpName); + + //2: 判断是否重号 + //IsRepeatedNumber true 不重号;false 重号; + IsNotRepeatedNumber = BaseDataSystemMES.EngineTypeID_IsNotRepeatedNumber(partSn); + if (IsNotRepeatedNumber) + { + // 从数据库获得机型、机型代码等信息 + BaseDataSystemMES.GetEngineTypeUpLoadOpName(partSn, OpName, out EngineTypeID, out EngineType, out OrderForm, out Recipe1, out Recipe2); + // 从数据库获得PTO等信息 + BaseDataSystemMES.UpLoadPTO(partSn, out PTO, out NgearSwitch, out RgearSwitch, out SpeedSensor, out PartTypeMid, out Tcu_V); + //PTO + MIS_BASE.WritePLC(115, OpName, PTO); + //空挡开关检测 + MIS_BASE.WritePLC(95, OpName, NgearSwitch); + //倒挡开关检测 + MIS_BASE.WritePLC(96, OpName, RgearSwitch); + //里程表检测 + MIS_BASE.WritePLC(97, OpName, SpeedSensor); + //大机型扩展 + MIS_BASE.WritePLC(98, OpName, PartTypeMid); + //TCU + MIS_BASE.WritePLC(122, OpName, Tcu_V); + // 先查询配方号 根据工位号 去moby表查配方号 + // 根据配方号 去配方表查配方数据 写入配方数据 + string tagStartAdr;//= "DB411.10"; + BaseDataSystemMES.PLCRcipeCurrent(OpName, out byte[] bytes, out tagStartAdr); + DtWebApi.ReadWritePLC.Write_TagValueByTagTypeID("94", OpName, System.Text.Encoding.ASCII.GetString(bytes)); + // 将产品信息写入PLC + MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID); + MIS_BASE.Write_EngineType_MES(OpName, EngineType); + MIS_BASE.Write_EngineID_MES(OpName, EngineID); + MIS_BASE.Write_OrderForm_MES(OpName, OrderForm); + + // 写入到数据库的[北汽福田工位状态监控MOBY]表中 + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID_MES, EngineID); + SendMessage.ShowMoby(OpName); + + SendMessageFun.AsyncSendMessage_Notice(OpName, "总成码扫码完成,请扫描后壳码!"); + + + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, true); + + //Thread.Sleep(1000); + //// 临时增加 清除MES的传递机型 + //MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "变速器序列号 重号,请确认!"); + } + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "变速器序列号格式不正确,请确认!"); + + } + } + else//验证物料 + { + //物料号 + { + //读取PLC的传递机型信号 + bool tagValue; + MIS_BASE.Read_EngineGetOver_PLC(OpName, out tagValue); + if (tagValue) + { + //验证物料 + BaseDataSystemMES.PartMaterial_DM_Update(OpName, barcode, out bool IsSuccess); + if (!IsSuccess)//???? + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认"); + return; + } + else + { + SendMessageFun.SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息 + } + //判断物料是否验证完成 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out int IsAllowWork); + + + if (IsSuccess) + { + if (IsAllowWork == 1) + { + //移到允许保存信号中 + //BaseDataSystemMES.Material_Insert(OpName, 1); + + ////更新订单完工数量及物料 + SendMessageFun.SendMessage("245", "111", OpName); + + // 写入到数据库的[北汽福田工位状态监控MOBY]表中 + SendMessage.ShowMoby(OpName); + + SendMessageFun.AsyncSendMessage_Notice(OpName, "扫码完成,请开始工作!"); + + //物料验证完成,通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC未传递机型"); + } + } + else + { + SendMessage.AsyncSendMessage_Notice(OpName, "产品上线后,PLC获得变速器序列号后,再验证物料!"); + } + + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:Barcode"); + } + } + + } + + + } +} diff --git a/MisDataFunction/Function1058/OpcServer/ConfirmOkGo.cs b/MisDataFunction/Function1058/OpcServer/ConfirmOkGo.cs new file mode 100644 index 0000000..a978c1f --- /dev/null +++ b/MisDataFunction/Function1058/OpcServer/ConfirmOkGo.cs @@ -0,0 +1,35 @@ +using System; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 合格放行 + /// + /// + /// + private void ConfirmOkGo(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + MIS_BASE.Write_MaterialVerifyOver(OpName, true);//工作完成 + SendMessageFun.SendInfomation("OrderFormList","1", OpName); + + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:ConfirmOkGo"); + } + } + } +} diff --git a/MisDataFunction/Function1058/OpcServer/EngineGetOver.cs b/MisDataFunction/Function1058/OpcServer/EngineGetOver.cs new file mode 100644 index 0000000..db8fde9 --- /dev/null +++ b/MisDataFunction/Function1058/OpcServer/EngineGetOver.cs @@ -0,0 +1,98 @@ +using System; +using System.Data; +using bizFacade; +using MesServerWork; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + object lockBarcodeEngineTypeGetOver = new object(); + + + /// + /// PLC传递机型处理 + /// + /// + /// + private void EngineTypeGetOver_PLC(object e) + { + lock(lockBarcodeEngineTypeGetOver) + { + + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + if (tagValue == 1) + { + bool MesRead = false; + + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + + int EngineTypeID_MES;//机型代码 + string EngineType_MES;//机型 + string EngineID_MES;//工件编号 + + //上线工位清MES传递机型信号 + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + + MIS_BASE.Read_QualityData_Read_CF(OpName, out MesRead); + //第一步,判断允许保存和保存完成信号是否全部被清空,若未清空,则通知复位MES&PLC + if (MesRead) + { + //未能清空信号,请求复位 + SendMessageFun.SendInfomation("AskReset", "1", OpName); + return; + } + string OrderForm; + string OrderForm_MES; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + MIS_BASE.GetEngineTypeFromPLC_MES(OpName, out EngineTypeID_MES, out EngineType_MES, out EngineID_MES, out OrderForm_MES); + + //判断PLC机型与MES机型是否一致 + if (EngineTypeID_MES == EngineTypeID & EngineID_MES == EngineID & EngineType_MES == EngineType) + { + // 如果机型改变的话 提示机型发生变化 + DataTable dt = BaseDataSystemMES.EngineTypeChange(OpName, EngineType); + if (dt.Rows.Count > 0) + { + string mesValue = Newtonsoft.Json.JsonConvert.SerializeObject(dt);//(recData); + string message = "MES|MaterialList_Dif_Resources|" + OpName + "|" + mesValue; + SendMessage.AsyncSendMessage(message); + } + //写入到数据库的[北汽福田工位状态监控MOBY]表中 + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineTypeID, EngineTypeID.ToString()); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineType, EngineType); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID, EngineID); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.OrderForm, OrderForm); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.PartPallet_Code, PartPallet_Code.ToString()); + + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm); + return; + } + else + { + SendMessage.AsyncSendMessage_Notice(OpName, "码块RFID机型与MES机型不匹配!"); + } + + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:EngineTypeGetOver_PLC"); + } + } + + } + + + + } +} diff --git a/MisDataFunction/Function1058/OpcServer/FalseGO.cs b/MisDataFunction/Function1058/OpcServer/FalseGO.cs new file mode 100644 index 0000000..54c73c7 --- /dev/null +++ b/MisDataFunction/Function1058/OpcServer/FalseGO.cs @@ -0,0 +1,37 @@ +using System; +using MesServerWork; +//using SystemFramework; + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + + /// + /// 返修放行 + /// + /// + /// + private void FalseGO(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + MIS_BASE.Write_MaterialVerifyOver(OpName, true);//工作完成 + SendMessageFun.SendInfomation("OrderFormList", "1", OpName); + + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1058/OpcServer/HeartBeat.cs b/MisDataFunction/Function1058/OpcServer/HeartBeat.cs new file mode 100644 index 0000000..93affd3 --- /dev/null +++ b/MisDataFunction/Function1058/OpcServer/HeartBeat.cs @@ -0,0 +1,35 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// MES与PLC心跳监听 + /// + /// + /// + private void HeartBeat(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //返写在MES心跳中 + MIS_BASE.WritePLC(15, OpName, tagValue); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1058/OpcServer/MesRead.cs b/MisDataFunction/Function1058/OpcServer/MesRead.cs new file mode 100644 index 0000000..4705f0a --- /dev/null +++ b/MisDataFunction/Function1058/OpcServer/MesRead.cs @@ -0,0 +1,85 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + object lockMesRead = new object (); + /// + /// 保存完成(针对半自动和手动压装工位) + /// + /// + /// + private void MesRead(object e) + { + lock(lockMesRead) + { + try + { + int EngineTypeID; + string EngineType; + string EngineID; + int PartPallet_Code; + string OrderForm; + + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + //保存数据到线首表 先保存到 北汽福田变速器序列号总线上线 用于之前判断是否重号 + if (Db.UpLoadOpNameInsert(EngineID, EngineTypeID, EngineType, OpName)) + { + //保存质量数据 + int qualityMask = MisDataSaveDateMesRead.Funtion.MesRead(OpName, tagValue.ToString(), msgEvent.TagID.ToString()); + //推送质量数据到MES的页面 + MIS_BASE.SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName); + + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartOut, DateTime.Now.ToString()); + + //保存物料数据 + BaseDataSystemMES.Material_Insert(OpName, tagValue); + //测量数据发动机在线状态 + BaseDataSystemMES.WorkStartInsert(OpName, qualityMask); + + // MIS_BASE.Write_ConfirmOkGo(OpName, true); + + //MisDataSaveDate. + MIS_BASE.Write_MesReadOver(OpName, true); + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + SendMessage.SendActuallyCount(OpName, tagValue);//统计在线产量,在线节拍 + } + else + { + SendMessage.AsyncSendMessage_Notice(OpName, "保存上线数据失败!"); + } + } + else + { + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + } + + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + + } + + } + } +} diff --git a/MisDataFunction/Function1058/OpcServer/MesReadOver.cs b/MisDataFunction/Function1058/OpcServer/MesReadOver.cs new file mode 100644 index 0000000..9b637f2 --- /dev/null +++ b/MisDataFunction/Function1058/OpcServer/MesReadOver.cs @@ -0,0 +1,37 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 保存完成(针对半自动和手动压装工位) + /// + /// + /// + private void MesReadOver(object e) + { + try + { + //DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + //string OpName = Convert.ToString(msgEvent.OpName); + //int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //if (tagValue == 1) + //{ + + // BaseDataSystemMES.Material_Insert(OpName, tagValue); + + // MIS_BASE.Write_ConfirmOkGo(OpName, true); + //} + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + } +} diff --git a/MisDataFunction/Function1058/OpcServer/WebSubmit.cs b/MisDataFunction/Function1058/OpcServer/WebSubmit.cs new file mode 100644 index 0000000..4bfd077 --- /dev/null +++ b/MisDataFunction/Function1058/OpcServer/WebSubmit.cs @@ -0,0 +1,342 @@ +using System; +using MesServerWork; +using bizFacade; +using System.Threading; +using MisDataSaveDate; +using System.Collections; +//using SystemFramework; + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + private void WebSubmit(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string Content = Convert.ToString(msgEvent.TagValue); + + string opName_SubLine = ""; + string engineID = "";//工件信息 + string[] dataArray = Content.Split('|'); + + if (dataArray.Length != 2) + return; + + + string m_Command = dataArray[0].ToString();//消息类型 + string m_Value = dataArray[1].ToString();//消息参数 + string[] m_Value_array = m_Value.Split('&');//消息参数数量 + int m_Value_length = m_Value_array.Length; //消息参数长度 + + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + engineID = MIS_BASE.hashtable_EngineGetOver_EngineID[OpName].ToString(); + } + if (MIS_BASE.hashtable_OpNameRepair == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + DoWhatPlc.CustomeEvetnArgs _e = new DoWhatPlc.CustomeEvetnArgs(); + _e.OpName = OpName; + _e.TagValue = m_Value; + + //根据请求的命令处理逻辑 + switch (m_Command) + { + case "Barcode": + if (m_Value_length > 1) return; + fun_Barcode(_e); + break; + case "ConfirmOkGo"://合格放行 + //修改托盘状态 + + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_ConfirmOkGo(OpName, true); + MIS_BASE.Write_FalseGO(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + break; + case "FalseGO"://返修放行 + //修改托盘状态 + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "NgGO"://不合格放行 + //修改托盘状态 + //保存不合格信息(必须保存不合格放行信息,由于B5A的Moby没有不合格标志位) + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Insert(OpName, engineID, "", ""); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "OnLineState"://在线0、离线1、屏蔽2 + try + { + if (m_Value_length > 1) return; + int a = Convert.ToInt32(m_Value); + if (a <= 2) + { + BaseDataSystemMES.IsOnLine_Update(OpName, m_Value.ToString()); + MIS_BASE.Write_OnLineState(OpName, Convert.ToInt32(m_Value)); + if (a == 2) SendMessage.AsyncSendMessage_Notice(OpName, "屏蔽MES!"); + if (a == 0) SendMessage.AsyncSendMessage_Notice(OpName, "启用MES!"); + } + } + catch + { + + } + break; + case "Reset"://复位,将MES所有的信息都复位了 + SetMoby(OpName);//将MES所有信号清空 + + break; + case "FixAllow"://重新拧紧 + break; + case "IsAutoGetEngineID"://自动手动申请编号(线首) + if (m_Value_length > 1) return; + MIS_BASE.Write_IsAutoGetEngineID(OpName, Convert.ToInt32(m_Value)); + break; + case "PartPalletGoOver"://空托盘放行 + MIS_BASE.Write_RepairUpline_MES(opName_SubLine, true); + //MIS_BASE.Write_PalletInfo(opName_SubLine, 4); + //MIS_BASE.Write_UpdatePalletOK(opName_SubLine, true); + MIS_BASE.Write_MaterialVerifyOver(opName_SubLine, true); + break; + case "SetMoby"://清空托盘(线首) + SetMoby(OpName);//将MES所有信号清空 + break; + case "RepairUplineMES"://返修上线 + MIS_BASE.Write_RepairUpline_MES(OpName, true); + break; + case "CancelRepair"://将返修件置为正常件 + + break; + case "PartPalletCode"://申请写入托盘号 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "WritePartPalletCode"://写入托盘号 + if (m_Value_length > 1) return; + MIS_BASE.Write_PalletCode(OpName, Convert.ToInt32(m_Value)); + break; + case "Normal"://启用正常拧紧工位 + MIS_BASE.Write_Normal(OpName, 1); + MIS_BASE.Write_UnNormal(OpName, 0); + break; + case "UnNormal"://启用备用拧紧工位 + MIS_BASE.Write_Normal(OpName, 0); + MIS_BASE.Write_UnNormal(OpName, 1); + break; + case "ResetDevice"://复位设备 + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + break; + case "IsNeedRepaire"://返修上线(返修上线点) + if (Convert.ToInt32(m_Value) == 1) + { + //修改托盘状态 + MIS_BASE.Write_PalletInfo(OpName, 3); + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + IsNeedRepaire_OK(OpName); + } + else if (Convert.ToInt32(m_Value) == 0) + { + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + break; + //强制匹配 + case "ForceMatch": + if (Convert.ToInt32(m_Value) == 1) + { + ForceMatch(OpName); + } + break; + case "PalletGO": + + if (Convert.ToInt32(m_Value) == 1) + { + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(opName_SubLine, true); + } + break; + case "ContinueMatch": + BaseDataSystemMES.QualityVerifyStatus_Hash_Write(OpName, true); + fun_EngineTypeGetOverPLC(_e); + break; + //初始化网页信号 + case "IniSingalToWeb": + InitializeSingalToWeb(OpName); + break; + default: break; + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:WebSubmit"); + } + } + + private void SetMoby(string OpName) + { + try + { + //清空Moby时,需要将MES信号清空 + MIS_BASE.Write_ClearMesMoby(OpName); + + BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName); + + SendMessageFun.SendMessage("5123", "1111", OpName); + + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + } + catch + { + + } + } + + + /// + /// 网页重现登录,恢复关闭前的页面状态 + /// + /// 工位号 + private void InitializeSingalToWeb(string Opname) + { + bool S_WorkOn;//申请上线 DBX0.1 + bool S_WorkStart;//工件到位 DBX0.1 + bool S_EngineGetOver;//传递机型 DBX0.4 + bool S_FixAllow;//允许工作 DBX3.1 + bool S_MaterialVerifyOver;//工作完成 DBX2.3 + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + + int IsCompleted = 0; + int S_Match = 0; + int PalletInfo_SubLine = 0;//显示分线托盘状态 + + MIS_BASE.Read_WorkStart(Opname, out S_WorkStart); + //5 显示订单、机型信息 线首工位用 + SendMessage.ShowMoby_FirstOpName(Opname); + //3显示操作指导图片 PicShow_String_FirstOpName + SendMessage.PicShow_FirstOpName(Opname); + //1(直接在界面通过选择机型确认工序内容) + SendMessage.ProcessList_FirstOpName(Opname); + //界面显示物料信息 + SendMessage.MaterialList_FirstOpName(Opname); + // 新增查询PLC直通状态 网页显示 + MIS_BASE.Read_TagTypeID(63, Opname, out S_plcStatus); + InitAlarm(Opname); + + if (S_plcStatus.ToLower() == "false") + { + SendMessageFun.SendInfomation("PlcStatus", "0", Opname); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", Opname); + } + + if (S_WorkStart == true) + { + SendMessageFun.SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname); + //sendmessage(Opname, Convert.ToInt32(S_WorkStart), "WorkStart_Subline"); + } + + //sendmessage(Opname, Convert.ToInt32(S_WorkStart), "EngineTypeGetOverMES_Subline"); + + MIS_BASE.Read_EngineGetOver_PLC(Opname, out S_EngineGetOver); + if (S_EngineGetOver == true) + { + SendMessageFun.SendInfomation("EngineTypeGetOverPLC", Convert.ToString(Convert.ToInt32(S_EngineGetOver)), Opname); + //sendmessage(Opname, Convert.ToInt32(S_EngineGetOver), "EngineTypeGetOverMES_Subline"); + } + + MIS_BASE.Read_FixAllow(Opname, out S_FixAllow); + + if (S_FixAllow == true) + { + SendMessageFun.SendInfomation("FixAllow", Convert.ToString(Convert.ToInt32(S_FixAllow)), Opname); + } + + MIS_BASE.Read_MaterialVerifyOver(Opname, out S_MaterialVerifyOver); + + if (S_MaterialVerifyOver == true) + { + SendMessageFun.SendInfomation("MaterialVerifyOver", Convert.ToString(Convert.ToInt32(S_MaterialVerifyOver)), Opname); + } + + //MIS_BASE.Read_MatchingCompleted(Opname, out IsCompleted); //DBX1.3 是否匹配 + //MIS_BASE.Read_Match(Opname, out S_Match); //DBX1.4 匹配结果 + + //if (IsCompleted == 1 && S_Match == 1)//发送匹配完成和匹配结果信息 + //{ + // SendMessageFun.SendInfomation("MatchingCompleted", "1", Opname); + // SendMessageFun.SendInfomation("Match", "1", Opname); + // SendMessageFun.SendInfomation("MatchSuccess", "1", Opname);//界面显示匹配成功 + //} + //else if (IsCompleted == 1 && S_Match == 0) + //{ + // SendMessageFun.SendInfomation("MatchSuccess", "0", Opname);//界面显示匹配失败 + //} + + //if (MIS_BASE.hashtable_OpNameRepair == null) + //{ + // MIS_BASE.InitHashtable_MesServerCode(); + //} + //string Opname_SubLine = ""; + //if (MIS_BASE.hashtable_OpNameRepair.ContainsKey(Opname)) + //{ + // Opname_SubLine = MIS_BASE.hashtable_OpNameRepair[Opname].ToString(); + //} + //if (Opname_SubLine == "") + //{ + // return; + //} + + //MIS_BASE.Read_PalletInfo(Opname, out PalletInfo_SubLine); + //sendmessage(Opname, PalletInfo_SubLine, "SubQualityMask"); + //SendMessageFun.SendInfomation("ShowMobySubLine", Opname_SubLine, Opname);//显示分线机型及流水号 + } + + //分线发送工件到位信号函数 + private void sendmessage(string OpName, int tagValue, string Command) + { + string SendMessage; + SendMessage = "MES|" + Command + "|" + OpName + "|" + tagValue; + SendMessageFun.AsyncSendMessage(SendMessage); + + } + private void InitAlarm(string Opname) + { + FuntionMesRead.Alarm_InitAlarm_Send(Opname, out Hashtable ht); + foreach (DictionaryEntry kv in ht) + { + var TagID = kv.Key.ToString(); + var TagValue = kv.Value.ToString(); + FuntionMesRead.Send_AlarmMsg(TagID, TagValue); + } + + } + } +} diff --git a/MisDataFunction/Function1058/OpcServer/WorkStart.cs b/MisDataFunction/Function1058/OpcServer/WorkStart.cs new file mode 100644 index 0000000..0582e8e --- /dev/null +++ b/MisDataFunction/Function1058/OpcServer/WorkStart.cs @@ -0,0 +1,55 @@ +using System; +using bizFacade; +using MesServerWork; +//using SystemFramework; + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工件到位与离开时,清空MES自身信号 + /// + /// + /// + private void WorkStart(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //线首显示订单信息 + + if (tagValue == 1) + { + MIS_BASE.Write_TagTypeID(115, OpName, 0); + MIS_BASE.Write_TagTypeID(95, OpName, 0); + MIS_BASE.Write_TagTypeID(96, OpName, 0); + MIS_BASE.Write_TagTypeID(97, OpName, 0); + MIS_BASE.Write_TagTypeID(98, OpName, ""); + //清空MOBY的产品流水号 + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartIn, DateTime.Now.ToString()); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStart, tagValue.ToString()); + + } + else + { + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartOut, DateTime.Now.ToString()); + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:WorkStart"); + } + } + } +} diff --git a/MisDataFunction/Function1058/OpcServer/vssver2.scc b/MisDataFunction/Function1058/OpcServer/vssver2.scc new file mode 100644 index 0000000..e8dac03 Binary files /dev/null and b/MisDataFunction/Function1058/OpcServer/vssver2.scc differ diff --git a/MisDataFunction/Function1058/Properties/AssemblyInfo.cs b/MisDataFunction/Function1058/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f3608c0 --- /dev/null +++ b/MisDataFunction/Function1058/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Function08")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("苏州宏软信息技术有限公司")] +[assembly: AssemblyProduct("Function08")] +[assembly: AssemblyCopyright("Copyright © 苏州宏软信息技术有限公司 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("47710f2c-e141-4252-8d13-701bf4c1c027")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MisDataFunction/Function1058/Properties/vssver2.scc b/MisDataFunction/Function1058/Properties/vssver2.scc new file mode 100644 index 0000000..87eebff Binary files /dev/null and b/MisDataFunction/Function1058/Properties/vssver2.scc differ diff --git a/MisDataFunction/Function1058/mssccprj.scc b/MisDataFunction/Function1058/mssccprj.scc new file mode 100644 index 0000000..f184c61 --- /dev/null +++ b/MisDataFunction/Function1058/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[Function08.csproj] +SCC_Aux_Path = "\\192.168.0.100\vss\MES4.0" +SCC_Project_Name = "$/MisData/MisData/MisData/MesServer.Function/Function08", KRHAAAAA diff --git a/MisDataFunction/Function1058/packages.config b/MisDataFunction/Function1058/packages.config new file mode 100644 index 0000000..b3e1761 --- /dev/null +++ b/MisDataFunction/Function1058/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1058/vssver2.scc b/MisDataFunction/Function1058/vssver2.scc new file mode 100644 index 0000000..93af295 Binary files /dev/null and b/MisDataFunction/Function1058/vssver2.scc differ diff --git a/MisDataFunction/Function1059/DataAccess/DataAccess.cs b/MisDataFunction/Function1059/DataAccess/DataAccess.cs new file mode 100644 index 0000000..a7f91fa --- /dev/null +++ b/MisDataFunction/Function1059/DataAccess/DataAccess.cs @@ -0,0 +1,16 @@ + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + //针对“MIS.BizFacade.Dll”中没有的存储过程,在此类中新建 + //新建原则:所有的函数用private,只允许在内部使用 + //针对单个工艺特殊,需要新建存储过程,但是存储过程不能被加入到“MIS.BizFacade.Dll”中 + + private void aa() + { + + } + } +} diff --git a/MisDataFunction/Function1059/Db.cs b/MisDataFunction/Function1059/Db.cs new file mode 100644 index 0000000..64286ed --- /dev/null +++ b/MisDataFunction/Function1059/Db.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DataLinkMesWork; + +namespace MesServerFunctions +{ + public class Db + { + /// + /// 北汽福田变速器序列号总线上线_获得机型信息 + /// + /// + /// + /// + /// + /// 0 不重号;1 重号;2:失败 + /// + public static bool GetEngineType(string partSn, out int EngineTypeID, out string EngineType, out string EngineID,out int IsRepeatedNumber) + { + DataTable dt = new DataTable(); + EngineTypeID = 0; + EngineType = ""; + EngineID = ""; + IsRepeatedNumber = 2; + string produceName = "北汽福田变速器序列号总线上线_获得机型信息"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@变速器序列号", partSn); + + thisParms[2].Direction = ParameterDirection.Output; + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms,out dt)) + { + if(dt.Rows.Count > 0) + { + IsRepeatedNumber = Convert.ToInt32( dt.Rows[0]["IsRepeatedNumber"]); + EngineTypeID = Convert.ToInt32(dt.Rows[0]["EngineTypeID"]); + EngineType = dt.Rows[0]["EngineType"].ToString(); + EngineID = partSn; + return true; + } + } + return false; + } + /// + /// 北汽福田变速器序列号总线上线_增加 + /// + /// + /// + /// + /// + /// + public static bool UpLoadOpNameInsert(string partSn, int EngineTypeID, string EngineType, string OpName) + { + + string produceName = "北汽福田变速器序列号总线上线_增加"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@变速器序列号", partSn); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@基本型号代码", EngineTypeID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@基本型号", EngineType); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@工位号", OpName); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + // ALTER PROCEDURE[dbo].[北汽福田变速器序列号总线上线_增加] + // @变速器序列号 nvarchar(50)='1333 050 062 0001*146012023*12345678',--'1333 050 062 0001' + //@基本型号代码 int=1, + //@基本型号 nvarchar(50)='1333 050 062 0001', + //@工位号 nvarchar(50) = 'J05PA010' + } +} diff --git a/MisDataFunction/Function1059/Function1059.csproj b/MisDataFunction/Function1059/Function1059.csproj new file mode 100644 index 0000000..2aadbf8 --- /dev/null +++ b/MisDataFunction/Function1059/Function1059.csproj @@ -0,0 +1,113 @@ + + + + + Debug + AnyCPU + {913CE3C1-7D16-4A19-A9B0-BBCDB6770B4B} + Library + Properties + Function1059 + Function1059 + v4.8 + 512 + true + + + + true + full + false + ..\..\MisDataFun_Exe\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\..\MisData_3.0_2022.08.23.1622.LLX\DLL\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {f55da1a0-a982-4479-8c47-0d9a5aaf3e18} + 00MesWorkMqtt + + + {0d1af432-439a-4920-8692-43ae139f5530} + 01_01DoWhatPlc + + + {3e6d1dd5-01c9-435f-9941-61f906ce35bb} + 02_02WebApiCallPLC + + + {f434e066-4c59-47c8-aa82-6f48cc84501a} + 04-DataBaseAccess + + + {f0a0c525-03fd-428a-9b17-7f54aa0e4475} + 07BusinessFacade + + + {d98be764-adeb-488d-9714-61e308aa8201} + 08-WebFun_base + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 09-MesDataFunction + + + {e4eb6420-906d-4672-947a-ca33ddcdadfc} + 12SendMessageToWeb + + + {55b510c1-59e9-4bfd-ae84-d76d46f6e365} + 02-13.3MIS_FuntionSaveData + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1059/MesServerFunction/Function1059.cs b/MisDataFunction/Function1059/MesServerFunction/Function1059.cs new file mode 100644 index 0000000..67c16df --- /dev/null +++ b/MisDataFunction/Function1059/MesServerFunction/Function1059.cs @@ -0,0 +1,270 @@ + +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Threading; + +namespace MesServerFunctions +{ + public partial class FunctionMES + { + object lockFunWork; + //public void FunWork(DoWhatPlc.CustomeEvetnArgs e) + public void FunWork(string recData) + { + + + lockFunWork = new object(); + lock (lockFunWork) + { + List dataArray = DoWhatPlc.MessageText.GetCmdStringList(recData); + //string[] dataArray = recData.Split('|'); + //if (dataArray.Count != 4) + //return; + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 Barcode + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + DoWhatPlc.CustomeEvetnArgs e =new DoWhatPlc.CustomeEvetnArgs();// = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string tagValue; + + switch (m_Source) + { + case "BarCode": + e.OpName = m_OpName; + e.TagValue = m_Value; + fun_Barcode(e); + + break; + case "WEB": + e.OpName = m_OpName; + e.TagValue = m_Command + "|" + m_Value; + fun_WebSubmit(e); + break; + case "PLC": + e = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + switch (e.TagValue.ToString().ToLower()) + { + case "false": + tagValue = "0"; + break; + case "true": + tagValue = "1"; + break; + default: + tagValue = e.TagValue.ToString(); + break; + } + e.TagValue = tagValue; + switch (e.TagTypeCodeID.ToString()) + { + //PLC 工件到位 + case "2": + fun_WorkStart(e); + break; + //PLC 允许保存质量数据 + case "19": + fun_MesRead(e); + break; + //MES 保存数据完成 + case "20": + fun_MesReadOver(e); + break; + //PLC 传递机型 + case "43": + PartLoad(e); + break; + //PLC 传递机型 + case "44": + fun_EngineTypeGetOverPLC(e); + break; + //MES 合格放行 + case "51": + fun_ConfirmOkGo(e); + break; + //MES 不合格放行 + case "8": + fun_FalseGo(e); + break; + //MES保存实时质量数据 + case "65": + fun_MesSaveNowData(e); + break; + //MES 系统健康心跳 + case "14": + fun_HeartBeatMIS(e); + break; + case "63": + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + MIS_BASE.Read_TagTypeID(63, m_OpName, out S_plcStatus); + if (S_plcStatus.ToLower() != "true" || S_plcStatus.ToLower() == "1") + { + SendMessageFun.SendInfomation("PlcStatus", "0", m_OpName); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", m_OpName); + } + break; + } + break; + } + } + } + //public void FunWork(DoWhatPlc.CustomeEvetnArgs e) + //{ + // //lock1 = new object(); + // //lock (lock1) + // { + // switch (e.TagTypeCodeID.ToString()) + // { + // //PLC 工件到位 + // case "2": + // fun_WorkStart(e); + // break; + // //PLC 允许保存质量数据 + // case "19": + // fun_MesRead(e); + // break; + // //MES 保存数据完成 + // case "20": + // fun_MesReadOver(e); + // break; + // //PLC 传递机型 + // case "44": + // fun_EngineTypeGetOverPLC(e); + // break; + // //MES 合格放行 + // case "51": + // fun_ConfirmOkGo(e); + // break; + // //MES 不合格放行 + // case "8": + // fun_FalseGo(e); + // break; + // //MES 扫描条码 + // case "Barcode": + // fun_Barcode(e); + // break; + // //WEB 处理页面传递过来的数据 + // case "WebSubmit": + // fun_WebSubmit(e); + // break; + // } + // } + + //} + //1.工件到位后,PLC给MES传递机型(DBX0.4)(44), + //2.MES判断是否扫描完成 + //3.若扫描完成,则MES给出合格放行(DBX2.5)(51) + /// + /// 扫描条码 + /// + /// + /// + public void fun_Barcode(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(Barcode, e); + } + + /// + /// 系统健康心跳监测 + /// + /// + /// + public void fun_HeartBeatMIS(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(HeartBeat, e); + } + /// + /// 传递机型 + /// + /// + /// + public void fun_EngineTypeGetOverPLC(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(EngineTypeGetOver_PLC, e); + } + + /// + /// 合格放行 + /// + /// + /// + public void fun_ConfirmOkGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(ConfirmOkGo, e); + } + + /// + /// 不合格放行 + /// + /// + /// + public void fun_FalseGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(FalseGO, e); + } + + + /// + /// 保存完成 20 + /// + /// + /// + public void fun_MesReadOver(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesReadOver, e); + } + + /// + /// 保存完成 19 + /// + /// + /// + public void fun_MesRead(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesRead, e); + } + + /// + /// 工件到位离开(清空所有的MES信号) + /// + /// + /// + public void fun_WorkStart(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WorkStart, e); + } + + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + public void fun_WebSubmit(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WebSubmit, e); + } + + public int fun_SubLineLoadPartCountMatch() + { + return SubLineLoadPartCountMatch; + } + + /// + /// MES实时保存质量数据 + /// + /// + /// + public void fun_MesSaveNowData(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesSaveNowData, e); + } + } +} diff --git a/MisDataFunction/Function1059/Methods/EngineGetOverBaseWork.cs b/MisDataFunction/Function1059/Methods/EngineGetOverBaseWork.cs new file mode 100644 index 0000000..895f4c1 --- /dev/null +++ b/MisDataFunction/Function1059/Methods/EngineGetOverBaseWork.cs @@ -0,0 +1,279 @@ +using System; +using System.Data; +using bizFacade; +using MesServerWork; +//using SystemFramework; + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 分线上总线的数量 + /// + public static int SubLineLoadPartCount = 2; + /// + /// 分线上总线已经匹配的数量 + /// + public static int SubLineLoadPartCountMatch = 0; + /// + /// 正常逻辑工作 + /// + /// + /// + /// + /// + /// + private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code,string OrderForm) + { + int IsAllowWork; + int RepairPartStatusPLC = 0; + int MES_QualityMask = 1; + //string OrderForm = "";//订单号 + //DataTable dt; + + if (EngineTypeID <= 0 || EngineID.Length == 0 || EngineType.Length == 0 || OrderForm.Length == 0) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC传递机型为空"); + return; + } + //电子看板_装配零件_临时表_增加_北汽 + //第二步,将零件信息转移到零件_临时表中 + // BaseDataSystemMES.MesServer_Process_EngineTypeOverBQ(OpName); + + //通知web显示 + //SendMessageFun.SendMessage("123", "111", OpName); + + //第四步,获取是否允许工作 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + // 暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况 + + if (IsAllowWork == 1) + { + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + + + } + + + /// + /// 保存MOBY信息 + /// + /// + /// + /// + /// + private void SaveMobyMessage(string OpName, int engineTypeID, string engineType, string engineID, string orderForm) + { + + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineTypeID[OpName] = engineTypeID; + } + if (MIS_BASE.hashtable_EngineGetOver_EngineType.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineType[OpName] = engineType; + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_EngineID[OpName] = engineID; + } + if (MIS_BASE.hashtable_EngineGetOver_OrderForm.ContainsKey(OpName)) + { + MIS_BASE.hashtable_EngineGetOver_OrderForm[OpName] = orderForm; + } + } + + /// + /// 返修件需要工作 + /// + /// 工位号 + private void IsNeedRepaire_OK(string OpName) + { + + int isRepair; + int engineTypeID; + + string engineType = ""; + string engineID = ""; + string palletCode = ""; + string orderForm = ""; + string repairCode = ""; + //从监控系统中查询出本工位信息 + BaseDataSystemMES.OpName_MIS_Moby_Select(OpName, + out orderForm, out engineTypeID, out engineType, + out engineID, out palletCode, out isRepair, out repairCode); + + EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode),orderForm); + } + /// + /// 正常匹配分线和总线 + /// + /// + /// 总线工件号 + /// 总线工件机型代码 + /// 总线工件机型 + private void Match(string opName, string engineID, int engineTypeID, string engineType, int PartPallet_Code) + { + try + { + bool m_EngineGetOver_PLC_SubLine; + int engineTypeID_SubLine; + int partPallet_Code_SubLine; + int PalletInfo = 1;//总线托盘状态 + + string opName_SubLine = "";//分线工件信息 + string engineID_SubLine; + string engineType_SubLine; + string AlarmStr; + if (MIS_BASE.hashtable_OpNameRepair == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + //第一步:获取分线中间交互工位号 + if (MIS_BASE.hashtable_OpNameRepair.ContainsKey(opName)) + { + opName_SubLine = MIS_BASE.hashtable_OpNameRepair[opName].ToString(); + } + if (opName_SubLine == "") + { + return; + } + + //第二步:获取分线传递机型信号 + MIS_BASE.Read_EngineGetOver_PLC(opName_SubLine, out m_EngineGetOver_PLC_SubLine); + if (!m_EngineGetOver_PLC_SubLine) return;//必须工件同时到位才能进行匹配 + + //第三步:判断合格标志 + MIS_BASE.Read_PalletInfo(opName_SubLine, out PalletInfo); + if (PalletInfo == 2) return; //若不合格则返回不进行匹配 + string OrderForm; + //第四步:获取分线的信息,匹配验证 + MIS_BASE.GetEngineTypeFromPLC(opName_SubLine, out engineTypeID_SubLine, out engineType_SubLine, out engineID_SubLine, out partPallet_Code_SubLine,out OrderForm); + //判断分线数据是否合格 + //if (!BaseDataSystemMES.QulityDataVerify(opName, engineID_SubLine, out AlarmStr) && !BaseDataSystemMES.QualityVerifyStatus_Hash_Read(opName)) + //{ + // SendInfomation("LineoutAlert", AlarmStr, opName); + // return; + //} + + if (engineTypeID_SubLine == engineTypeID) + { + BaseDataSystemMES.SubLineLoadPartCountMatch_Select(opName, out SubLineLoadPartCountMatch); + SubLineLoadPartCountMatch = SubLineLoadPartCountMatch + 1; + BaseDataSystemMES.SubLineLoadPartCountMatch_Update(opName, SubLineLoadPartCountMatch); + + + BaseDataSystemMES.MailLineAndSubLineData_Insert(engineID, engineTypeID, engineType, engineID_SubLine);//分线上总线数据转移 + MIS_BASE.Write_Match(opName, true);//匹配结果 + MIS_BASE.Write_MatchingCompleted(opName, true);//匹配完成 + if(SubLineLoadPartCountMatch== SubLineLoadPartCount) + { + MIS_BASE.Write_FixAllow(opName, true); + SubLineLoadPartCountMatch = 0; + BaseDataSystemMES.SubLineLoadPartCountMatch_Update(opName, SubLineLoadPartCountMatch); + + } + + SendMessageFun.SendInfomation("MatchSuccess", "1", opName); + sendmessage(opName, 1, "Match");//匹配结果 + } + else + { + MIS_BASE.Write_Match(opName, false);//匹配结果 + MIS_BASE.Write_MatchingCompleted(opName, true);//匹配完成//68:1、取消返修;2、匹配成功 自己监控发送 MES|MatchingCompleted + + //发送匹配完成和匹配结果信息 + SendMessageFun.AsyncSendMessage_Notice(opName,"匹配失败,工件型号不匹配!"); + SendMessageFun.SendInfomation("MatchSuccess", "0", opName); + sendmessage(opName, 0, "Match");//匹配结果 + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog("Match:" + err.ToString()); + + } + } + + + + /// + /// 强制匹配分线和总线 + /// + /// + private void ForceMatch(string opName) + { + try + { + bool m_EngineGetOver_PLC_SubLine; + bool m_EngineGetOver_PLC; + + int engineTypeID_SubLine; + int engineTypeID; + int partPallet_Code_SubLine; + int partPallet_Code; + + string opName_SubLine = "";//分线工件信息 + string engineID_SubLine; + string engineType_SubLine; + string engineID; + string engineType; + if (MIS_BASE.hashtable_OpNameRepair == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + //获取分线中间交互工位号 + if (MIS_BASE.hashtable_OpNameRepair.ContainsKey(opName)) + { + opName_SubLine = MIS_BASE.hashtable_OpNameRepair[opName].ToString(); + } + if (opName_SubLine == "") + { + return; + } + + MIS_BASE.Read_EngineGetOver_PLC(opName_SubLine, out m_EngineGetOver_PLC_SubLine);//1:读取分线工件到位的传递机型信号。 + + if (!m_EngineGetOver_PLC_SubLine) return;//必须工件同时到位才能进行匹配 + + MIS_BASE.Read_EngineGetOver_PLC(opName, out m_EngineGetOver_PLC);//2:读取总线工件到位的传递机型信号。 + + if (!m_EngineGetOver_PLC) return;//必须工件同时到位才能进行匹配 + string OrderForm; + MIS_BASE.GetEngineTypeFromPLC(opName_SubLine, out engineTypeID_SubLine, out engineType_SubLine, out engineID_SubLine, out partPallet_Code_SubLine,out OrderForm);//获取分线的信息 + MIS_BASE.GetEngineTypeFromPLC(opName, out engineTypeID, out engineType, out engineID, out partPallet_Code, out OrderForm); + + BaseDataSystemMES.MailLineAndSubLineData_Insert(engineID, engineTypeID, engineType, engineID_SubLine);//分线上总线数据转移 + + MIS_BASE.Write_Match(opName, true);//匹配结果 + MIS_BASE.Write_MatchingCompleted(opName, true);//匹配完成 + + SendMessageFun.SendInfomation("MatchSuccess", "1", opName);//界面显示匹配成功 + + MIS_BASE.Write_FixAllow(opName, true);//允许PLC工作 + + //发送匹配完成和匹配结果信息 + sendmessage(opName, 1, "MatchingComplete");//匹配完成 + sendmessage(opName, 1, "Match");//匹配结果 + } + catch + { + + } + } + } +} diff --git a/MisDataFunction/Function1059/Methods/SubmitToMisweb.cs b/MisDataFunction/Function1059/Methods/SubmitToMisweb.cs new file mode 100644 index 0000000..8d84430 --- /dev/null +++ b/MisDataFunction/Function1059/Methods/SubmitToMisweb.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using bizFacade; +//using SystemFramework; + +namespace MesServerFunctions +{ + + /// + /// 此类用于向WEB发送各种类型消息 + /// + partial class FunctionMES + { + + + // /// + // /// 批量发送WEB消息(Value为BOOL值) + // /// + // /// 消息编号组合 + // /// 消息值组合 + // /// 工位号 + // void Sendmessage(string MessageNumm,string Value, string OpName) + //{ + // for (int i=0;i + // /// 选择发送给WEB的消息 + // /// + // /// 消息类型 + // /// 消息工位 + //void Sendmessage(char Num,string Value, string OpName) + //{ + // string SendMessage; + // switch (Num) + // { + // case '1': + // //1(直接在界面通过选择机型确认工序内容) + // SendMessage = "MES|ProcessList|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + + // case '2': + // //2显示物料 + // SendMessage = "MES|MaterialList|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + + // case '3': + + // //3显示操作指导图片 + // SendMessage = "MES|PicShow|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case '4': + // //3显示操作指导图片 + // SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + + // case '5': + // SendMessage = "MES|ShowMoby|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case '6': + // SendMessage = "MES|MaterialCheckPosition|" + OpName + "|" +Value; + // AsyncSendMessage(SendMessage); + // break; + // case '7': + // SendMessage = "MES|WorkStart|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case '8': + // SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case '9': + // SendMessage = "MES|ConfirmOkGo|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case 'a': + // SendMessage = "MES|FixAllow|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case 'b': + // SendMessage = "MES|ShaftPosition|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // case 'c': + // SendMessage = "MES|ShowQuality|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + // break; + // } + //} + + /// + /// 向WEB发送信息(value为字符串) + /// + /// 消息种类 + /// 消息内容 + /// 工位号 + //void SendInfomation(string Command, string Value, string OpName) + //{ + + // string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value; + // AsyncSendMessage(SendMessage); + //} + + + ///// + ///// 发送在线产量、在线节拍 + ///// + ///// + ///// + //private void SendActuallyCount(string OpName, int tagValue) + //{ + // //当工件离开时,更新在线产量、在线节拍 + // if (tagValue == 0) + // { + // try + // { + // int opNameCount = 0;//在线产量 + // int opNameCountTime = 0;//在线节拍 + + // BaseDataSystemMES.OpNameCount_New(OpName, out opNameCount, out opNameCountTime); //基本数据_工作日历_班次产量查询_New + + // SendInfomation("ActuallyCount", opNameCount.ToString() + "&" + opNameCountTime.ToString(), OpName); + + // } + // catch (Exception err) + // { + // ////ApplicationLog.WriteLog(err, "Function01:SendActuallyCount"); + // } + // } + //} + + + } +} diff --git a/MisDataFunction/Function1059/Methods/UDP.Send.cs b/MisDataFunction/Function1059/Methods/UDP.Send.cs new file mode 100644 index 0000000..26acece --- /dev/null +++ b/MisDataFunction/Function1059/Methods/UDP.Send.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using MesServerWork; +//using BasicData; +using System.Collections; +using bizFacade; +//using SystemFramework; +using System.Data; +using System.Threading; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + ///// + ///// 发送信息到MES通讯服务器或者其他的 + ///// + ///// + //private void AsyncSendMessage(string Message) + //{ + // MIS_BASE.asyncSendMessage(Message); + //} + + /// + /// 发送提示消息 + /// + /// + //private void AsyncSendMessage_Notice(string opname, string notice) + //{ + // //通知Web界面 + // BaseDataSystemMES.Web_Notice_Insert(opname, notice); + // string SendMessage = "MES|Notice|" + opname + "|" + "1"; + // MIS_BASE.asyncSendMessage(SendMessage); + //} + + /// + /// 发送信息到打印机 + /// + /// + private void asyncSendMessageToMark(string Message) + { + string messageSend = (string)Message; + //UDPClientSend.Send_ALL(ApplicationConfig.MES_MarkPortNum, messageSend); + } + + /// + /// 发送信息到LED + /// + /// + private void asyncSendMessageLED(string OpName) + { + + //发送到大屏幕显示 41104 + string strMessage = "MIS|" + OpName + "|" + "0" + "|" + "1"; + //UDPClientSend.Send_ALL(ApplicationConfig.Port_ShowLED_ProductCount, strMessage); + + } + + } +} diff --git a/MisDataFunction/Function1059/OpcServer/Barcode.cs b/MisDataFunction/Function1059/OpcServer/Barcode.cs new file mode 100644 index 0000000..f99b4a1 --- /dev/null +++ b/MisDataFunction/Function1059/OpcServer/Barcode.cs @@ -0,0 +1,239 @@ +using System; +using System.Threading; +using System.Xml.Linq; +using bizFacade; + +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + object lockBarcode = new object(); + + ///第一步,判断条码类型,根据条码类型,执行对应的存储过程 + ///第二步,条码类型(将扫描的条码保存到对应的表中) + ///第三步,扫描完成之后给出允许工作信号 + /// 处理页面扫描条码 + /// + /// + /// + public void Barcode(object e) + { + lock(lockBarcode) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + //+*************DbName***************** + string DbName = Convert.ToString(msgEvent.OpName); + string barcode = Convert.ToString(msgEvent.TagValue); + + int EngineTypeID;//机型代码 + string EngineType;//机型 + string EngineID;//工件编号 + + string OrderForm; + int Recipe1; + int Recipe2; + + bool IsNotRepeatedNumber = false; + //1:获得申请上线信息后,扫描条码才处理业务 + bool ispartload; + //(115) + int PTO; + //(118)0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + int NgearSwitch; + //(119)0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + int RgearSwitch; + //(120)0=不检测;1=检测。检测线上线工位扫描总成条码,根据BOM,查出 + int SpeedSensor; + //(121)例如:5S 400。检测线上线工位扫描总成条码,根据BOM,查出 + string PartTypeMid; + //(122) 0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出 + int Tcu_V; + //判断工件是否到位 + MIS_BASE.Read_WorkStart(OpName, out ispartload); + if (!ispartload) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请检查设备是否到位(DBX500.1=1)"); + return; + } + //判断设备是否申请上线 + //MIS_BASE.Read_UpdatePalletOK(OpName, out ispartload); + //if (!ispartload) + //{ + // SendMessageFun.AsyncSendMessage_Notice(OpName, "请检查设备是否申请上线(DBX500.3=1)"); + // return; + //} + // 判读条码是变速器序列号条码号还是物料号 小机型*日月年* 流水号(给起始号 + 数量) + // 选小机型 从北汽福田BOM中选 得先维护BOM + // 变速器序列号 '1333 050 062*16012023*30000001' + + //扫描完变速器序列号条码号 true + bool isGetOver_MES = false; + //判断上线工位,MES 是否将工件流水号、机型等信息已经写入到PLC了 + MIS_BASE.Read_EngineTypeGetOver_MES(OpName, out isGetOver_MES); + + //如果工件流水号、机型等信息没有写入PLC,扫描的条码按工件流水号进行验证 + //否则按装配物料进行验证 + if (!isGetOver_MES) + { + + if (barcode.Split('*').Length > 2) + { + //2: 判断是否重号, 从数据库获得机型、机型代码等信息 + string partSn = barcode; + EngineID = barcode; + + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID_MES, EngineID); + + //Db.GetEngineType( partSn, out EngineTypeID, out EngineType, out EngineID, out IsRepeatedNumber); + //Db.GetEngineType( partSn, out EngineTypeID, out EngineType, out EngineID, out IsRepeatedNumber); + + //IsRepeatedNumber true 不重号;false 重号; + IsNotRepeatedNumber = BaseDataSystemMES.EngineTypeID_IsNotRepeatedNumber(partSn); + if (IsNotRepeatedNumber) + { + BaseDataSystemMES.GetEngineTypeUpLoadOpName(partSn, OpName, out EngineTypeID, out EngineType, out OrderForm, out Recipe1, out Recipe2); + + //MIS_BASE.Write_EngineID_MES(OpName, EngineID); + //MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID); + //MIS_BASE.Write_EngineType_MES(OpName, EngineType); + //MIS_BASE.Write_OrderForm_MES(OpName, OrderForm); + + + BaseDataSystemMES.UpLoadPTO(partSn, out PTO, out NgearSwitch, out RgearSwitch, out SpeedSensor, out PartTypeMid, out Tcu_V); + //PTO + MIS_BASE.WritePLC(115, OpName, PTO); + //空挡开关检测 + MIS_BASE.WritePLC(95, OpName, NgearSwitch); + //倒挡开关检测 + MIS_BASE.WritePLC(96, OpName, RgearSwitch); + //里程表检测 + MIS_BASE.WritePLC(97, OpName, SpeedSensor); + //大机型扩展 + MIS_BASE.WritePLC(98, OpName, PartTypeMid); + //TCU + MIS_BASE.WritePLC(122, OpName, PartTypeMid); + string tagStartAdr;//= "DB411.10"; + + // 先查询配方号 根据工位号 去moby表查配方号 + // 根据配方号 去配方表查配方数据 + // 写入配方数据 + BaseDataSystemMES.PLCRcipeCurrent(OpName, out byte[] bytes, out tagStartAdr); + DtWebApi.ReadWritePLC.Write_TagValueByTagTypeID("94", OpName, System.Text.Encoding.ASCII.GetString(bytes)); + ////将产品信息写入PLC + MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID); + MIS_BASE.Write_EngineType_MES(OpName, EngineType); + MIS_BASE.Write_EngineID_MES(OpName, EngineID); + MIS_BASE.Write_OrderForm_MES(OpName, OrderForm); + + //写入到数据库的[北汽福田工位状态监控MOBY]表中 + //BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineTypeID_MES, EngineTypeID.ToString()); + //BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineType_MES, EngineType); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID_MES, EngineID); + //BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.OrderForm_MES, OrderForm); + + + // 工位号],[订单号],[产品型号代码],[变速器序列号],[发动机型号],[机型基本代码],[变速器总成号] ,[托盘号] + // [产品型号代码_MES],[变速器序列号_MES],[发动机型号_MES] + // [机床上电],[循环开始],[机床故障],[上料无件],[下料堵塞],[工件到位] + // [传递机型],[申请上件],[允许保存],[保存完成],[合格标志],[前序合格] + // [工号],[班次],[是否返修件],[合格放行],[不合格放行],[扫描条码] + + //BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, "产品型号代码_MES", EngineTypeID.ToString()); + //BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, "发动机型号_MES", EngineType); + + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, true); + + //Thread.Sleep(5000); + //MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + + //等待PLC将数据写入RFID;写入PLC的DB块,通知MES验证RFID机型数据是否正确传递 + + //通知web显示 + SendMessage.ShowMoby(OpName); + //SendMessageFun.SendMessage("1235", "1111", OpName); + + SendMessageFun.AsyncSendMessage_Notice(OpName, "扫码完成!"); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "变速器序列号 重号,请确认!"); + } + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "变速器序列号格式不正确,请确认!"); + + } + } + else//验证物料 + { + //物料号 + { + //读取PLC的传递机型信号 + bool tagValue; + MIS_BASE.Read_EngineGetOver_PLC(OpName, out tagValue); + if (tagValue) + { + //验证物料 + BaseDataSystemMES.PartMaterial_DM_Update(OpName, barcode, out bool IsSuccess); + if (!IsSuccess)//???? + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认"); + return; + } + else + { + SendMessageFun.SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息 + } + //判断物料是否验证完成 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out int IsAllowWork); + + + if (IsSuccess) + { + if (IsAllowWork == 1) + { + //移到允许保存信号中 + //BaseDataSystemMES.Material_Insert(OpName, 1); + + ////更新订单完工数量及物料 + SendMessageFun.SendMessage("24", "11", OpName); + + //物料验证完成,通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC未传递机型"); + } + } + else + { + SendMessage.AsyncSendMessage_Notice(OpName, "产品上线后,PLC获得变速器序列号后,再验证物料!"); + } + + } + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:Barcode"); + } + } + + } + + + } +} diff --git a/MisDataFunction/Function1059/OpcServer/ConfirmOkGo.cs b/MisDataFunction/Function1059/OpcServer/ConfirmOkGo.cs new file mode 100644 index 0000000..a978c1f --- /dev/null +++ b/MisDataFunction/Function1059/OpcServer/ConfirmOkGo.cs @@ -0,0 +1,35 @@ +using System; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 合格放行 + /// + /// + /// + private void ConfirmOkGo(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + MIS_BASE.Write_MaterialVerifyOver(OpName, true);//工作完成 + SendMessageFun.SendInfomation("OrderFormList","1", OpName); + + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:ConfirmOkGo"); + } + } + } +} diff --git a/MisDataFunction/Function1059/OpcServer/EngineGetOver.cs b/MisDataFunction/Function1059/OpcServer/EngineGetOver.cs new file mode 100644 index 0000000..5cf02f9 --- /dev/null +++ b/MisDataFunction/Function1059/OpcServer/EngineGetOver.cs @@ -0,0 +1,108 @@ +using System; +using System.Data; +using bizFacade; +using MesServerWork; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + object lockBarcodeEngineTypeGetOver = new object(); + + + /// + /// PLC传递机型处理 + /// + /// + /// + private void EngineTypeGetOver_PLC(object e) + { + lock(lockBarcodeEngineTypeGetOver) + { + + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + //判断PLC机型与MES机型是否一致 + if (tagValue == 1) + { + bool MesRead = false; + + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + + int EngineTypeID_MES;//机型代码 + string EngineType_MES;//机型 + string EngineID_MES;//工件编号 + + //上线工位清MES传递机型信号 + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + + MIS_BASE.Read_QualityData_Read_CF(OpName, out MesRead); + //第一步,判断允许保存和保存完成信号是否全部被清空,若未清空,则通知复位MES&PLC + if (MesRead) + { + //未能清空信号,请求复位 + SendMessageFun.SendInfomation("AskReset", "1", OpName); + return; + } + string OrderForm; + string OrderForm_MES; + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + MIS_BASE.GetEngineTypeFromPLC_MES(OpName, out EngineTypeID_MES, out EngineType_MES, out EngineID_MES, out OrderForm_MES); + + // 测试的时候用的 plc读取订单号有问题 + // OrderForm = BaseDataSystemMES.GetOrderDataBySn(EngineID); + + if (EngineTypeID_MES == EngineTypeID & EngineID_MES == EngineID & EngineType_MES == EngineType & OrderForm_MES == OrderForm) + { + // + DataTable dt = BaseDataSystemMES.EngineTypeChange(OpName, EngineType); + // 提示机型发生变化 + if (dt.Rows.Count > 0) + { + string mesValue = Newtonsoft.Json.JsonConvert.SerializeObject(dt);//(recData); + string message = "MES|MaterialList_Dif_Resources|" + OpName + "|" + mesValue; + SendMessage.AsyncSendMessage(message); + } + + + //写入到数据库的[北汽福田工位状态监控MOBY]表中 + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineTypeID, EngineTypeID.ToString()); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineType, EngineType); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID, EngineID); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.OrderForm, OrderForm); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.PartPallet_Code, PartPallet_Code.ToString()); + + //显示当前订单信息 + SendMessage.ShowMoby(OpName); + + + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm); + return; + } + else + { + SendMessage.AsyncSendMessage_Notice(OpName, "码块RFID机型与MES机型不匹配!"); + } + + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:EngineTypeGetOver_PLC"); + } + } + + } + + + + } +} diff --git a/MisDataFunction/Function1059/OpcServer/FalseGO.cs b/MisDataFunction/Function1059/OpcServer/FalseGO.cs new file mode 100644 index 0000000..54c73c7 --- /dev/null +++ b/MisDataFunction/Function1059/OpcServer/FalseGO.cs @@ -0,0 +1,37 @@ +using System; +using MesServerWork; +//using SystemFramework; + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + + /// + /// 返修放行 + /// + /// + /// + private void FalseGO(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + MIS_BASE.Write_MaterialVerifyOver(OpName, true);//工作完成 + SendMessageFun.SendInfomation("OrderFormList", "1", OpName); + + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1059/OpcServer/HeartBeat.cs b/MisDataFunction/Function1059/OpcServer/HeartBeat.cs new file mode 100644 index 0000000..93affd3 --- /dev/null +++ b/MisDataFunction/Function1059/OpcServer/HeartBeat.cs @@ -0,0 +1,35 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// MES与PLC心跳监听 + /// + /// + /// + private void HeartBeat(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //返写在MES心跳中 + MIS_BASE.WritePLC(15, OpName, tagValue); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1059/OpcServer/MesRead.cs b/MisDataFunction/Function1059/OpcServer/MesRead.cs new file mode 100644 index 0000000..9bc056d --- /dev/null +++ b/MisDataFunction/Function1059/OpcServer/MesRead.cs @@ -0,0 +1,77 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + object lockMesRead = new object (); + /// + /// 保存完成(针对半自动和手动压装工位) + /// + /// + /// + private void MesRead(object e) + { + lock(lockMesRead) + { + try + { + int EngineTypeID; + string EngineType; + string EngineID; + int PartPallet_Code; + string OrderForm; + + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + //保存数据到线首表 先保存到 北汽福田变速器序列号总线上线 用于之前判断是否重号 + if (Db.UpLoadOpNameInsert(EngineID, EngineTypeID, EngineType, OpName)) + { + // 保存质量数据 + int qualityMask = MisDataSaveDateMesRead.Funtion.MesRead(OpName, tagValue.ToString(), msgEvent.TagID.ToString()); + // 推送质量数据到MES的页面 + MIS_BASE.SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartOut, DateTime.Now.ToString()); + // 保存物料数据 + BaseDataSystemMES.Material_Insert(OpName, tagValue); + // 测量数据发动机在线状态 + BaseDataSystemMES.WorkStartInsert(OpName, qualityMask); + SendMessage.SendActuallyCount(OpName, tagValue);//统计在线产量,在线节拍 + + //通知设备,MES的质量数据(和物料数据)保存完成 + MIS_BASE.Write_MesReadOver(OpName, true); + // MES工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + else + { + SendMessage.AsyncSendMessage_Notice(OpName, "保存上线数据失败!"); + } + } + else + { + MIS_BASE.Write_MesReadOver(OpName, false); + } + + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + + } + + } + } +} diff --git a/MisDataFunction/Function1059/OpcServer/MesReadOver.cs b/MisDataFunction/Function1059/OpcServer/MesReadOver.cs new file mode 100644 index 0000000..9b637f2 --- /dev/null +++ b/MisDataFunction/Function1059/OpcServer/MesReadOver.cs @@ -0,0 +1,37 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 保存完成(针对半自动和手动压装工位) + /// + /// + /// + private void MesReadOver(object e) + { + try + { + //DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + //string OpName = Convert.ToString(msgEvent.OpName); + //int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //if (tagValue == 1) + //{ + + // BaseDataSystemMES.Material_Insert(OpName, tagValue); + + // MIS_BASE.Write_ConfirmOkGo(OpName, true); + //} + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + } +} diff --git a/MisDataFunction/Function1059/OpcServer/MesSaveNowData.cs b/MisDataFunction/Function1059/OpcServer/MesSaveNowData.cs new file mode 100644 index 0000000..be4c8ce --- /dev/null +++ b/MisDataFunction/Function1059/OpcServer/MesSaveNowData.cs @@ -0,0 +1,35 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// MES保存实时质量数据 + /// + /// + /// + private void MesSaveNowData(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + // 保存质量数据 + MisDataSaveDateMesRead.Funtion.MesRead(OpName, tagValue.ToString(), msgEvent.TagID.ToString(),true); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1059/OpcServer/PartLoad.cs b/MisDataFunction/Function1059/OpcServer/PartLoad.cs new file mode 100644 index 0000000..e221f64 --- /dev/null +++ b/MisDataFunction/Function1059/OpcServer/PartLoad.cs @@ -0,0 +1,39 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 申请上线(针对上线工位) + /// + /// + /// + private void PartLoad(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描总成码"); + } + else + { + //上线工位清MES传递机型信号 + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + } +} diff --git a/MisDataFunction/Function1059/OpcServer/WebSubmit.cs b/MisDataFunction/Function1059/OpcServer/WebSubmit.cs new file mode 100644 index 0000000..0272c32 --- /dev/null +++ b/MisDataFunction/Function1059/OpcServer/WebSubmit.cs @@ -0,0 +1,343 @@ +using System; +using MesServerWork; +using bizFacade; +using System.Threading; +using MisDataSaveDate; +using System.Collections; +//using SystemFramework; + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + private void WebSubmit(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string Content = Convert.ToString(msgEvent.TagValue); + + string opName_SubLine = ""; + string engineID = "";//工件信息 + string[] dataArray = Content.Split('|'); + + if (dataArray.Length != 2) + return; + + + string m_Command = dataArray[0].ToString();//消息类型 + string m_Value = dataArray[1].ToString();//消息参数 + string[] m_Value_array = m_Value.Split('&');//消息参数数量 + int m_Value_length = m_Value_array.Length; //消息参数长度 + + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + engineID = MIS_BASE.hashtable_EngineGetOver_EngineID[OpName].ToString(); + } + if (MIS_BASE.hashtable_OpNameRepair == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + DoWhatPlc.CustomeEvetnArgs _e = new DoWhatPlc.CustomeEvetnArgs(); + _e.OpName = OpName; + _e.TagValue = m_Value; + + //根据请求的命令处理逻辑 + switch (m_Command) + { + case "Barcode": + if (m_Value_length > 1) return; + fun_Barcode(_e); + break; + case "ConfirmOkGo"://合格放行 + //修改托盘状态 + + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_ConfirmOkGo(OpName, true); + MIS_BASE.Write_FalseGO(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + break; + case "FalseGO"://返修放行 + //修改托盘状态 + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "NgGO"://不合格放行 + //修改托盘状态 + //保存不合格信息(必须保存不合格放行信息,由于B5A的Moby没有不合格标志位) + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Insert(OpName, engineID, "", ""); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "OnLineState"://在线0、离线1、屏蔽2 + try + { + if (m_Value_length > 1) return; + int a = Convert.ToInt32(m_Value); + if (a <= 2) + { + BaseDataSystemMES.IsOnLine_Update(OpName, m_Value.ToString()); + MIS_BASE.Write_OnLineState(OpName, Convert.ToInt32(m_Value)); + + if (a == 2) SendMessage.AsyncSendMessage_Notice(OpName, "屏蔽MES!"); + if (a == 0) SendMessage.AsyncSendMessage_Notice(OpName, "启用MES!"); + } + } + catch + { + + } + break; + case "Reset"://复位,将MES所有的信息都复位了 + SetMoby(OpName);//将MES所有信号清空 + + break; + case "FixAllow"://重新拧紧 + break; + case "IsAutoGetEngineID"://自动手动申请编号(线首) + if (m_Value_length > 1) return; + MIS_BASE.Write_IsAutoGetEngineID(OpName, Convert.ToInt32(m_Value)); + break; + case "PartPalletGoOver"://空托盘放行 + MIS_BASE.Write_RepairUpline_MES(opName_SubLine, true); + //MIS_BASE.Write_PalletInfo(opName_SubLine, 4); + //MIS_BASE.Write_UpdatePalletOK(opName_SubLine, true); + MIS_BASE.Write_MaterialVerifyOver(opName_SubLine, true); + break; + case "SetMoby"://清空托盘(线首) + SetMoby(OpName);//将MES所有信号清空 + break; + case "RepairUplineMES"://返修上线 + MIS_BASE.Write_RepairUpline_MES(OpName, true); + break; + case "CancelRepair"://将返修件置为正常件 + + break; + case "PartPalletCode"://申请写入托盘号 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "WritePartPalletCode"://写入托盘号 + if (m_Value_length > 1) return; + MIS_BASE.Write_PalletCode(OpName, Convert.ToInt32(m_Value)); + break; + case "Normal"://启用正常拧紧工位 + MIS_BASE.Write_Normal(OpName, 1); + MIS_BASE.Write_UnNormal(OpName, 0); + break; + case "UnNormal"://启用备用拧紧工位 + MIS_BASE.Write_Normal(OpName, 0); + MIS_BASE.Write_UnNormal(OpName, 1); + break; + case "ResetDevice"://复位设备 + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + break; + case "IsNeedRepaire"://返修上线(返修上线点) + if (Convert.ToInt32(m_Value) == 1) + { + //修改托盘状态 + MIS_BASE.Write_PalletInfo(OpName, 3); + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + IsNeedRepaire_OK(OpName); + } + else if (Convert.ToInt32(m_Value) == 0) + { + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + break; + //强制匹配 + case "ForceMatch": + if (Convert.ToInt32(m_Value) == 1) + { + ForceMatch(OpName); + } + break; + case "PalletGO": + + if (Convert.ToInt32(m_Value) == 1) + { + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(opName_SubLine, true); + } + break; + case "ContinueMatch": + BaseDataSystemMES.QualityVerifyStatus_Hash_Write(OpName, true); + fun_EngineTypeGetOverPLC(_e); + break; + //初始化网页信号 + case "IniSingalToWeb": + InitializeSingalToWeb(OpName); + break; + default: break; + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:WebSubmit"); + } + } + + private void SetMoby(string OpName) + { + try + { + //清空Moby时,需要将MES信号清空 + MIS_BASE.Write_ClearMesMoby(OpName); + + BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName); + + SendMessageFun.SendMessage("5123", "1111", OpName); + + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + } + catch + { + + } + } + + + /// + /// 网页重现登录,恢复关闭前的页面状态 + /// + /// 工位号 + private void InitializeSingalToWeb(string Opname) + { + bool S_WorkStart;//工件到位 DBX0.1 + bool S_EngineGetOver;//传递机型 DBX0.4 + bool S_FixAllow;//允许工作 DBX3.1 + bool S_MaterialVerifyOver;//工作完成 DBX2.3 + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + + int IsCompleted = 0; + int S_Match = 0; + int PalletInfo_SubLine = 0;//显示分线托盘状态 + + MIS_BASE.Read_WorkStart(Opname, out S_WorkStart); + + //5 显示订单、机型信息 线首工位用 + SendMessage.ShowMoby_FirstOpName(Opname); + //3显示操作指导图片 PicShow_String_FirstOpName + SendMessage.PicShow_FirstOpName(Opname); + //1(直接在界面通过选择机型确认工序内容) + SendMessage.ProcessList_FirstOpName(Opname); + //界面显示物料信息 + SendMessage.MaterialList_FirstOpName(Opname); + // 新增查询PLC直通状态 网页显示 + MIS_BASE.Read_TagTypeID(63, Opname, out S_plcStatus); + InitAlarm(Opname); + + if (S_plcStatus.ToLower() == "false") + { + SendMessageFun.SendInfomation("PlcStatus", "0", Opname); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", Opname); + } + + if (S_WorkStart == true) + { + SendMessageFun.SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname); + //sendmessage(Opname, Convert.ToInt32(S_WorkStart), "WorkStart_Subline"); + } + + //sendmessage(Opname, Convert.ToInt32(S_WorkStart), "EngineTypeGetOverMES_Subline"); + + MIS_BASE.Read_EngineGetOver_PLC(Opname, out S_EngineGetOver); + if (S_EngineGetOver == true) + { + SendMessageFun.SendInfomation("EngineTypeGetOverPLC", Convert.ToString(Convert.ToInt32(S_EngineGetOver)), Opname); + //sendmessage(Opname, Convert.ToInt32(S_EngineGetOver), "EngineTypeGetOverMES_Subline"); + } + + MIS_BASE.Read_FixAllow(Opname, out S_FixAllow); + + if (S_FixAllow == true) + { + SendMessageFun.SendInfomation("FixAllow", Convert.ToString(Convert.ToInt32(S_FixAllow)), Opname); + } + + MIS_BASE.Read_MaterialVerifyOver(Opname, out S_MaterialVerifyOver); + + if (S_MaterialVerifyOver == true) + { + SendMessageFun.SendInfomation("MaterialVerifyOver", Convert.ToString(Convert.ToInt32(S_MaterialVerifyOver)), Opname); + } + + //MIS_BASE.Read_MatchingCompleted(Opname, out IsCompleted); //DBX1.3 是否匹配 + //MIS_BASE.Read_Match(Opname, out S_Match); //DBX1.4 匹配结果 + + //if (IsCompleted == 1 && S_Match == 1)//发送匹配完成和匹配结果信息 + //{ + // SendMessageFun.SendInfomation("MatchingCompleted", "1", Opname); + // SendMessageFun.SendInfomation("Match", "1", Opname); + // SendMessageFun.SendInfomation("MatchSuccess", "1", Opname);//界面显示匹配成功 + //} + //else if (IsCompleted == 1 && S_Match == 0) + //{ + // SendMessageFun.SendInfomation("MatchSuccess", "0", Opname);//界面显示匹配失败 + //} + + //if (MIS_BASE.hashtable_OpNameRepair == null) + //{ + // MIS_BASE.InitHashtable_MesServerCode(); + //} + //string Opname_SubLine = ""; + //if (MIS_BASE.hashtable_OpNameRepair.ContainsKey(Opname)) + //{ + // Opname_SubLine = MIS_BASE.hashtable_OpNameRepair[Opname].ToString(); + //} + //if (Opname_SubLine == "") + //{ + // return; + //} + + //MIS_BASE.Read_PalletInfo(Opname, out PalletInfo_SubLine); + //sendmessage(Opname, PalletInfo_SubLine, "SubQualityMask"); + //SendMessageFun.SendInfomation("ShowMobySubLine", Opname_SubLine, Opname);//显示分线机型及流水号 + } + + //分线发送工件到位信号函数 + private void sendmessage(string OpName, int tagValue, string Command) + { + string SendMessage; + SendMessage = "MES|" + Command + "|" + OpName + "|" + tagValue; + SendMessageFun.AsyncSendMessage(SendMessage); + + } + private void InitAlarm(string Opname) + { + FuntionMesRead.Alarm_InitAlarm_Send(Opname, out Hashtable ht); + foreach (DictionaryEntry kv in ht) + { + var TagID = kv.Key.ToString(); + var TagValue = kv.Value.ToString(); + FuntionMesRead.Send_AlarmMsg(TagID, TagValue); + } + + } + } +} diff --git a/MisDataFunction/Function1059/OpcServer/WorkStart.cs b/MisDataFunction/Function1059/OpcServer/WorkStart.cs new file mode 100644 index 0000000..a16c909 --- /dev/null +++ b/MisDataFunction/Function1059/OpcServer/WorkStart.cs @@ -0,0 +1,75 @@ +using System; +using bizFacade; +using MesServerWork; +//using SystemFramework; + + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工件到位与离开时,清空MES自身信号 + /// + /// + /// + private void WorkStart(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //线首显示订单信息 + + if (tagValue == 1) + { + MIS_BASE.Write_TagTypeID(115, OpName, 0); + MIS_BASE.Write_TagTypeID(95, OpName, 0); + MIS_BASE.Write_TagTypeID(96, OpName, 0); + MIS_BASE.Write_TagTypeID(97, OpName, 0); + MIS_BASE.Write_TagTypeID(98, OpName, ""); + //清空MOBY的产品流水号 + + // 北汽福田工位状态监控MOBY_增加 + // 工位号],[订单号],[产品型号代码],[变速器序列号],[发动机型号],[机型基本代码],[变速器总成号] ,[托盘号] + // [产品型号代码_MES],[变速器序列号_MES],[发动机型号_MES] + // [机床上电],[循环开始],[机床故障],[上料无件],[下料堵塞],[工件到位] + // [传递机型],[申请上件],[允许保存],[保存完成],[合格标志],[前序合格] + // [工号],[班次],[是否返修件],[合格放行],[不合格放行],[扫描条码] + //[到达时间],[离开时间],[持续时间] + + //初始化物料临时表 + //第二步,将零件信息转移到零件_临时表中(本地BOM与订单BOM的选择显示关系) + BaseDataSystemMES.MesServer_Process_EngineTypeOver_BQ_FirstOP(OpName); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartIn, DateTime.Now.ToString()); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStart, tagValue.ToString()); + + //5 显示订单、机型信息 线首工位用 + SendMessage.ShowMoby_FirstOpName(OpName); + //3显示操作指导图片 PicShow_String_FirstOpName + SendMessage.PicShow_FirstOpName(OpName); + //1(直接在界面通过选择机型确认工序内容) + SendMessage.ProcessList_FirstOpName(OpName); + //界面显示物料信息 + SendMessage.MaterialList_FirstOpName(OpName); + } + else + { + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartOut, DateTime.Now.ToString()); + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:WorkStart"); + } + } + } +} diff --git a/MisDataFunction/Function1059/Properties/AssemblyInfo.cs b/MisDataFunction/Function1059/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5afe3c2 --- /dev/null +++ b/MisDataFunction/Function1059/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Function1059")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Function1059")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("3dcc04c0-32bf-4573-91f6-c4e342a0cf2a")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MisDataFunction/Function1059/mssccprj.scc b/MisDataFunction/Function1059/mssccprj.scc new file mode 100644 index 0000000..f184c61 --- /dev/null +++ b/MisDataFunction/Function1059/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[Function08.csproj] +SCC_Aux_Path = "\\192.168.0.100\vss\MES4.0" +SCC_Project_Name = "$/MisData/MisData/MisData/MesServer.Function/Function08", KRHAAAAA diff --git a/MisDataFunction/Function1059/packages.config b/MisDataFunction/Function1059/packages.config new file mode 100644 index 0000000..b3e1761 --- /dev/null +++ b/MisDataFunction/Function1059/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1060/DataAccess/DataAccess.cs b/MisDataFunction/Function1060/DataAccess/DataAccess.cs new file mode 100644 index 0000000..cd36930 --- /dev/null +++ b/MisDataFunction/Function1060/DataAccess/DataAccess.cs @@ -0,0 +1,15 @@ + +namespace MesServerFunctions +{ + partial class Function1053 + { + //针对“MIS.BizFacade.Dll”中没有的存储过程,在此类中新建 + //新建原则:所有的函数用private,只允许在内部使用 + //针对单个工艺特殊,需要新建存储过程,但是存储过程不能被加入到“MIS.BizFacade.Dll”中 + + private void aa() + { + + } + } +} diff --git a/MisDataFunction/Function1060/Db.cs b/MisDataFunction/Function1060/Db.cs new file mode 100644 index 0000000..64286ed --- /dev/null +++ b/MisDataFunction/Function1060/Db.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DataLinkMesWork; + +namespace MesServerFunctions +{ + public class Db + { + /// + /// 北汽福田变速器序列号总线上线_获得机型信息 + /// + /// + /// + /// + /// + /// 0 不重号;1 重号;2:失败 + /// + public static bool GetEngineType(string partSn, out int EngineTypeID, out string EngineType, out string EngineID,out int IsRepeatedNumber) + { + DataTable dt = new DataTable(); + EngineTypeID = 0; + EngineType = ""; + EngineID = ""; + IsRepeatedNumber = 2; + string produceName = "北汽福田变速器序列号总线上线_获得机型信息"; + SqlParameter[] thisParms = new SqlParameter[1]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@变速器序列号", partSn); + + thisParms[2].Direction = ParameterDirection.Output; + if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms,out dt)) + { + if(dt.Rows.Count > 0) + { + IsRepeatedNumber = Convert.ToInt32( dt.Rows[0]["IsRepeatedNumber"]); + EngineTypeID = Convert.ToInt32(dt.Rows[0]["EngineTypeID"]); + EngineType = dt.Rows[0]["EngineType"].ToString(); + EngineID = partSn; + return true; + } + } + return false; + } + /// + /// 北汽福田变速器序列号总线上线_增加 + /// + /// + /// + /// + /// + /// + public static bool UpLoadOpNameInsert(string partSn, int EngineTypeID, string EngineType, string OpName) + { + + string produceName = "北汽福田变速器序列号总线上线_增加"; + SqlParameter[] thisParms = new SqlParameter[4]; + thisParms[0] = new System.Data.SqlClient.SqlParameter("@变速器序列号", partSn); + thisParms[1] = new System.Data.SqlClient.SqlParameter("@基本型号代码", EngineTypeID); + thisParms[2] = new System.Data.SqlClient.SqlParameter("@基本型号", EngineType); + thisParms[3] = new System.Data.SqlClient.SqlParameter("@工位号", OpName); + return DataAccess.ExecuteStoredProcedure(produceName, ref thisParms); + } + + // ALTER PROCEDURE[dbo].[北汽福田变速器序列号总线上线_增加] + // @变速器序列号 nvarchar(50)='1333 050 062 0001*146012023*12345678',--'1333 050 062 0001' + //@基本型号代码 int=1, + //@基本型号 nvarchar(50)='1333 050 062 0001', + //@工位号 nvarchar(50) = 'J05PA010' + } +} diff --git a/MisDataFunction/Function1060/Function1060.csproj b/MisDataFunction/Function1060/Function1060.csproj new file mode 100644 index 0000000..12f2824 --- /dev/null +++ b/MisDataFunction/Function1060/Function1060.csproj @@ -0,0 +1,109 @@ + + + + + Debug + AnyCPU + {D5DC93C7-91DD-4C82-9444-64180F15A9C9} + Library + Properties + Function1060 + Function1060 + v4.8 + 512 + true + + + true + full + false + ..\..\MisDataFun_Exe\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\MisDataFunDll\MisDataFunDll\bin\Debug\00.1Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {f55da1a0-a982-4479-8c47-0d9a5aaf3e18} + 00MesWorkMqtt + + + {0d1af432-439a-4920-8692-43ae139f5530} + 01_01DoWhatPlc + + + {3e6d1dd5-01c9-435f-9941-61f906ce35bb} + 02_02WebApiCallPLC + + + {f434e066-4c59-47c8-aa82-6f48cc84501a} + 04-DataBaseAccess + + + {f0a0c525-03fd-428a-9b17-7f54aa0e4475} + 07BusinessFacade + + + {d98be764-adeb-488d-9714-61e308aa8201} + 08-WebFun_base + + + {90e76fb4-646d-45e2-95db-0b8ab4e465d6} + 09-MesDataFunction + + + {e4eb6420-906d-4672-947a-ca33ddcdadfc} + 12SendMessageToWeb + + + {55b510c1-59e9-4bfd-ae84-d76d46f6e365} + 02-13.3MIS_FuntionSaveData + + + + \ No newline at end of file diff --git a/MisDataFunction/Function1060/MesServerFunction/Fun_1060.cs b/MisDataFunction/Function1060/MesServerFunction/Fun_1060.cs new file mode 100644 index 0000000..48817f0 --- /dev/null +++ b/MisDataFunction/Function1060/MesServerFunction/Fun_1060.cs @@ -0,0 +1,217 @@ +using MesServerWork; +using System.Collections.Generic; +using System.Threading; + +namespace MesServerFunctions +{ + public partial class FunctionMES + { + object lockFunWork; + //public void FunWork(DoWhatPlc.CustomeEvetnArgs e) + public void FunWork(string recData) + { + + + lockFunWork = new object(); + lock (lockFunWork) + { + List dataArray = DoWhatPlc.MessageText.GetCmdStringList(recData); + //string[] dataArray = recData.Split('|'); + //if (dataArray.Count != 4) + //return; + //消息来源 + string m_Source = dataArray[0].ToString(); + //消息类型 Barcode + string m_Command = dataArray[1].ToString(); + //工位号 + string m_OpName = dataArray[2].ToString(); + //消息参数 + string m_Value = dataArray[3].ToString(); + + DoWhatPlc.CustomeEvetnArgs e = new DoWhatPlc.CustomeEvetnArgs();// = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + string tagValue; + + switch (m_Source) + { + case "BarCode": + e.OpName = m_OpName; + e.TagValue = m_Value; + fun_Barcode(e); + break; + case "WEB": + e.OpName = m_OpName; + e.TagValue = m_Command + "|" + m_Value; + fun_WebSubmit(e); + break; + case "PLC": + e = Newtonsoft.Json.JsonConvert.DeserializeObject(m_Value); + switch (e.TagValue.ToString().ToLower()) + { + case "false": + tagValue = "0"; + break; + case "true": + tagValue = "1"; + break; + default: + tagValue = e.TagValue.ToString(); + break; + } + e.TagValue = tagValue; + switch (e.TagTypeCodeID.ToString()) + { + //PLC 工件到位 + case "2": + fun_WorkStart(e); + break; + //PLC 允许保存质量数据 + case "19": + fun_MesRead(e); + break; + //MES 保存数据完成 + case "20": + fun_MesReadOver(e); + break; + //PLC 传递机型 + case "44": + fun_EngineTypeGetOverPLC(e); + break; + //MES 合格放行 + case "51": + fun_ConfirmOkGo(e); + break; + //MES 不合格放行 + case "8": + fun_FalseGo(e); + break; + //MES保存实时质量数据 + case "65": + fun_MesSaveNowData(e); + break; + //MES 系统健康心跳 + case "14": + fun_HeartBeatMIS(e); + break; + case "63": + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + MIS_BASE.Read_TagTypeID(63, m_OpName, out S_plcStatus); + if (S_plcStatus.ToLower() != "true" || S_plcStatus.ToLower() == "1") + { + SendMessageFun.SendInfomation("PlcStatus", "0", m_OpName); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", m_OpName); + } + break; + } + break; + } + } + } + //1.工件到位后,PLC给MES传递机型(DBX0.4)(44), + //MES判断条码是否全部扫描完成 + //PLC给出允许保存(DBX100.2)(19),MES见到(DBX100.2)(19)为1后给出保存完成(DBX102.2)(20), + //PLC见到保存完成(DBX102.2)(20)为1后,清空允许保存(DBX100.2)(19), + //MES见到允许保存(DBX100.2)(19)为0后,清空保存完成(DBX102.2)(20) + //MES判断总合格标志(INT104)(21)为1后,给出合格放行(DBX2.5)(51) + /// + /// 扫描条码 + /// + /// + /// + public void fun_Barcode(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(Barcode, e); + } + + /// + /// 传递机型 + /// + /// + /// + public void fun_EngineTypeGetOverPLC(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(EngineTypeGetOver_PLC, e); + } + + /// + /// 合格放行 + /// + /// + /// + public void fun_ConfirmOkGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(ConfirmOkGo, e); + } + /// + /// 系统健康心跳监测 + /// + /// + /// + public void fun_HeartBeatMIS(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(HeartBeat, e); + } + /// + /// 不合格放行 + /// + /// + /// + public void fun_FalseGo(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(FalseGO, e); + } + + /// + /// 允许保存 + /// + /// + /// + public void fun_MesRead(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesRead, e); + } + + /// + /// 保存完成 + /// + /// + /// + public void fun_MesReadOver(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesReadOver, e); + } + + /// + /// 工件到位离开(清空所有的MES信号) + /// + /// + /// + public void fun_WorkStart(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WorkStart, e); + } + + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + public void fun_WebSubmit(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(WebSubmit, e); + } + + /// + /// MES实时保存质量数据 + /// + /// + /// + public void fun_MesSaveNowData(DoWhatPlc.CustomeEvetnArgs e) + { + ThreadPool.QueueUserWorkItem(MesSaveNowData, e); + } + + } +} diff --git a/MisDataFunction/Function1060/Methods/EngineGetOverBaseWork.cs b/MisDataFunction/Function1060/Methods/EngineGetOverBaseWork.cs new file mode 100644 index 0000000..a9dd932 --- /dev/null +++ b/MisDataFunction/Function1060/Methods/EngineGetOverBaseWork.cs @@ -0,0 +1,96 @@ +using System; +using System.Data; +using bizFacade; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 正常逻辑工作(传递机型) + /// + /// + /// + /// + /// + /// + private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code,string OrderForm) + { + int IsAllowWork; + int RepairPartStatusPLC = 0; + int MES_QualityMask = 1; + //string OrderForm = "";//订单号 + //DataTable dt; + + if (EngineTypeID <= 0 || EngineID.Length == 0 || EngineType.Length == 0 || OrderForm.Length == 0) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC传递机型为空"); + return; + } + //电子看板_装配零件_临时表_增加_北汽 + //第二步,将零件信息转移到零件_临时表中 + BaseDataSystemMES.MesServer_Process_EngineTypeOverBQ(OpName); + + //通知web显示 + SendMessageFun.SendMessage("1235", "1111", OpName); + MIS_BASE.Read_PalletInfo(OpName, out MES_QualityMask);//合格标志 + MIS_BASE.Read_RepairStatus_PLC(OpName, out RepairPartStatusPLC);//返修标志 + SendMessageFun.SendInfomation("QualityMask", Convert.ToString(MES_QualityMask), OpName);//显示合格标志 + SendMessageFun.SendInfomation("RepairPartStatusPLC", Convert.ToString(RepairPartStatusPLC), OpName);//显示返修标志 + + if (MES_QualityMask == 2) + { + //// 工作完成 + //MIS_BASE.Write_MaterialVerifyOver(OpName, true); + //SendMessageFun.SendInfomation("NgGO", "1", OpName);//显示不合格标志 + //return; + } + + + //第三步,用于工件离开后完工数量统计及工件编号追溯 + //BaseDataSystemMES.MaterialPush_EngineIDStatus_Insert(OpName);//更新订单产量 + + //第四步,获取是否允许工作 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + //暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况 + if (IsAllowWork == 1) + { + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + + } + + + /// + /// 返修件需要工作 + /// + /// 工位号 + private void IsNeedRepaire_OK(string OpName) + { + string orderForm = ""; + int engineTypeID; + string engineType = ""; + string engineID = ""; + string palletCode = ""; + int isRepair; + string repairCode = ""; + //从监控系统中查询出本工位信息 + BaseDataSystemMES.OpName_MIS_Moby_Select(OpName, + out orderForm, out engineTypeID, out engineType, + out engineID, out palletCode, out isRepair, out repairCode); + + EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode),orderForm); + } + + + + + } +} diff --git a/MisDataFunction/Function1060/Methods/SubmitToMisweb.cs b/MisDataFunction/Function1060/Methods/SubmitToMisweb.cs new file mode 100644 index 0000000..52ce16f --- /dev/null +++ b/MisDataFunction/Function1060/Methods/SubmitToMisweb.cs @@ -0,0 +1,127 @@ +using System; +using bizFacade; +//using SystemFramework; + +namespace MesServerFunctions +{ + + /// + /// 此类用于向WEB发送各种类型消息 + /// + partial class FunctionMES + { + + /// + /// 批量发送WEB消息(Value为BOOL值) + /// + /// 消息编号组合 + /// 消息值组合 + /// 工位号 + void Sendmessage(string MessageNumm,string Value, string OpName) + { + for (int i=0;i + /// 选择发送给WEB的消息 + /// + /// 消息类型 + /// 消息工位 + string Sendmessage(char Num,string Value, string OpName) + { + string SendMessage; + string result = ""; + switch (Num) + { + case '1': + //1(直接在界面通过选择机型确认工序内容) + SendMessage = "MES|ProcessList|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '2': + //2显示物料 + SendMessage = "MES|MaterialList|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '3': + //3显示操作指导图片 + SendMessage = "MES|PicShow|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '4': + //4订单完工模块刷新完成数量 + SendMessage = "MES|OrderFormList|" + OpName + "|" + Value; + AsyncSendMessage(SendMessage); + break; + case '5': + SendMessage = "MES|ShowMoby|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '6': + SendMessage = "MES|MaterialCheckPosition|" + OpName + "|" +Value; + result = AsyncSendMessage(SendMessage); + break; + case '7': + SendMessage = "MES|WorkStart|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case '8'://清除MES生成编号 + + break; + case '9': + SendMessage = "MES|ConfirmOkGo|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + case 'a': + SendMessage = "MES|FixAllow|" + OpName + "|" + Value; + result = AsyncSendMessage(SendMessage); + break; + } + return result; + } + /// + /// 向WEB发送信息(value为字符串) + /// + /// 消息种类 + /// 消息内容 + /// 工位号 + string SendInfomation(string Command, string Value, string OpName) + { + string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value; + return AsyncSendMessage(SendMessage); + } + + + /// + /// 发送在线产量、在线节拍 + /// + /// + /// + private void SendActuallyCount(string OpName, int tagValue) + { + //当工件离开时,更新在线产量、在线节拍 + if (tagValue == 0) + { + try + { + int opNameCount = 0;//在线产量 + int opNameCountTime = 0;//在线节拍 + //基本数据_工作日历_班次产量查询_New + BaseDataSystemMES.OpNameCount_New(OpName, out opNameCount, out opNameCountTime); + string SendMessage; + SendMessage = "MES|ActuallyCount|" + OpName + "|" + opNameCount.ToString() + "&" + opNameCountTime.ToString(); + AsyncSendMessage(SendMessage); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:SendActuallyCount"); + } + } + } + + + } +} diff --git a/MisDataFunction/Function1060/Methods/UDP.Send.cs b/MisDataFunction/Function1060/Methods/UDP.Send.cs new file mode 100644 index 0000000..aed7cc3 --- /dev/null +++ b/MisDataFunction/Function1060/Methods/UDP.Send.cs @@ -0,0 +1,53 @@ +using bizFacade; +//using SystemFramework; +using MesServerWork; +using DataLinkMesWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 发送信息到MES通讯服务器或者其他的 + /// + /// + private string AsyncSendMessage(string Message) + { + return MIS_BASE.asyncSendMessage(Message); + } + + /// + /// 发送提示消息 + /// + /// + private void AsyncSendMessage_Notice(string opname, string notice) + { + //通知Web界面 + BaseDataSystemMES.Web_Notice_Insert(opname, notice); + string SendMessage = "MES|Notice|" + opname + "|" + "1"; + MIS_BASE.asyncSendMessage(SendMessage); + } + + /// + /// 发送信息到打印机 + /// + /// + private void asyncSendMessageToMark(string Message) + { + string messageSend = (string)Message; + //UDPClientSend.Send_ALL(ApplicationConfig.MES_MarkPortNum, messageSend); + } + + /// + /// 发送信息到LED + /// + /// + private void asyncSendMessageLED(string OpName) + { + //发送到大屏幕显示 41104 + string strMessage = "MIS|" + OpName + "|" + "0" + "|" + "1"; + //UDPClientSend.Send_ALL(ApplicationConfig.Port_ShowLED_ProductCount, strMessage); + + } + } +} diff --git a/MisDataFunction/Function1060/OpcServer/Barcode.cs b/MisDataFunction/Function1060/OpcServer/Barcode.cs new file mode 100644 index 0000000..5d80b2f --- /dev/null +++ b/MisDataFunction/Function1060/OpcServer/Barcode.cs @@ -0,0 +1,97 @@ +using System; +//using System.Windows.Forms; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + ///1.扫描配送单号,用于接收物料,扫描单号的时候,将接收的物料信息显示在“物料拉动”Tab区域 + ///2.扫描料箱标签/看板卡,用于追溯物料批次信息 + ///3.扫描零件条码,根据零件图号进行防错 + ///第一步,判断条码类型,根据条码类型,执行对应的存储过程 + ///第二步,条码类型(将扫描的条码保存到对应的表中) + ///第三步,扫描完成之后给出允许工作信号 + /// 处理页面扫描条码 + /// + /// + /// + public void Barcode(object e) + { + + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + string barcode = Convert.ToString(msgEvent.TagValue); + string AlarmStr = ""; + + int IsAllowWork; + bool IsSuccess = false; + bool EngineGetOver_PLC_NextWorkStep; + //传递机型是否到位 + MIS_BASE.Read_EngineGetOver_PLC(OpName, out EngineGetOver_PLC_NextWorkStep); + if (!EngineGetOver_PLC_NextWorkStep) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC未传递机型"); + return; + } + //物料验证 + BaseDataSystemMES.PartMaterial_DM_Update(OpName, barcode, out IsSuccess); + if (!IsSuccess) + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认"); + return; + } + else + { + SendMessageFun.SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息 + } + + + + + //获取是否允许工作 + BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork); + + //此处逻辑有问题 需要考虑到批次扫描 提示PLC未传递机型的情况 + if (IsAllowWork == 1) + { + //BaseDataSystemMES.Material_Insert(OpName, 1); + + //更新订单完工数量及物料 + SendMessageFun.SendMessage("24", "11", OpName); + + //工作完成 + //MIS_BASE.Write_MaterialVerifyOver(OpName, true); + //if (!BaseDataSystemMES.QualityVerifyStatusOutline(OpName, out AlarmStr)) + //{ + // SendInfomation("LineoutAlert", AlarmStr, OpName); + // return; + //} + //通知PLC允许工作,允许工作在保存完成时清空 + MIS_BASE.Write_FixAllow(OpName, true); + } + else + { + SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!"); + } + + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:Barcode"); + } + + } + + } + + + } +} diff --git a/MisDataFunction/Function1060/OpcServer/ConfirmOkGo.cs b/MisDataFunction/Function1060/OpcServer/ConfirmOkGo.cs new file mode 100644 index 0000000..ac8affd --- /dev/null +++ b/MisDataFunction/Function1060/OpcServer/ConfirmOkGo.cs @@ -0,0 +1,41 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 合格放行 + /// + /// + /// + private void ConfirmOkGo(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + + //BaseDataSystemMES.Material_Insert(OpName, 1); + + ////更新订单完工数量及物料 + //Sendmessage("24", "11", OpName); + + ////工作完成 + //MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:ConfirmOkGo"); + } + } + } +} diff --git a/MisDataFunction/Function1060/OpcServer/EngineGetOver.cs b/MisDataFunction/Function1060/OpcServer/EngineGetOver.cs new file mode 100644 index 0000000..db74c48 --- /dev/null +++ b/MisDataFunction/Function1060/OpcServer/EngineGetOver.cs @@ -0,0 +1,90 @@ +using System; +using System.Data; +//using System.Windows.Forms; +using System.Xml.Linq; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// PLC传递机型处理 + /// + /// + /// + private void EngineTypeGetOver_PLC(object e) + { + + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + int EngineTypeID;//机型代码 + int PartPallet_Code;//托盘编号 + + string EngineType;//机型 + string EngineID;//工件编号 + string OrderForm; + string OrderForm_MES; + + int EngineTypeID_MES;//机型代码 + string EngineType_MES;//机型 + string EngineID_MES;//工件编号 + + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + MIS_BASE.GetEngineTypeFromPLC_MES(OpName, out EngineTypeID_MES, out EngineType_MES, out EngineID_MES, out OrderForm_MES); + + // 测试的时候用的 plc读取订单号有问题 + // OrderForm = BaseDataSystemMES.GetOrderDataBySn(EngineID); + + if (EngineTypeID_MES == EngineTypeID & EngineID_MES == EngineID & EngineType_MES == EngineType) + { + DataTable dt; + dt = BaseDataSystemMES.EngineTypeChange(OpName, EngineType); + //提示机型发生变化 + if (dt.Rows.Count > 0) + { + string mesValue = Newtonsoft.Json.JsonConvert.SerializeObject(dt);//(recData); + string message = "MES|MaterialList_Dif_Resources|" + OpName + "|" + mesValue; + SendMessage.AsyncSendMessage(message); + } + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineTypeID, EngineTypeID.ToString()); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineType, EngineType); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID, EngineID); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.OrderForm, OrderForm); + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.PartPallet_Code, PartPallet_Code.ToString()); + + //显示当前订单信息 + SendMessage.ShowMoby(OpName); + + EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm); + } + else + { + SendMessage.AsyncSendMessage_Notice(OpName, "PLC机型与MES机型不匹配!"); + } + + + + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:EngineTypeGetOver_PLC"); + } + } + + + } + + + } +} diff --git a/MisDataFunction/Function1060/OpcServer/FalseGO.cs b/MisDataFunction/Function1060/OpcServer/FalseGO.cs new file mode 100644 index 0000000..e6d4179 --- /dev/null +++ b/MisDataFunction/Function1060/OpcServer/FalseGO.cs @@ -0,0 +1,41 @@ +using System; +using bizFacade; +//using SystemFramework; +using MesServerWork; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 不合格放行 + /// + /// + /// + private void FalseGO(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + if (tagValue == 1) + { + //总合格标志2(不合格) + + //BaseDataSystemMES.Material_Insert_NG(OpName, 2); + + //Sendmessage("24", "11", OpName); + + ////工作完成 + //MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1060/OpcServer/HeartBeat.cs b/MisDataFunction/Function1060/OpcServer/HeartBeat.cs new file mode 100644 index 0000000..93affd3 --- /dev/null +++ b/MisDataFunction/Function1060/OpcServer/HeartBeat.cs @@ -0,0 +1,35 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// MES与PLC心跳监听 + /// + /// + /// + private void HeartBeat(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + //返写在MES心跳中 + MIS_BASE.WritePLC(15, OpName, tagValue); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1060/OpcServer/MesRead.cs b/MisDataFunction/Function1060/OpcServer/MesRead.cs new file mode 100644 index 0000000..2c468df --- /dev/null +++ b/MisDataFunction/Function1060/OpcServer/MesRead.cs @@ -0,0 +1,72 @@ +using bizFacade; +using MesServerWork; +using System; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 允许保存(针对半自动和手动压装工位) + /// + /// + /// + private void MesRead(object e) + { + { + try + { + int EngineTypeID; + string EngineType; + string EngineID; + int PartPallet_Code; + string OrderForm; + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + if (tagValue == 1) + { + MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm); + + //保存数据到线首表 先保存到 北汽福田变速器序列号总线上线 用于之前判断是否重号 + if (Db.UpLoadOpNameInsert(EngineID, EngineTypeID, EngineType, OpName)) + { + //保存质量数据 + int qualityMask = MisDataSaveDateMesRead.Funtion.MesRead(OpName, tagValue.ToString(), msgEvent.TagID.ToString()); + //保存物料数据 + BaseDataSystemMES.Material_Insert(OpName, qualityMask); + //测量数据发动机在线状态 + BaseDataSystemMES.WorkStartInsert(OpName, qualityMask); + //推送质量数据到MES的页面 + SendMessageFun.SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName); + //统计在线产量,在线节拍 + SendMessage.SendActuallyCount(OpName, tagValue); + + //通知设备,MES的质量数据(和物料数据)保存完成 + MIS_BASE.Write_MesReadOver(OpName, true); + //MES工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + else + { + SendMessage.AsyncSendMessage_Notice(OpName, "保存上线数据失败!"); + } + } + else + { + MIS_BASE.Write_MesReadOver(OpName, false); + } + } + + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function08:MesReadOver"); + } + } + + } + } +} diff --git a/MisDataFunction/Function1060/OpcServer/MesReadOver.cs b/MisDataFunction/Function1060/OpcServer/MesReadOver.cs new file mode 100644 index 0000000..f96a7d3 --- /dev/null +++ b/MisDataFunction/Function1060/OpcServer/MesReadOver.cs @@ -0,0 +1,55 @@ +using System; +//using SystemFramework; +using MesServerWork; +using bizFacade; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 保存完成(针对半自动和手动压装工位) + /// + /// + /// + private void MesReadOver(object e) + { + //try + //{ + // DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + // string OpName = Convert.ToString(msgEvent.OpName); + // var tagValue = msgEvent.TagValue.ToString (); + + // if (tagValue == "1" | tagValue.ToLower () == "true") + // { + // int qualityMask; + // MIS_BASE.Read_QualityMask(OpName, out qualityMask); + + // SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName);//发给Web页面显示质量数据 + + // if (qualityMask == 1)//全部OK,给出合格放行 + // { + // //如果存在线外扫描工位,根据扫描条码绑定线外数据 需要时解除禁用 + // //BaseDataSystemMES.TransLaunchDataByMainMaterial(OpName, EngineType, EngineID, EngineTypeID); + + // //如果存在线外排队工位,根据排队编号绑定线外数据 需要时解除禁用 + // ////BaseDataSystemMES.MailLineAndSubLineData_InsertByEngineID_Subline(OpName,EngineID, EngineTypeID, EngineType); + + // MIS_BASE.Write_ConfirmOkGo(OpName, true); + // //MIS_BASE.Write_FalseGO(OpName, false); + // } + // else + // { + // //MIS_BASE.Write_ConfirmOkGo(OpName, false); + // MIS_BASE.Write_FalseGO(OpName, true); + // } + + // } + //} + //catch (Exception err) + //{ + // ////ApplicationLog.WriteLog(err, "Function02:MesReadOver"); + //} + } + } +} diff --git a/MisDataFunction/Function1060/OpcServer/MesSaveNowData.cs b/MisDataFunction/Function1060/OpcServer/MesSaveNowData.cs new file mode 100644 index 0000000..11c9129 --- /dev/null +++ b/MisDataFunction/Function1060/OpcServer/MesSaveNowData.cs @@ -0,0 +1,35 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// MES保存实时质量数据 + /// + /// + /// + private void MesSaveNowData(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + int tagValue = Convert.ToInt32(msgEvent.TagValue); + + // 保存质量数据 + MisDataSaveDateMesRead.Funtion.MesRead(OpName, tagValue.ToString(), msgEvent.TagID.ToString()); + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + } +} diff --git a/MisDataFunction/Function1060/OpcServer/PartLoad.cs b/MisDataFunction/Function1060/OpcServer/PartLoad.cs new file mode 100644 index 0000000..75debe9 --- /dev/null +++ b/MisDataFunction/Function1060/OpcServer/PartLoad.cs @@ -0,0 +1,23 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 申请上线 43 + /// + /// + /// + private void PartLoad(object e) + { + } + } +} diff --git a/MisDataFunction/Function1060/OpcServer/WebSubmit.cs b/MisDataFunction/Function1060/OpcServer/WebSubmit.cs new file mode 100644 index 0000000..87548a3 --- /dev/null +++ b/MisDataFunction/Function1060/OpcServer/WebSubmit.cs @@ -0,0 +1,334 @@ +using System; +using MesServerWork; +using bizFacade; +using System.Threading; +using MisDataSaveDate; +using System.Collections; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;) + /// + /// + /// + private void WebSubmit(object e) + { + try + { + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName=Convert.ToString(msgEvent.OpName); + string Content = Convert.ToString(msgEvent.TagValue); + + string[] dataArray = Content.Split('|'); + if (dataArray.Length != 2) + return; + //消息类型 + string m_Command = dataArray[0].ToString(); + //消息参数 + string m_Value = dataArray[1].ToString(); + //消息参数数量 + string[] m_Value_array = m_Value.Split('&'); + //消息参数长度 + int m_Value_length = m_Value_array.Length; + + //工件信息 + string engineID = ""; + if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null) + { + MIS_BASE.InitHashtable_MesServerCode(); + } + if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName)) + { + engineID = MIS_BASE.hashtable_EngineGetOver_EngineID[OpName].ToString(); + } + + DoWhatPlc.CustomeEvetnArgs _e = new DoWhatPlc.CustomeEvetnArgs(); + _e.OpName = OpName; + _e.TagValue = m_Value; + + //根据请求的命令处理逻辑 + switch (m_Command) + { + case "Barcode": + if (m_Value_length > 1) return; + fun_Barcode(_e); + break; + case "ConfirmOkGo"://合格放行 + //删除不合格放行记录 + //修改托盘状态 + //Update_PalletStatus(OpName, 1, false); + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_ConfirmOkGo(OpName, true); + MIS_BASE.Write_FalseGO(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + break; + case "FalseGO"://返修放行 + //修改托盘状态 + //Update_PalletStatus(OpName, 3, false); + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "NgGO"://不合格放行 + //修改托盘状态 + //Update_PalletStatus(OpName, 2, false); + //保存不合格信息(必须保存不合格放行信息,由于B5A的Moby没有不合格标志位) + BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Insert(OpName, engineID, "", ""); + MIS_BASE.Write_FalseGO(OpName, true); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + Thread.Sleep(1000); + MIS_BASE.Write_FalseGO(OpName, false); + break; + case "OnLineState"://在线0、离线1、屏蔽2 + try + { + if (m_Value_length > 1) return; + int a = Convert.ToInt32(m_Value); + if (a <= 2) + { + BaseDataSystemMES.IsOnLine_Update(OpName, m_Value.ToString()); + MIS_BASE.Write_OnLineState(OpName, Convert.ToInt32(m_Value)); + if (a == 2) SendMessage.AsyncSendMessage_Notice(OpName, "屏蔽MES!"); + if (a == 0) SendMessage.AsyncSendMessage_Notice(OpName, "启用MES!"); + } + } + catch + { + + } + break; + case "Reset"://复位,将MES所有的信息都复位了 + SetMoby(OpName);//将MES所有信号清空 + break; + case "FixAllow"://重新拧紧 + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_FixAllow(OpName, true); + break; + case "IsAutoGetEngineID"://自动手动申请编号(线首) + if (m_Value_length > 1) return; + MIS_BASE.Write_IsAutoGetEngineID(OpName, Convert.ToInt32(m_Value)); + break; + case "PartPalletGoOver"://空托盘放行 + int Is_PartPalletGoOver; + MIS_BASE.Read_PartPalletGoOver(OpName, out Is_PartPalletGoOver); + if (Is_PartPalletGoOver == 1) + { + MIS_BASE.Write_PartPalletGoOver(OpName, 1); + } + else + { + MIS_BASE.Write_PartPalletGoOver(OpName,0); + } + break; + case "SetMoby"://清空托盘(线首) + SetMoby(OpName);//将MES所有信号清空 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "RepairUplineMES"://返修上线 + MIS_BASE.Write_RepairUpline_MES(OpName, true); + break; + case "CancelRepair"://将返修件置为正常件 + + break; + case "PartPalletCode"://申请写入托盘号 + //MIS_BASE.Write_PartPalletCode_PLC(OpName, 1); + break; + case "WritePartPalletCode"://写入托盘号 + if (m_Value_length > 1) return; + MIS_BASE.Write_PalletCode(OpName, Convert.ToInt32(m_Value)); + break; + case "Normal"://启用正常拧紧工位 + MIS_BASE.Write_Normal(OpName, 1); + MIS_BASE.Write_UnNormal(OpName, 0); + break; + case "UnNormal"://启用备用拧紧工位 + MIS_BASE.Write_Normal(OpName, 0); + MIS_BASE.Write_UnNormal(OpName, 1); + break; + case "ResetDevice"://复位设备 + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + break; + case "IsNeedRepaire"://返修上线(返修上线点) + if (Convert.ToInt32(m_Value) == 1) + { + //修改托盘状态 + MIS_BASE.Write_PalletInfo(OpName, 3); + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + IsNeedRepaire_OK(OpName); + + } + else if (Convert.ToInt32(m_Value) == 0) + { + //通知修改成功 + MIS_BASE.Write_UpdatePalletOK(OpName, true); + //直接给出工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, true); + } + else + { } + + break; + case "ContinueMatch": + BaseDataSystemMES.QualityVerifyStatus_Hash_Write(OpName, true); + break; + //初始化网页信号 + case "IniSingalToWeb": + InitializeSingalToWeb(OpName); + break; + case "Reset_Engine"://返修上线(返修上线点) + SetMoby(OpName);//将MES所有信号清空 + //fun_EngineTypeGetOverPLC(OpName, 0); + //fun_EngineTypeGetOverPLC(OpName, 1); + break; + + + default: break; + } + } + catch(Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:WebSubmit"); + } + } + private void SetMoby(string OpName) + { + try + { + //清空Moby时,需要将MES信号清空 + MIS_BASE.Write_ClearMesMoby(OpName); + + BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName); + + Sendmessage("5123", "1111", OpName); + + MIS_BASE.Write_ResetDevice(OpName, true); + System.Threading.Thread.Sleep(1000); + MIS_BASE.Write_ResetDevice(OpName, false); + } + catch + { + + } + } + /// 网页重现登录,恢复关闭前的页面状态 + /// + /// 工位号 + private void InitializeSingalToWeb(string Opname) + { + bool S_WorkStart;//工件到位 DBX0.1 + bool S_EngineGetOver;//传递机型 DBX0.4 + bool S_FixAllow;//允许工作 DBX3.1 + bool S_MaterialVerifyOver;//工作完成 DBX2.3 + string S_plcStatus;//DBX501.5 PLC直通,1 强制放行 0 正常循环 + + int IsCompleted = 0; + int S_Match = 0; + int PalletInfo_SubLine = 0;//显示分线托盘状态 + + MIS_BASE.Read_WorkStart(Opname, out S_WorkStart); + + //5 显示订单、机型信息 线首工位用 + SendMessage.ShowMoby_FirstOpName(Opname); + //3显示操作指导图片 PicShow_String_FirstOpName + SendMessage.PicShow_FirstOpName(Opname); + //1(直接在界面通过选择机型确认工序内容) + SendMessage.ProcessList_FirstOpName(Opname); + //界面显示物料信息 + SendMessage.MaterialList_FirstOpName(Opname); + // 新增查询PLC直通状态 网页显示 + MIS_BASE.Read_TagTypeID(63, Opname, out S_plcStatus); + InitAlarm(Opname); + + if (S_plcStatus.ToLower() == "false") + { + SendMessageFun.SendInfomation("PlcStatus", "0", Opname); + } + else + { + SendMessageFun.SendInfomation("PlcStatus", "1", Opname); + } + + if (S_WorkStart == true) + { + SendMessageFun.SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname); + //sendmessage(Opname, Convert.ToInt32(S_WorkStart), "WorkStart_Subline"); + } + + //sendmessage(Opname, Convert.ToInt32(S_WorkStart), "EngineTypeGetOverMES_Subline"); + + MIS_BASE.Read_EngineGetOver_PLC(Opname, out S_EngineGetOver); + if (S_EngineGetOver == true) + { + SendMessageFun.SendInfomation("EngineTypeGetOverPLC", Convert.ToString(Convert.ToInt32(S_EngineGetOver)), Opname); + //sendmessage(Opname, Convert.ToInt32(S_EngineGetOver), "EngineTypeGetOverMES_Subline"); + } + + MIS_BASE.Read_FixAllow(Opname, out S_FixAllow); + + if (S_FixAllow == true) + { + SendMessageFun.SendInfomation("FixAllow", Convert.ToString(Convert.ToInt32(S_FixAllow)), Opname); + } + + MIS_BASE.Read_MaterialVerifyOver(Opname, out S_MaterialVerifyOver); + + if (S_MaterialVerifyOver == true) + { + SendMessageFun.SendInfomation("MaterialVerifyOver", Convert.ToString(Convert.ToInt32(S_MaterialVerifyOver)), Opname); + } + + //MIS_BASE.Read_MatchingCompleted(Opname, out IsCompleted); //DBX1.3 是否匹配 + //MIS_BASE.Read_Match(Opname, out S_Match); //DBX1.4 匹配结果 + + //if (IsCompleted == 1 && S_Match == 1)//发送匹配完成和匹配结果信息 + //{ + // SendMessageFun.SendInfomation("MatchingCompleted", "1", Opname); + // SendMessageFun.SendInfomation("Match", "1", Opname); + // SendMessageFun.SendInfomation("MatchSuccess", "1", Opname);//界面显示匹配成功 + //} + //else if (IsCompleted == 1 && S_Match == 0) + //{ + // SendMessageFun.SendInfomation("MatchSuccess", "0", Opname);//界面显示匹配失败 + //} + + //if (MIS_BASE.hashtable_OpNameRepair == null) + //{ + // MIS_BASE.InitHashtable_MesServerCode(); + //} + //string Opname_SubLine = ""; + //if (MIS_BASE.hashtable_OpNameRepair.ContainsKey(Opname)) + //{ + // Opname_SubLine = MIS_BASE.hashtable_OpNameRepair[Opname].ToString(); + //} + //if (Opname_SubLine == "") + //{ + // return; + //} + + //MIS_BASE.Read_PalletInfo(Opname, out PalletInfo_SubLine); + //sendmessage(Opname, PalletInfo_SubLine, "SubQualityMask"); + //SendMessageFun.SendInfomation("ShowMobySubLine", Opname_SubLine, Opname);//显示分线机型及流水号 + } + private void InitAlarm(string Opname) + { + FuntionMesRead.Alarm_InitAlarm_Send(Opname, out Hashtable ht); + foreach (DictionaryEntry kv in ht) + { + var TagID = kv.Key.ToString(); + var TagValue = kv.Value.ToString(); + FuntionMesRead.Send_AlarmMsg(TagID, TagValue); + } + + } + } +} diff --git a/MisDataFunction/Function1060/OpcServer/WorkStart.cs b/MisDataFunction/Function1060/OpcServer/WorkStart.cs new file mode 100644 index 0000000..904295e --- /dev/null +++ b/MisDataFunction/Function1060/OpcServer/WorkStart.cs @@ -0,0 +1,91 @@ +using bizFacade; +using MesServerWork; +using System; +using System.Data; +using System.Threading; +//using SystemFramework; + +namespace MesServerFunctions +{ + partial class FunctionMES + { + /// + /// 工件到位与离开时,清空MES自身信号 + /// + /// + /// + private void WorkStart(object e) + { + try + { + int EngineTypeID;//机型代码 + string EngineType;//机型 + string EngineID;//工件编号 + + string OrderForm; + + int PLCRcipe; + + DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e; + string OpName = Convert.ToString(msgEvent.OpName); + + int tagValue = Convert.ToInt32(msgEvent.TagValue); + if (tagValue > 0) + { + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartIn, DateTime.Now.ToString()); + //北汽福田工位状态监控MOBY_查询_订单下达用 + DataTable dt; + dt = BaseDataSystemMES.DownOrderToOpNameMobyList(OpName); + if (dt != null) + { + //开始上线前清空交互区数据 + MIS_BASE.WritePLC(73, OpName, ""); + MIS_BASE.WritePLC(74, OpName, ""); + MIS_BASE.WritePLC(75, OpName, ""); + int workType = 0; + if (dt.Rows.Count > 0) + { + // 正常逻辑 获得机型信息、配方号、 + EngineTypeID = Convert.ToInt32(dt.Rows[0][MobyTagType.EngineTypeID_MES]); + EngineType = dt.Rows[0][MobyTagType.EngineType_MES].ToString(); + OrderForm = dt.Rows[0][MobyTagType.OrderForm_MES].ToString(); + PLCRcipe = Convert.ToInt32(dt.Rows[0][MobyTagType.PLCRcipe]); + EngineID = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss").Replace("-", "").Replace(" ", "").Replace(":", ""); + EngineID = EngineID + "_" + EngineType; //拼接工件编号 按照唯一码加时间来拼接 + // 将产品信息写入PLC + MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID); + MIS_BASE.Write_EngineType_MES(OpName, EngineType); + MIS_BASE.Write_EngineID_MES(OpName, EngineID); + MIS_BASE.Write_OrderForm_MES(OpName, OrderForm); + + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID_MES, EngineID); + // 获得配方数据 + BaseDataSystemMES.PLCRcipeByOpName(OpName, out byte[] bytes, out string tagStartAdr, PLCRcipe); + // 写入配方数据 + DtWebApi.ReadWritePLC.Write_TagValueByTagTypeID("94", OpName, System.Text.Encoding.ASCII.GetString(bytes)); + // MES传递机型 + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, true); + } + } + } + else + { + BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartOut, DateTime.Now.ToString()); + + MIS_BASE.Write_MesReadOver(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_FixAllow(OpName, false); + MIS_BASE.Write_ConfirmOkGo(OpName, false); + MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false); + //工作完成 + MIS_BASE.Write_MaterialVerifyOver(OpName, false); + } + } + catch (Exception err) + { + ////ApplicationLog.WriteLog(err, "Function02:FalseGO"); + } + } + + } +} diff --git a/MisDataFunction/Function1060/Properties/AssemblyInfo.cs b/MisDataFunction/Function1060/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..36f4b02 --- /dev/null +++ b/MisDataFunction/Function1060/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Function1060")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Function1060")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("58215063-87f5-4708-8dda-031524c70b54")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MisDataFunction/Function1060/packages.config b/MisDataFunction/Function1060/packages.config new file mode 100644 index 0000000..b3e1761 --- /dev/null +++ b/MisDataFunction/Function1060/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dll_common/Monitor.MesWork.xml b/dll_common/Monitor.MesWork.xml new file mode 100644 index 0000000..f978604 --- /dev/null +++ b/dll_common/Monitor.MesWork.xml @@ -0,0 +1,2860 @@ + + + + Monitor.MesWork + + + + + AlarmListView 的摘要说明。 + + + + + 从OnDataChange发送int tagID, int tagValue到处理程序 + private void OnDataChange(int tagID, int tagValue) + + + + + + + 从OnDataChange发送int tagID, int tagValue到处理程序 + private void OnDataChange(int tagID, int tagValue) + + + + + 必需的设计器变量。 + + + + + 当时发生的报警总行数 + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + 报警到达 + + + + + 报警到达 + + + + + 报警解除 + + + + + 报警解除 + + + + + 报警确认 + + + + + 报警确认 + + + + + 报警过滤条件 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 报警过滤条件 + + + + + 从系统获得 + =null 时,初始化时显示全部报警 + =AlarmItemSelect,初始化时显示AlarmItemSelect条件报警 + + + + + + + + + + 报警到达文字颜色 + + + + + 报警到达文本底色 + + + + + 报警解除文字颜色 + + + + + 报警解除文本底色 + + + + + 报警确认文字颜色 + + + + + 报警确认文本底色 + + + + + 初始化报警显示 + + + + + 报警控件,监控值变化时,图形重绘 + + + + + + 增加TagKey + + + + + =true,调Gif;false不调Gif + + + + + Gif图像 + + + + + Gif图像 + + + + + IsRotation =0不调用Gif;=1调用Gif TagValueType + + + + + IsRotation =0不调用Gif;=1调用Gif + + + + + Tag位置0时颜色 1 + + + + + Tag位置1时颜色 2 + + + + + Tag位置2时颜色 4 + + + + + Tag位置3时颜色 8 + + + + + Tag位置4时颜色 16 + + + + + Tag位置5时颜色 32 + + + + + Tag位置6时颜色 64 + + + + + Tag位置7时颜色 128 + + + + + 设置Tag位置0时颜色 + + + + + 设置Tag位置1时颜色 + + + + + 设置Tag位置2时颜色 + + + + + 设置Tag位置3时颜色 + + + + + 设置Tag位置4时颜色 + + + + + 设置Tag位置5时颜色 + + + + + 设置Tag位置6时颜色 + + + + + 设置Tag位置7时颜色 + + + + + TagKey 显示选项 + + + + + TagKey 显示选项 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 序号 + + + + + 序号 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + + + + + + 绘制图形 + + + + + + 正常绘制 + + + + + + 显示Gif + + + + + + 增加TagKey + + + + + =true,调Gif;false不调Gif + + + + + Gif图像 + + + + + IsRotation =0不调用Gif;=1调用Gif TagValueType + + + + + IsRotation =0不调用Gif;=1调用Gif + + + + + Tag位置0时颜色 1 + + + + + Tag位置1时颜色 2 + + + + + Tag位置2时颜色 4 + + + + + Tag位置3时颜色 8 + + + + + Tag位置4时颜色 16 + + + + + Tag位置5时颜色 32 + + + + + Tag位置6时颜色 64 + + + + + Tag位置7时颜色 128 + + + + + 设置Tag位置0时颜色 + + + + + 设置Tag位置1时颜色 + + + + + 设置Tag位置2时颜色 + + + + + 设置Tag位置3时颜色 + + + + + 设置Tag位置4时颜色 + + + + + 设置Tag位置5时颜色 + + + + + 设置Tag位置6时颜色 + + + + + 设置Tag位置7时颜色 + + + + + TagKey 显示选项 + + + + + TagKey 显示选项 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 序号 + + + + + 序号 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + + + + + + 绘制图形 + + + + + + 正常绘制 + + + + + + 显示Gif + + + + + + PlcLinkStatus 的摘要说明。 + + + + + 显示PLC连接状态 + + + + + + PLC连接正常时图形 + + + + + PLC连接正常时图形 + + + + + PLC连接不正常时图形 + + + + + PLC连接不正常时图形 + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + PlcLinkStatusWork 的摘要说明。 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + + + + + + 根据变量是否正确,显示通讯状态 通讯数据交换 + + + + + + 通讯正常 + + + + + 通讯失败 + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + PlcLinkStatusWork 的摘要说明。 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + + + + + + 根据变量是否正确,显示通讯状态 通讯数据交换 + + + + + + 通讯正常 + + + + + 通讯失败 + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + Tag位置1时颜色 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 变量类型 + + + + + 变量类型 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + 显示机床状态 + + + + + + 绘制图形 + + + + + + Tag位置1时颜色 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + 显示机床状态 + + + + + + 绘制图形 + + + + + + 增加TagKey + + + + + TagKey 显示选项 + + + + + TagKey 显示选项 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + 显示到位信号 + + + + + + 绘制图形 + + + + + + 发动机工位在线显示 + + + + + OpName + 工位名称 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + 发动机号 + + + + + 发动机号 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + OpName + 工位名称 + + + + + 是否进行具体发动机号追踪 + + + + + 是否进行具体发动机号追踪 + + + + + 具体发动机号追踪发动机号 + 发动机号 + + + + + 具体发动机号追踪 + 发动机号 + + + + + 具体发动机号追踪 + Tag位置0时颜色 + + + + + 具体发动机号追踪 + Tag位置1时颜色 + + + + + + + + + + 发动机号的变化,给本控件的发动机号赋值 + 确定被追踪的发动机号 + + + + + + + 发动机号动态追踪设定 + + + + + + + 显示被追踪的发动机 + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + 托盘到位 + + + + + + + 绘制图形 + + + + + + 发动机工位在线显示 + + + + + 当鼠标在上方时出现工件编号 + + + + + Tag位置0时颜色 1 + + + + + Tag位置1时颜色 2 + + + + + Tag位置2时颜色 4 + + + + + Tag位置3时颜色 8 + + + + + Tag位置4时颜色 16 + + + + + Tag位置5时颜色 32 + + + + + Tag位置6时颜色 64 + + + + + Tag位置7时颜色 128 + + + + + 设置Tag位置0时颜色 + + + + + 设置Tag位置1时颜色 + + + + + 设置Tag位置2时颜色 + + + + + 设置Tag位置3时颜色 + + + + + 设置Tag位置4时颜色 + + + + + 设置Tag位置5时颜色 + + + + + 设置Tag位置6时颜色 + + + + + 设置Tag位置7时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + OpName + 工位名称 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + 发动机号 + + + + + 发动机号 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + OpName + 工位名称 + + + + + 是否进行具体发动机号追踪 + + + + + 是否进行具体发动机号追踪 + + + + + 具体发动机号追踪发动机号 + 发动机号 + + + + + 具体发动机号追踪 + 发动机号 + + + + + 具体发动机号追踪 + Tag位置0时颜色 + + + + + 具体发动机号追踪 + Tag位置1时颜色 + + + + + + + + + + 发动机号的变化,给本控件的发动机号赋值 + 确定被追踪的发动机号 + + + + + + + 发动机号动态追踪设定 + + + + + + + 显示被追踪的发动机 + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + + 显示托盘状态 + 1 有托盘(黄色) + 0 无托盘(灰色) + + + + + 托盘到位 + + + + + + + 绘制图形 + + + + + + UserControlButton 的摘要说明。 + + + + + 发动机号 + + + + + 发动机号 + + + + + 当鼠标在上方时出现发动机号 + + + + + + + + + + Button 文本 + + + + + Button 文本 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + Button 文本 + + + + + Button 文本 + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + UserControlButton 的摘要说明。 + + + + + 机床状态 + + + + + 机床状态 + + + + + 工件编号 + + + + + 工件编号 + + + + + 当鼠标在上方时出现工件编号 + + + + + + + + + + Button 文本 + + + + + Button 文本 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + Button 文本 + + + + + Button 文本 + + + + + + + + + + 机床状态 + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + UserControlLable11 的摘要说明。 + + + + + 必需的设计器变量。 + + + + + 变量值 + + + + + 变量值 + + + + + 变量类型 + + + + + 变量类型 + + + + + LableText 变量值 + + + + + LableText 变量值 + + + + + + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + UserControlLable11 的摘要说明。 + + + + + 必需的设计器变量。 + + + + + TagNameID名称 + + + + + LableText 变量值 + + + + + LableText 变量值 + + + + + + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + UserControlButton 的摘要说明。 + + + + + 发动机号 + + + + + 发动机号 + + + + + 当鼠标在上方时出现发动机号 + + + + + + + + + + Button 文本 + + + + + Button 文本 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + Button 文本 + + + + + Button 文本 + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + Tag位置1时颜色 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + 显示心跳控件 + + + + + + 绘制图形 + + + + + + 增加TagKey + + + + + Tag位置0时颜色 1 + + + + + Tag位置1时颜色 2 + + + + + Tag位置2时颜色 4 + + + + + Tag位置3时颜色 8 + + + + + Tag位置4时颜色 16 + + + + + Tag位置5时颜色 32 + + + + + Tag位置6时颜色 64 + + + + + Tag位置7时颜色 128 + + + + + 设置Tag位置0时颜色 + + + + + 设置Tag位置1时颜色 + + + + + 设置Tag位置2时颜色 + + + + + 设置Tag位置3时颜色 + + + + + 设置Tag位置4时颜色 + + + + + 设置Tag位置5时颜色 + + + + + 设置Tag位置6时颜色 + + + + + 设置Tag位置7时颜色 + + + + + TagKey 显示选项 + + + + + TagKey 显示选项 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 序号 + + + + + 序号 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + 绘制图形 + + + + + + 水平方式显示工件编号。 + + + + + 机床状态 + + + + + 机床状态 + + + + + 工件编号 + + + + + 工件编号 + + + + + 当鼠标在上方时出现工件编号 + + + + + + + + + + Button 文本 + + + + + Button 文本 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + Button 文本 + + + + + Button 文本 + + + + + + + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + 垂直方式显示工件编号。 + + + + + Tag位置0时颜色 1 + + + + + Tag位置1时颜色 2 + + + + + Tag位置2时颜色 4 + + + + + Tag位置3时颜色 8 + + + + + Tag位置4时颜色 16 + + + + + Tag位置5时颜色 32 + + + + + Tag位置6时颜色 64 + + + + + Tag位置7时颜色 128 + + + + + 设置Tag位置0时颜色 + + + + + 设置Tag位置1时颜色 + + + + + 设置Tag位置2时颜色 + + + + + 设置Tag位置3时颜色 + + + + + 设置Tag位置4时颜色 + + + + + 设置Tag位置5时颜色 + + + + + 设置Tag位置6时颜色 + + + + + 设置Tag位置7时颜色 + + + + + TagKey 显示选项 + + + + + TagKey 显示选项 + + + + + 变量值 + + + + + 机床状态 + + + + + 机床状态 + + + + + 工件编号 + + + + + 工件编号 + + + + + 当鼠标在上方时出现工件编号 + + + + + + + + + + Button 文本 + + + + + Button 文本 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + Button 文本 + + + + + Button 文本 + + + + + Button 文本颜色代码 + + + + + + + + + + 显示工件编号 + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + UserControlButton 的摘要说明。 + + + + + Tag位置0时颜色 1 + + + + + Tag位置1时颜色 2 + + + + + Tag位置2时颜色 4 + + + + + Tag位置3时颜色 8 + + + + + Tag位置4时颜色 16 + + + + + Tag位置5时颜色 32 + + + + + Tag位置6时颜色 64 + + + + + Tag位置7时颜色 128 + + + + + 设置Tag位置0时颜色 + + + + + 设置Tag位置1时颜色 + + + + + 设置Tag位置2时颜色 + + + + + 设置Tag位置3时颜色 + + + + + 设置Tag位置4时颜色 + + + + + 设置Tag位置5时颜色 + + + + + 设置Tag位置6时颜色 + + + + + 设置Tag位置7时颜色 + + + + + TagKey 显示选项 + + + + + TagKey 显示选项 + + + + + 变量值 + + + + + 机床状态 + + + + + 机床状态 + + + + + 工件编号 + + + + + 工件编号 + + + + + 当鼠标在上方时出现工件编号 + + + + + + + + + + Button 文本 + + + + + Button 文本 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + Button 文本 + + + + + Button 文本 + + + + + Button 文本颜色代码 + + + + + + + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + UserControlLable11 的摘要说明。 + + + + + 必需的设计器变量。 + + + + + TagNameID名称 + + + + + TagNameID名称 + + + + + TagNameID名称 + + + + + TagNameID名称 + + + + + LableText 变量值 + + + + + LableText 变量值 + + + + + + + + + + + + + + + 清理所有正在使用的资源。 + + + + + 设计器支持所需的方法 - 不要使用代码编辑器 + 修改此方法的内容。 + + + + + + + + + + + 增加TagKey + + + + + TagKey 显示选项 + + + + + TagKey 显示选项 + + + + + OpName + 工位名称 + + + + + OpName + 工位名称 + + + + + 是否保存到数据库 + + + + + LineColor设置外园线颜色 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + 变量值 + + + + + 变量值 + + + + + TagBit变量测试位 + + + + + Tag位置1时颜色 + + + + + Tag位置0时颜色 + + + + + TagBit变量测试位 + + + + + LineColor设置外园线颜色 + + + + + 是否保存到数据库 + + + + + + + + + + 绘制图形 + + + + + + 一个强类型的资源类,用于查找本地化的字符串等。 + + + + + 返回此类使用的缓存的 ResourceManager 实例。 + + + + + 重写当前线程的 CurrentUICulture 属性 + 重写当前线程的 CurrentUICulture 属性。 + + + + + 查找 System.Drawing.Bitmap 类型的本地化资源。 + + + + + 查找 System.Drawing.Bitmap 类型的本地化资源。 + + + + + 查找 System.Drawing.Bitmap 类型的本地化资源。 + + + + diff --git a/icon/断开状态.png b/icon/断开状态.png new file mode 100644 index 0000000..0ae6189 Binary files /dev/null and b/icon/断开状态.png differ diff --git a/icon/连接状态.png b/icon/连接状态.png new file mode 100644 index 0000000..fcf9db7 Binary files /dev/null and b/icon/连接状态.png differ