chore: 初始化东安动力MES采集程序
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
using DataLinkMesWork;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace bizFacade
|
||||
{
|
||||
/// <summary>
|
||||
/// 通用BizFaced类
|
||||
/// </summary>
|
||||
public partial class BaseDataSystemMES
|
||||
{
|
||||
/// <summary>
|
||||
/// 验证质量数据状态哈希表
|
||||
/// </summary>
|
||||
public static Hashtable QualityVerifyStatus_Hash = new Hashtable();
|
||||
|
||||
/// <summary>
|
||||
/// 读取工位质量数据验证状态
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <returns></returns>
|
||||
public static bool QualityVerifyStatus_Hash_Read(string OpName)
|
||||
{
|
||||
if (QualityVerifyStatus_Hash.Contains(OpName))
|
||||
{
|
||||
return Convert.ToBoolean(QualityVerifyStatus_Hash[OpName]);
|
||||
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 写入工位质量数据验证状态
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="Result"></param>
|
||||
public static void QualityVerifyStatus_Hash_Write(string OpName, bool Result)
|
||||
{
|
||||
if (QualityVerifyStatus_Hash.Contains(OpName))
|
||||
{
|
||||
QualityVerifyStatus_Hash[OpName] = Result;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
QualityVerifyStatus_Hash.Add(OpName, Result);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 部装工位质量数据验证
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static bool QulityDataVerify(string OpName, string EngineID_Subline, out string AlarmStr)
|
||||
{
|
||||
int IsAlarm = 0;
|
||||
AlarmStr = "";
|
||||
string procedureName;
|
||||
procedureName = "测量数据工位_监控系统_部装质量数据验证";
|
||||
SqlParameter[] thisParms = new SqlParameter[4];
|
||||
thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", OpName);
|
||||
thisParms[1] = new System.Data.SqlClient.SqlParameter("@部装总成号", EngineID_Subline);
|
||||
thisParms[2] = new System.Data.SqlClient.SqlParameter("@是否报警", IsAlarm);
|
||||
thisParms[2].Direction = ParameterDirection.Output;
|
||||
thisParms[3] = new System.Data.SqlClient.SqlParameter("@报警工位号", AlarmStr);
|
||||
thisParms[3].Direction = ParameterDirection.Output;
|
||||
|
||||
if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms))
|
||||
{
|
||||
IsAlarm = Convert.ToInt32(thisParms[2].Value.ToString());
|
||||
AlarmStr = thisParms[3].Value.ToString();
|
||||
|
||||
if (IsAlarm == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 线外工位质量数据验证
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static bool QualityVerifyStatusOutline(string OpName, out string AlarmStr)
|
||||
{
|
||||
int IsAlarm = 0;
|
||||
AlarmStr = "";
|
||||
string procedureName;
|
||||
procedureName = "测量数据工位_监控系统_线外质量数据验证";
|
||||
SqlParameter[] thisParms = new SqlParameter[3];
|
||||
thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", OpName);
|
||||
thisParms[1] = new System.Data.SqlClient.SqlParameter("@是否报警", IsAlarm);
|
||||
thisParms[1].Direction = ParameterDirection.Output;
|
||||
thisParms[2] = new System.Data.SqlClient.SqlParameter("@报警工位号", AlarmStr);
|
||||
thisParms[2].Direction = ParameterDirection.Output;
|
||||
|
||||
if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms))
|
||||
{
|
||||
IsAlarm = Convert.ToInt32(thisParms[1].Value.ToString());
|
||||
AlarmStr = thisParms[2].Value.ToString();
|
||||
|
||||
if (IsAlarm == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,448 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using DataLinkMesWork;
|
||||
using System.Collections;
|
||||
|
||||
using SystemFramework;
|
||||
using DoWhatPlc;
|
||||
//using BasicData;
|
||||
//using OpcData;
|
||||
|
||||
namespace bizFacade
|
||||
{
|
||||
|
||||
public partial class BaseDataSystemMES
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 对应玉柴项目
|
||||
/// 20111101
|
||||
/// 质量数据的上限值,下限值,理论值来源于表[MES_基本数据_测量范围]
|
||||
/// 通过TagID和engineTypeID。如果engineTypeID=0,上限值,下限值,理论值=""
|
||||
/// 质量数据可以读数据 19
|
||||
/// 分散控制
|
||||
/// tagID_CF质量数据激发变量对应的质量数据列表
|
||||
/// </summary>
|
||||
/// <param name="valuList">tagID_CF质量数据激发变量对应的质量数据列表(Hashtable)</param>
|
||||
/// <param name="opName">质量数据列表</param>
|
||||
/// <param name="BasicDataTagValue">质量数据列表</param>
|
||||
/// <param name="BasicDataTagValueUpDown"></param>
|
||||
/// <param name="dt">质量数据列表</param>
|
||||
/// <param name="qualityMask">质量数据总成合格标志 21( =0 数据合格) (= 1数据不合格)</param>
|
||||
/// <param name="engineTypeID">质量数据发动机机型标志 9</param>
|
||||
/// <param name="engineID">质量数据发动机号 10</param>
|
||||
/// <param name="engineType">质量数据发动机机型 11</param>
|
||||
/// <param name="partPallet"></param>
|
||||
/// <param name="engineTraceCode"></param>
|
||||
/// <param name="engineCap">缸盖号[TagValue2]</param>
|
||||
/// <param name="hashtable_EngineTypeID">发动机类型转换表</param>
|
||||
/// <param name="mes_MustTest">发动机类型转换表</param>
|
||||
/// <param name="onLineState">发动机类型转换表</param>
|
||||
/// <param name="partMoveDirection">发动机类型转换表</param>
|
||||
/// <param name="pressIsOK">发动机类型转换表</param>
|
||||
/// <param name="pressIsNoOK">发动机类型转换表</param>
|
||||
static public void GetQualityDataTable_B5A(Hashtable valuList, string opName, DataTable BasicDataTagValue,
|
||||
DataTable BasicDataTagValueUpDown,
|
||||
out DataTable dt,
|
||||
out int qualityMask,
|
||||
out int engineTypeID,
|
||||
out string engineID,
|
||||
out string engineType,out string partPallet, out string engineTraceCode, out string engineCap, Hashtable hashtable_EngineTypeID,
|
||||
out int mes_MustTest,out int onLineState,out int partMoveDirection,
|
||||
out int pressIsOK, out int pressIsNoOK)
|
||||
{
|
||||
//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)
|
||||
mes_MustTest = 0;
|
||||
onLineState = 0;
|
||||
partMoveDirection = 0;
|
||||
pressIsOK = 0;
|
||||
pressIsNoOK = 0;
|
||||
QualityDataType qualityData;
|
||||
//是否有数据
|
||||
//bool isUsing;
|
||||
|
||||
DataRow dr;
|
||||
DataRow[] dr_WWW;
|
||||
//MES_基本数据_测量范围
|
||||
DataRow[] dr_WWW_UpDown;
|
||||
|
||||
dt = BuildDataTables_WWW();
|
||||
qualityMask = 0;
|
||||
engineTypeID = 0;
|
||||
engineID = "";
|
||||
engineType = "";
|
||||
engineTraceCode = "";
|
||||
engineCap = "";
|
||||
partPallet = "";
|
||||
//测量位置
|
||||
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 = (QualityDataType)valueItem.Value;
|
||||
|
||||
switch (qualityData.tagValueType)
|
||||
{
|
||||
case 21:
|
||||
qualityMask = Convert.ToInt32(qualityData.tagValue);
|
||||
//转变一下
|
||||
//qualityMask = transferIsOK_OpName_2(Convert.ToInt32(qualityData.tagValue));
|
||||
break;
|
||||
case 8:
|
||||
//8 只要返修,必须由mes发送此信号,plc接收此信号后才能放行
|
||||
//(暂时没用)用于有扳手拧紧工位。通知设备螺钉拧紧完成。PC已经将数据保存到数据库中。(B5A)
|
||||
pressIsNoOK = Convert.ToInt32(qualityData.tagValue);
|
||||
break;
|
||||
//质量数据发动机机型标志 22(玉柴) 发动机机型标志 9 (有MOBY)需要换算成2的n次幂的形式,以便生成报表
|
||||
case 9:
|
||||
engineTypeID = Convert.ToInt32(qualityData.tagValue);
|
||||
if (engineTypeID == 0)
|
||||
{
|
||||
engineTypeID = 1;
|
||||
}
|
||||
if (hashtable_EngineTypeID.ContainsKey(engineTypeID))
|
||||
{
|
||||
string engineTypeIDString = hashtable_EngineTypeID[engineTypeID].ToString();
|
||||
engineTypeID = Convert.ToInt32(engineTypeIDString);
|
||||
if (engineTypeID == 0)
|
||||
{
|
||||
engineTypeID = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
//发动机编号 23 10
|
||||
//case 23:
|
||||
case 10:
|
||||
engineID = Convert.ToString(qualityData.tagValue);
|
||||
break;
|
||||
//质量数据发动机机型 24(玉柴) 11(有MOBY)
|
||||
//case 24:
|
||||
case 11:
|
||||
engineType = Convert.ToString(qualityData.tagValue);
|
||||
break;
|
||||
case 41:
|
||||
//41 机体流向标志(1 BYTE):0普通工位:1:上线(发动机上线);
|
||||
//2:下线(发动机下线);(必须PLC)
|
||||
partMoveDirection = Convert.ToInt32(qualityData.tagValue);
|
||||
break;
|
||||
case 51:
|
||||
//51 返修工位,修改后的数据MES将数据写入PLC ,MES通知PLC数据修改完成。(YN)
|
||||
pressIsOK = Convert.ToInt32(qualityData.tagValue);
|
||||
break;
|
||||
//78 0:屏蔽MES;1:启用MES(必须MIS)
|
||||
case 78:
|
||||
mes_MustTest = Convert.ToInt32(qualityData.tagValue);
|
||||
break;
|
||||
//79 通过线体工位PC实现下达工位工作状态:工位有三种状态:在线、离线、屏蔽。在线:
|
||||
//0正常状态,实现正常功能。1离线:2屏蔽。(必须MIS)
|
||||
case 79:
|
||||
onLineState = Convert.ToInt32(qualityData.tagValue);
|
||||
break;
|
||||
//托盘编号(B5A)
|
||||
case 80:
|
||||
partPallet = Convert.ToString(qualityData.tagValue);
|
||||
break;
|
||||
}
|
||||
//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 = "";
|
||||
if (dr_WWW_UpDown != null&& dr_WWW_UpDown.Length >0)
|
||||
{
|
||||
tagValueUp = dr_WWW_UpDown[0]["值上限"].ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
tagValueUp = "";
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
tagValueUp = "";
|
||||
}
|
||||
try
|
||||
{
|
||||
tagValueDown = "";
|
||||
if (dr_WWW_UpDown != null && dr_WWW_UpDown.Length > 0)
|
||||
{
|
||||
tagValueDown = dr_WWW_UpDown[0]["值下限"].ToString();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
tagValueDown = "";
|
||||
}
|
||||
try
|
||||
{
|
||||
tagValeNormal = "";
|
||||
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"] = BaseDataSystemMES.GetQualityData_GoodBad_String((bool[])qualityData.tagValue);
|
||||
break;
|
||||
case 8209:
|
||||
dr["TagValue"] = "";
|
||||
break;
|
||||
//非标准REAL
|
||||
case 8210:
|
||||
dr["TagValue"] = GetNoNormalReal(qualityData.tagValue);
|
||||
dt.Rows.Add(dr);
|
||||
break;
|
||||
default:
|
||||
dr["TagValue"] = Convert.ToString(qualityData.tagValue);
|
||||
dt.Rows.Add(dr);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, err.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
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 BuildDataTables_WWW_538()
|
||||
{
|
||||
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("TagValue1", typeof(System.String));
|
||||
table.Columns.Add("TagValue2", typeof(System.String));
|
||||
table.Columns.Add("TagValue3", typeof(System.String));
|
||||
table.Columns.Add("TagValue4", typeof(System.String));
|
||||
table.Columns.Add("TagValue5", typeof(System.String));
|
||||
table.Columns.Add("TagValue6", typeof(System.String));
|
||||
table.Columns.Add("TagValue7", typeof(System.String));
|
||||
table.Columns.Add("TagValue8", typeof(System.String));
|
||||
table.Columns.Add("TagValue9", 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));
|
||||
table.Columns.Add("operationTime", typeof(System.String));
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回非标准real
|
||||
/// </summary>
|
||||
/// <param name="vDataValue"></param>
|
||||
/// <returns></returns>
|
||||
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";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 29 工位具体零件合格标志
|
||||
/// </summary>
|
||||
/// <param name="QualityData_GoodBad"></param>
|
||||
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;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 返回非标准real
|
||||
/// </summary>
|
||||
/// <param name="vDataValue"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user