예제 #1
0
파일: Form1.cs 프로젝트: MaTiUs77/Newsan
        public void Start()
        {
            // Obtengo turno actual.
            Config.turno_actual = PickerDB.getTurno();

            bool releaseDebug = false;

            // Inicio modulo
            //try
            //{
            if (!releaseDebug)
            {
                switch (Config.config_modulo)
                {
                case "npm":
                    NPM npm = new NPM();
                    npm.iniciar();
                    break;

                case "cm":
                    CM cm = new CM();
                    cm.iniciar();
                    break;
                }
            }

            try
            { PickerDB.ping(Config.config_linea.ToString(), Config.config_modulo.ToString()); }
            catch (Exception ex) { Log.msg("[Error] No se puede actualizar el ping en el servidor: " + ex.Message); }

            //}
            //catch (Exception ex)
            //{
            //    Log.msg("-------- ERROR ----------");
            //    Log.msg(ex.Message);
            //    Log.msg(ex.Source);
            //    Log.msg("-------- ///// ----------");
            //}
        }
예제 #2
0
파일: NPM.cs 프로젝트: MaTiUs77/Newsan
        /*
         *  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
파일: CM.cs 프로젝트: MaTiUs77/Newsan
        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();
                }
            }
        }