using Mesnac.Compressor.Entity; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Mesnac.Compressor.Station { public class ChangeLineStation : Common, IStation { /// /// 只判断是否有上一工位信息,校验与计划是否匹配 /// /// /// public bool PrepareWork(StationInfo station) { //验证一下换线时是否能取到上工位信息 try { //未扫描条码报警 if (station.stationID == "18" || station.stationID == "27") { 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; } } ICSharpCode.Core.LoggingService.Debug(station.StationCode + "PLC上传壳体条码:"+ station.Data.ProductBarcode); //判断是否重投 if (station.Data.Restart) { //重投键打开说明肯定是重投的 this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.OK); 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) { //换线工位不能根据托盘号验证,根据条码 station.Data.semibacode = getSemiBacode(station.Data.ProductBarcode); //if (station.Data.Restart) //{ // ICSharpCode.Core.LoggingService.Debug(station.StationCode + "重投数据"); // station.Data.semibacode = getSemiBacode(station.Data.ProductBarcode); // UpdateTrayChongtou(station.Data.RFIDNo, station.Data.semibacode); // //判断当前工位是否可以过滤 // if (this.CurrentStationInfo(station, station.Data.RFIDNo)) // { // this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.NG); // return false; // } //} //判断上一工位开关是否打开 string preStationID = GetFirstStationIDByStationID(station.stationID); if (!string.IsNullOrEmpty(preStationID)) { //这里一定获取到了产品条码 //根据产品码判断当前到哪个工位 if (!ChangeLineStationHaveWork(station)) { ICSharpCode.Core.LoggingService.Debug(station.StationCode + "检测无上工位信息"); this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.PreNoWork); return false; } } string mainBarcode = GetMainBarcode(station.Data.semibacode); base.UpdateTray(station.Data.RFIDNo, mainBarcode, station.Data.semibacode, station.stationID, station.Data.ProductOkNg); } this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.OK); return true; } catch (Exception ex) { this.DaoWeiQingQiuHandle(station, (int)DaoWeiResult.OK); return false; } } public bool HandleData(StationInfo station) { try { ICSharpCode.Core.LoggingService.Debug("换线工位:" + station.stationID + ",托盘号:" + station.Data.RFIDNo + ",条码:" + station.Data.ProductBarcode + ",OKNG:" + station.Data.ProductOkNg); //保存数据 //根据物料查询产品A码和M码 station.Data.semibacode = getSemiBacode(station.Data.ProductBarcode); string mainBarcode = GetMBarcodeByProductBarCode(station.Data.ProductBarcode); if (station.stationID == "27") { if (station.Data.ProductOkNg == 0) { station.Data.ProductOkNg = 1; ICSharpCode.Core.LoggingService.Debug("OKNG:1"); } } base.UpdateTray(station.Data.RFIDNo, mainBarcode, station.Data.semibacode, station.stationID, station.Data.ProductOkNg); base.SaveStationData(station,StationType.ChangeLineStation); } catch (Exception e) { ICSharpCode.Core.LoggingService.Error(e.ToString()); return false; } finally { //这里要加一个OK放行 FinishSavePLCWork(station); } return true; } } }