Beispiel #1
0
 private void TimeScan()
 {
     while (true)
     {
         DataTable dt = crcb.GetTask();
         foreach (DataRow row in dt.Rows)
         {
             string equipmentnumber = row["num"].ToString();
             if (equipmentnumber.Length == 1)
             {
                 equipmentnumber = "CRC00" + equipmentnumber;
             }
             else
             {
                 equipmentnumber = "CRC0" + equipmentnumber;
             }
             CRCObjectB co = crclistB.Find(
                 delegate(CRCObjectB info)
             {
                 return(info.ScNo == equipmentnumber && info.Port == 2000);
                 //return (info.ScNo == row["num"].ToString() && info.Port == 2000);
             }
                 );
             CRCStatusB cs = CRCItemsB.Find(
                 delegate(CRCStatusB info)
             {
                 return(info.CRCNum == equipmentnumber);
                 //return (info.CRCNum == row["num"].ToString());
             }
                 );
             if (co != null && cs.FunctionReport == CR_NO_FUNC.ToString())
             {
                 //string[] info_4099 = ReadStationInfo(4099);
                 //string[] info_4100 = ReadStationInfo(4100);
                 //if ((row[2].ToString() == "4078" && info_4099[1] == "1" && info_4099[2] == "1") || (row[3].ToString() == "4057" && info_4100[1] == "2" && info_4100[2] == "2") || (row[3].ToString() == "4078" && info_4099[2] == "2" && info_4099[1] == "2") || (row[2].ToString() == "4057" && info_4100[2] == "1" && info_4100[1] == "1") || row[2].ToString().Length == 6 && row[2].ToString().Length == 6)
                 //co.BllSrm.SendTask(row["num"].ToString(), row[1].ToString(), row[2].ToString(), row[3].ToString(), row[4].ToString(), row[6].ToString(), row[7].ToString());
                 co.BllSrm.SendTask(row["num"].ToString(), row[1].ToString(), row[2].ToString().Replace("A", "").Replace("B", ""), row[3].ToString().Replace("A", "").Replace("B", ""), row[4].ToString(), row[6].ToString());
             }
         }
         //AsyncDelegate dlgt = ScanOutCommand;
         //dlgt.BeginInvoke(null, null);
         //blc.GetOutLanewayGono();                ////blc.GetOutBoundTask(); //blc.TimeScanOutLanway();
         Thread.Sleep(2000);                //Thread.Sleep(5000);
     }
 }
