Пример #1
0
        private void readMPR(string mpr, string nombre_estacion, int cm)
        {
            StreamReader reader    = new StreamReader(mpr);
            string       op        = "";
            string       contenido = reader.ReadToEnd();

            reader.Close();
            string programName = "";
            string pickCount   = "";
            string pickData    = "";
            string recogData   = "";
            string programN    = "";

            string[] progHeader = { };
            string[] pickCountN = { };
            string[] pickDataN  = { };
            string[] recogDataN = { };
            try
            {
                op          = Cogiscan.DB2.getPo();
                programName = extraerTag(contenido, "programa", "Index");
                pickCount   = extraerTag(contenido, "TakeUpCount", "TakeUpMiss");
                pickData    = extraerTag(contenido, "TakeUpMiss", "ChipRcgMiss");
                recogData   = extraerTag(contenido, "ChipRcgMiss", "ChipStanding");

                progHeader = Regex.Split(programName, @"([A-z0-9\-?]+)");
                programN   = decodeProgramName(progHeader);
                pickCountN = pickCount.Trim().Split('\n');
                pickDataN  = pickData.Trim().Split('\n');
                recogDataN = recogData.Trim().Split('\n');
            }
            catch (Exception e)
            { e.Message.ToString(); }

            List <Pickinfo> pickcount = explodeData(pickCountN, "pickcount");
            List <Pickinfo> pick      = explodeData(pickDataN, "pickup");
            List <Pickinfo> recog     = explodeData(recogDataN, "recog");

            // Una vez calculado los errores, junto la informacion reconocimiento con pick para guardar en DB.
            foreach (Pickinfo rec in recog)
            {
                Pickinfo findPick = pick.Find(x => x.feeder == rec.feeder && x.lado == rec.lado);
                if (findPick == null)
                {
                    pick.Add(rec);
                }
                else
                {
                    findPick.error_recog = rec.error_recog;
                }
            }

            // Recorro Pick
            foreach (Pickinfo db in pick)
            {
                int total_error = db.error_pickup + db.error_recog;
                if (total_error >= Config.config_limite_error)
                {
                    Pickinfo findPickCount = pickcount.Find(x => x.feeder == db.feeder && x.lado == db.lado);
                    if (findPickCount != null)
                    {
                        db.total_pickup = findPickCount.total_pickup;
                    }
                    Log.msg("ADD: " + nombre_estacion + "," + db.tabla + "," + db.feeder_completo + ", Part# " + db.partnumber + " Prog: " + programN + " Error:" + total_error + " Pick:" + db.total_pickup);

                    PickerDB pq = new PickerDB();
                    pq.linea        = Config.config_linea.ToString();
                    pq.maquina      = nombre_estacion;
                    pq.modulo       = cm;
                    pq.tabla        = db.tabla;
                    pq.feeder       = db.feeder_completo;
                    pq.partNumber   = db.partnumber;
                    pq.programa     = programN;
                    pq.op           = op;
                    pq.total_error  = total_error;
                    pq.total_pickup = db.total_pickup;
                    pq.turno        = Config.turno_actual;
                    pq.insert();
                }
            }
        }
