Ejemplo n.º 1
0
        public void Run()
        {
            ConveryClass.GetEquipMentInfo += new CRLConveryControl.GetEquipment_Inquery(ConveryClass_GetEquipMentInfo);
            //CComputeService.eNotify += new CComputeService.Notify(CComputeService_eNotify);
            DLed.Add(1272, new LED_UDP(System.Configuration.ConfigurationSettings.AppSettings["LED1A1"].ToString(), 28123, 1272));
            DLed.Add(1251, new LED_UDP(System.Configuration.ConfigurationSettings.AppSettings["LED1A2"].ToString(), 28123, 1251));
            DLed.Add(1205, new LED_UDP(System.Configuration.ConfigurationSettings.AppSettings["LED2A1"].ToString(), 28123, 1205));
            DLed.Add(1172, new LED_UDP(System.Configuration.ConfigurationSettings.AppSettings["LED2A2"].ToString(), 28123, 1172));
            DLed.Add(1009, new LED_UDP(System.Configuration.ConfigurationSettings.AppSettings["LED3A1"].ToString(), 28123, 1009));
            DLed.Add(1103, new LED_UDP(System.Configuration.ConfigurationSettings.AppSettings["LED3A2"].ToString(), 28123, 1103));
            DLed.Add(1084, new LED_UDP(System.Configuration.ConfigurationSettings.AppSettings["LED4A1"].ToString(), 28123, 1084));
            DLed.Add(1001, new LED_UDP(System.Configuration.ConfigurationSettings.AppSettings["LED4A2"].ToString(), 28123, 1001));
            if (ConveryClass.InitOPCData(dal.GetOPCItem()))
            {
                ConveryClass.Run();

                LEDThread = new Thread(new ThreadStart(TimeScan));
                LEDThread.IsBackground = true;
                LEDThread.Start();
            }
            else
            {
                logsta.WriteLog("加载数据库OPC数据失败!");
            }
        }
Ejemplo n.º 2
0
 private string CheckStation(string fromstation, string tostation, string taskno, int num)
 {
     if (fromstation == "00000000" && tostation == "00000000")
     {
         return(taskno);
     }
     //if (fromstation.Length == 10 && tostation.Length == 10)//移库
     //    return taskno;
     if (taskno.TrimStart('0').Length == 5)
     {
         string[] stationinfo;
         //if (int.Parse(fromstation.Substring(3,3)) > 92)//入库
         if (fromstation.Length == 4)//入库
         {
             if (fromstation == "5211" && num == 2)
             {
                 fromstation = "5011";
             }
             if (fromstation == "5212" && num == 2)
             {
                 fromstation = "5012";
             }
             if (fromstation == "5215" && num == 2)
             {
                 fromstation = "5015";
             }
             //return taskno;
             stationinfo = ConveryClass.ReadStationInfo(int.Parse(fromstation));
             return(stationinfo[1]);
         }
         else
         {
             if (tostation == "5145" && num == 2)
             {
                 tostation = "5345";
             }
             if (tostation == "5144" && num == 2)
             {
                 tostation = "5344";
             }
             if (tostation == "5141" && num == 2)
             {
                 tostation = "5341";
             }
             stationinfo = ConveryClass.ReadStationInfo(int.Parse(tostation));
             if (stationinfo[1] == "0")
             {
                 return(taskno);
             }
         }
     }
     return("0");
 }
