Exemplo n.º 1
0
        public bool SendTask(string num, string taskno, string fromstation, string tostation, int type)
        {
            CRCObjectB co = crclistB.Find(
                delegate(CRCObjectB 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);
        }
Exemplo n.º 2
0
        private void AddSRM(string scno, string ipaddress, int port, int aisle)
        {
            CRCObjectB newcrc = new CRCObjectB();
            BLLSRMB    srm    = new BLLSRMB(scno, ipaddress, port, aisle);

            newcrc.BllSrm    = srm;
            newcrc.ScNo      = scno;
            newcrc.IpAddress = ipaddress;
            newcrc.Port      = port;
            crclistB.Add(newcrc);
        }
Exemplo n.º 3
0
        private void OSRM_AnalyseMessageEvent(string CommandType, object msg)
        {
            CRCObjectB findcob = crclistB.Find(
                delegate(CRCObjectB 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);
                }
                crcb.UpdateCRCStatus(m_strSRMNo, msg.ToString(), aisle.ToString());
                if (!string.IsNullOrEmpty(crcb.GetAlarmInfo(m_strSRMNo, "", false)))
                {
                    log.WriteLog(crcb.GetAlarmInfo(m_strSRMNo, "", false));
                }
                if (ENotifyTypeEventHandler != null)
                {
                    ENotifyTypeEventHandler(m_strSRMNo, m_strport, CommandType, msg);
                }
            }
            else if (m_strport == "6000" && CommandType == "RecvData")
            {
                crcb.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");
                crcb.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);
            }
        }
Exemplo n.º 4
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);
     }
 }
Exemplo n.º 5
0
        public void UpdateCRCStatus(string num, string str, string aisle)
        {
            string[]   msg = str.Split(new char[] { ';' });
            CRCStatusB css = CRCItemsB.Find(
                delegate(CRCStatusB 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";
                    }

                    CRCObjectB co = crclistB.Find(
                        delegate(CRCObjectB 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.Replace("A", "").Replace("B", ""));
                            }
                            //发指令调试注释
                            #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.Replace("A", "").Replace("B", "")))
                                {
                                    dal.UpdateTaskStatus(css.TaskNo, "SC", "1", "1");
                                    #region Tostation.Length == 4
                                    if (css.Tostation != null && css.Tostation.Length == 4 && dal.GetIsPut(css.TaskNo) == "0")
                                    {
                                        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 = 0;
                                        int upbarcode2 = 0;
                                        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 (crcb.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 (crcb.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
            {
                CRCStatusB status = new CRCStatusB();
                status.CRCNum      = num;
                status.AisleNumber = aisle;
                CRCItemsB.Add(status);
            }
        }