public bool stepIn(LotReaderDeviceElement lotinfo, Lot lot, LotReaderFinishedArgs Args, TrackInParameter p1) { bool flag = true; //进站 MethodReturnResult result = null; using (WipEngineerServiceClient client = new WipEngineerServiceClient()) { if (lot.StateFlag == EnumLotState.WaitTrackIn) { result = client.TrackInLot(p1); if (result.Code == 0) { Args.TransferMsg = string.Format("批次:{0} 进站成功", lotinfo.LotNumber); flag = true; } else { Args.TransferMsg = string.Format("批次:{0} 进站失败", lotinfo.LotNumber); //存储读头扫码结果信息 Args.TransferMsg = Args.TransferMsg + "-------------"; if (OnLotReaderFinished != null) { CommonFun.eventInvoket(() => { OnLotReaderFinished(this, Args); }); } flag = false; } } } ErrorLog(null, Args.TransferMsg); return(flag); }
/// <summary> /// 构造函数。 /// </summary> public LotReaderThreadWrapper(LotReaderDeviceElement lotinfo, ParameterizedThreadStart threadStart) { this.Loop = true; this.Lotinfo = lotinfo; this.AutoResetEvent = new AutoResetEvent(false); this.Thread = new Thread(threadStart); }
private void Server_Load(object sender, EventArgs e) { this._section = (LotReaderConfigurationSection)ConfigurationManager.GetSection("mes.reader"); if (_section.Devices.Count > 0) { this._deviceElement = _section.Devices[0]; } }
/// <summary> /// 数据转置 /// </summary> private void DealData(LotReaderThreadWrapper wrapper) { while (wrapper.Loop) { try { if (queue != null && queue.Count > 0) { LotReaderDeviceElement lotinfo = new LotReaderDeviceElement(); lock (queue) { //获取读头配置信息 lotinfo.ReaderIP = queue.Peek().ReaderIP; lotinfo.LineCode = queue.Peek().LineCode; lotinfo.LotNumber = queue.Peek().LotNumber; lotinfo.FirstStepCode = queue.Peek().FirstStepCode; lotinfo.FirstEquipmentCode = queue.Peek().FirstEquipmentCode; lotinfo.SecondStepCode = queue.Peek().SecondStepCode; lotinfo.SecondEquipmentCode = queue.Peek().SecondEquipmentCode; lotinfo.WorkShop = queue.Peek().WorkShop; lotinfo.WorkShopId = queue.Peek().WorkShopId; lotinfo.FlowId = queue.Peek().FlowId; lotinfo.FlowSubId = queue.Peek().FlowSubId; DateTime dtStartTime = DateTime.Now; //执行过站操作 lotReaderAction.Execute(lotinfo); //请除队列中执行的批次信息 queue.Dequeue(); } } } catch (Exception ex) { } if (wrapper.Loop) { Thread.Sleep(1000); } } wrapper.AutoResetEvent.Set(); }
public void Execute(LotReaderDeviceElement lotinfo) { LotReaderFinishedArgs Args = new LotReaderFinishedArgs(); try { if (lotinfo.LotNumber.Length < 3) { Args.TransferMsg = string.Format("未扫到码,车间{0}线别{1}" , lotinfo.WorkShop , lotinfo.LineCode); Args.TransferMsg = Args.TransferMsg + "-------------"; ErrorLog(null, Args.TransferMsg); if (OnLotReaderFinished != null) { CommonFun.eventInvoket(() => { OnLotReaderFinished(this, Args); }); } } else { //根据条码获取批次信息 Lot lot = null; MethodReturnResult resultLot = new MethodReturnResult(); try { string lotNumber = lotinfo.LotNumber.ToUpper(); lot = GetLot(lotNumber); if (lot == null) { return; } } catch (Exception ex) { resultLot.Code = 1000; resultLot.Message = ex.Message; resultLot.Detail = ex.ToString(); ErrorLog(ex, resultLot.Message); } //判断进出站状态、设备及工序 TrackInParameter pIn = new TrackInParameter() { Creator = "system", RouteOperationName = "", LineCode = lotinfo.LineCode, LotNumbers = new List <string>(), OperateComputer = lotinfo.ReaderIP, Operator = "system", EquipmentCode = "" }; pIn.LotNumbers.Add(lotinfo.LotNumber); TrackOutParameter pOut = new TrackOutParameter() { Creator = "system", RouteOperationName = "", LineCode = lotinfo.LineCode, LotNumbers = new List <string>(), OperateComputer = lotinfo.ReaderIP, Operator = "system", EquipmentCode = "" }; pOut.LotNumbers.Add(lotinfo.LotNumber); //工序,状态 if (lot.RouteStepName == lotinfo.FirstStepCode) { if (lot.StateFlag == EnumLotState.WaitTrackIn) { //第一站进站赋值进站属性 pIn.RouteOperationName = lotinfo.FirstStepCode; pIn.EquipmentCode = lotinfo.FirstEquipmentCode; if (stepIn(lotinfo, lot, Args, pIn))//第一站进站 { //第一站出站赋值出站属性 pOut.RouteOperationName = lotinfo.FirstStepCode; pOut.EquipmentCode = lotinfo.FirstEquipmentCode; lot.StateFlag = EnumLotState.WaitTrackOut; if (stepOut(lotinfo, lot, Args, pOut))//第一站出站 { //第二站进站赋值进站属性 pIn.RouteOperationName = lotinfo.SecondStepCode; pIn.EquipmentCode = lotinfo.SecondEquipmentCode; lot.StateFlag = EnumLotState.WaitTrackIn; if (stepIn(lotinfo, lot, Args, pIn)) //第二站进站 { //第二站出站赋值进站属性 pOut.RouteOperationName = lotinfo.SecondStepCode; pOut.EquipmentCode = lotinfo.SecondEquipmentCode; lot.RouteStepName = lotinfo.SecondStepCode; lot.EquipmentCode = lotinfo.SecondEquipmentCode; lot.StateFlag = EnumLotState.WaitTrackOut; if (stepOut(lotinfo, lot, Args, pOut))//第二站出站 { //启线 //m_retFlag = m_soap.SetLineState(m_workShopId, m_flowId, m_flowSubId, 1); //StartLine(lotinfo.WorkShopId, lotinfo.FlowId, lotinfo.FlowSubId, lotinfo.LineCode, lotinfo.SecondEquipmentCode); } } } } } else if (lot.StateFlag == EnumLotState.WaitTrackOut) { //第一站出站赋值出站属性 pOut.RouteOperationName = lotinfo.FirstStepCode; pOut.EquipmentCode = lotinfo.FirstEquipmentCode; lot.StateFlag = EnumLotState.WaitTrackOut; if (stepOut(lotinfo, lot, Args, pOut))//第一站出站 { //第二站进站赋值进站属性 pIn.RouteOperationName = lotinfo.SecondStepCode; pIn.EquipmentCode = lotinfo.SecondEquipmentCode; lot.StateFlag = EnumLotState.WaitTrackIn; if (stepIn(lotinfo, lot, Args, pIn)) //第二站进站 { //第二站出站赋值进站属性 pOut.RouteOperationName = lotinfo.SecondStepCode; pOut.EquipmentCode = lotinfo.SecondEquipmentCode; lot.RouteStepName = lotinfo.SecondStepCode; lot.EquipmentCode = lotinfo.SecondEquipmentCode; lot.StateFlag = EnumLotState.WaitTrackOut; if (stepOut(lotinfo, lot, Args, pOut))//第二站出站 { //启线 //m_retFlag = m_soap.SetLineState(m_workShopId, m_flowId, m_flowSubId, 1); //StartLine(lotinfo.WorkShopId, lotinfo.FlowId, lotinfo.FlowSubId, lotinfo.LineCode, lotinfo.SecondEquipmentCode); } } } } } else if (lot.RouteStepName == lotinfo.SecondStepCode) { if (lot.StateFlag == EnumLotState.WaitTrackIn) { //第二站进站赋值进站属性 pIn.RouteOperationName = lotinfo.SecondStepCode; pIn.EquipmentCode = lotinfo.SecondEquipmentCode; lot.StateFlag = EnumLotState.WaitTrackIn; if (stepIn(lotinfo, lot, Args, pIn)) //第二站进站 { //第二站出站赋值进站属性 pOut.RouteOperationName = lotinfo.SecondStepCode; pOut.EquipmentCode = lotinfo.SecondEquipmentCode; lot.RouteStepName = lotinfo.SecondStepCode; lot.EquipmentCode = lotinfo.SecondEquipmentCode; lot.StateFlag = EnumLotState.WaitTrackOut; if (stepOut(lotinfo, lot, Args, pOut))//第二站出站 { //启线 //m_retFlag = m_soap.SetLineState(m_workShopId, m_flowId, m_flowSubId, 1); //StartLine(lotinfo.WorkShopId, lotinfo.FlowId, lotinfo.FlowSubId, lotinfo.LineCode, lotinfo.SecondEquipmentCode); } } } if (lot.StateFlag == EnumLotState.WaitTrackOut) { //第二站出站赋值进站属性 pOut.RouteOperationName = lotinfo.SecondStepCode; pOut.EquipmentCode = lotinfo.SecondEquipmentCode; lot.RouteStepName = lotinfo.SecondStepCode; lot.EquipmentCode = lotinfo.SecondEquipmentCode; lot.StateFlag = EnumLotState.WaitTrackOut; if (stepOut(lotinfo, lot, Args, pOut))//第二站出站 { string msg = null; //启线 //m_retFlag = m_soap.SetLineState(m_workShopId, m_flowId, m_flowSubId, 1); //StartLine(lotinfo.WorkShopId, lotinfo.FlowId, lotinfo.FlowSubId, lotinfo.LineCode, lotinfo.SecondEquipmentCode); } } } } } catch (Exception ex) { Args.TransferMsg = Args.TransferMsg + "-------------" + ex; ErrorLog(ex, Args.TransferMsg); } }
public bool stepOut(LotReaderDeviceElement lotinfo, Lot lot, LotReaderFinishedArgs Args, TrackOutParameter p) { bool flag = true; //出站 MethodReturnResult result = null; using (WipEngineerServiceClient client = new WipEngineerServiceClient()) { if (lot.StateFlag == EnumLotState.WaitTrackOut) { IDictionary <string, IList <TransactionParameter> > dicParams = new Dictionary <string, IList <TransactionParameter> >(); //获取工序参数列表。 IList <RouteStepParameter> lstRouteStepParameter = GetParameterList(lot.RouteName, lot.RouteStepName, EnumLotState.WaitTrackOut); if (lstRouteStepParameter != null) { #region 组织批次附加代码 foreach (RouteStepParameter item in lstRouteStepParameter) { if (!dicParams.ContainsKey(lot.Key)) { dicParams.Add(lot.Key, new List <TransactionParameter>()); } string val = null; if (item.Key.ParameterName == "电池片批号" || item.Key.ParameterName == "电池片小包装号") { val = GetCellLotList(item.MaterialType, lot.LineCode, lot.RouteStepName, lot.OrderNumber, p.EquipmentCode); } else { val = GetParameterLotList(item.MaterialType, lot.LineCode, lot.RouteStepName, lot.OrderNumber, p.EquipmentCode); } TransactionParameter tp = new TransactionParameter() { Index = item.ParamIndex, Name = item.Key.ParameterName, Value = val }; dicParams[lot.Key].Add(tp); } p.Paramters = dicParams; #endregion } MethodReturnResult resultTrackOut = client.TrackOutLot(p); if (resultTrackOut.Code == 0) { Args.TransferMsg = string.Format("批次:{0} {1}出站成功", lotinfo.LotNumber, p.RouteOperationName); flag = true; } else { flag = false; Args.TransferMsg = string.Format("批次:{0} {1}出站失败 => ", lotinfo.LotNumber, p.RouteOperationName) + resultTrackOut.Message; } //存储读头扫码结果信息 Args.TransferMsg = Args.TransferMsg + "-------------"; if (OnLotReaderFinished != null) { CommonFun.eventInvoket(() => { OnLotReaderFinished(this, Args); }); } } } ErrorLog(null, Args.TransferMsg); return(flag); }