You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

258 lines
12 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using Mesnac.Compressor.Data;
using Mesnac.Compressor.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mesnac.Compressor.Station
{
public class NormarlStation : Common, IStation
{
public bool PrepareWork(StationInfo station)
{
//主线产品码未扫描到条码下发PLC报警
if (station.stationID == "24")
{
if (string.IsNullOrEmpty(station.Data.ProductBarcode) || station.Data.ProductBarcode.Equals("ERROR"))
{
ICSharpCode.Core.LoggingService.Error(station.StationCode + "未收到PLC传递的条码");
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.NoBarCode);
return false;
}
if (station.Data.Restart)
{
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.OK);
return Chongtou(station);
}
}
//是否重投
if (station.Data.Restart)
{
return Chongtou(station);
}
//是否当前工位重做
if (station.Data.ReWork)
{
ICSharpCode.Core.LoggingService.Debug(station.StationCode + "检测到当前工位重做信号,下发可以工作信号");
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.OK);
return true;
}
bool iflag = IsOpen(station.stationID);
if (iflag)
{
#region 测试暂时去掉
//动静盘工位支线上线互锁逻辑
if (station.stationID == "13")
{
//根据静盘条码判断在上工位是否合格不合格则下发NG物料拿取
string JP_BarCode = station.Data.subLineList[4].barcode;
//获取静盘条码在上工位是否合格(该工位需要试错,由于不合格品较多,暂时屏蔽互锁功能)
//if (!GetJPProductionQuality(JP_BarCode))
//{
// ICSharpCode.Core.LoggingService.Debug(station.StationCode + "静盘检测工位不合格");
// this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.TakeNG);
// return false;
//}
//动盘扫码开关是否打开
if (!station.Data.DP_OpenFlag)
{
//判断动盘与静盘是否匹配
string DP_BarCode = station.Data.subLineList[3].barcode;
//根据静盘码查询库表中动静盘关系
DJPBarCodeRelationShip dJPBarCodeRelationShip = new DJPBarCodeRelationShip();
dJPBarCodeRelationShip = GetProductQuality(JP_BarCode);
if (dJPBarCodeRelationShip.DPBarCode != "" && dJPBarCodeRelationShip.DPBarCode != null)
{
if (DP_BarCode != dJPBarCodeRelationShip.DPBarCode || JP_BarCode != dJPBarCodeRelationShip.JPBarCode)
{
ICSharpCode.Core.LoggingService.Error(station.StationCode + "静盘不匹配");
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.MaterialNoMatch);
return false;
}
else
{
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.OK);
return true;
}
}
//应该不存在这种情况
else
{
ICSharpCode.Core.LoggingService.Error(station.StationCode + "动静盘没有动盘码");
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.PreNoWork);
return false;
}
}
//动盘扫码枪未打开
else
{
//只判断静盘在上工位是否完成
string LastWorkInfo = LastWorkProductionInfo(station.Data.subLineList[4].barcode, "T_RP_StationPara_S320");
if (string.IsNullOrEmpty(LastWorkInfo))
{
ICSharpCode.Core.LoggingService.Error(station.StationCode + "检测无上工位信息");
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.PreNoWork);
return false;
}
else
{
//NG物料拿取
if (LastWorkInfo != "1")
{
ICSharpCode.Core.LoggingService.Error(station.StationCode + "检测上工位不合格");
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.TakeNG);
return false;
}
}
}
}
else
{
WorkTray tray = new WorkTray();
//如果托盘是空的,直接放行这里可能有个问题PLC已经判断不是空托盘了如果是空托盘肯定是系统数据有问题
if (this.TrayIsNull(station, out tray))
{
ICSharpCode.Core.LoggingService.Debug(station.StationCode + "检测到托盘未绑定");
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.OK);
return true;
}
//判断当前工位是否已经合格
//if (this.CurrentStationInfo(station, tray.RfidNum))
//{
// ICSharpCode.Core.LoggingService.Debug(station.StationCode + "检测当前工位已合格");
// this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.NG);
// return false;
//}
//这里应该判断一下是不是重投的
//if (IsReStartProduction(station.Data.semibacode))
//{
// ICSharpCode.Core.LoggingService.Debug(station.StationCode + "检测为重投");
// if (station.stationID == "4")
// {
// this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.NG);
// return false;
// }
//}
//这里要过滤掉重投的,不然重投的到本工位会报警
bool ReSatrtWork = IsReStartWork(station);
//如果是重投并且到了重做工位(此处并不是重投口,而是对应拆解台选择的重做工位)
if (ReSatrtWork)
{
//已经重投到了本工位,可以工作
//获取重投的工位号
string CurrentStationID = GetCurrentStationByRFID(tray.RfidNum);
if (int.Parse(station.stationID) < int.Parse(CurrentStationID))
{
ICSharpCode.Core.LoggingService.Debug(station.StationCode + "检测到未到重做工位");
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.NG);
return false;
}
else if(int.Parse(station.stationID) == int.Parse(CurrentStationID))
{
ICSharpCode.Core.LoggingService.Debug(station.StationCode + "检测到已到重做工位");
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.OK);
return false;
}
else if(int.Parse(station.stationID) > int.Parse(CurrentStationID))
{
//这里需要判断一下上工位开关是否打开
string preStationID = GetFirstStationIDByStationID(station.stationID);
bool iPreflag = IsOpen(preStationID);
if (iPreflag)
{
if (!this.PreStationInfo(station, tray.RfidNum))
{
ICSharpCode.Core.LoggingService.Debug(station.StationCode + "检测无上工位信息");
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.PreNoWork);
return false;
}
}
}
}
else
{
//这里需要判断一下上工位开关是否打开
string preStationID = GetFirstStationIDByStationID(station.stationID);
if (!string.IsNullOrEmpty(preStationID))
{
bool iPreflag = IsOpen(preStationID);
if (iPreflag)
{
//判断上一工位是否有工作信息
if (!this.PreStationInfo(station, tray.RfidNum))
{
ICSharpCode.Core.LoggingService.Debug(station.StationCode + "检测无上工位信息");
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.PreNoWork);
return false;
}
//如果不是空托盘判断当前是否合格f
if (tray.OKNG != 1)
{
ICSharpCode.Core.LoggingService.Debug(station.StationCode + "检测上工位信息不合格");
//这里要判断当前工位是否是NG拿取工位=====
if (station.NGTakeStation)
{
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.TakeNG);
//托盘状态清空(这里加了当前工位重做逻辑,不需要清空)
//UpdateTray(tray.RfidNum, tray.RfidNum, "", "", 0);
}
else
{
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.NG);
}
return false;
}
}
}
}
}
#endregion
}
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.OK);
//这里加一个物料是否匹配=======//还要加判断,当前工位是否需要判断
return true;
}
public bool HandleData(StationInfo station)
{
try
{
//暂时不用
//if (!CheckNewData(station, ""))
//{
// ICSharpCode.Core.LoggingService.Debug("工位:" + station.StationCode + "的RFID" + station.Data.RFIDNo + "数据已上传。条码号:" + station.Data.ProductBarcode + " 任务号:" + station.Data.MaskID.ToString());
// return false;
//}
//保存数据
base.SaveStationData(station,StationType.NormarlStation);
}
catch (Exception e)
{
ICSharpCode.Core.LoggingService.Info(e.ToString());
return false;
}
finally
{
//这里要加一个OK放行
FinishSavePLCWork(station);
}
return true;
}
}
}