chore: initial commit
This commit is contained in:
236
MisDataFunction/Function1051/OpcServer/Barcode.cs
Normal file
236
MisDataFunction/Function1051/OpcServer/Barcode.cs
Normal file
@@ -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();
|
||||
|
||||
///第一步,判断条码类型,根据条码类型,执行对应的存储过程
|
||||
///第二步,条码类型(将扫描的条码保存到对应的表中)
|
||||
///第三步,扫描完成之后给出允许工作信号
|
||||
/// 处理页面扫描条码
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="barcode"></param>
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
135
MisDataFunction/Function1051/OpcServer/EngineGetOver.cs
Normal file
135
MisDataFunction/Function1051/OpcServer/EngineGetOver.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using MesServerWork;
|
||||
using MisDataFunDll;
|
||||
//using SystemFramework;
|
||||
|
||||
namespace MesServerFunctions
|
||||
{
|
||||
partial class FunctionMES
|
||||
{
|
||||
object lockBarcodeEngineTypeGetOver = new object();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// PLC传递机型处理
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
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;
|
||||
|
||||
//上线工位清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);
|
||||
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;
|
||||
}
|
||||
|
||||
DataTable checkTable = MisDataFun.WorkOrderCheck(OpName,EngineID_MES,OrderForm_MES,EngineType_MES);
|
||||
int result = Convert.ToInt32(checkTable.Rows[0]["result"]);
|
||||
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);
|
||||
}
|
||||
//写入到数据库的[北汽福田工位状态监控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, 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);
|
||||
|
||||
SendMessageFun.SendMessage("5123", "11111", OpName);
|
||||
|
||||
// 将工序数据转入临时表中
|
||||
//BaseDataSystemMES.ProcessDataToTemp(OpName, EngineTypeID, OrderForm, EngineID);
|
||||
}
|
||||
else
|
||||
{
|
||||
string msg = "【" + OpName + "】" + resultMsg;
|
||||
MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg);
|
||||
SendMessage.AsyncSendMessage_Notice(OpName, msg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
55
MisDataFunction/Function1051/OpcServer/MaterialsScanOver.cs
Normal file
55
MisDataFunction/Function1051/OpcServer/MaterialsScanOver.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料扫码完成
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
62
MisDataFunction/Function1051/OpcServer/MaterialsVerify.cs
Normal file
62
MisDataFunction/Function1051/OpcServer/MaterialsVerify.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Threading;
|
||||
using System.Xml.Linq;
|
||||
|
||||
using MesServerWork;
|
||||
using MisDataFunDll;
|
||||
|
||||
namespace MesServerFunctions
|
||||
{
|
||||
partial class FunctionMES
|
||||
{
|
||||
/// <summary>
|
||||
/// PLC物料扫码校验
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
public void MaterialsVerify(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)
|
||||
{
|
||||
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);
|
||||
|
||||
int MaterialsTypeCode = Convert.ToInt32(MIS_BASE.ReadPLC(201, OpName));
|
||||
string MaterialsCode = MIS_BASE.ReadPLC(40, OpName).ToString();
|
||||
|
||||
DataTable dt = MisDataFun.XD_MaterialsVerify(OpName, EngineID, MaterialsCode, MaterialsTypeCode);
|
||||
int result = Convert.ToInt32(dt.Rows[0]["result"]);
|
||||
if (result == 1)
|
||||
{
|
||||
MIS_BASE.WritePLC(95, OpName, 1); // 物料校验成功
|
||||
}
|
||||
else
|
||||
{
|
||||
MIS_BASE.WritePLC(95, OpName, 2); // 物料校验失败
|
||||
string msg = $"【{OpName}】产品:{EngineID} | 物料码:{MaterialsCode} | 物料类型:{MaterialsTypeCode.ToString()} 物料校验失败!";
|
||||
MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "MaterialsVerify " + msg, MisDataSaveDate.Helper.MesLogType.ERROR);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MIS_BASE.WritePLC(95, OpName, 0); // 物料验证结果清空
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "Function08:EngineTypeGetOver_PLC");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
84
MisDataFunction/Function1051/OpcServer/MesRead.cs
Normal file
84
MisDataFunction/Function1051/OpcServer/MesRead.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using MesServerWork;
|
||||
using MisDataFunDll;
|
||||
|
||||
namespace MesServerFunctions
|
||||
{
|
||||
partial class FunctionMES
|
||||
{
|
||||
object lockMesRead = new object ();
|
||||
/// <summary>
|
||||
/// 保存完成(针对半自动和手动压装工位)
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
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.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);
|
||||
//调用工厂MES接口报工
|
||||
WebApi.CALL_Inerface_DataHandle.CALL_Inerface_JobFinished(OpName, EngineID, OrderForm);
|
||||
}
|
||||
else
|
||||
{
|
||||
MIS_BASE.Write_MesReadOver(OpName, false);
|
||||
MIS_BASE.Write_MaterialVerifyOver(OpName, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "Function08:MesReadOver");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
36
MisDataFunction/Function1051/OpcServer/MesReadOver.cs
Normal file
36
MisDataFunction/Function1051/OpcServer/MesReadOver.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
//using SystemFramework;
|
||||
using MesServerWork;
|
||||
|
||||
namespace MesServerFunctions
|
||||
{
|
||||
partial class FunctionMES
|
||||
{
|
||||
/// <summary>
|
||||
/// 保存完成(针对半自动和手动压装工位)
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
70
MisDataFunction/Function1051/OpcServer/PartLoad.cs
Normal file
70
MisDataFunction/Function1051/OpcServer/PartLoad.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Threading;
|
||||
//using SystemFramework;
|
||||
using MesServerWork;
|
||||
using MisDataFunDll;
|
||||
|
||||
namespace MesServerFunctions
|
||||
{
|
||||
partial class FunctionMES
|
||||
{
|
||||
/// <summary>
|
||||
/// 申请上线(针对上线工位)
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
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
|
||||
// 获取订单的机型
|
||||
MisDataFun.GetEngineType_Order(OpName, out int EngineTypeID, out string EngineType, out string EngineID, out string OrderForm, out int parType, out int isCheckOk,out string msg2);
|
||||
if (isCheckOk == 2)
|
||||
{
|
||||
string msg = "【" + OpName + "】" + msg2;
|
||||
// 判断到线体上有滞留工件 ,让去管理系统进行处理
|
||||
SendMessage.AsyncSendMessage_Notice(OpName, msg);
|
||||
MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "PartLoad " + msg, MisDataSaveDate.Helper.MesLogType.ERROR);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
MIS_BASE.WritePLC(115, OpName, parType); // 托盘类型 1 静 2 动 3 拐
|
||||
|
||||
// MES传递机型
|
||||
MIS_BASE.Write_EngineTypeGetOver_MES(OpName, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//上线工位清MES传递机型信号
|
||||
MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false);
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "Function08:MesReadOver");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
73
MisDataFunction/Function1051/OpcServer/ReqEarlyFeeding.cs
Normal file
73
MisDataFunction/Function1051/OpcServer/ReqEarlyFeeding.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Threading;
|
||||
using MesServerWork;
|
||||
using MisDataFunDll;
|
||||
|
||||
namespace MesServerFunctions
|
||||
{
|
||||
partial class FunctionMES
|
||||
{
|
||||
/// <summary>
|
||||
/// 申请提前上料
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
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)
|
||||
{
|
||||
MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "ReqEarlyFeeding " + $"写入提前上料机型{EngineTypeID.ToString()} 与 读取到的{ReadEngineID.ToString()}不一致", MisDataSaveDate.Helper.MesLogType.ERROR);
|
||||
return;
|
||||
}
|
||||
if (EngineTypeID == 0 || ReadEngineID == 0)
|
||||
{
|
||||
MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "ReqEarlyFeeding " + $"写入提前上料机型{EngineTypeID.ToString()} 与 读取到的{ReadEngineID.ToString()} 其中存在空值", MisDataSaveDate.Helper.MesLogType.ERROR);
|
||||
return;
|
||||
}
|
||||
MIS_BASE.WritePLC(33, OpName, true); // 允许提前上料
|
||||
|
||||
}
|
||||
else if (result == 2)
|
||||
{
|
||||
MIS_BASE.WritePLC(33, OpName, false);
|
||||
string msg2 = "【" + OpName + "】" + msg;
|
||||
SendMessage.AsyncSendMessage_Notice(OpName, msg);
|
||||
MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "ReqEarlyFeeding " + msg2, MisDataSaveDate.Helper.MesLogType.ERROR);
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
238
MisDataFunction/Function1051/OpcServer/ReqTestResistor.cs
Normal file
238
MisDataFunction/Function1051/OpcServer/ReqTestResistor.cs
Normal file
@@ -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; // 预期结果长度
|
||||
|
||||
/// <summary>
|
||||
/// 电阻测试
|
||||
/// </summary>
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行电阻测试
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送命令到电阻仪
|
||||
/// </summary>
|
||||
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<byte>(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
410
MisDataFunction/Function1051/OpcServer/WebSubmit.cs
Normal file
410
MisDataFunction/Function1051/OpcServer/WebSubmit.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;)
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="Content"></param>
|
||||
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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 网页重现登录,恢复关闭前的页面状态
|
||||
/// </summary>
|
||||
/// <param name="Opname">工位号</param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
66
MisDataFunction/Function1051/OpcServer/WorkStart.cs
Normal file
66
MisDataFunction/Function1051/OpcServer/WorkStart.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MesServerWork;
|
||||
using MisDataFunDll;
|
||||
//using SystemFramework;
|
||||
|
||||
|
||||
namespace MesServerFunctions
|
||||
{
|
||||
partial class FunctionMES
|
||||
{
|
||||
/// <summary>
|
||||
/// 工件到位与离开时,清空MES自身信号
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
MisDataFunction/Function1051/OpcServer/vssver2.scc
Normal file
BIN
MisDataFunction/Function1051/OpcServer/vssver2.scc
Normal file
Binary file not shown.
Reference in New Issue
Block a user