Ejemplo n.º 3
0
        //CRLConveryControl bll = new CRLConveryControl();
        /// <summary>
        /// 更新堆垛机状态
        /// </summary>
        /// <param name="num">堆垛机编号</param>
        /// <param name="str">交互信息</param>
        /// <param name="aisle">巷道</param>
        public string UpdateSCStatus(string num, string str, string aisle, string zone)
        {
            if (str.Length == 43)
            {
                num   = "CRN00" + (int.Parse(str.Substring(41, 1)) + 2);
                aisle = str.Substring(41, 1);
            }
            if (str.Length == 17)
            {
                num   = "CRN00" + (int.Parse(str.Substring(15, 1)) + 2);
                aisle = str.Substring(15, 1);
            }

            CRNStatus css = CRNList.Find(
                delegate(CRNStatus info)
            {
                return(info.CRCNum == num && info.Zone == zone);
            }
                );

            if (css == null)
            {
                CRNStatus status = new CRNStatus();
                status.CRCNum = num;
                //status.AisleNumber = aisle;
                status.Zone           = zone;
                status.CraneMode      = "MCT已连接";
                status.CrcStatus      = "Socket已连接!";
                status.Position       = "0000";
                status.RackSide       = "0";
                status.RackLevel      = "0";
                status.FunctionReport = "112";
                status.AlarmMessage   = "无故障";
                CRNList.Add(status);
                return("");
            }
            string alarmMsg = "";

            #region 关闭模式
            if (str == "Break")
            {
                css.CraneMode      = "MCT断开!";
                css.CrcStatus      = "Socket断开!";
                css.Position       = "0000";
                css.RackSide       = "0";
                css.RackLevel      = "0";
                css.FunctionReport = "112";
                css.AlarmMessage   = "Socket断开!";
                alarmMsg           = css.AlarmMessage;
                css.LabelInfo      = "任务号:" + css.TaskNo + ".位置:" + css.Position + ".是否在站点位置:否" + ".状态:" + alarmMsg + ".事件类型:无" + ".起止:" + css.Fromstation + "-->" + css.Tostation + ".无故障";
                dal.UpdateSCStatus("SC" + (int.Parse(num.Substring(5, 1)) + 2).ToString(), "Equipment_Error");
            }
            #endregion
            #region 连接
            if (str == "Connect")
            {
                css.CraneMode      = "MCT已连接";
                css.CrcStatus      = "Socket已连接!";
                css.Position       = "0000";
                css.RackSide       = "0";
                css.RackLevel      = "0";
                css.FunctionReport = "112";
                css.AlarmMessage   = "无故障";
                css.LabelInfo      = "任务号:" + css.TaskNo + ".位置:" + css.Position + ".是否在站点位置:否" + ".MCT模式:" + css.CraneMode + ".状态:" + css.CrcStatus + ".事件类型:无" + ".货叉1起止:" + css.Fromstation + "-->" + css.Tostation + ".货叉2起止:" + css.SecFromstation + "-->" + css.SecTostation + ".无故障";
                if (css.CrcStatus == "Equipment_OK")
                {
                    dal.UpdateSCStatus(num, "Equipment_OK");
                }
            }
            #endregion
            #region 返回堆垛机状态信息
            else if (str.Substring(1, 2) == "LA")
            {
                //css.CraneMode = GetGenSongMode(str.Substring(3, 2));
                css.CrcStatus = GetGenSongStatus(str.Substring(3, 2));
                if (str.Substring(3, 2) == "02")
                {
                    css.CraneMode = "可调度";
                }
                else
                {
                    css.CraneMode = "不可调度";
                }
                css.Position     = GetGenSongPosition(str.Substring(5, 6)).Replace("?", "0");
                css.RackPosition = str.Substring(5, 3).Replace("?", "0");
                css.RackLevel    = str.Substring(8, 3).Replace("?", "0");
                string stationPosistion = str.Substring(12, 1);
                css.AlarmMessage = "无故障";
                foreach (DictionaryEntry de in AlarmHash)
                {
                    if (de.Key.ToString() == str.Substring(13, 4))
                    {
                        css.AlarmMessage = de.Value.ToString();
                    }
                }
                string eventType = GetEventType(str.Substring(17, 1));
                int    etype     = int.Parse(str.Substring(17, 1));
                css.TaskNo        = str.Substring(30, 10).Replace("GOT", "000");
                css.RackSide      = str.Substring(26, 1);
                css.RackStatus    = str.Substring(28, 1); //货叉1状态 1无货,2有货,3故障
                css.SecRackStatus = str.Substring(29, 1); //货叉2状态 1无货,2有货,3故障
                int number = int.Parse(str.Substring(40, 2));
                if (etype < 2)
                {
                    css.FunctionReport = CR_GETC_WAIT_H;
                }
                else if (etype == 3)
                {
                    css.FunctionReport = CR_GETC_EXECUTED;
                }
                else if (etype == 4)
                {
                    css.FunctionReport = CR_PUTC_PUT_RUNNING;
                }
                else if (etype == 5)
                {
                    css.FunctionReport = CR_PUTC_EXECUTED;
                }
                else
                {
                    css.FunctionReport = CR_GETC_WAIT_H;
                }
                css.LabelInfo = "任务号:" + css.TaskNo + ".位置:" + css.Position + ".是否在站点位置:" + (stationPosistion == "1" ? "是" : "否") + ".MCT模式:" + css.CraneMode + ".状态:" + css.CrcStatus + ".事件类型:" + eventType + ".货叉1起止:" + css.Fromstation + "-->" + css.Tostation + ".货叉2起止:" + css.SecFromstation + "-->" + css.SecTostation + "." + css.AlarmMessage;
            }
            #endregion
            #region 返回堆垛机动作信息
            else if (str.Substring(1, 2) == "LD")
            {
                string   scno        = str.Substring(14, 2);
                string   taskStatus  = str.Substring(3, 1);
                string   taskno1     = str.Substring(4, 5);
                string   taskno2     = str.Substring(9, 5);//.TrimStart('0');
                string[] taskinfo    = dal.GetTostation(taskno1);
                string[] sectaskinfo = dal.GetTostation(taskno2);
                string[] stainfo     = null;
                string[] secstainfo  = null;
                if (taskStatus == "1")//取货完成
                {
                    if (taskinfo != null && taskinfo[0] != null && taskinfo[0].Length == 4)
                    {
                        dal.UpdateMiniGetState(taskno1);
                        stainfo    = new string[11];// ConveryClass.ReadStationInfo(int.Parse(taskinfo[0]));
                        stainfo[0] = taskinfo[0];
                        for (int i = 1; i < 11; i++)
                        {
                            stainfo[i] = "0";
                        }
                        ConveryClass.WriteStationInfo(stainfo);
                    }
                    if (sectaskinfo != null && sectaskinfo[0] != null && sectaskinfo[0].Length == 4)
                    {
                        dal.UpdateMiniGetState(taskno2);
                        secstainfo    = new string[11];// ConveryClass.ReadStationInfo(int.Parse(taskinfo[0]));
                        secstainfo[0] = sectaskinfo[0];
                        for (int i = 1; i < 11; i++)
                        {
                            secstainfo[i] = "0";
                        }
                        if (secstainfo[0] == "5211")
                        {
                            secstainfo[0] = "5011";
                        }
                        if (secstainfo[0] == "5212")
                        {
                            secstainfo[0] = "5012";
                        }
                        if (secstainfo[0] == "5215")
                        {
                            secstainfo[0] = "5015";
                        }
                        ConveryClass.WriteStationInfo(secstainfo);
                    }
                    alarmMsg += num + "堆垛机取货完成:" + css.TaskNo;
                }
                else if (taskStatus == "2" || taskStatus == "4")//堆垛机放货完成
                {
                    #region 堆垛机放货完成
                    if (taskinfo != null && taskinfo[0] != null)
                    {
                        if (taskinfo[1].Length == 4)//放货到输送机
                        {
                            stainfo = ConveryClass.ReadStationInfo(int.Parse(taskinfo[1]));
                            if (int.Parse(stainfo[1]) > 0)
                            {
                                alarmMsg += taskinfo[1] + "站台有货物!";
                            }
                            else
                            {
                                stainfo[1]  = taskno1;
                                stainfo[2]  = "0";
                                stainfo[3]  = "0";
                                stainfo[4]  = "3";         //类型 件烟
                                stainfo[5]  = taskinfo[1]; // "0"; //起始站台 taskinfo[1];//
                                stainfo[6]  = "5156";      //5156或0
                                stainfo[7]  = "0";
                                stainfo[8]  = "0";
                                stainfo[9]  = "0";
                                stainfo[10] = "0";
                                if (scno == "01")
                                {
                                    stainfo[6] = "5353";
                                }
                                else if (scno == "02")
                                {
                                    stainfo[6] = "5343";
                                }
                                else if (scno == "03")
                                {
                                    stainfo[6] = "5342";
                                }
                                ConveryClass.WriteStationInfo(stainfo);

                                if (dal.UpdateTaskStatus(taskno1, "SC", "1", "1") != "0")//堆垛机完成任务
                                {
                                    dal.UpdateTaskStatus(taskno1, "STA", "2", "1");
                                }
                            }
                        }
                        else
                        {
                            dal.UpdateTaskStatus(taskno1, "SC", "1", "1");//堆垛机完成任务
                        }
                    }
                    if (sectaskinfo != null && sectaskinfo[0] != null)
                    {
                        if (sectaskinfo[1].Length == 4)//放货到输送机
                        {
                            secstainfo = ConveryClass.ReadStationInfo(int.Parse(sectaskinfo[1]) + 200);
                            if (int.Parse(secstainfo[1]) > 0)
                            {
                                alarmMsg += sectaskinfo[1] + "站台有货物!";
                            }
                            else
                            {
                                secstainfo[1]  = taskno2;
                                secstainfo[2]  = "0";
                                secstainfo[3]  = "0";
                                secstainfo[4]  = "3";                                          //类型 件烟
                                secstainfo[5]  = (int.Parse(sectaskinfo[1]) + 200).ToString(); // "0"; 起始站台
                                secstainfo[6]  = "5156";                                       //5156或0
                                secstainfo[7]  = "0";
                                secstainfo[8]  = "0";
                                secstainfo[9]  = "0";
                                secstainfo[10] = "0";
                                if (scno == "01")
                                {
                                    secstainfo[6] = "5353";
                                }
                                else if (scno == "02")
                                {
                                    secstainfo[6] = "5343";
                                }
                                else if (scno == "03")
                                {
                                    secstainfo[6] = "5342";
                                }
                                ConveryClass.WriteStationInfo(secstainfo);
                                if (dal.UpdateTaskStatus(taskno2, "SC", "1", "1") != "0")//堆垛机完成任务
                                {
                                    dal.UpdateTaskStatus(taskno2, "STA", "2", "1");
                                }
                            }
                        }
                        else
                        {
                            dal.UpdateTaskStatus(taskno2, "SC", "1", "1");//堆垛机完成任务
                        }
                    }
                    #endregion
                    if (taskinfo[1].Length == 4 && (css.CrcStatus == "无货待命" || css.CrcStatus == "无货运行" || css.CrcStatus == "有货运行" || css.CrcStatus == "有货待命"))
                    {
                        DataSet ds = dal.GetGSInTask(scno);
                        if (ds != null && ds.Tables[0].Rows.Count > 0)
                        {
                            foreach (DataRow row in ds.Tables[0].Rows)
                            {
                                CRNObject co = CRNOBList.Find(
                                    delegate(CRNObject info)
                                {
                                    return(info.ScNo == "CRN00" + row["equipmentnumber"].ToString().Substring(5, 1) && info.zone == zone);
                                }
                                    );
                                if (co != null)
                                {
                                    //((GenSongSRM)co.BllSrm).SendTask(row[1].ToString(), row[2].ToString(), row[3].ToString(), row[4].ToString(), row[5].ToString());
                                    ((GenSongSRM)co.BllSrm).SendTask(row["taskno"].ToString(), row["fromstation"].ToString(), row["tostation"].ToString(), row["sectaskno"].ToString(), row["secfromstation"].ToString(), row["sectostation"].ToString(), row["currentstation"].ToString(), row["field2"].ToString());
                                }
                            }
                        }
                    }
                }
                else if (taskStatus == "3")
                {
                    alarmMsg += "任务被取消,任务号:" + taskno1 + taskno2;
                }
            }
            #endregion
            //if (css.LabelInfo == css.OldLabelInfo)
            //    css.Change = false;
            //else
            //{
            if (str.Substring(1, 2) == "LA")
            {
                //if (str.Substring(15, 4) != "0000")
                string test = str.Substring(13, 4);

                if (str.Substring(13, 4) != "0000")
                {
                    //dal.UpdateSCStatus(num, "Equipment_Error");//"SC" + int.Parse(num.Substring(5, 3)).ToString()
                    dal.UpdateSCStatus("SC" + int.Parse(num.Substring(5, 1)).ToString(), "Equipment_Error");
                    alarmMsg = css.AlarmMessage;
                }
                //else
                //{
                //    dal.UpdateSCStatus("SC" + int.Parse(num.Substring(5, 1)).ToString(), "Equipment_OK");
                //}
                //dal.UpdateSCStatus(num, "Equipment_OK");
                if (str.Substring(3, 2) == "11" || str.Substring(3, 2) == "12")
                {
                    dal.UpdateSCStatus("SC" + int.Parse(num.Substring(5, 1)).ToString(), "Equipment_Error");
                    alarmMsg = "未连接或手动状态";
                }
            }
            css.OldLabelInfo = css.LabelInfo;
            css.Change       = true;
            //}
            return(alarmMsg);
        }