Ejemplo n.º 1
0
 public int IndexOf(ProductViaStation product)
 {
     for (int i = 0; i < _products.Count; i++)
     {
         if (Products[i].T102LeafID == product.T102LeafID)
         {
             return(i);
         }
     }
     return(-1);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据 T102LeafID 或 T120LeafID 从当面的产品列表中获取产品
        /// </summary>
        /// <param name="leafID"></param>
        /// <returns></returns>
        public ProductViaStation GetProductWithLeafID(int leafID)
        {
            ProductViaStation rlt = null;

            foreach (ProductViaStation product in _products)
            {
                if (product.T102LeafID == leafID ||
                    product.T120LeafID == leafID)
                {
                    rlt = product;
                    break;
                }
            }
            return(rlt);
        }
Ejemplo n.º 3
0
        private void timer_Tick(object sender, EventArgs e)
        {
            string strProcedureName =
                string.Format(
                    "{0}.{1}",
                    className,
                    MethodBase.GetCurrentMethod().Name);

            timer.Enabled = false;
            try
            {
                string barCode = "";

                // 从条码池中获取一条待处理的在产品条码
                lstBarCodes.Invoke(
                    new EventHandler(
                        delegate
                {
                    if (lstBarCodes.Items.Count > 0)
                    {
                        object item = lstBarCodes.Items[0];
                        barCode     = lstBarCodes.Items[0].ToString();
                        lstBarCodes.Items.Remove(item);
                    }
                }));

                string[] splitString = barCode.Split('|');
                if (splitString.Length <= 1)
                {
                    return;
                }

                foreach (ScannerView view in scannerViews)
                {
                    if (view.PortName == splitString[0])
                    {
                        view.BarCode = splitString[1];
                        grdvSerialPortScanners.BestFitColumns();

                        if (Options.SelectStation == null ||
                            Options.SelectProduct == null)
                        {
                            WriteToScreenLog(
                                view.BarCode,
                                "",
                                "",
                                -1,
                                "当前站点没有配置产品流程和或工位");
                            return;
                        }

                        WriteLog.Instance.WriteBeginSplitter(strProcedureName);

                        try
                        {
                            int            errCode     = 0;
                            string         errText     = "";
                            WIPBarCodeInfo barcodeInfo = new WIPBarCodeInfo();

                            #region 获取条码信息
                            IRAPMESClient.Instance.ufn_GetInfo_WIPBarcode(
                                IRAPUser.Instance.CommunityID,
                                view.BarCode,
                                Options.SelectProduct.T120LeafID,
                                Options.SelectStation.T107LeafID,
                                ref barcodeInfo,
                                out errCode,
                                out errText);
                            WriteLog.Instance.Write(
                                string.Format("({0}){1}", errCode, errText),
                                strProcedureName);
                            if (errCode != 0)
                            {
                                WriteToScreenLog(
                                    view.BarCode,
                                    "",
                                    "",
                                    errCode,
                                    errText);
                                return;
                            }
                            #endregion

                            #region 根据条码信息中的条码状态和路由状态,进行生产记载
                            switch (barcodeInfo.BarcodeStatus)
                            {
                            case 0:
                                switch (barcodeInfo.RoutingStatus)
                                {
                                case 1:
                                    break;

                                default:
                                    WriteToScreenLog(
                                        view.BarCode,
                                        "",
                                        "",
                                        barcodeInfo.RoutingStatus,
                                        barcodeInfo.RoutingStatusStr);
                                    return;
                                }
                                break;

                            case 1:
                                switch (barcodeInfo.RoutingStatus)
                                {
                                case 1:
                                    // 自动切换工艺流程
                                    ProductViaStation product =
                                        AvailableProducts.Instance.GetProductWithLeafID(barcodeInfo.ProcessLeaf);
                                    if (product == null)
                                    {
                                        WriteToScreenLog(
                                            view.BarCode,
                                            "",
                                            barcodeInfo.SerialNumber,
                                            -1,
                                            "该条码的在产品生产流程不在当前工位上");
                                        return;
                                    }
                                    else
                                    {
                                        CurrentOptions.Instance.OptionTwo = product;
                                        Options.RefreshOptionTwo(product.T102LeafID);
                                    }
                                    break;

                                default:
                                    WriteToScreenLog(
                                        view.BarCode,
                                        "",
                                        "",
                                        barcodeInfo.BarcodeStatus,
                                        barcodeInfo.BarcodeStatusStr);
                                    return;
                                }
                                break;

                            case 7:
                                return;

                            default:
                                WriteToScreenLog(
                                    view.BarCode,
                                    "",
                                    "",
                                    barcodeInfo.BarcodeStatus,
                                    barcodeInfo.BarcodeStatusStr);
                                return;
                            }

                            long transactNo = 0;
                            long factID     = 0;

                            // 申请交易号
                            transactNo =
                                IRAPUTSClient.Instance.mfn_GetTransactNo(
                                    IRAPUser.Instance.CommunityID,
                                    1,
                                    IRAPUser.Instance.SysLogID,
                                    "14");
                            // 申请事实编号
                            factID =
                                IRAPUTSClient.Instance.mfn_GetFactID(
                                    IRAPUser.Instance.CommunityID,
                                    barcodeInfo.NumOfSubPCBs,
                                    IRAPUser.Instance.SysLogID,
                                    "0");

                            IRAPMESClient.Instance.usp_ManufactureRecord(
                                IRAPUser.Instance.CommunityID,
                                transactNo,
                                factID,
                                Options.SelectProduct.T120LeafID,
                                Options.SelectStation.T107LeafID,
                                view.BarCode,
                                barcodeInfo.SerialNumber,
                                IRAPUser.Instance.SysLogID,
                                out errCode,
                                out errText);
                            WriteToScreenLog(
                                view.BarCode,
                                "",
                                barcodeInfo.SerialNumber,
                                errCode,
                                errText);
                            #endregion
                        }
                        catch (Exception error)
                        {
                            WriteLog.Instance.Write(error.Message, strProcedureName);
                            WriteToScreenLog(
                                view.BarCode,
                                "",
                                "",
                                -1,
                                error.Message);
                        }
                        finally
                        {
                            WriteLog.Instance.WriteEndSplitter(strProcedureName);
                        }
                    }
                }
            }
            finally
            {
                timer.Enabled = true;
            }
        }