Exemple #1
0
        public bool SendTask(string num, string taskno, string fromstation, string tostation, int type)
        {
            CRCObject co = crclist.Find(
                delegate(CRCObject info)
            {
                return(info.ScNo == num && info.Port == 2000);
            }
                );

            if (co != null)
            {
                if (type == 1)
                {
                    //return co.BllSrm.SendTask(num, taskno, fromstation, tostation, "0", "", "");
                    return(co.BllSrm.SendTask(num, taskno, fromstation, tostation, "0", ""));
                }
                //return false;
                else
                if (fromstation.Length == 4)
                {
                    string codeh = fromstation.Substring(0, 1);
                    string code  = fromstation.Substring(1, 3);
                    return(co.BllSrm.SendCode(num, int.Parse(code), int.Parse(codeh), int.Parse(taskno), tostation));
                }
                else
                {
                    return(co.BllSrm.SendCode(num, int.Parse(fromstation), 0, int.Parse(taskno), tostation));
                }
            }
            return(false);
        }
Exemple #2
0
        public void Run()
        {
            #region 堆垛机基础信息
            XmlDocument doc = new XmlDocument();
            doc.Load(@"..\..\XmlSRM.xml");

            XmlNode xn = doc.SelectSingleNode("SRM");

            XmlNodeList xnl = xn.ChildNodes;
            foreach (var item in xnl)
            {
                XmlElement  xe   = item as XmlElement;
                XmlNodeList xnll = xe.ChildNodes;
                SRMStr      sr   = new SRMStr
                {
                    Ip   = xnll.Item(0).InnerText,
                    Name = xnll.Item(1).InnerText,
                    Port = xnll.Item(2).InnerText
                };
                BLLSRMERegist lsr    = new BLLSRMERegist(sr);
                CRCObject     newcrc = new CRCObject
                {
                    //BllSrm = lsr,
                    IpAddress = sr.Ip,
                    Port      = int.Parse(sr.Port),
                    ScNo      = sr.Name
                };
            }
            #endregion
        }
Exemple #3
0
        private void AddSRM(string scno, string ipaddress, int port, int aisle)
        {
            CRCObject newcrc = new CRCObject();
            BLLSRM    srm    = new BLLSRM(scno, ipaddress, port, aisle);

            newcrc.BllSrm    = srm;
            newcrc.ScNo      = scno;
            newcrc.IpAddress = ipaddress;
            newcrc.Port      = port;
            crclist.Add(newcrc);
        }
Exemple #4
0
        private void OSRM_AnalyseMessageEvent(string CommandType, object msg)
        {
            CRCObject findcob = crclist.Find(
                delegate(CRCObject info)
            {
                return(info.ScNo == m_strSRMNo && info.Port == int.Parse(m_strport));
            }
                );

            if (m_strport == "4000" && CommandType == "RecvData")
            //if (m_strport == "80" && CommandType == "RecvData")
            {
                if (findcob != null)
                {
                    findcob.connectstatus = (findcob.connectstatus == 1 ? 2 : 1);
                }
                crc.UpdateCRCStatus(m_strSRMNo, msg.ToString(), aisle.ToString());
                if (!string.IsNullOrEmpty(crc.GetAlarmInfo(m_strSRMNo, "", false)))
                {
                    log.WriteLog(crc.GetAlarmInfo(m_strSRMNo, "", false));
                }
                if (ENotifyTypeEventHandler != null)
                {
                    ENotifyTypeEventHandler(m_strSRMNo, m_strport, CommandType, msg);
                }
            }
            else if (m_strport == "6000" && CommandType == "RecvData")
            {
                crc.GetAlarmInfo(m_strSRMNo, msg.ToString(), true);
            }
            else if (CommandType == "Break")
            {
                if (findcob != null)
                {
                    findcob.connectstatus = 0;
                }
                CheckConnectTimer.Start();
                GetSCStatusTimer.Stop();
                dal.UpdateSCStatusNTI(m_strSRMNo, "Equipment_Error");
                crc.UpdateCRCStatus(m_strSRMNo, CommandType, aisle.ToString());
                //ShowText("C", "连接中断,IP地址" + m_ip + ",堆垛机编号" + m_strSRMNo + ",端口" + m_strport);
            }
            else if (CommandType == "Connect")
            {
                if (findcob != null)
                {
                    findcob.connectstatus = 1;
                }
                CheckConnectTimer.Stop();
                GetSCStatusTimer.Start();
                ShowText("C", "连接成功,IP地址" + m_ip + ",堆垛机编号" + m_strSRMNo + ",端口" + m_strport);
            }
        }