Beispiel #2
0
        public DataTable GetTask()
        {
            string    lane = "", executingsc = "";
            int       distance;
            bool      flag = true;
            DataTable dt   = new DataTable();

            dt.Columns.Add("num", Type.GetType("System.String"));
            dt.Columns.Add("taskno", Type.GetType("System.String"));
            dt.Columns.Add("fromstation", Type.GetType("System.String"));
            dt.Columns.Add("tostation", Type.GetType("System.String"));
            dt.Columns.Add("statostation", Type.GetType("System.String"));
            dt.Columns.Add("distance", Type.GetType("System.Int32"));
            dt.Columns.Add("tasktype", Type.GetType("System.String"));
            //dt.Columns.Add("field3", Type.GetType("System.String"));
            CRCStatusB css = null;

            foreach (CRCObjectB co in crclistB)
            {
                if (co.Port == 4000)
                {
                    lane  = "";
                    lane += co.ScNo.Substring(co.ScNo.Length - 2, 2);
                    css   = CRCItemsB.Find(
                        delegate(CRCStatusB info)
                    {
                        return(info.CRCNum == co.ScNo);
                    }
                        );
                    if (css != null)
                    {
                        lane += css.CrcTaskFlag;
                    }
                    else
                    {
                        lane += "0";
                    }
                    //DataSet ds = dal.GetSRMTask("010021");
                    DataSet ds = dal.GetSRMTask(lane);
                    if (ds != null && css.FunctionReport == CR_NO_FUNC.ToString())
                    {
                        DataTable dts = ds.Tables[0];
                        foreach (DataRow row in dts.Rows)
                        {
                            if (row["taskstatus"].ToString() == "2")
                            {
                                executingsc += row["equipmentnumber"].ToString() + ";";
                            }
                        }
                        for (int k = 0; k < dts.Rows.Count; k++)
                        {
                            if (dts.Rows[k]["taskstatus"].ToString() == "0" && !executingsc.Contains(dts.Rows[k]["equipmentnumber"].ToString()))
                            {
                                if (CheckStation(dts.Rows[k]["fromstation"].ToString().Replace("B", ""), dts.Rows[k]["tostation"].ToString().Replace("B", ""), dts.Rows[k]["taskno"].ToString()) == dts.Rows[k]["taskno"].ToString())
                                {
                                    distance = GetDistance(dts.Rows[k]["fromstation"].ToString(), dts.Rows[k]["tostation"].ToString(), dts.Rows[k]["equipmentnumber"].ToString());
                                    if (distance >= 0)
                                    {
                                        //for (int i = 0; i < dt.Rows.Count; i++)
                                        //{
                                        //    if (dt.Rows[i]["num"].ToString() == dts.Rows[k]["equipmentnumber"].ToString())
                                        //    {
                                        //        flag = false;
                                        //        if (int.Parse(dt.Rows[i]["distance"].ToString()) > distance)
                                        //        {
                                        //            dt.Rows.Remove(dt.Rows[i]);
                                        //            dt.Rows.Add(new object[] { dts.Rows[k]["equipmentnumber"].ToString(), dts.Rows[k]["taskno"].ToString(), dts.Rows[k]["fromstation"].ToString(), dts.Rows[k]["tostation"].ToString(), dts.Rows[k]["currentstation"].ToString(), distance });
                                        //        }
                                        //    }
                                        //}
                                        foreach (DataRow row in dt.Rows)
                                        {
                                            if (row["num"].ToString() == dts.Rows[k]["equipmentnumber"].ToString())
                                            {
                                                flag = false;
                                                if (int.Parse(row["distance"].ToString()) > distance)
                                                {
                                                    row["num"]          = dts.Rows[k]["equipmentnumber"].ToString();
                                                    row["taskno"]       = dts.Rows[k]["taskno"].ToString();
                                                    row["fromstation"]  = dts.Rows[k]["fromstation"].ToString();
                                                    row["tostation"]    = dts.Rows[k]["tostation"].ToString();
                                                    row["statostation"] = dts.Rows[k]["currentstation"].ToString();
                                                    row["tasktype"]     = dts.Rows[k]["field2"].ToString();
                                                    row["distance"]     = distance;
                                                    //row["field3"] = dts.Rows[k]["field3"].ToString();
                                                    //dt.Rows.Remove(row);
                                                    //dt.Rows.Add(new object[] { dts.Rows[k]["equipmentnumber"].ToString(), dts.Rows[k]["taskno"].ToString(), dts.Rows[k]["fromstation"].ToString(), dts.Rows[k]["tostation"].ToString(), dts.Rows[k]["currentstation"].ToString(), distance });
                                                }
                                            }
                                        }
                                        if (flag)
                                        {
                                            //if (dts.Rows[k]["tostation"].ToString().Length < 5 && !string.IsNullOrEmpty(dts.Rows[k]["field4"].ToString()))
                                            //    //dt.Rows.Add(new object[] { dts.Rows[k]["equipmentnumber"].ToString(), dts.Rows[k]["taskno"].ToString(), dts.Rows[k]["fromstation"].ToString(), dts.Rows[k]["tostation"].ToString(), dts.Rows[k]["currentstation"].ToString(), distance, dts.Rows[k]["tasktype"].ToString(), dts.Rows[k]["field3"].ToString() });
                                            //    dt.Rows.Add(new object[] { dts.Rows[k]["equipmentnumber"].ToString(), dts.Rows[k]["taskno"].ToString(), dts.Rows[k]["fromstation"].ToString(), dts.Rows[k]["tostation"].ToString(), dts.Rows[k]["currentstation"].ToString(), distance, dts.Rows[k]["tasktype"].ToString() });
                                            //else if (dts.Rows[k]["tostation"].ToString().Length > 4 || dts.Rows[k]["barcode"].ToString() == "99999999")
                                            dt.Rows.Add(new object[] { dts.Rows[k]["equipmentnumber"].ToString(), dts.Rows[k]["taskno"].ToString(), dts.Rows[k]["fromstation"].ToString(), dts.Rows[k]["tostation"].ToString(), dts.Rows[k]["currentstation"].ToString(), distance, dts.Rows[k]["field2"].ToString() });
                                        }
                                        else
                                        {
                                            flag = true;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(dt);
        }