Пример #2
0
        /*
         *  filtrarErrores()
         *  ANALIZA ARCHIVO XML Y GUARDA DATOS EN DB
         */
        private void filtrarErrores(string xml)
        {
            // Analizo informacion
            DateTime now = DateTime.Now;

            Log.msg("[+] Analizando informacion XML");
            Log.msg("- " + now);

            XmlDocument motoXML = new XmlDocument();
            XmlNodeList xnList  = null;

            try
            {
                motoXML.LoadXml(xml);
                xnList = motoXML.SelectNodes("/PAGE/PickupInfo/MissFeederTrend/Record");
            }
            catch (Exception ex)
            {
                Log.msg("Error al intentar acceder a los nodos del XML: " + ex.Message);
            }

            /*Obtengo nombre de programa por línea*/
            string program = getProgram();

            try
            {
                List <Pickinfo> missfeedertrend = new List <Pickinfo>();

                bool   added = false;
                string op    = Cogiscan.DB2.getPo();

                foreach (XmlNode x in xnList)
                {
                    string   valores = x["Values"].InnerText;
                    string[] info    = valores.Split(new char[] { ',' });

                    //int verMode = 1;

                    //int infoValues = int.Parse(info.Length.ToString());

                    //if (infoValues >= 16) {
                    //    verMode = 2;
                    //}

                    /*
                     * En la version 2, encontrada en el servidor LNB apartir de la version 08.01.03D,
                     * se agregan 2 valores nuevos.
                     * es necesario separar las versiones ya que en versiones anteriores no posee estos valores.
                     * y no recopilaria datos.
                     */

                    Pickinfo pick = new Pickinfo();
                    pick.historial  = int.Parse(info[0]);
                    pick.npm        = int.Parse(info[1]);
                    pick.lado       = info[3];
                    pick.partnumber = info[5];
                    pick.programa   = program;
                    pick.tabla      = info[2];

                    pick.total_pickup = int.Parse(info[9]);
                    pick.total_error  = int.Parse(info[10]);
                    pick.error_pickup = int.Parse(info[14]);
                    pick.error_recog  = int.Parse(info[13]);

                    if (pick.historial.Equals(0))
                    {
                        #region Feeder side
                        string side = "";
                        switch (int.Parse(pick.lado))
                        {
                        case 0:
                            side = "";
                            break;

                        case 1:
                            side = "-L";
                            break;

                        case 2:
                            side = "-R";
                            break;
                        }
                        #endregion

                        #region Table format
                        string formatTabla = "";
                        switch (pick.tabla[0])
                        {
                        case '1':
                            formatTabla = ((pick.npm * 2) - 1).ToString();
                            break;

                        case '2':
                            formatTabla = ((pick.npm * 2)).ToString();
                            break;
                        }
                        if (pick.tabla[1] != '0')
                        {
                            side = "-TRAY";
                        }
                        pick.feeder = int.Parse(pick.tabla.Substring(2)) + side;
                        #endregion

                        if (pick.total_error >= Config.config_limite_error)
                        {
                            Log.msg("[+] P: " + pick.programa + ", T: " + formatTabla + ", F: " + pick.feeder + ", P#: " + pick.partnumber + ", Errores: " + pick.total_error + ", Pick: " + pick.error_pickup + ", Recog: " + pick.error_recog);
                            added = true;

                            PickerDB pq = new PickerDB();
                            pq.linea      = Config.config_linea.ToString();
                            pq.maquina    = "NPM";
                            pq.modulo     = pick.npm;
                            pq.tabla      = formatTabla;
                            pq.feeder     = pick.feeder;
                            pq.partNumber = pick.partnumber;
                            pq.programa   = pick.programa;
                            pq.op         = op;

                            pq.total_error  = pick.total_error;
                            pq.total_pickup = pick.total_pickup;
                            pq.turno        = Config.turno_actual;
                            pq.insert();
                        }
                    }
                }

                if (added)
                {
                    Log.msg("**** INFORMACION CARGADA CON EXITO ****");
                }
            }
            catch (Exception ex)
            {
                Log.msg("Error al intentar cargar la información de PickUp's: " + ex.Message);
            }
        }
Пример #3
0
        /*
         * explodeData()
         * ANALIZA ARCHIVO MPR Y CALCULA ERRORES
         */
        private List <Pickinfo> explodeData(string[] lineas, string modo)
        {
            List <Pickinfo> data    = new List <Pickinfo>();
            List <string>   headvar = new List <string>();
            // Remuevo header

            bool header = true;

            foreach (string linea in lineas)
            {
                string[] vari = linea.Split(' ');

                if (header)
                {
                    foreach (string variable in vari)
                    {
                        headvar.Add(variable);
                    }
                    header = false;
                }
                else
                {
                    int      index = 0;
                    int      error = 0;
                    Pickinfo feed  = new Pickinfo();

                    foreach (string variable in vari)
                    {
                        string setVar = headvar[index];
                        string setVal = variable;
                        if (setVar.All(Char.IsLetter))
                        {
                            if (!setVal.Equals("0"))
                            {
                                switch (setVar)
                                {
                                case "Address":
                                    int feed_completo = int.Parse(setVal.Substring(2));
                                    int feed_tabla    = int.Parse(setVal[0].ToString());

                                    feed.tabla           = feed_tabla.ToString();
                                    feed.feeder          = setVal;
                                    feed.feeder_completo = feed_completo.ToString();

                                    break;

                                case "SubAdd":
                                    feed.lado = setVal;
                                    string side = "";
                                    switch (int.Parse(feed.lado))
                                    {
                                    case 0:
                                        side = "";
                                        break;

                                    case 1:
                                        side = "-L";
                                        break;

                                    case 2:
                                        side = "-R";
                                        break;
                                    }
                                    feed.feeder_completo = feed.feeder_completo + side;
                                    break;

                                case "Name":
                                    feed.partnumber = setVal;
                                    break;

                                default:
                                    if (setVar.StartsWith("NP"))
                                    {
                                        error = error + int.Parse(setVal);
                                    }
                                    break;
                                }
                            }
                        }
                        index++;
                    }

                    switch (modo)
                    {
                    case "pickup":
                        feed.error_pickup = error;
                        break;

                    case "recog":
                        feed.error_recog = error;
                        break;

                    case "pickcount":
                        feed.total_pickup = error;
                        break;
                    }

                    data.Add(feed);
                }
            }
            return(data);
        }