chore: 初始化东安动力MES采集程序
This commit is contained in:
@@ -0,0 +1,260 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Xml.Linq;
|
||||
using bizFacade;
|
||||
|
||||
//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
|
||||
{
|
||||
DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e;
|
||||
string OpName = Convert.ToString(msgEvent.OpName);
|
||||
string OpName_mes = Convert.ToString(msgEvent.OpName) + "_mes";
|
||||
string barcode = Convert.ToString(msgEvent.TagValue);
|
||||
//将随工单零件号写入PLC
|
||||
MIS_BASE.Write_EngineType_MES(OpName_mes, "");
|
||||
//将唯一标识写入PLC
|
||||
MIS_BASE.Write_EngineID_MES(OpName_mes, "");
|
||||
// 判断条码格式是否正确
|
||||
if (barcode.Split(';').Length > 2)
|
||||
{
|
||||
//m003000214179;p23003;x0;g|JS8C.12.825|1|22-K-255-1/组件|ZM6|20230109134927285001740003
|
||||
//[0]m003000214179
|
||||
//[1]p23003
|
||||
//[2]x0
|
||||
//[3]g
|
||||
//[4]JS8C.12.825
|
||||
//[5]1
|
||||
//[6]22-K-255-1/组件z
|
||||
//[7]ZM6
|
||||
//[8]20230109134927285001740003
|
||||
|
||||
var barArray = barcode.Split(new char[] { ';', '|' });
|
||||
var orderNo = barArray[0].Substring(1); // 订单号
|
||||
var batchNo = barArray[1].Substring(1); // 批次号
|
||||
var partNo = barArray[4]; // 零件号/机型
|
||||
var partName = barArray[6].Split('/')[1]; //零件名称
|
||||
var partSort = barArray[6].Split('/')[0]; //零件类别
|
||||
var partSortType = barArray[6].Split('/')[0]; //零件类别
|
||||
var partSnNo = barArray[8]; // 零件唯一码
|
||||
|
||||
string EngineType = partNo;//机型
|
||||
string EngineID = partSnNo.Substring(0,18);//发动机号
|
||||
|
||||
//为产品生成唯一标识(扫码时间戳)
|
||||
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||
//EngineID = Convert.ToInt64(ts.TotalMilliseconds).ToString();
|
||||
|
||||
bool IsNotRepeatedNumber = false; // 是否重号
|
||||
int IsTodayPlan = 0; // 是否是今天的计划
|
||||
|
||||
|
||||
|
||||
//判断当前设备的模式:手动、自动、脉动
|
||||
//自动模式:
|
||||
MIS_BASE.Read_TagTypeID(63, OpName, out string workModel);
|
||||
switch (workModel.ToLower())
|
||||
{
|
||||
case "true":
|
||||
case "1":
|
||||
workModel = "1";
|
||||
break;
|
||||
default:
|
||||
workModel = "0";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//1:获得申请上线信息后,扫描条码才处理业务
|
||||
bool ispartload = false;
|
||||
|
||||
MIS_BASE.Read_PartLoad(OpName, out ispartload);
|
||||
if (!ispartload)
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "等待人工扫码信号!!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (workModel.ToString() == "1" && ispartload )
|
||||
{
|
||||
string opName_db = "";
|
||||
//自动模式时,进行工位转换
|
||||
if (OpName == "OP10")
|
||||
{
|
||||
OpName_mes = "OP10_mes";
|
||||
opName_db = "OP20";
|
||||
}
|
||||
else if (OpName == "OP30")
|
||||
{
|
||||
OpName_mes = "OP30_mes";
|
||||
opName_db = "OP40";
|
||||
}
|
||||
else
|
||||
{
|
||||
opName_db = OpName;
|
||||
}
|
||||
|
||||
//判断该产品标识在该工位是否重复
|
||||
IsNotRepeatedNumber = BaseDataSystemMES.EngineTypeID_IsNotRepeatedNumber(EngineID, opName_db);
|
||||
if (IsNotRepeatedNumber)
|
||||
{
|
||||
// 判断是否是今天的计划
|
||||
BaseDataSystemMES.GetEngineTypeUpLoadOpName(EngineID, partNo, opName_db, orderNo, batchNo, out IsTodayPlan);
|
||||
if (IsTodayPlan == 1)
|
||||
{
|
||||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(opName_db, MobyTagType.WorkStartIn, DateTime.Now.ToString());
|
||||
//将唯一标识写入PLC
|
||||
//MIS_BASE.Write_EngineID_MES(OpName_mes, EngineID);
|
||||
MIS_BASE.WritePLC(74, OpName_mes, EngineID);
|
||||
//将随工单零件号写入PLC
|
||||
//MIS_BASE.Write_EngineType_MES(OpName_mes, EngineType);
|
||||
MIS_BASE.WritePLC(75, OpName_mes, EngineType);
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "收到扫码信号···········");
|
||||
//先把延时屏蔽掉看看效果如何
|
||||
//Thread.Sleep(5000);
|
||||
MIS_BASE.Write_EngineTypeGetOver_MES(OpName_mes, true);
|
||||
// MES传递机型
|
||||
//string WriteStr1 = MIS_BASE.ReadPLC(74, OpName_mes).ToString();
|
||||
//string WriteStr2 = MIS_BASE.ReadPLC(75, OpName_mes).ToString();
|
||||
|
||||
//if (WriteStr1 != "" && WriteStr2 != "")
|
||||
//{
|
||||
// MIS_BASE.Write_EngineTypeGetOver_MES(OpName_mes, true);
|
||||
// SendMessageFun.AsyncSendMessage_Notice(OpName, "扫码成功·········");
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// SendMessageFun.AsyncSendMessage_Notice(OpName, "写入传递机型时码值为空!!!!!!!!");
|
||||
//}
|
||||
//显示当前订单信息
|
||||
SendMessage.ShowMoby(opName_db);
|
||||
//通知web显示
|
||||
SendMessageFun.SendMessage("13", "111", opName_db);
|
||||
MIS_BASE.asyncSendMessage("MES|showBarcode|" + OpName + "|" + barcode);
|
||||
}
|
||||
else
|
||||
{
|
||||
MIS_BASE.asyncSendMessage("MES|showBarcode|" + OpName + "|" + "");
|
||||
SendMessageFun.AsyncSendMessage_Notice(opName_db, "计划不匹配!!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MIS_BASE.asyncSendMessage("MES|showBarcode|" + OpName + "|" + barcode);
|
||||
SendMessageFun.AsyncSendMessage_Notice(opName_db, "工件零件号重号,请确认!");
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
//获取脉动模式:
|
||||
MIS_BASE.Read_TagTypeID(64, OpName, out string workModel_MD);
|
||||
//获取手动模式:
|
||||
MIS_BASE.Read_TagTypeID(62, OpName, out string workModel_SD);
|
||||
|
||||
switch (workModel_MD.ToLower())
|
||||
{
|
||||
case "true":
|
||||
case "1":
|
||||
workModel_MD = "1";
|
||||
break;
|
||||
default:
|
||||
workModel_MD = "0";
|
||||
break;
|
||||
}
|
||||
switch (workModel_SD.ToLower())
|
||||
{
|
||||
case "true":
|
||||
case "1":
|
||||
workModel_SD = "1";
|
||||
break;
|
||||
default:
|
||||
workModel_SD = "0";
|
||||
break;
|
||||
}
|
||||
|
||||
//手动模式:
|
||||
|
||||
|
||||
if (workModel_MD.ToString() == "1" || workModel_SD.ToString() == "1")
|
||||
{ }
|
||||
else
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC模式不正确!!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//2:从数据库判断判断是否已经扫描过这个码 IsRepeatedNumber true 不重号;false 重号;
|
||||
|
||||
IsNotRepeatedNumber = BaseDataSystemMES.EngineTypeID_IsNotRepeatedNumber(EngineID, OpName);
|
||||
if (IsNotRepeatedNumber)
|
||||
{
|
||||
// 判断是否是今天的计划
|
||||
BaseDataSystemMES.GetEngineTypeUpLoadOpName(EngineID, partNo, OpName, orderNo, batchNo, out IsTodayPlan);
|
||||
if (IsTodayPlan == 1)
|
||||
{
|
||||
//将随工单零件号写入PLC
|
||||
MIS_BASE.Write_EngineType_MES(OpName_mes, EngineType);
|
||||
//将唯一标识写入PLC
|
||||
MIS_BASE.Write_EngineID_MES(OpName_mes, EngineID);
|
||||
Thread.Sleep(1000);
|
||||
// MES传递机型
|
||||
MIS_BASE.Write_EngineTypeGetOver_MES(OpName_mes, true);
|
||||
//显示当前订单信息
|
||||
SendMessage.ShowMoby(OpName);
|
||||
//通知web显示
|
||||
SendMessageFun.SendMessage("13", "111", OpName);
|
||||
MIS_BASE.asyncSendMessage("MES|showBarcode|" + OpName + "|" + barcode);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "计划不匹配!!");
|
||||
MIS_BASE.asyncSendMessage("MES|showBarcode|" + OpName + "|" + "");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "工件零件号重号,请确认!");
|
||||
MIS_BASE.asyncSendMessage("MES|showBarcode|" + OpName + "|" + barcode);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "工件条码格式不正确,请确认!");
|
||||
MIS_BASE.asyncSendMessage("MES|showBarcode|" + OpName + "|" + barcode);
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "Function08:Barcode");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using bizFacade;
|
||||
using MesServerWork;
|
||||
//using SystemFramework;
|
||||
|
||||
|
||||
namespace MesServerFunctions
|
||||
{
|
||||
partial class FunctionMES
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 切换配方 初始化数据
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
private void ChengeRepice(object e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e;
|
||||
string OpName = Convert.ToString(msgEvent.OpName);
|
||||
int tagValue = Convert.ToInt32(msgEvent.TagValue);
|
||||
string OpName_mes = Convert.ToString(msgEvent.OpName) + "_mes";
|
||||
|
||||
//int EngineTypeID;//机型代码
|
||||
//int PartPallet_Code;//托盘编号
|
||||
|
||||
//string EngineType;//机型
|
||||
//string EngineID;//工件编号
|
||||
|
||||
//int EngineTypeID_MES;//机型代码
|
||||
//string EngineType_MES;//机型
|
||||
//string EngineID_MES;//工件编号
|
||||
//string OrderForm;//订单号
|
||||
|
||||
//MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm);
|
||||
|
||||
MIS_BASE.Write_TagTypeID(201, OpName_mes, 0);
|
||||
MIS_BASE.Write_TagTypeID(202, OpName_mes, 0);
|
||||
MIS_BASE.Write_TagTypeID(203, OpName_mes, 0);
|
||||
MIS_BASE.Write_TagTypeID(204, OpName_mes, 0);
|
||||
MIS_BASE.Write_TagTypeID(205, OpName_mes, 0);
|
||||
MIS_BASE.Write_TagTypeID(206, OpName_mes, 0);
|
||||
MIS_BASE.Write_TagTypeID(207, OpName_mes, 0);
|
||||
MIS_BASE.Write_TagTypeID(208, OpName_mes, 0);
|
||||
//MIS_BASE.Write_EngineTypeGetOver_MES(OpName_mes, false);
|
||||
//MIS_BASE.Write_TagTypeID(75, OpName_mes, "");
|
||||
//MIS_BASE.Write_TagTypeID(20, OpName_mes, 0);
|
||||
|
||||
// 发送切换信号 前端关闭手动拧紧指导
|
||||
SendMessageFun.SendInfomation("CutRecipe", "1", OpName);
|
||||
|
||||
// 将配方号写入到MOBY表中 然后拉去页面工艺数据
|
||||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineTypeID, tagValue.ToString());
|
||||
SendMessageFun.SendMessage("13", "111", OpName);
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "Function08:FalseGO");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
//using SystemFramework;
|
||||
using MesServerWork;
|
||||
|
||||
namespace MesServerFunctions
|
||||
{
|
||||
partial class FunctionMES
|
||||
{
|
||||
/// <summary>
|
||||
/// 合格放行
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using bizFacade;
|
||||
using MesServerWork;
|
||||
//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
|
||||
{
|
||||
DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e;
|
||||
string OpName = Convert.ToString(msgEvent.OpName);
|
||||
string OpName_mes = OpName+"_mes";
|
||||
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);
|
||||
|
||||
//显示当前订单信息
|
||||
|
||||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineTypeID, EngineTypeID.ToString());
|
||||
// 写入工位工作状态 0 无工件(工件到位0) 1 工件到位(工件到位1) 2 工作中(传递机型1) 3 工作完成(允许保存1)
|
||||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineWorkType, "2");
|
||||
|
||||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID, EngineID);
|
||||
EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm);
|
||||
|
||||
//SendMessage.ShowMoby(OpName);
|
||||
}
|
||||
else
|
||||
{
|
||||
MIS_BASE.Write_FixAllow(OpName_mes, false);
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "Function08:EngineTypeGetOver_PLC");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using MesServerWork;
|
||||
//using SystemFramework;
|
||||
|
||||
|
||||
namespace MesServerFunctions
|
||||
{
|
||||
partial class FunctionMES
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 返修放行
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// MES与PLC心跳监听
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
private void HeartBeat(object e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e;
|
||||
string OpName = Convert.ToString(msgEvent.OpName);
|
||||
string OpName_mes = OpName+"_mes";
|
||||
int tagValue = Convert.ToInt32(msgEvent.TagValue);
|
||||
|
||||
//返写在MES心跳中
|
||||
MIS_BASE.WritePLC(15, OpName_mes, tagValue);
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "Function02:FalseGO");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using bizFacade;
|
||||
//using SystemFramework;
|
||||
using MesServerWork;
|
||||
|
||||
namespace MesServerFunctions
|
||||
{
|
||||
partial class FunctionMES
|
||||
{
|
||||
object lockMesRead = new object ();
|
||||
/// <summary>
|
||||
/// 保存完成(针对半自动和手动压装工位)
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
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);
|
||||
string OpName_mes = Convert.ToString(msgEvent.OpName) + "_mes";
|
||||
int tagValue = Convert.ToInt32(msgEvent.TagValue);
|
||||
|
||||
if (tagValue == 1)
|
||||
{
|
||||
//保存数据到线首表 先保存到 北汽福田变速器序列号总线上线 用于之前判断是否重号
|
||||
if (Db.UpLoadOpNameInsert(OpName))
|
||||
{
|
||||
// 读取配方号
|
||||
MIS_BASE.Read_EngineTypeID(OpName, out EngineTypeID);
|
||||
// 保存质量数据
|
||||
|
||||
int qualityMask = Funtion.MesRead_538(OpName, tagValue.ToString(), msgEvent.TagID.ToString(), EngineTypeID.ToString());
|
||||
// 推送质量数据到MES的页面
|
||||
MIS_BASE.SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName);
|
||||
|
||||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartOut, DateTime.Now.ToString());
|
||||
|
||||
// 测量数据发动机在线状态 保存过站信息
|
||||
BaseDataSystemMES.WorkStartInsert(OpName, qualityMask);
|
||||
|
||||
// 将数据存到上传接口表里 准备被读取上传
|
||||
//BaseDataSystemMES.MES_SaveQualityData_TO_UpLoadTable(OpName);
|
||||
|
||||
// 读取一下是否有允许保存信号,若没有允许保存信号那就不能给保存完成,不然后续流程会乱
|
||||
MIS_BASE.Read_QualityData_Read_CF(OpName, out bool isRead_CF);
|
||||
if(isRead_CF)
|
||||
{
|
||||
//通知设备,MES的质量数据(和物料数据)保存完成
|
||||
MIS_BASE.Write_MesReadOver(OpName_mes, true);
|
||||
}
|
||||
|
||||
|
||||
// 写入工位工作状态 0 无工件(工件到位0) 1 工件到位(工件到位1) 2 工作中(传递机型1) 3 工作完成(允许保存1)
|
||||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineWorkType, "3");
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessage.AsyncSendMessage_Notice(OpName, "保存上线数据失败!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MIS_BASE.Write_MesReadOver(OpName_mes, false);
|
||||
// 写入工位工作状态 0 无工件(工件到位0) 1 工件到位(工件到位1) 2 工作中(传递机型1) 3 工作完成(允许保存1)
|
||||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineWorkType, "0");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "Function08:MesReadOver");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using bizFacade;
|
||||
//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
|
||||
{
|
||||
DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e;
|
||||
string OpName = Convert.ToString(msgEvent.OpName); // 这个是带_mes的
|
||||
int tagValue = Convert.ToInt32(msgEvent.TagValue);
|
||||
string OpName_PLC = OpName.Replace("_mes", "");
|
||||
|
||||
// 由于mes工位的特殊限制,导致misdata的监控变化不会以正确的工位号传递给网页,所以在这里特殊处理一下
|
||||
MIS_BASE.asyncSendMessage("MES|MesReadOver|" + OpName_PLC + "|" + tagValue.ToString());
|
||||
|
||||
//if (tagValue == 1)
|
||||
//{
|
||||
|
||||
// BaseDataSystemMES.Material_Insert(OpName, tagValue);
|
||||
|
||||
// MIS_BASE.Write_ConfirmOkGo(OpName, true);
|
||||
//}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "Function08:MesReadOver");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using bizFacade;
|
||||
using DoWhatPlc;
|
||||
//using SystemFramework;
|
||||
using MesServerWork;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MesServerFunctions
|
||||
{
|
||||
partial class FunctionMES
|
||||
{
|
||||
/// <summary>
|
||||
/// 参数刷入完成
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
private void ParamsWriteOver(object e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e;
|
||||
string OpName = Convert.ToString(msgEvent.OpName);
|
||||
string OpName_mes = Convert.ToString(msgEvent.OpName) + "_mes";
|
||||
int tagValue = Convert.ToInt32(msgEvent.TagValue);
|
||||
int EngineTypeID;
|
||||
if (tagValue == 1)
|
||||
{
|
||||
ConcurrentDictionary<string, object> rtList = MIS_BASE.ReadPLC_OpName(OpName);
|
||||
var pp = JsonConvert.SerializeObject(rtList);
|
||||
var tagValues = JsonConvert.DeserializeObject<ConcurrentDictionary<string, TagFormat>>(pp);
|
||||
// 读取配方号
|
||||
MIS_BASE.Read_EngineTypeID(OpName, out EngineTypeID);
|
||||
var keyValues = tagValues.Where(x => x.Value.TagTypeCodeID == 58).Where(x => x.Value.TagOrderBy == EngineTypeID.ToString()).OrderBy(x => x.Key).ToDictionary(k => k.Key, v => v.Value);
|
||||
var qc_value_list = keyValues.Values.ToList();
|
||||
for (int i = 0; i < qc_value_list.Count; i++)
|
||||
{
|
||||
string tagValue1 = qc_value_list[i].TagValue.ToString();
|
||||
switch (tagValue1.ToLower())
|
||||
{
|
||||
case "true":
|
||||
case "1":
|
||||
tagValue1 = "1";
|
||||
break;
|
||||
default:
|
||||
tagValue1 = "0";
|
||||
break;
|
||||
}
|
||||
|
||||
if (tagValue1 == "1")
|
||||
{
|
||||
var ee = qc_value_list[i];
|
||||
ee.TagValue = tagValue1;
|
||||
SendMessageFun.SendInfomation("PlcShowWorkPositionUpdate", JsonHelper.ObjectToJson(ee), OpName);
|
||||
|
||||
Thread.Sleep(500);
|
||||
SendMessageFun.SendInfomation("PlcShowWorkPositionUpdate", JsonHelper.ObjectToJson(ee), OpName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "Function08:MesReadOver");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using bizFacade;
|
||||
//using SystemFramework;
|
||||
using MesServerWork;
|
||||
|
||||
namespace MesServerFunctions
|
||||
{
|
||||
partial class FunctionMES
|
||||
{
|
||||
/// <summary>
|
||||
/// 申请上线(针对上线工位)
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
private void PartLoad(object e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e;
|
||||
string OpName = Convert.ToString(msgEvent.OpName);
|
||||
string OpName_mes = Convert.ToString(msgEvent.OpName) + "_mes";
|
||||
int tagValue = Convert.ToInt32(msgEvent.TagValue);
|
||||
|
||||
if (tagValue == 1)
|
||||
{
|
||||
|
||||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartIn, DateTime.Now.ToString());
|
||||
|
||||
MIS_BASE.Write_TagTypeID(201, OpName_mes, 0);
|
||||
MIS_BASE.Write_TagTypeID(202, OpName_mes, 0);
|
||||
MIS_BASE.Write_TagTypeID(203, OpName_mes, 0);
|
||||
MIS_BASE.Write_TagTypeID(204, OpName_mes, 0);
|
||||
MIS_BASE.Write_TagTypeID(205, OpName_mes, 0);
|
||||
MIS_BASE.Write_TagTypeID(206, OpName_mes, 0);
|
||||
MIS_BASE.Write_TagTypeID(207, OpName_mes, 0);
|
||||
MIS_BASE.Write_TagTypeID(208, OpName_mes, 0);
|
||||
MIS_BASE.Write_TagTypeID(74, OpName_mes, "");
|
||||
MIS_BASE.Write_TagTypeID(75, OpName_mes, "");
|
||||
MIS_BASE.Write_TagTypeID(20, OpName_mes, 0);
|
||||
MIS_BASE.Write_EngineTypeGetOver_MES(OpName_mes, false);
|
||||
MIS_BASE.Write_FixAllow(OpName_mes, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
//上线工位清MES传递机型信号
|
||||
MIS_BASE.Write_EngineTypeGetOver_MES(OpName_mes, false);
|
||||
MIS_BASE.Write_TagTypeID(74, OpName_mes, "");
|
||||
MIS_BASE.Write_TagTypeID(75, OpName_mes, "");
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "Function08:MesReadOver");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,475 @@
|
||||
using System;
|
||||
using MesServerWork;
|
||||
using bizFacade;
|
||||
using System.Threading;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using DoWhatPlc;
|
||||
//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
|
||||
{
|
||||
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('|');
|
||||
string m_Command = dataArray[0].ToString();//消息类型
|
||||
if(m_Command == "Barcode")
|
||||
{
|
||||
string splitString = "Barcode|";
|
||||
string[] separatingStrings = { "Barcode|" };
|
||||
string[] m_ValueBarcodeArray = Content.Split(separatingStrings, System.StringSplitOptions.RemoveEmptyEntries);
|
||||
string m_ValueBarcode = m_ValueBarcodeArray[0];
|
||||
|
||||
DoWhatPlc.CustomeEvetnArgs _eBarcode = new DoWhatPlc.CustomeEvetnArgs();
|
||||
_eBarcode.OpName = OpName;
|
||||
_eBarcode.TagValue = m_ValueBarcode;
|
||||
fun_Barcode(_eBarcode);
|
||||
return;
|
||||
}
|
||||
|
||||
if (dataArray.Length != 2)
|
||||
return;
|
||||
|
||||
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;
|
||||
//初始化网页拧紧数据
|
||||
case "IniSingalToWeb_NingJin":
|
||||
getAllNingJing_Position(OpName);
|
||||
break;
|
||||
//拧紧指导
|
||||
case "NingJin_Work":
|
||||
changeNingJing_Position(OpName, m_Value);
|
||||
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)
|
||||
{
|
||||
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);
|
||||
if (S_WorkStart == true)
|
||||
{
|
||||
SendMessageFun.SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname);
|
||||
}
|
||||
Thread.Sleep(1000);
|
||||
//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);
|
||||
|
||||
//if (S_plcStatus.ToLower() == "false")
|
||||
//{
|
||||
// SendMessageFun.SendInfomation("PlcStatus", "0", Opname);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// SendMessageFun.SendInfomation("PlcStatus", "1", Opname);
|
||||
//}
|
||||
|
||||
// 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);//显示分线机型及流水号
|
||||
getAllNingJing_Position(Opname);
|
||||
}
|
||||
private void getAllNingJing_Position(string Opname)
|
||||
{
|
||||
string Opname_mes = Opname + "_mes";
|
||||
ConcurrentDictionary<string, object> rtList = MIS_BASE.ReadPLC_OpName(Opname);
|
||||
var pp = JsonConvert.SerializeObject(rtList);
|
||||
var tagValues = JsonConvert.DeserializeObject<ConcurrentDictionary<string, TagFormat>>(pp);
|
||||
// 读取配方号
|
||||
MIS_BASE.Read_EngineTypeID(Opname, out int EngineTypeID);
|
||||
var keyValues = tagValues.Where(x => x.Value.TagTypeCodeID == 58)
|
||||
.Where(x => x.Value.TagOrderBy == EngineTypeID.ToString())
|
||||
.OrderBy(x => x.Key).ToDictionary(k => k.Key, v => v.Value);
|
||||
|
||||
Hashtable ht = new Hashtable();
|
||||
var qc_value_list = keyValues.Values.ToList();
|
||||
|
||||
List<DoWhatPlc.TagFormat> newList = new List<DoWhatPlc.TagFormat>();
|
||||
|
||||
foreach (var kvp in qc_value_list)
|
||||
{
|
||||
string tagValue;
|
||||
var myTagFormat = kvp;
|
||||
switch (kvp.TagValue.ToString().ToLower())
|
||||
{
|
||||
case "false":
|
||||
tagValue = "0";
|
||||
break;
|
||||
case "true":
|
||||
tagValue = "1";
|
||||
break;
|
||||
default:
|
||||
tagValue = kvp.TagValue.ToString();
|
||||
break;
|
||||
}
|
||||
myTagFormat.TagValue = tagValue;
|
||||
newList.Add(myTagFormat);
|
||||
}
|
||||
|
||||
string qc_value_string = JsonHelper.ObjectToJson(newList);
|
||||
|
||||
|
||||
//Thread.Sleep(200);
|
||||
string position = "0";
|
||||
switch (EngineTypeID)
|
||||
{
|
||||
case 1:
|
||||
MIS_BASE.Read_TagTypeID(201, Opname_mes, out position);
|
||||
break;
|
||||
case 2:
|
||||
MIS_BASE.Read_TagTypeID(202, Opname_mes, out position);
|
||||
break;
|
||||
case 3:
|
||||
MIS_BASE.Read_TagTypeID(203, Opname_mes, out position);
|
||||
break;
|
||||
case 4:
|
||||
MIS_BASE.Read_TagTypeID(204, Opname_mes, out position);
|
||||
break;
|
||||
case 5:
|
||||
MIS_BASE.Read_TagTypeID(205, Opname_mes, out position);
|
||||
break;
|
||||
case 6:
|
||||
MIS_BASE.Read_TagTypeID(206, Opname_mes, out position);
|
||||
break;
|
||||
case 7:
|
||||
MIS_BASE.Read_TagTypeID(207, Opname_mes, out position);
|
||||
break;
|
||||
case 8:
|
||||
MIS_BASE.Read_TagTypeID(208, Opname_mes, out position);
|
||||
break;
|
||||
|
||||
}
|
||||
SendMessageFun.SendInfomation("PlcShowWorkPosition", qc_value_string, Opname);
|
||||
|
||||
SendMessageFun.SendInfomation("PlcShowWorkPosition_Current", position, Opname);
|
||||
|
||||
}
|
||||
private void changeNingJing_Position(string Opname, string positionValue)
|
||||
{
|
||||
string OpName_mes = Opname + "_mes";
|
||||
int EngineTypeID;
|
||||
// 读取配方号
|
||||
MIS_BASE.Read_EngineTypeID(Opname, out EngineTypeID);
|
||||
if (Convert.ToInt32(positionValue) == 0) {
|
||||
SendMessageFun.AsyncSendMessage_Notice(Opname, "请重新选择拧紧位置!!");
|
||||
return;
|
||||
}
|
||||
switch (EngineTypeID)
|
||||
{
|
||||
case 1:
|
||||
MIS_BASE.Write_TagTypeID(201, OpName_mes, positionValue);
|
||||
break;
|
||||
case 2:
|
||||
MIS_BASE.Write_TagTypeID(202, OpName_mes, positionValue);
|
||||
break;
|
||||
case 3:
|
||||
MIS_BASE.Write_TagTypeID(203, OpName_mes, positionValue);
|
||||
break;
|
||||
case 4:
|
||||
MIS_BASE.Write_TagTypeID(204, OpName_mes, positionValue);
|
||||
break;
|
||||
case 5:
|
||||
MIS_BASE.Write_TagTypeID(205, OpName_mes, positionValue);
|
||||
break;
|
||||
case 6:
|
||||
MIS_BASE.Write_TagTypeID(206, OpName_mes, positionValue);
|
||||
break;
|
||||
case 7:
|
||||
MIS_BASE.Write_TagTypeID(207, OpName_mes, positionValue);
|
||||
break;
|
||||
case 8:
|
||||
MIS_BASE.Write_TagTypeID(208, OpName_mes, positionValue);
|
||||
break;
|
||||
|
||||
}
|
||||
SendMessageFun.AsyncSendMessage_Notice(Opname, "请进行拧紧!!");
|
||||
|
||||
|
||||
}
|
||||
|
||||
//分线发送工件到位信号函数
|
||||
private void sendmessage(string OpName, int tagValue, string Command)
|
||||
{
|
||||
string SendMessage;
|
||||
SendMessage = "MES|" + Command + "|" + OpName + "|" + tagValue;
|
||||
SendMessageFun.AsyncSendMessage(SendMessage);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using bizFacade;
|
||||
using MesServerWork;
|
||||
//using SystemFramework;
|
||||
|
||||
|
||||
namespace MesServerFunctions
|
||||
{
|
||||
partial class FunctionMES
|
||||
{
|
||||
/// <summary>
|
||||
/// 工件到位与离开时,清空MES自身信号
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
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.WorkStart, tagValue.ToString());
|
||||
|
||||
// 写入工位工作状态 0 无工件(工件到位0) 1 工件到位(工件到位1) 2 工作中(传递机型1) 3 工作完成(允许保存1)
|
||||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineWorkType, "1");
|
||||
}
|
||||
else
|
||||
{
|
||||
MIS_BASE.Write_MesReadOver(OpName, false);
|
||||
MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
catch(Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "Function08:WorkStart");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user