chore: initial commit
This commit is contained in:
89
MisDataFunction/Function1052/OpcServer/Barcode.cs
Normal file
89
MisDataFunction/Function1052/OpcServer/Barcode.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using MesServerWork;
|
||||
using MisDataFunDll;
|
||||
|
||||
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
|
||||
{
|
||||
DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e;
|
||||
string OpName = Convert.ToString(msgEvent.OpName);
|
||||
string barcode = Convert.ToString(msgEvent.TagValue);
|
||||
string AlarmStr = "";
|
||||
|
||||
int IsAllowWork;
|
||||
bool IsSuccess = false;
|
||||
bool EngineGetOver_PLC_NextWorkStep;
|
||||
//传递机型是否到位
|
||||
MIS_BASE.Read_EngineGetOver_PLC(OpName, out EngineGetOver_PLC_NextWorkStep);
|
||||
if (!EngineGetOver_PLC_NextWorkStep)
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC未传递机型");
|
||||
return;
|
||||
}
|
||||
//物料验证
|
||||
MisDataFun.PartMaterial_DM_Update(OpName, barcode, out IsSuccess);
|
||||
if (!IsSuccess)
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessageFun.SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//获取是否允许工作
|
||||
MisDataFun.MesServer_Judge_IsCanWork(OpName, out IsAllowWork);
|
||||
|
||||
//此处逻辑有问题 需要考虑到批次扫描 提示PLC未传递机型的情况
|
||||
if (IsAllowWork == 1)
|
||||
{
|
||||
//BaseDataSystemMES.Material_Insert(OpName, 1);
|
||||
|
||||
//更新订单完工数量及物料
|
||||
SendMessageFun.SendMessage("24", "11", OpName);
|
||||
|
||||
//通知PLC允许工作,允许工作在保存完成时清空
|
||||
MIS_BASE.Write_FixAllow(OpName, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "Function02:Barcode");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
119
MisDataFunction/Function1052/OpcServer/EngineGetOver.cs
Normal file
119
MisDataFunction/Function1052/OpcServer/EngineGetOver.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using MesServerWork;
|
||||
using MisDataFunDll;
|
||||
|
||||
namespace MesServerFunctions
|
||||
{
|
||||
partial class FunctionMES
|
||||
{
|
||||
/// <summary>
|
||||
/// PLC传递机型处理
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
private void EngineTypeGetOver_PLC(object e)
|
||||
{
|
||||
|
||||
{
|
||||
try
|
||||
{
|
||||
DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e;
|
||||
string OpName = Convert.ToString(msgEvent.OpName);
|
||||
int tagValue = Convert.ToInt32(msgEvent.TagValue);
|
||||
//判断PLC机型与MES机型是否一致
|
||||
if (tagValue == 1)
|
||||
{
|
||||
bool MesRead = false;
|
||||
|
||||
int EngineTypeID;//机型代码
|
||||
int PartPallet_Code;//托盘编号
|
||||
string EngineType;//机型
|
||||
string EngineID;//工件编号
|
||||
|
||||
//上线工位清MES传递机型信号
|
||||
MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false);
|
||||
|
||||
MIS_BASE.Read_QualityData_Read_CF(OpName, out MesRead);
|
||||
//第一步,判断允许保存和保存完成信号是否全部被清空,若未清空,则通知复位MES&PLC
|
||||
if (MesRead)
|
||||
{
|
||||
//未能清空信号,请求复位
|
||||
string msg = "【" + OpName + "】" + "未能清空MesRead信号,请求复位!";
|
||||
SendMessageFun.SendInfomation("AskReset", "1", OpName);
|
||||
MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "PLC传递机型 " + msg, MisDataSaveDate.Helper.MesLogType.ERROR);
|
||||
return;
|
||||
}
|
||||
string OrderForm;
|
||||
MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm);
|
||||
|
||||
// 读取MES区数据 校验MES区数据是否符合 同时判断是否此工件已工作过,若已工作过则弹出弹窗提示
|
||||
if (EngineID != "" & EngineType != "" & OrderForm != "")
|
||||
{
|
||||
DataTable checkTable = MisDataFun.WorkOrderCheck(OpName, EngineID, OrderForm, EngineType);
|
||||
int result = Convert.ToInt32(checkTable.Rows[0]["result"]);
|
||||
//int result = 1;
|
||||
string resultMsg = checkTable.Rows[0]["msg"].ToString();
|
||||
if (result != 2)
|
||||
{
|
||||
if (result == 3)
|
||||
{
|
||||
string msg = "【" + OpName + "】" + resultMsg;
|
||||
MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg);
|
||||
SendMessage.AsyncSendMessage_Notice(OpName, msg);
|
||||
MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "PLC传递机型 "+ msg, MisDataSaveDate.Helper.MesLogType.ERROR);
|
||||
}
|
||||
int parType = Convert.ToInt32(checkTable.Rows[0]["小机型"]);
|
||||
EngineTypeID = Convert.ToInt32(checkTable.Rows[0]["型号代码"]);
|
||||
MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID);
|
||||
|
||||
MIS_BASE.WritePLC(115, OpName, parType); // 托盘类型 1 静 2 动 3 拐
|
||||
|
||||
//写入到数据库的[北汽福田工位状态监控MOBY]表中
|
||||
MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineTypeID, EngineTypeID.ToString());
|
||||
MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineType, EngineType);
|
||||
MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineID, EngineID);
|
||||
MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.OrderForm, OrderForm);
|
||||
MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.PartPallet_Code, PartPallet_Code.ToString());
|
||||
MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineTypeID_MES, EngineTypeID.ToString());
|
||||
MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineType_MES, EngineType);
|
||||
MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.EngineID_MES, EngineID);
|
||||
MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.OrderForm_MES, OrderForm);
|
||||
EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, PartPallet_Code, OrderForm);
|
||||
SendMessage.ShowMoby(OpName);
|
||||
SendMessageFun.SendMessage("5123", "1111", OpName);
|
||||
}
|
||||
else
|
||||
{
|
||||
string msg = "【" + OpName + "】" + resultMsg;
|
||||
SendMessage.AsyncSendMessage_Notice(OpName, msg);
|
||||
MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "PLC传递机型 " + msg, MisDataSaveDate.Helper.MesLogType.ERROR);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
string msg = "【" + OpName + "】" + "读取信息存在空值!";
|
||||
MisDataSaveDate.Helper.ApiLogHelper.SaveMesLog(OpName, "PLC传递机型 " + msg, MisDataSaveDate.Helper.MesLogType.ERROR);
|
||||
SendMessage.AsyncSendMessage_Notice(OpName, msg);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
MIS_BASE.Write_FixAllow(OpName, false);
|
||||
MIS_BASE.Write_EngineTypeID_MES(OpName, 0);
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "Function08:EngineTypeGetOver_PLC");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
62
MisDataFunction/Function1052/OpcServer/MaterialsVerify.cs
Normal file
62
MisDataFunction/Function1052/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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
89
MisDataFunction/Function1052/OpcServer/MesRead.cs
Normal file
89
MisDataFunction/Function1052/OpcServer/MesRead.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using MesServerWork;
|
||||
using MisDataFunDll;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
//using SystemFramework;
|
||||
|
||||
namespace MesServerFunctions
|
||||
{
|
||||
partial class FunctionMES
|
||||
{
|
||||
/// <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);
|
||||
//MIS_BASE.GetEngineTypeFromPLC_MES(OpName, out EngineTypeID_MES, out EngineType_MES, out EngineID_MES, out OrderForm_MES);
|
||||
//保存数据到线首表 先保存到 北汽福田变速器序列号总线上线 用于之前判断是否重号
|
||||
// 保存质量数据
|
||||
qualityMask = MisDataSaveDateMesRead.Funtion.MesRead(OpName, tagValue.ToString(), msgEvent.TagID.ToString());
|
||||
|
||||
// 保存物料数据
|
||||
MisDataFun.Material_Insert(OpName, qualityMask);
|
||||
|
||||
// 测量数据发动机在线状态
|
||||
MisDataFun.WorkStartInsert(OpName, qualityMask);
|
||||
|
||||
// 存追溯表数据
|
||||
MisDataFun.WorkOrderOpWorkOver(OpName, EngineID, OrderForm);
|
||||
|
||||
// 推送质量数据到MES的页面
|
||||
SendMessageFun.SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName);
|
||||
|
||||
//对应手动工位的
|
||||
//MIS_BASE.Write_ConfirmOkGo(OpName, true);
|
||||
//通知设备,MES的质量数据(和物料数据)保存完成
|
||||
MIS_BASE.Write_MesReadOver(OpName, true);
|
||||
//MIS_BASE.Write_MaterialVerifyOver(OpName, true);
|
||||
//统计在线产量,在线节拍
|
||||
SendMessage.SendActuallyCount(OpName, tagValue);
|
||||
|
||||
//调用工厂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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
72
MisDataFunction/Function1052/OpcServer/ReqEarlyFeeding.cs
Normal file
72
MisDataFunction/Function1052/OpcServer/ReqEarlyFeeding.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Threading;
|
||||
using MesServerWork;
|
||||
using MisDataFunDll;
|
||||
|
||||
namespace MesServerFunctions
|
||||
{
|
||||
partial class FunctionMES
|
||||
{
|
||||
/// <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/Function1052/OpcServer/ReqTestResistor.cs
Normal file
238
MisDataFunction/Function1052/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("连接电阻仪超时");
|
||||
}
|
||||
|
||||
if (tcpClient.Connected)
|
||||
{
|
||||
MyLog4Net.MyLogHelper.Info("电阻测试", "电阻仪链接成功!");
|
||||
await SendCommand(tcpClient, "01 09 64 00 05 00 00 00 00 00 73");
|
||||
|
||||
await Task.Delay(DEFAULT_TIMEOUT);
|
||||
|
||||
var readTask = Task.Run(() => Read(tcpClient));
|
||||
|
||||
int count = 0;
|
||||
while (!_isTestOk && count < MAX_RETRY_COUNT)
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
await SendCommand(tcpClient, "03 01 04");
|
||||
count++;
|
||||
}
|
||||
|
||||
if (count >= MAX_RETRY_COUNT && !_isTestOk)
|
||||
{
|
||||
MyLog4Net.MyLogHelper.Error("电阻测试", "测试超时,未收到有效结果");
|
||||
ErrPLCValues();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MyLog4Net.MyLogHelper.Error("电阻测试", $"测试过程发生错误: {ex.Message}");
|
||||
ErrPLCValues();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (tcpClient != null)
|
||||
{
|
||||
tcpClient.Close();
|
||||
MyLog4Net.MyLogHelper.Info("电阻测试", "电阻仪链接关闭");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetPLCValues()
|
||||
{
|
||||
lock (_lockObject)
|
||||
{
|
||||
MIS_BASE.WritePLC(202, _opName, 0);
|
||||
MIS_BASE.WritePLC(203, _opName, 0);
|
||||
MIS_BASE.WritePLC(204, _opName, 0);
|
||||
MIS_BASE.WritePLC(34, _opName, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void ErrPLCValues()
|
||||
{
|
||||
lock (_lockObject)
|
||||
{
|
||||
MIS_BASE.WritePLC(202, _opName, 0);
|
||||
MIS_BASE.WritePLC(203, _opName, 0);
|
||||
MIS_BASE.WritePLC(204, _opName, 0);
|
||||
MIS_BASE.WritePLC(34, _opName, true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <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("电阻测试Send", $"发送命令: {command}");
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
MyLog4Net.MyLogHelper.Error("电阻测试Send", $"发送命令失败: {err.Message}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void Read(TcpClient tcpClient)
|
||||
{
|
||||
try
|
||||
{
|
||||
while (!_isTestOk)
|
||||
{
|
||||
if (tcpClient != null && tcpClient.Connected)
|
||||
{
|
||||
byte[] byteCommand = new byte[1024];
|
||||
int icommand = tcpClient.Client.Receive(byteCommand);
|
||||
string hexString = BitConverter.ToString(byteCommand, 0, icommand).Replace("-", " ");
|
||||
|
||||
if (hexString.Length == RESULT_LENGTH)
|
||||
{
|
||||
DataAnalysis(hexString);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
MyLog4Net.MyLogHelper.Error("电阻测试Read", err.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void DataAnalysis(string hexString)
|
||||
{
|
||||
try
|
||||
{
|
||||
var byteArray = HexStringToByteArray(hexString.Replace(" ", ""));
|
||||
var start = 2;
|
||||
|
||||
var 状态 = BitConverter.ToInt32(byteArray.Skip(start + 0).Take(4).ToArray(), 0);
|
||||
if (状态 != 2) return;
|
||||
var 电压V = BitConverter.ToDouble(byteArray.Skip(start + 4).Take(8).ToArray(), 0);
|
||||
var 电流A = BitConverter.ToDouble(byteArray.Skip(start + 12).Take(8).ToArray(), 0);
|
||||
var 电阻uΩ = BitConverter.ToDouble(byteArray.Skip(start + 20).Take(8).ToArray(), 0) * 1000000;
|
||||
var yyyy = BitConverter.ToUInt16(byteArray.Skip(start + 28).Take(2).ToArray(), 0);
|
||||
var MM = byteArray[start + 30];
|
||||
var dd = byteArray[start + 31];
|
||||
var HH = byteArray[start + 32];
|
||||
var mm = byteArray[start + 33];
|
||||
var ss = byteArray[start + 34];
|
||||
var datetime = $"{yyyy}-{MM}-{dd} {HH}:{mm}:{ss}";
|
||||
|
||||
lock (_lockObject)
|
||||
{
|
||||
MIS_BASE.WritePLC(202, _opName, 电压V);
|
||||
MIS_BASE.WritePLC(203, _opName, 电流A);
|
||||
MIS_BASE.WritePLC(204, _opName, 电阻uΩ);
|
||||
MIS_BASE.WritePLC(34, _opName, true);
|
||||
_isTestOk = true;
|
||||
}
|
||||
|
||||
MyLog4Net.MyLogHelper.Info("电阻测试", $"电阻结果写入完毕 【电压】{电压V}【电流】{电流A}【电阻】{电阻uΩ}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MyLog4Net.MyLogHelper.Error("电阻测试DataAnalysis", $"数据分析错误: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] HexStringToByteArray(string hex)
|
||||
{
|
||||
if (hex.Length % 2 != 0)
|
||||
{
|
||||
throw new ArgumentException("十六进制字符串长度必须是偶数");
|
||||
}
|
||||
|
||||
byte[] bytes = new byte[hex.Length / 2];
|
||||
for (int i = 0; i < hex.Length; i += 2)
|
||||
{
|
||||
bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
352
MisDataFunction/Function1052/OpcServer/WebSubmit.cs
Normal file
352
MisDataFunction/Function1052/OpcServer/WebSubmit.cs
Normal file
@@ -0,0 +1,352 @@
|
||||
using System;
|
||||
using MesServerWork;
|
||||
using MisDataSaveDate;
|
||||
using System.Collections;
|
||||
using MisDataFunDll;
|
||||
|
||||
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
|
||||
{
|
||||
DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e;
|
||||
string OpName=Convert.ToString(msgEvent.OpName);
|
||||
string Content = Convert.ToString(msgEvent.TagValue);
|
||||
|
||||
string[] dataArray = Content.Split('|');
|
||||
if (dataArray.Length != 2)
|
||||
return;
|
||||
//消息类型
|
||||
string m_Command = dataArray[0].ToString();
|
||||
//消息参数
|
||||
string m_Value = dataArray[1].ToString();
|
||||
//消息参数数量
|
||||
string[] m_Value_array = m_Value.Split('&');
|
||||
//消息参数长度
|
||||
int m_Value_length = m_Value_array.Length;
|
||||
|
||||
//工件信息
|
||||
string engineID = "";
|
||||
if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null)
|
||||
{
|
||||
MIS_BASE.InitHashtable_MesServerCode();
|
||||
}
|
||||
if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName))
|
||||
{
|
||||
engineID = MIS_BASE.hashtable_EngineGetOver_EngineID[OpName].ToString();
|
||||
}
|
||||
|
||||
DeviceDriver_BasicData.CustomeEvetnArgs _e = new DeviceDriver_BasicData.CustomeEvetnArgs();
|
||||
_e.OpName = OpName;
|
||||
_e.TagValue = m_Value;
|
||||
|
||||
string msg;
|
||||
bool bolVal;
|
||||
|
||||
//根据请求的命令处理逻辑
|
||||
switch (m_Command)
|
||||
{
|
||||
case "Barcode":
|
||||
if (m_Value_length > 1) return;
|
||||
fun_Barcode(_e);
|
||||
break;
|
||||
case "OnLineState"://在线0、离线1、屏蔽2
|
||||
try
|
||||
{
|
||||
if (m_Value_length > 1) return;
|
||||
int a = Convert.ToInt32(m_Value);
|
||||
if (a <= 2)
|
||||
{
|
||||
//MisDataFun.IsOnLine_Update(OpName, m_Value.ToString());
|
||||
MIS_BASE.Write_OnLineState(OpName, Convert.ToInt32(m_Value));
|
||||
if (a == 2) SendMessage.AsyncSendMessage_Notice(OpName, "屏蔽MES!");
|
||||
if (a == 0) SendMessage.AsyncSendMessage_Notice(OpName, "启用MES!");
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
case "Reset"://复位,将MES所有的信息都复位了
|
||||
SetMoby(OpName);//将MES所有信号清空
|
||||
break;
|
||||
case "FixAllow"://重新拧紧
|
||||
MIS_BASE.Write_FixAllow(OpName, false);
|
||||
MIS_BASE.Write_FixAllow(OpName, true);
|
||||
break;
|
||||
case "IsAutoGetEngineID"://自动手动申请编号(线首)
|
||||
if (m_Value_length > 1) return;
|
||||
MIS_BASE.Write_IsAutoGetEngineID(OpName, Convert.ToInt32(m_Value));
|
||||
break;
|
||||
case "PartPalletGoOver"://空托盘放行
|
||||
int Is_PartPalletGoOver;
|
||||
MIS_BASE.Read_PartPalletGoOver(OpName, out Is_PartPalletGoOver);
|
||||
if (Is_PartPalletGoOver == 1)
|
||||
{
|
||||
MIS_BASE.Write_PartPalletGoOver(OpName, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
MIS_BASE.Write_PartPalletGoOver(OpName,0);
|
||||
}
|
||||
break;
|
||||
case "SetMoby"://清空托盘(线首)
|
||||
SetMoby(OpName);//将MES所有信号清空
|
||||
//MIS_BASE.Write_PartPalletCode_PLC(OpName, 1);
|
||||
break;
|
||||
case "RepairUplineMES"://返修上线
|
||||
MIS_BASE.Write_RepairUpline_MES(OpName, true);
|
||||
break;
|
||||
case "CancelRepair"://将返修件置为正常件
|
||||
|
||||
break;
|
||||
case "PartPalletCode"://申请写入托盘号
|
||||
//MIS_BASE.Write_PartPalletCode_PLC(OpName, 1);
|
||||
break;
|
||||
case "WritePartPalletCode"://写入托盘号
|
||||
if (m_Value_length > 1) return;
|
||||
MIS_BASE.Write_PalletCode(OpName, Convert.ToInt32(m_Value));
|
||||
break;
|
||||
case "Normal"://启用正常拧紧工位
|
||||
MIS_BASE.Write_Normal(OpName, 1);
|
||||
MIS_BASE.Write_UnNormal(OpName, 0);
|
||||
break;
|
||||
case "UnNormal"://启用备用拧紧工位
|
||||
MIS_BASE.Write_Normal(OpName, 0);
|
||||
MIS_BASE.Write_UnNormal(OpName, 1);
|
||||
break;
|
||||
case "ResetDevice"://复位设备
|
||||
MIS_BASE.Write_ResetDevice(OpName, true);
|
||||
System.Threading.Thread.Sleep(1000);
|
||||
MIS_BASE.Write_ResetDevice(OpName, false);
|
||||
break;
|
||||
case "IsNeedRepaire"://返修上线(返修上线点)
|
||||
if (Convert.ToInt32(m_Value) == 1)
|
||||
{
|
||||
//修改托盘状态
|
||||
MIS_BASE.Write_PalletInfo(OpName, 3);
|
||||
//通知修改成功
|
||||
MIS_BASE.Write_UpdatePalletOK(OpName, true);
|
||||
IsNeedRepaire_OK(OpName);
|
||||
|
||||
}
|
||||
else if (Convert.ToInt32(m_Value) == 0)
|
||||
{
|
||||
//通知修改成功
|
||||
MIS_BASE.Write_UpdatePalletOK(OpName, true);
|
||||
//直接给出工作完成
|
||||
MIS_BASE.Write_MaterialVerifyOver(OpName, true);
|
||||
}
|
||||
else
|
||||
{ }
|
||||
|
||||
break;
|
||||
case "ContinueMatch":
|
||||
//BaseDataSystemMES.QualityVerifyStatus_Hash_Write(OpName, true);
|
||||
break;
|
||||
//初始化网页信号
|
||||
case "IniSingalToWeb":
|
||||
InitializeSingalToWeb(OpName);
|
||||
break;
|
||||
case "Reset_Engine"://返修上线(返修上线点)
|
||||
SetMoby(OpName);//将MES所有信号清空
|
||||
//fun_EngineTypeGetOverPLC(OpName, 0);
|
||||
//fun_EngineTypeGetOverPLC(OpName, 1);
|
||||
break;
|
||||
case "twoWorkSkip"://重新工作工件跳过工作(重新工作工件)
|
||||
//工作完成
|
||||
EngineTypeGetOver_PLC_Work_Skip(OpName);
|
||||
break;
|
||||
case "twoWork"://重新工作工件重新工作(重新工作工件)
|
||||
//允许工作
|
||||
EngineTypeGetOver_PLC_Work_two(OpName);
|
||||
break;
|
||||
// 检查项 检查完成
|
||||
case "checkWorkOver":
|
||||
MIS_BASE.WritePLC(30, OpName, 1);
|
||||
string message = "MES|checkWorkOverIsShow|" + OpName + "|" + 0;
|
||||
SendMessage.AsyncSendMessage(message);
|
||||
break;
|
||||
// 跳过交互
|
||||
case "skipWork":
|
||||
// 判断是否有工件到位
|
||||
MIS_BASE.Read_WorkStart(OpName, out bolVal);
|
||||
if (bolVal)
|
||||
{
|
||||
MIS_BASE.Write_EngineTypeGetOver_MES(OpName, true); // 传递机型
|
||||
MIS_BASE.Write_FixAllow(OpName, true); // 允许工作
|
||||
MIS_BASE.WritePLC(30, OpName, 1); // 检查完成
|
||||
MIS_BASE.Write_MesReadOver(OpName, true); // 保存完成
|
||||
MIS_BASE.Write_MaterialVerifyOver(OpName, true); // 工作完成
|
||||
msg = "【" + OpName + "】" + "跳过交互完成!";
|
||||
SendMessage.AsyncSendMessage_Notice(OpName, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = "【" + OpName + "】" + "当前无工件到位信号,请确认是否存在工件!";
|
||||
SendMessage.AsyncSendMessage_Notice(OpName, msg);
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
catch(Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "Function02:WebSubmit");
|
||||
}
|
||||
}
|
||||
private void SetMoby(string OpName)
|
||||
{
|
||||
try
|
||||
{
|
||||
//清空Moby时,需要将MES信号清空
|
||||
MIS_BASE.Write_ClearMesMoby(OpName);
|
||||
|
||||
MisDataFun.MesServer_Process_EngineTypeOver(OpName);
|
||||
|
||||
SendMessageFun.SendMessage("5123", "1111", OpName);
|
||||
|
||||
MIS_BASE.Write_ResetDevice(OpName, true);
|
||||
System.Threading.Thread.Sleep(1000);
|
||||
MIS_BASE.Write_ResetDevice(OpName, false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void sendmessage(string OpName, int tagValue, string Command)
|
||||
{
|
||||
string SendMessage;
|
||||
SendMessage = "MES|" + Command + "|" + OpName + "|" + tagValue;
|
||||
SendMessageFun.AsyncSendMessage(SendMessage);
|
||||
|
||||
}
|
||||
|
||||
/// 网页重现登录,恢复关闭前的页面状态
|
||||
/// </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);
|
||||
// 物料信息 物料信息
|
||||
SendMessage.MaterialList(Opname);
|
||||
|
||||
// 新增查询PLC直通状态 网页显示
|
||||
//MIS_BASE.Read_TagTypeID(63, Opname, out S_plcStatus);
|
||||
InitAlarm(Opname);
|
||||
}
|
||||
|
||||
private void InitAlarm(string Opname)
|
||||
{
|
||||
FuntionMesRead.Alarm_InitAlarm_Send(Opname, out Hashtable ht);
|
||||
foreach (DictionaryEntry kv in ht)
|
||||
{
|
||||
var TagID = kv.Key.ToString();
|
||||
var TagValue = kv.Value.ToString();
|
||||
FuntionMesRead.Send_AlarmMsg(TagID, TagValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void InitOpPosion(string Opname)
|
||||
{
|
||||
int S_WorkCheckOver = Convert.ToInt32(MIS_BASE.ReadPLC(30, Opname));
|
||||
string S_WorkCheckOver_Msg = "MES|checkWorkOverIsShow|" + Opname + "|" + S_WorkCheckOver;
|
||||
SendMessage.AsyncSendMessage(S_WorkCheckOver_Msg);
|
||||
|
||||
bool S_WorkStart;//工件到位 DBX0.1
|
||||
MIS_BASE.Read_WorkStart(Opname, out S_WorkStart);
|
||||
if (S_WorkStart == true)
|
||||
{
|
||||
SendMessageFun.SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname);
|
||||
}
|
||||
//----------------------------------------------------
|
||||
bool S_PartLoad;//申请上线
|
||||
MIS_BASE.Read_PartLoad(Opname, out S_PartLoad);
|
||||
if (S_PartLoad == true)
|
||||
{
|
||||
SendMessageFun.SendInfomation("PartLoad", Convert.ToString(Convert.ToInt32(S_PartLoad)), Opname);
|
||||
}
|
||||
//----------------------------------------------------
|
||||
bool S_EngineGetOver;//传递机型 DBX0.4
|
||||
MIS_BASE.Read_EngineGetOver_PLC(Opname, out S_EngineGetOver);
|
||||
if (S_EngineGetOver == true)
|
||||
{
|
||||
SendMessageFun.SendInfomation("EngineTypeGetOverPLC", Convert.ToString(Convert.ToInt32(S_EngineGetOver)), Opname);
|
||||
|
||||
//5 显示订单、机型信息 线首工位用
|
||||
SendMessage.ShowMoby_FirstOpName(Opname);
|
||||
//界面显示物料信息
|
||||
SendMessage.MaterialList_FirstOpName(Opname);
|
||||
}
|
||||
//----------------------------------------------------
|
||||
bool S_FixAllow;//允许工作 DBX3.1
|
||||
MIS_BASE.Read_FixAllow(Opname, out S_FixAllow);
|
||||
if (S_FixAllow == true)
|
||||
{
|
||||
SendMessageFun.SendInfomation("FixAllow", Convert.ToString(Convert.ToInt32(S_FixAllow)), Opname);
|
||||
}
|
||||
//----------------------------------------------------
|
||||
bool S_MesRead;//允许保存 DBX3.1
|
||||
MIS_BASE.Read_QualityData_Read_CF(Opname, out S_MesRead);
|
||||
if (S_MesRead == true)
|
||||
{
|
||||
SendMessageFun.SendInfomation("MesRead", Convert.ToString(Convert.ToInt32(S_MesRead)), Opname);
|
||||
}
|
||||
//----------------------------------------------------
|
||||
bool S_ReadOver;//保存完成
|
||||
MIS_BASE.Read_MesReadOver(Opname, out S_ReadOver);
|
||||
if (S_ReadOver == true)
|
||||
{
|
||||
SendMessageFun.SendInfomation("MesReadOver", Convert.ToString(Convert.ToInt32(S_ReadOver)), Opname);
|
||||
}
|
||||
//----------------------------------------------------
|
||||
bool S_MaterialVerifyOver;//工作完成 DBX2.3
|
||||
MIS_BASE.Read_MaterialVerifyOver(Opname, out S_MaterialVerifyOver);
|
||||
if (S_MaterialVerifyOver == true)
|
||||
{
|
||||
SendMessageFun.SendInfomation("MaterialVerifyOver", Convert.ToString(Convert.ToInt32(S_MaterialVerifyOver)), Opname);
|
||||
}
|
||||
//----------------------------------------------------
|
||||
int S_QualityMask;//合格标志 DBX588
|
||||
MIS_BASE.Read_QualityMask(Opname, out S_QualityMask);
|
||||
if (S_QualityMask == 1)
|
||||
{
|
||||
SendMessageFun.SendInfomation("QualityMask", Convert.ToString(Convert.ToInt32(S_QualityMask)), Opname);
|
||||
}
|
||||
//----------------------------------------------------
|
||||
string S_plcStatus = "false";//DBX501.5 PLC直通,1 强制放行 0 正常循环
|
||||
if (S_plcStatus.ToLower() == "false")
|
||||
{
|
||||
SendMessageFun.SendInfomation("PlcStatus", "0", Opname);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessageFun.SendInfomation("PlcStatus", "1", Opname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
44
MisDataFunction/Function1052/OpcServer/WorkIsOk.cs
Normal file
44
MisDataFunction/Function1052/OpcServer/WorkIsOk.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using MesServerWork;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MesServerFunctions
|
||||
{
|
||||
partial class FunctionMES
|
||||
{
|
||||
/// <summary>
|
||||
/// 工位合格标志
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
private void IsOk(object e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DeviceDriver_BasicData.CustomeEvetnArgs msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e;
|
||||
string OpName = Convert.ToString(msgEvent.OpName);
|
||||
int tagValue = Convert.ToInt32(msgEvent.TagValue);
|
||||
|
||||
int qualityMask;
|
||||
MIS_BASE.Read_QualityMask(OpName, out qualityMask);
|
||||
//判断是否合格
|
||||
if (qualityMask == 1)
|
||||
{
|
||||
qualityMask = 1;
|
||||
} else {
|
||||
qualityMask = 0;
|
||||
}
|
||||
//通知WEB修改状态
|
||||
string message = "MES|QualityMask|" + OpName + "|" + qualityMask.ToString();
|
||||
SendMessage.AsyncSendMessage(message);
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "Function02:FalseGO");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
57
MisDataFunction/Function1052/OpcServer/WorkStart.cs
Normal file
57
MisDataFunction/Function1052/OpcServer/WorkStart.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using MesServerWork;
|
||||
using MisDataFunDll;
|
||||
using System;
|
||||
using System.Threading;
|
||||
//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 > 0)
|
||||
{
|
||||
MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.WorkStartIn, DateTime.Now.ToString());
|
||||
MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.WorkStart, tagValue.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
MIS_BASE.Write_EngineTypeID_MES(OpName, 0);
|
||||
MIS_BASE.Write_EngineType_MES(OpName, "");
|
||||
MIS_BASE.Write_EngineID_MES(OpName, "");
|
||||
MIS_BASE.Write_OrderForm_MES(OpName, "");
|
||||
|
||||
MisDataFun.OpName_MIS_MOBY_Insert(OpName, MisDataFun.MobyTagType.WorkStartOut, DateTime.Now.ToString());
|
||||
MIS_BASE.Write_MesReadOver(OpName, false);
|
||||
MIS_BASE.Write_ConfirmOkGo(OpName, false);
|
||||
MIS_BASE.Write_FixAllow(OpName, false);
|
||||
MIS_BASE.Write_ConfirmOkGo(OpName, false);
|
||||
MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false);
|
||||
//工作完成
|
||||
MIS_BASE.Write_MaterialVerifyOver(OpName, false);
|
||||
|
||||
// 检查项完成
|
||||
MIS_BASE.Write_TagTypeID(30, OpName, 0);
|
||||
string message = "MES|checkWorkOverIsShow|" + OpName + "|" + 0;
|
||||
SendMessage.AsyncSendMessage(message);
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "Function02:WorkStart");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
BIN
MisDataFunction/Function1052/OpcServer/vssver2.scc
Normal file
BIN
MisDataFunction/Function1052/OpcServer/vssver2.scc
Normal file
Binary file not shown.
Reference in New Issue
Block a user