示例#1
0
 public static void ScanConSts()
 {
     while (PLCSystem_CON.IsScanCONSTS)
     {
         try
         {
             string outString = "";
             var    vs        = PLCSystem_SRM.SysSRMMaping.Where((e) => e.StnType == eStationType.EP);
             foreach (var item in vs)
             {
                 CON_Status conSts;
                 var        exists = Dic_CON_STS.TryGetValue(item.ConNodeID, out conSts);
                 if (exists && conSts.s_OccupyStats == 1)
                 {
                     WMBusiness wmsbus = new WMBusiness();
                     var        b      = wmsbus.ActivateOrderInfo(item.LinkLine, item.StnNo, conSts.s_TUID, out outString);
                     if (b)
                     {
                         //写日志
                         Program.Log_Agent_CON.WriteLog(Enum_LogType.LogType_Evnet,
                                                        Enum_LogGrade.LogGrade_Nin,
                                                        Enum_LogMessageType.LogMsgType_Exception,
                                                        "ActivateOrderInfo",
                                                        vs.ToString(),
                                                        conSts.ToString());
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             Program.Log_Agent_CON.WriteLog(Enum_LogType.LogType_Error,
                                            Enum_LogGrade.LogGrade_Nin,
                                            Enum_LogMessageType.LogMsgType_Exception,
                                            "InitItem",
                                            ex.Message,
                                            ex.StackTrace);
         }
         finally
         {
             Thread.Sleep(ScanSleepTime);
         }
     }
 }
示例#2
0
        /// <summary>
        /// 输送机PLC连接的处理逻辑
        /// </summary>
        /// <param name="Sender"></param>
        /// <param name="e"></param>
        private static void V_LoopWrite(object Sender, EArgOnHandle_Process e)
        {
            string plcID        = ((PLCProcesser)Sender).Name;
            string currentConNo = "";

            try
            {
                var ps  = Dic_SRM_PS.Where(item => item.Value.address.PLC == plcID).ToList();
                var spw = Dic_SRM_SPW.Where(item => item.Value.address.PLC == plcID).ToList();

                foreach (var p in ps)
                {
                    //p.Value.LoadFromPLC(e.PLCConn);
                }
                foreach (var s in spw)
                {
                    s.Value.LoadFromPLC(e.PLCConn);
                }

                var arry_sts = Dic_CON_STS.Where(item => item.Value.address.PLC == plcID).ToList();

                foreach (var kv in arry_sts)
                {
                    currentConNo = kv.Key;
                    kv.Value.LoadFromPLC(e.PLCConn);

                    #region 写日志
                    Program.Log_Agent_CON.WriteLog(Enum_LogType.LogType_Debug,
                                                   Enum_LogGrade.LogGrade_Nin,
                                                   Enum_LogMessageType.LogMsgType_Event,
                                                   "V_LoopWrite-ReadConnStatus",
                                                   string.Format("[{0}]-[{1}]", plcID, currentConNo),
                                                   ByteHelper.ToMessage(kv.Value.Tobytes(), CON_Status.cGroupLen));
                    #endregion
                }
                var arry_req = Dic_CON_Req.Where(item => item.Value.address.PLC == plcID).ToList();
                foreach (var kv in arry_req)
                {
                    currentConNo = kv.Key;
                    kv.Value.LoadFromPLC(e.PLCConn);
                    #region 写日志
                    Program.Log_Agent_CON.WriteLog(Enum_LogType.LogType_Debug,
                                                   Enum_LogGrade.LogGrade_Nin,
                                                   Enum_LogMessageType.LogMsgType_Event,
                                                   "V_LoopWrite-ReadRequest",
                                                   string.Format("[{0}]-[{1}]-{2}", plcID, currentConNo, kv.Value.s_ScanBarCode),
                                                   ByteHelper.ToMessage(kv.Value.Tobytes(), CON_Request.cGroupLen));
                    #endregion
                    #region
                    //if (kv.Value.s_OverRead == 1)
                    //{
                    //    string sql = string.Format(ConfigurationManager.AppSettings["Sql_CodeSel"].Replace('\n', ' '));
                    //    string outString = "";
                    //    var db = new DBAccess_MySql("MySql");
                    //    DBAccess_MySql dby = new DBAccess_MySql();
                    //    dby = db.ReturnSQL_String(sql, out outString);
                    //    string a = null;
                    //    while (dby.rec.Read())
                    //    {
                    //        a = dby.rec.GetString(0);
                    //    }
                    //    if (a != "")
                    //    {
                    //        string outBC = "";
                    //        if (!PLCSystem_CON.SIMPLCRequest.TryGetValue(currentConNo, out outBC))
                    //        {
                    //            kv.Value.s_ScanBarCode = a;// outBC;
                    //            kv.Value.s_OverRead = 0;
                    //            PLCSystem_CON.SIMPLCRequest.Remove(currentConNo);

                    //        }
                    //    }
                    //string sql3 = string.Format(ConfigurationManager.AppSettings["Sql_CodeDel"].Replace('\n', ' '));
                    //var rlt = db.ExecSql(sql, out outString);
                    //kv.Value.s_ScanBarCode = ff.txt_BarCode.Text; //"1121712-BN76:S1Q0893:24:011:S22333:";// outBC;
                    //kv.Value.s_OverRead = 0;
                    //PLCSystem_CON.SIMPLCRequest.Remove(currentConNo);
                    ////ff.txt_BarCode.Text = "";
                    //}
                    #endregion
                    if (kv.Value.s_OverRead == 1)
                    {
                        string outBC = "";
                        if (PLCSystem_CON.SIMPLCRequest.TryGetValue("102", out outBC))//(currentConNo, out outBC))
                        {
                            kv.Value.s_ScanBarCode = outBC;
                            kv.Value.s_OverRead    = 0;
                            PLCSystem_CON.SIMPLCRequest.Remove("102");
                        }
                        if (PLCSystem_CON.SIMPLCRequest.TryGetValue(currentConNo, out outBC))
                        {
                            kv.Value.s_ScanBarCode = outBC;
                            kv.Value.s_OverRead    = 1;
                            PLCSystem_CON.SIMPLCRequest.Remove(currentConNo);
                        }
                    }
                    if (kv.Value.s_OverRead == 0)
                    {
                        string outString = "";
                        //插入输入库,分配货位,分配目的地
                        //应答消息
                        CON_Response cr = null;
                        Dic_CON_Res.TryGetValue(kv.Key, out cr);
                        if (cr == null)
                        {
                            continue;
                        }
                        cr.s_TUID    = kv.Value.s_ScanBarCode;
                        cr.s_TaskID  = kv.Value.s_TaskID;
                        cr.s_FromLoc = kv.Value.s_RequestLoc;

                        BarcodeInfo bi = new BarcodeInfo(cr.s_TUID);

                        #region
                        //Program.Log_Agent_CON.WriteLog(Enum_LogType.LogType_Debug,
                        //    Enum_LogGrade.LogGrade_Nin,
                        //    Enum_LogMessageType.LogMsgType_Event,
                        //    "V_LoopWrite-WriteResponse",
                        //    "条码分解",
                        //    bi.ToString());
                        #endregion

                        CurentBarcode = bi.ToString();
                        if (kv.Value.StnType == eStationType.SP)
                        {
                            //匹配路线更新目的地,(紧测试用,将来会用WMBusiness里业务类代替)
                            string toLoc = "0";
                            //Dic_setPath.TryGetValue(cr.s_FromLoc.ToString(), out toLoc);

                            WMBusiness wmsbus = new WMBusiness();
                            var        b      = wmsbus.RequestInStock(cr.s_TUID, cr.s_FromLoc.ToString(), out toLoc, out outString);
                            if (b)
                            {
                                byte tb_toLoc = 0;
                                if (!byte.TryParse(toLoc, out tb_toLoc))
                                {
                                    continue;
                                }
                                cr.s_ToLoc = tb_toLoc;
                                //将应答任务目的地写入PLC
                                cr.WirteToPLC(e.PLCConn);
                                #region
                                Program.Log_Agent_CON.WriteLog(Enum_LogType.LogType_Debug,
                                                               Enum_LogGrade.LogGrade_Nin,
                                                               Enum_LogMessageType.LogMsgType_Event,
                                                               "V_LoopWrite-WriteResponse",
                                                               string.Format("PLC:[{0}]-CON:[{1}]-TUID:[{2}]-FROMLOC:[{3}]-TOLOC:{4}-Resoponse:", plcID, currentConNo, cr.s_TUID, cr.s_FromLoc.ToString(), cr.s_ToLoc),
                                                               ByteHelper.ToMessage(cr.Tobytes(), CON_Response.cGroupLen));
                                #endregion
                            }
                            else
                            {
                                Program.Log_Agent_CON.WriteLog(Enum_LogType.LogType_Error,
                                                               Enum_LogGrade.LogGrade_Nin,
                                                               Enum_LogMessageType.LogMsgType_Event,
                                                               "V_LoopWrite-WriteResponse", "入库请求失败.", outString);
                            }
                        }
                        else if (kv.Value.StnType == eStationType.AP)
                        {
                            string toLoc = "0";
                            Dic_setPath.TryGetValue(kv.Value.s_RequestLoc.ToString(), out toLoc);
                            cr.s_ToLoc = byte.Parse(toLoc);
                            //将应答任务目的地写入PLC
                            cr.WirteToPLC(e.PLCConn);
                        }
                        else
                        {
                            //异常处理20181206
                        }
                        //更新请求任务WCS已写入状态
                        var r = kv.Value.SetOverRead(e.PLCConn);
                        Program.Log_Agent_CON.WriteLog(Enum_LogType.LogType_Debug,
                                                       Enum_LogGrade.LogGrade_Nin,
                                                       Enum_LogMessageType.LogMsgType_Event,
                                                       "V_LoopWrite-UpdateRequestStats",
                                                       string.Format("PLC:[{0}]-CON:[{1}]-TUID:[{2}]-FROMLOC:[{3}]-WriteStatus:[{4}]", plcID, currentConNo, cr.s_FromLoc.ToString(), cr.s_TUID, r.ToString()), "");
                    }
                }
                e.result = true;
            }
            catch (Exception ex)
            {
                Program.Log_Agent_CON.WriteLog(Enum_LogType.LogType_Error,
                                               Enum_LogGrade.LogGrade_Nin,
                                               Enum_LogMessageType.LogMsgType_Exception,
                                               string.Format("V_LoopWrite-[{0}]-[{1}]", plcID, currentConNo),
                                               ex.Message,
                                               ex.StackTrace);
                e.result = false;
            }
        }
示例#3
0
文件: FRM_CC.cs 项目: 13TT/TEST2
 private void Fill_T()
 {
     WMBusiness wmbus = new WMBusiness();
 }