chore: 初始化平芝126KV断路器线程序
This commit is contained in:
228
MisDataFunction/Function1057/OpcServer/Barcode.cs
Normal file
228
MisDataFunction/Function1057/OpcServer/Barcode.cs
Normal file
@@ -0,0 +1,228 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using bizFacade;
|
||||
//using SystemFramework;
|
||||
using MesServerWork;
|
||||
|
||||
namespace MesServerFunctions
|
||||
{
|
||||
partial class FunctionMES
|
||||
{
|
||||
/// <summary>
|
||||
///1.扫描配送单号,用于接收物料,扫描单号的时候,将接收的物料信息显示在“物料拉动”Tab区域
|
||||
///2.扫描料箱标签/看板卡,用于追溯物料批次信息
|
||||
///3.扫描零件条码,根据零件图号进行防错
|
||||
///第一步,判断条码类型,根据条码类型,执行对应的存储过程
|
||||
///第二步,条码类型(将扫描的条码保存到对应的表中)
|
||||
///第三步,扫描完成之后给出允许工作信号
|
||||
/// 处理页面扫描条码
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="barcode"></param>
|
||||
public void Barcode(object e)
|
||||
{
|
||||
|
||||
{
|
||||
try
|
||||
{
|
||||
DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e;
|
||||
string OpName = Convert.ToString(msgEvent.OpName);
|
||||
string barcode = Convert.ToString(msgEvent.TagValue);
|
||||
|
||||
int EngineTypeID;//机型代码
|
||||
string EngineType;//机型
|
||||
string EngineID;//工件编号
|
||||
|
||||
string OrderForm;
|
||||
int Recipe1;
|
||||
int Recipe2;
|
||||
|
||||
bool IsNotRepeatedNumber = false;
|
||||
//1:获得申请上线信息后,扫描条码才处理业务
|
||||
bool ispartload;
|
||||
//(115)
|
||||
int PTO;
|
||||
//(118)0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出
|
||||
int NgearSwitch;
|
||||
//(119)0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出
|
||||
int RgearSwitch;
|
||||
//(120)0=不检测;1=检测。检测线上线工位扫描总成条码,根据BOM,查出
|
||||
int SpeedSensor;
|
||||
//(121)例如:5S 400。检测线上线工位扫描总成条码,根据BOM,查出
|
||||
string PartTypeMid;
|
||||
//(122) 0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出
|
||||
int Tcu_V;
|
||||
|
||||
//判断是否开启线外上线
|
||||
if (!Convert.ToBoolean(MIS_BASE.ReadPLC(64, OpName)))
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "若转线上线工件请在系统选择转线工件选项");
|
||||
return;
|
||||
}
|
||||
|
||||
//判断工件是否到位
|
||||
MIS_BASE.Read_WorkStart(OpName, out ispartload);
|
||||
if (!ispartload)
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "请检查设备是否到位(DBX500.1=1)");
|
||||
return;
|
||||
}
|
||||
//判断设备是否申请上线
|
||||
MIS_BASE.Read_UpdatePalletOK(OpName, out ispartload);
|
||||
if (!ispartload)
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "请检查设备是否申请上线(DBX500.3=1)");
|
||||
return;
|
||||
}
|
||||
// 判读条码是变速器序列号条码号还是物料号 小机型*日月年* 流水号(给起始号 + 数量)
|
||||
// 选小机型 从北汽福田BOM中选 得先维护BOM
|
||||
// 变速器序列号 '1333 050 062*16012023*30000001'
|
||||
|
||||
//扫描完变速器序列号条码号 true
|
||||
bool isGetOver_PLC = false;
|
||||
//判断上线工位,MES 是否将工件流水号、机型等信息已经写入到PLC了
|
||||
MIS_BASE.Read_EngineGetOver_PLC(OpName, out isGetOver_PLC);
|
||||
//如果工件流水号、机型等信息没有写入PLC,扫描的条码按工件流水号进行验证
|
||||
//否则按装配物料进行验证
|
||||
if (!isGetOver_PLC)
|
||||
{
|
||||
|
||||
if (barcode.Split('*').Length > 2)
|
||||
{
|
||||
//2: 判断是否重号, 从数据库获得机型、机型代码等信息
|
||||
string partSn = barcode;
|
||||
EngineID = barcode;
|
||||
|
||||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID_MES, EngineID);
|
||||
|
||||
//IsRepeatedNumber true 不重号;false 重号;
|
||||
IsNotRepeatedNumber = BaseDataSystemMES.EngineTypeID_IsNotRepeatedNumber(partSn);
|
||||
if (IsNotRepeatedNumber)
|
||||
{
|
||||
BaseDataSystemMES.GetEngineTypeUpLoadOpName(partSn, OpName, out EngineTypeID, out EngineType, out OrderForm, out Recipe1, out Recipe2);
|
||||
|
||||
|
||||
BaseDataSystemMES.UpLoadPTO(EngineType, out PTO, out NgearSwitch, out RgearSwitch, out SpeedSensor, out PartTypeMid, out Tcu_V);
|
||||
//PTO
|
||||
MIS_BASE.WritePLC(115, OpName, PTO);
|
||||
//空挡开关检测
|
||||
MIS_BASE.WritePLC(95, OpName, NgearSwitch);
|
||||
//倒挡开关检测
|
||||
MIS_BASE.WritePLC(96, OpName, RgearSwitch);
|
||||
//里程表检测
|
||||
MIS_BASE.WritePLC(97, OpName, SpeedSensor);
|
||||
//大机型扩展
|
||||
MIS_BASE.WritePLC(98, OpName, PartTypeMid);
|
||||
//TCU
|
||||
MIS_BASE.WritePLC(122, OpName, Tcu_V);
|
||||
string tagStartAdr;//= "DB411.10";
|
||||
|
||||
// 先查询配方号 根据工位号 去moby表查配方号
|
||||
// 根据配方号 去配方表查配方数据
|
||||
// 写入配方数据
|
||||
BaseDataSystemMES.PLCRcipeCurrent(OpName, out byte[] bytes, out tagStartAdr);
|
||||
DtWebApi.ReadWritePLC.Write_TagValueByTagTypeID("94", OpName, System.Text.Encoding.ASCII.GetString(bytes));
|
||||
////将产品信息写入PLC
|
||||
MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID);
|
||||
MIS_BASE.Write_EngineType_MES(OpName, EngineType);
|
||||
MIS_BASE.Write_EngineID_MES(OpName, EngineID);
|
||||
MIS_BASE.Write_OrderForm_MES(OpName, OrderForm);
|
||||
|
||||
//写入到数据库的[北汽福田工位状态监控MOBY]表中
|
||||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineTypeID_MES, EngineTypeID.ToString());
|
||||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineType_MES, EngineType);
|
||||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID_MES, EngineID);
|
||||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.OrderForm_MES, OrderForm);
|
||||
|
||||
//通知web显示
|
||||
SendMessage.ShowMoby(OpName);
|
||||
//在PLC传递机型后进行允许工作
|
||||
//MIS_BASE.Write_FixAllow(OpName, true);
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "扫码成功,请开始工作!");
|
||||
//SendMessageFun.SendMessage("1235", "1111", OpName);
|
||||
|
||||
MIS_BASE.Write_EngineTypeGetOver_MES(OpName, true);
|
||||
//Thread.Sleep(1000);
|
||||
//MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "变速器序列号 重号,请确认!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "变速器序列号格式不正确,请确认!");
|
||||
|
||||
}
|
||||
}
|
||||
else//验证物料
|
||||
{
|
||||
//物料号
|
||||
{
|
||||
//读取PLC的传递机型信号
|
||||
bool tagValue;
|
||||
MIS_BASE.Read_EngineGetOver_PLC(OpName, out tagValue);
|
||||
if (tagValue)
|
||||
{
|
||||
//验证物料
|
||||
BaseDataSystemMES.PartMaterial_DM_Update(OpName, barcode, out bool IsSuccess);
|
||||
if (!IsSuccess)//????
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessageFun.SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息
|
||||
}
|
||||
//判断物料是否验证完成
|
||||
BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out int IsAllowWork);
|
||||
|
||||
|
||||
if (IsSuccess)
|
||||
{
|
||||
if (IsAllowWork == 1)
|
||||
{
|
||||
//移到允许保存信号中
|
||||
//BaseDataSystemMES.Material_Insert(OpName, 1);
|
||||
|
||||
////更新订单完工数量及物料
|
||||
SendMessageFun.SendMessage("24", "11", OpName);
|
||||
|
||||
//物料验证完成,通知PLC允许工作,允许工作在保存完成时清空
|
||||
MIS_BASE.Write_FixAllow(OpName, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC未传递机型");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessage.AsyncSendMessage_Notice(OpName, "产品上线后,PLC获得变速器序列号后,再验证物料!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "Function02:Barcode");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user