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.

189 lines
8.6 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.Data;
using System.Linq;
using System.Text;
using System.Threading;
namespace Mesnac.Compressor.Station
{
/// <summary>
/// 下线工位
/// </summary>
public class LineEnd : Common, IStation
{
public bool PrepareWork(StationInfo station)
{
if (station.stationID == "10")
{
//重投到当前工位
ICSharpCode.Core.LoggingService.Debug(station.StationCode + "收到PLC传递的托盘号:" + station.Data.RFIDNo);
string Abarcode = GetTraySemiBarcode(station.Data.RFIDNo);
if (!string.IsNullOrEmpty(Abarcode))
{
string ISDis = getChongTouState("", Abarcode);
if (!string.IsNullOrEmpty(ISDis))
{
if (ISDis == "4")
{
//更新工位信息并放行
UpdateTray(station.stationID, station.Data.RFIDNo);
//更新当前工位
UpdateTraceReStartStation(station.stationID, Abarcode);
//解绑
UnbandTray(station);
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.FangXing);
return false;
}
}
}
//bool ReSatrtWork = IsReStartWork(station);
//if (ReSatrtWork)
//{
// string Abarcode = GetTraySemiBarcode(station.Data.RFIDNo);
// //更新工位信息并放行
// UpdateTray(station.stationID, station.Data.RFIDNo);
// //更新当前工位
// UpdateTraceReStartStation(station.stationID, Abarcode);
// //解绑
// UnbandTray(station);
// this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.FangXing);
// return false;
//}
}
//是否当前工位重做
//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)
{
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;
}
//这里要过滤掉重投的,不然重投的到本工位会报警
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.FangXing);
// 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;
//}
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);
Thread.Sleep(1000);
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.FangXing);
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);
Thread.Sleep(1000);
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.FangXing);
return false;
}
//如果不是空托盘判断当前是否合格f
if (tray.OKNG != 1)
{
ICSharpCode.Core.LoggingService.Debug(station.StationCode + "检测上工位信息不合格");
//这里要判断当前工位是否是NG拿取工位=====
if (station.NGTakeStation)
{
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.TakeNG);
Thread.Sleep(1000);
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.FangXing);
//托盘状态清空(这里加了当前工位重做逻辑,不需要清空)
//UpdateTray(tray.RfidNum, tray.RfidNum, "", "", 0);
}
else
{
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.TakeNG);
Thread.Sleep(1000);
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.FangXing);
}
return false;
}
}
}
}
}
this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.OK);
return true;
}
public new bool HandleData(StationInfo station)
{
try
{
//保存数据
base.SaveStationData(station,StationType.LineEnd);
UnbandTray(station);
ICSharpCode.Core.LoggingService.Debug(station.stationID +"托盘解绑:" + station.Data.RFIDNo);
}
catch (Exception e)
{
ICSharpCode.Core.LoggingService.Info(e.ToString());
return false;
}
finally
{
//这里要加一个OK放行
FinishSavePLCWork(station);
}
return true;
}
}
}