Exemple #5
0
 private void TimeScan()
 {
     while (true)
     {
         DataTable dt = crc.GetTask();
         foreach (DataRow row in dt.Rows)
         {
             string equipmentnumber = row["num"].ToString();
             if (equipmentnumber.Length == 1)
             {
                 equipmentnumber = "CRC00" + equipmentnumber;
             }
             else
             {
                 equipmentnumber = "CRC0" + equipmentnumber;
             }
             CRCObject co = crclist.Find(
                 delegate(CRCObject info)
             {
                 return(info.ScNo == equipmentnumber && info.Port == 2000);
                 //return (info.ScNo == row["num"].ToString() && info.Port == 2000);
             }
                 );
             CRCStatus cs = CRCItems.Find(
                 delegate(CRCStatus 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(equipmentnumber, 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);
     }
 }
        /// <summary>
        /// 如果连接失败,定时检测网络,网络正常则自动连接
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CheckConnectTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            List <CRCObject> crclist = new List <CRCObject>();
            CRCObject        findCob = crclist.Find(info => info.ScNo == srs.Name && info.Port == int.Parse(srs.Port));

            if (crs.Connect(srs.Ip, srs.Port))
            {
                GetSCStatusTimer.Start();
                CheckConnectTimer.Stop();
                if (findCob != null)
                {
                    findCob.connectstatus = 1;
                }
                NotifyShowEvent?.Invoke("C", $"检测连接成功,IP地址{srs.Ip},堆垛机编号{srs.Name},端口{srs.Port}");
            }
            else
            {
                NotifyShowEvent?.Invoke("C", $"检测连接失败,IP地址{srs.Ip},堆垛机编号{srs.Name},端口{srs.Port}");
                if (findCob != null)
                {
                    findCob.connectstatus = 0;
                }
            }
        }
Exemple #7
0
        public void UpdateCRCStatus(string num, string str, string aisle)
        {
            string[]  msg = str.Split(new char[] { ';' });
            CRCStatus css = CRCItems.Find(
                delegate(CRCStatus info)
            {
                return(info.CRCNum == num);
            }
                );

            if (css != null)
            {
                if (str == "Break")
                {
                    css.CrcStatus = EQUIPMENT_ERROR;
                    css.CraneMode = "0";
                    css.LabelInfo = "位置:" + css.Position + ".模式:关闭.状态:无.起止:" + css.Fromstation + "-->" + css.Tostation + ".";
                    dal.UpdateSCStatusNTI(css.CRCNum, css.CrcStatus);
                }
                else if (msg.Length > 38)
                {
                    string mode         = EQUIPMENT_ERROR;
                    int[]  functionmode = FunctionMode(int.Parse(msg[23]));
                    int[]  cranemode    = FunctionMode(int.Parse(msg[38]));
                    if (functionmode[0] == 1 && functionmode[4] == 1 && msg[38] == "1")
                    {
                        mode = EQUIPMENT_OK;
                    }

                    int t = int.Parse(msg[20].ToString()) * 256 + int.Parse(msg[21].ToString());
                    if (t != 0 && t.ToString() != css.TaskNo)
                    {
                        dal.UpdateTaskStatus(t.ToString(), "SC", "2", "1");
                    }
                    //dal.UpdateTaskStatus(t.ToString(), "SC", "2", "1");
                    css.TaskNo    = t.ToString();
                    css.CraneMode = msg[38];
                    //css.FunctionReportH = msg[38];
                    css.FunctionMode   = msg[23];
                    css.FunctionReport = msg[22];
                    css.CrcStatus      = mode;
                    css.ZAlarm         = functionmode[7];
                    css.ActionPoint    = msg[26];
                    css.AisleNumber    = msg[27];
                    css.RackSide       = msg[28];
                    css.RackPosition   = msg[29];
                    css.RackPlace      = msg[30];
                    css.RackLevel      = msg[31];
                    css.RackDepth      = msg[32];
                    css.Position       = GetLocation(num, int.Parse(msg[27]), int.Parse(msg[28]), int.Parse(msg[29]), int.Parse(msg[30]), int.Parse(msg[31]), int.Parse(msg[32]));
                    css.AlarmMessage   = GetAlarmInfo(num, "", false);
                    css.LabelInfo      = "任务号:" + css.TaskNo + ".位置:" + css.Position + ".模式:" + GetFunctionMode(functionmode, cranemode) + ".状态:" + GetTaskStatusBase(msg[22], msg[38]) + ".起止:" + css.Fromstation + "-->" + css.Tostation + "." + css.AlarmMessage;
                    if (css.LabelInfo == css.OldLabelInfo)
                    {
                        css.Change = false;
                    }
                    else
                    {
                        css.OldLabelInfo = css.LabelInfo;
                        css.Change       = true;
                        dal.UpdateSCStatusNTI(css.CRCNum, css.CrcStatus);
                        //UpdateEquipmentStatus(t.ToString(), css.Position, GetFunctionMode(functionmode, cranemode), GetTaskStatusBase(msg[22],msg[38]), css.Fromstation, css.Tostation, css.AlarmMessage, num);
                    }
                    if (css.CrcStatus == EQUIPMENT_ERROR)
                    {
                        css.CrcTaskFlag = "0";
                    }
                    else
                    {
                        css.CrcTaskFlag = "1";
                    }

                    CRCObject co = crclist.Find(
                        delegate(CRCObject cob)
                    {
                        return(cob.ScNo == num && cob.Port == 2000);
                    }
                        );
                    if (co != null)
                    {
                        if (System.String.IsNullOrEmpty(css.Fromstation) || System.String.IsNullOrEmpty(css.Tostation))
                        {
                            string[] ss = new string[2];
                            ss = dal.GetTostation(css.TaskNo);
                            if (ss != null)
                            {
                                css.Fromstation = ss[0];
                                css.Tostation   = ss[1];
                            }
                        }
                        string destr = "";
                        if (!System.String.IsNullOrEmpty(css.Tostation))
                        {
                            if (css.Tostation.Contains("A"))
                            {
                                destr = css.Tostation.Replace("A", "");
                            }
                            else
                            {
                                destr = css.Tostation;
                            }
                        }
                        if (css.FunctionReport == CR_GETC_EXECUTED)
                        {
                            #region CR_GETC_EXECUTED 取货完成
                            if (css.Fromstation != null && css.Fromstation.Length == 4 && css.TaskNo.Length > 4)
                            {
                                string[] clear = new string[11];
                                string[] info  = ReadStationInfo(int.Parse(css.Fromstation));
                                for (int i = 0; i < 11; i++)
                                {
                                    clear[i] = "0";
                                }
                                clear[0] = css.Fromstation;
                                co.BllSrm.SendCode(num, CR_PUTC, 0, int.Parse(css.TaskNo), destr.Replace("A", "").Replace("B", ""));
                                if (info[1] == css.TaskNo)
                                {
                                    logsta.WriteLog("清除入库口任务" + clear[0]);
                                    bool clearstation = WriteStationInfo(clear);
                                    if (clearstation)
                                    {
                                        logsta.WriteLog("清除入库口任务成功");
                                    }
                                }
                            }
                            //发指令调试注释
                            else
                            {
                                //co.BllSrm.SendCode(num, CR_PUTC, 0, int.Parse(css.TaskNo), css.Tostation.Replace("A",""));
                                co.BllSrm.SendCode(num, CR_PUTC, 0, int.Parse(css.TaskNo), destr);
                            }
                            //发指令调试注释
                            #endregion
                        }
                        else if (css.FunctionReport == CR_PUTC_EXECUTED)
                        {
                            #region CR_PUTC_EXECUTED 放货完成
                            if (css.TaskNo != null && css.TaskNo.Length > 4)
                            {
                                //co.BllSrm.SendCode(num, CR_NO_FUNC, 0, int.Parse(css.TaskNo), destr);
                                //dal.UpdateTaskStatus(css.TaskNo, "SC", "1", "1");
                                if (co.BllSrm.SendCode(num, CR_NO_FUNC, 0, int.Parse(css.TaskNo), destr))
                                {
                                    dal.UpdateTaskStatus(css.TaskNo, "SC", "1", "1");
                                    #region Tostation.Length == 4
                                    if (css.Tostation != null && css.Tostation.Length == 4)
                                    {
                                        string itemtype;
                                        string barcode, addressstation = "0";
                                        barcode = dal.GetBarcode(css.TaskNo);
                                        string[] info = barcode.Split(new char[] { ',' });
                                        if (info.Length > 2)
                                        {
                                            addressstation = info[2];
                                        }
                                        //else
                                        //    addressstation = num == "CRC001" ? "5066" : "5071";

                                        if (info[0] == "99999999")
                                        {
                                            itemtype = "2";
                                        }
                                        else
                                        {
                                            itemtype = "3";
                                        }
                                        string[] strsta = new string[11];
                                        strsta[0] = css.Tostation;
                                        strsta[1] = css.TaskNo;
                                        int upbarcode1 = int.Parse(info[0]) / 65536;
                                        int upbarcode2 = int.Parse(info[0]) % 65536;
                                        strsta[2]  = upbarcode1.ToString();
                                        strsta[3]  = upbarcode2.ToString();
                                        strsta[4]  = itemtype;
                                        strsta[5]  = css.Tostation;
                                        strsta[6]  = addressstation;//info[2];//css.STAToStation;
                                        strsta[7]  = "0";
                                        strsta[8]  = "0";
                                        strsta[9]  = "0";
                                        strsta[10] = "0";
                                        if (WriteStationInfo(strsta))
                                        {
                                            dal.UpdateTaskStatus(css.TaskNo, "STA", "2", "1");
                                            //#region 出库放货后取入库任务
                                            //if (num.Equals("CRC001"))
                                            //{
                                            //    string task5041 = ReadStationInfo(5041)[1];
                                            //    if (Int32.Parse(task5041) > 9999)
                                            //    {
                                            //        DataSet dstemp = dal.CheckInTask_1073(task5041);
                                            //        if (dstemp != null && dstemp.Tables.Count > 0 && dstemp.Tables[0].Rows.Count > 0)
                                            //        {
                                            //            String taskno = dstemp.Tables[0].Rows[0][0].ToString();
                                            //            String fromstation = dstemp.Tables[0].Rows[0][1].ToString();
                                            //            String tostation = dstemp.Tables[0].Rows[0][2].ToString();
                                            //            if (crc.UpdateCRCTaskInfo(num, fromstation, tostation, "0", "Task_InBound"))
                                            //            {
                                            //                bool sendflag = co.BllSrm.SendCode(num, CR_GETC, 0, int.Parse(taskno), fromstation);
                                            //                if (sendflag)
                                            //                    dal.UpdateTaskStatus(taskno, "SC", "2", "1");
                                            //                //dal.UpdateTaskStatus(taskno, "SC", "2", "1");
                                            //            }
                                            //        }
                                            //    }
                                            //}
                                            //if (num.Equals("CRC002"))
                                            //{
                                            //    string task5049 = ReadStationInfo(5049)[1];
                                            //    if (Int32.Parse(task5049) > 9999)
                                            //    {
                                            //        DataSet dstemp = dal.CheckInTask_1073(task5049);
                                            //        if (dstemp != null && dstemp.Tables.Count > 0 && dstemp.Tables[0].Rows.Count > 0)
                                            //        {
                                            //            String taskno = dstemp.Tables[0].Rows[0][0].ToString();
                                            //            String fromstation = dstemp.Tables[0].Rows[0][1].ToString();
                                            //            String tostation = dstemp.Tables[0].Rows[0][2].ToString();
                                            //            if (crc.UpdateCRCTaskInfo(num, fromstation, tostation, "0", "Task_InBound"))
                                            //            {
                                            //                bool sendflag = co.BllSrm.SendCode(num, CR_GETC, 0, int.Parse(taskno), fromstation);
                                            //                if (sendflag)
                                            //                    dal.UpdateTaskStatus(taskno, "SC", "2", "1");
                                            //                //dal.UpdateTaskStatus(taskno, "SC", "2", "1");
                                            //            }
                                            //        }
                                            //    }
                                            //}
                                            //#endregion
                                        }
                                    }
                                    #endregion
                                }
                            }

                            #endregion
                        }
                        //else if (css.FunctionReport == CR_NO_FUNC.ToString())
                        //{
                        //    if (num.Equals("CRC001"))
                        //    {
                        //        string task5041 = ReadStationInfo(5041)[1];
                        //        if (Int32.Parse(task5041) > 9999)
                        //        {
                        //            DataSet dstemp = dal.CheckInTask_1073(task5041);
                        //            if (dstemp != null && dstemp.Tables.Count > 0 && dstemp.Tables[0].Rows.Count > 0)
                        //            {
                        //                String taskno = dstemp.Tables[0].Rows[0][0].ToString();
                        //                String fromstation = dstemp.Tables[0].Rows[0][1].ToString();
                        //                String tostation = dstemp.Tables[0].Rows[0][2].ToString();
                        //                if (crc.UpdateCRCTaskInfo(num, fromstation, tostation, "0", "Task_InBound"))
                        //                {
                        //                    bool sendflag = co.BllSrm.SendCode(num, CR_GETC, 0, int.Parse(taskno), fromstation);
                        //                    if(sendflag)
                        //                        dal.UpdateTaskStatus(taskno, "SC", "2", "1");
                        //                    //dal.UpdateTaskStatus(taskno, "SC", "2", "1");
                        //                }
                        //            }
                        //        }
                        //    }
                        //    if (num.Equals("CRC002"))
                        //    {
                        //        string task5049 = ReadStationInfo(5049)[1];
                        //        if (Int32.Parse(task5049) > 9999)
                        //        {
                        //            DataSet dstemp = dal.CheckInTask_1073(task5049);
                        //            if (dstemp != null && dstemp.Tables.Count > 0 && dstemp.Tables[0].Rows.Count > 0)
                        //            {
                        //                String taskno = dstemp.Tables[0].Rows[0][0].ToString();
                        //                String fromstation = dstemp.Tables[0].Rows[0][1].ToString();
                        //                String tostation = dstemp.Tables[0].Rows[0][2].ToString();
                        //                if (crc.UpdateCRCTaskInfo(num, fromstation, tostation, "0", "Task_InBound"))
                        //                {
                        //                    bool sendflag = co.BllSrm.SendCode(num, CR_GETC, 0, int.Parse(taskno), fromstation);
                        //                    if(sendflag)
                        //                        dal.UpdateTaskStatus(taskno, "SC", "2", "1");
                        //                    //dal.UpdateTaskStatus(taskno, "SC", "2", "1");
                        //                }
                        //            }
                        //        }
                        //    }
                        //}
                    }
                }
            }
            else
            {
                CRCStatus status = new CRCStatus();
                status.CRCNum      = num;
                status.AisleNumber = aisle;
                CRCItems.Add(status);
            }
        }