コード例 #1
0
        public void CreatePanel_WithAddingPanel()
        {
            int code = 2;
            AlarmMonitorContext context = new AlarmMonitorContext();
            PanelService        service = new PanelService(context.GetPanelRepository());

            service.CreatePanel(code);

            int actual   = context.GetPanelRepository().GetAll().Count();
            int expected = 1;

            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
        /// <summary>
        /// Obtiene datos de panel desde el webservice
        /// </summary>
        /// <returns>InspectionService</returns>
        public PanelService GetBarcodeInfoFromIAServer()
        {
            PanelService panelService = new PanelService();

            // Por ahora no verifica si ya fue declarado....
            panelService.GetPanelInfo(barcode, false);
            if (panelService.error == null)
            {
                if (panelService.result.panel != null)
                {
                    panelId = panelService.result.panel.id;
                    op      = panelService.result.panel.inspected_op;

                    machine.LogBroadcast("notify",
                                         string.Format("El panel ID: ({0}) tiene OP Asignada: {1}", panelId, op)
                                         );
                }
                else
                {
                    machine.LogBroadcast("warning",
                                         string.Format("El panel no fue registrado en IAServer ({0})", barcode)
                                         );
                }
            }
            else
            {
                machine.log.stack(
                    string.Format("+ Stack Error en la verificacion de panel en IAServer ({0}) ", barcode
                                  ), this, panelService.error);
            }

            if (panelId == 0)
            {
                spMode = "insert";
            }

            return(panelService);
        }
コード例 #3
0
        private PanelService SavePanel(PanelService panelService)
        {
            Stopwatch sw = Stopwatch.StartNew();

            if (Config.debugMode)
            {
                machine.LogBroadcast("warning", "Debug mode ON, no ejecuta StoreProcedure para guardar panel");
            }
            else
            {
                #region SAVE PANELS ON DB
                string query = @"CALL sp_setInspectionPanel_optimizando('" + panelId + "','" + machine.mysql_id + "',  '" + barcode + "',  '" + programa + "',  '" + fecha + "',  '" + hora + "',  '',  '" + revisionAoi + "',  '" + revisionIns + "',  '" + totalErrores + "',  '" + totalErroresFalsos + "',  '" + totalErroresReales + "',  '" + pcbInfo.bloques + "',  '" + tipoBarcode + "',  '" + Convert.ToInt32(pendiente) + "' ,  '" + machine.oracle_id + "' ,  '" + vtwinProgramNameId + "' ,  '" + spMode + "'  );";

                machine.LogBroadcast("debug",
                                     string.Format("Ejecutando StoreProcedure: sp_setInspectionPanel_optimizando({0}) =>", barcode)
                                     );

                MySqlConnector sql = new MySqlConnector();
                sql.LoadConfig("IASERVER");
                DataTable sp = sql.Query(query);
                if (sql.rows)
                {
                    // En caso de insert, informo el id_panel creado, si fue un update, seria el mismo id_panel...
                    panelId = int.Parse(sp.Rows[0]["id_panel"].ToString());
                    //if (pendiente)
                    //{
                    //    Pendiente.Save(this);
                    //}

                    if (pendienteDelete)
                    {
                        Pendiente.Delete(this);
                    }

                    if (panelId > 0)
                    {
                        try
                        {
                            history.SavePanel(panelId, spMode);
                        }
                        catch (Exception ex)
                        {
                            machine.log.stack(
                                string.Format("+ Error al ejecutar history.SavePanel({0}, {1}) ", panelId, spMode
                                              ), this, ex);
                        }
                    }
                }
                #endregion
            }

            // Es necesario volver a ejecutar el service, para obtener la OP asignada al panel
            if (spMode == "insert")
            {
                machine.LogBroadcast("debug", "Actualizando datos de panel insertado");
                panelService = GetBarcodeInfoFromIAServer();
            }

            sw.Stop();

            machine.LogBroadcast("success",
                                 string.Format("Panel guardado: {0} (ms) {1} ",
                                               barcode,
                                               (long)sw.ElapsedMilliseconds)
                                 );

            // Retorno ID, 0 si no pudo insertar, o actualizar
            return(panelService);
        }
コード例 #4
0
        private PanelService PanelHandlerService(string path)
        {
            Stopwatch sw = Stopwatch.StartNew();

            // Verifica si existe la placa en iaserver
            PanelService panelService = GetBarcodeInfoFromIAServer();

            sw.Stop();

            machine.LogBroadcast("success",
                                 string.Format("API GetBarcodeInfo Tiempo de respuesta: (ms) {0} ",
                                               (long)sw.ElapsedMilliseconds)
                                 );

            // Solo proceso si el servicio respondio sin problemas
            if (panelService.error == null)
            {
                machine.LogBroadcast("debug",
                                     string.Format("Panel Modo: {0}", spMode)
                                     );

                try
                {
                    if (spMode.Equals("insert"))
                    {
                        // Placa nueva, solo procedo si la OP no esta completa...

                        /*
                         * if (machine.prodService.isFinished())
                         * {
                         *  machine.LogBroadcast("warning",
                         *      string.Format("Produccion finalizada")
                         *  );
                         * }
                         */
                        SavePanel(panelService);
                    }
                    else
                    {
                        // La placa ya existe, actualizo sus datos
                        SavePanel(panelService);
                    }
                } catch (Exception ex) {
                    machine.log.stack(
                        string.Format("+ SavePanel exception"
                                      ), this, ex);
                }

                // Si la linea tiene configurada la Trazabilidad por Cogiscan, valida ruta
                #region Validacion con rutas de cogiscan

                /*
                 * if (machine.prodService.result.produccion.cogiscan.Equals("T"))
                 * {
                 *  machine.LogBroadcast("warning",
                 *      string.Format("Esta ruta requiere validacion con cogiscan")
                 *  );
                 *  if (panelService.result.cogiscan.product.attributes.operation.Equals("AOI"))
                 *  {
                 *      SavePanel(panelService);
                 *  } else {
                 *      machine.LogBroadcast("warning",
                 *          string.Format("+ El panel {0} no se encuentra en la ruta AOI", barcode)
                 *      );
                 *  }
                 * } else {
                 *  SavePanel(panelService);
                 * }
                 */
                #endregion
            }
            else   // IF ERROR EN SERVICE
            {
                machine.log.stack(
                    string.Format("+ PanelService exception"
                                  ), this, panelService.error);
            }

            // Solo guardo bloques, si se realizaron correctamente las tareas anteriores
            if (panelId > 0 && panelService.error == null)
            {
                SaveBlocks(path);

                // Verifica si la ruta declara
                if (machine.prodService.routeDeclare)
                {
                    // Verifica si la produccion no termino AOI_PROD >= AOI_QTY
                    if (!machine.prodService.isFinished())
                    {
                        machine.LogBroadcast("info",
                                             string.Format("Declarando panel")
                                             );

                        Declarar declarar = new Declarar();
                        declarar.withPanelBarcode(panelService.result.panel.panel_barcode);
                    }
                    else
                    {
                        machine.LogBroadcast("warning",
                                             string.Format("No se puede declarar el panel {0} se detecto produccion finalizada!", panelService.result.panel.panel_barcode)
                                             );
                    }
                }

                #region Legacy mode, exporta XML

                /*
                 * foreach (Bloque bloque in bloqueList)
                 * {
                 *  if (machine.prodService.routeMode.Equals("sfcs"))
                 *  {
                 *      Export.toXML(this, bloque, path);
                 *  }
                 * }
                 */
                #endregion
            }

            return(panelService);
        }
コード例 #5
0
        // LLAMADA EN FASE BETA, necesita testing, pero en modo async podria aumentar mucho la velocidad de inspeccion
        private async Task <PanelService> AsyncGetBarcodeInfoFromIAServer()
        {
            PanelService panelService = await Task.Run(() => GetBarcodeInfoFromIAServer());

            return(panelService);
        }