コード例 #1
0
ファイル: Principal.cs プロジェクト: echicerman/cncmatic
        //List<string> lineas = Metodos.CilindroCentrado(20, 30, 5, 1,5);
        //List<string> lineas = Metodos.GastarPlano(0,0,20, 20, 1);
        //List<string> lineas = Metodos.Escalera(50, 50, 50, 10, 10);
        //List<string> lineas = Metodos.Escalera(15, 15, 15, 5, 5);
        //this.txtPreview.Text += ("G00 Z15" + Environment.NewLine);
        //foreach (string s in lineas)
        //    this.txtPreview.Text += (s + Environment.NewLine);
        private void btnPlay_Click(object sender, EventArgs e)
        {
            try
            {
                //validamos los comandos
                //removemos los blancos
                List<string> lineas = txtPreview.Lines.ToList();
                /*while (lineas.Contains(""))
                {
                    lineas.Remove("");
                }

                txtPreview.Text = "";
                foreach (string linea in lineas)
                {
                    txtPreview.Text += linea + Environment.NewLine;
                }

                foreach (string linea in lineas)
                {
                    if (Char.ToUpper(linea[0]) != 'G' && Char.ToUpper(linea[0]) != 'M')
                    {
                        ////limpiamos el enter ingresado
                        //e.KeyChar = new char();
                        MessageBox.Show("Instrucción \"" + linea + "\" no válida, por favor corregir", "Ingreso manual de instrucciones", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else if (!Char.IsNumber(linea[1]))
                    {
                        ////limpiamos el enter ingresado
                        //e.KeyChar = new char();
                        MessageBox.Show("Instrucción \"" + linea + "\" no válida, por favor corregir", "Ingreso manual de instrucciones", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                txtPreview.Select(txtPreview.Text.Length, 0);
                */
                //Muestra figura en el previsualizador
                //this.LimpiarPrevisualizador(); <<--sacamos la previsualizacion de nuevo
                //PrevisualizarFigurasManual();  <<--porque en figuras grandes tardaba mucho

                //---validamos que haya instrucciones para ser enviadas
                //obtenemos las lineas del previsualizador y removemos los blancos
                List<string> loteInstrucciones = txtPreview.Lines.ToList();
                /*while (loteInstrucciones.Contains(""))
                {
                    loteInstrucciones.Remove("");
                }*/

                if (loteInstrucciones.Count == 0)
                {
                    MessageBox.Show("No posee instrucciones para ser transferidas al CNC", "Transferencia CNC", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                    return;
                }

                //sino esta en un estado válido para continuar...
                if (lblEstado.Text != "Conectando (paso 3 de 3): Conexión establecida" && lblEstado.Text != "Fin del programa" && !pausado)
                {
                    //ver que hacemos...
                }
                else
                {
                    //sino venimos de una pausa
                    if (!pausado)
                    {
                        DialogResult dr = MessageBox.Show("Se iniciará el envío de las instrucciones al CNC." + Environment.NewLine + "¿Desea Continuar?", "Transferencia CNC", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                        if (dr == DialogResult.Yes)
                        {
                            Punto p = Interfaz.PosicionActual();

                            List<string> loteInstruccionesAlOrigen = null;

                            FrmDibujoParams f = new FrmDibujoParams(ref p);
                            f.ShowDialog();

                            if (p.X != Interfaz.PosicionActual().X || p.Y != Interfaz.PosicionActual().Y || p.Z != Interfaz.PosicionActual().Z)
                            {
                                p.Z = 0 - p.Z;
                                loteInstruccionesAlOrigen = Metodos.IrAL(p);
                            }
                            else
                                p = null;

                            if (Interfaz.ConectarCNC(ref lblEstado, loteInstrucciones, ref lblPosicionActual, ref this.prgBar, loteInstruccionesAlOrigen))
                            {
                                //bloqueamos controles
                                btnPlay.Enabled = false;
                                btnInicio.Enabled = false;
                                btnStop2.Enabled = true;
                                gbMovXY.Enabled = false;
                                gbMovZ.Enabled = false;
                                txtLineaManual.Enabled = false;
                                btnLimpiar.Enabled = false;
                                toolStrip1.Enabled = false;
                                txtPreview.Enabled = false;

                                btnPause.Enabled = true;

                                //bloqueamos el menu para que no modifiquen la configuracion
                                configuracionToolStripMenuItem.Enabled = false;
                            }
                        }

                    }
                    else
                    {//reanuda la ejecucion luego de una pausa

                        DialogResult dr = MessageBox.Show("Se reanudará el envío de las instrucciones al CNC." + Environment.NewLine + "¿Desea Continuar?", "Reanudar Transferencia CNC", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                        if (dr == DialogResult.Yes)
                        {
                            Interfaz.ReaudarTransmision();

                            //bloqueamos controles
                            btnPlay.Enabled = false;
                            btnInicio.Enabled = false;
                            btnStop2.Enabled = true;
                            gbMovXY.Enabled = false;
                            gbMovZ.Enabled = false;
                            txtLineaManual.Enabled = false;
                            btnLimpiar.Enabled = false;
                            toolStrip1.Enabled = false;
                            txtPreview.Enabled = false;

                            btnPause.Enabled = true;

                            //salimos de la pausa
                            this.pausado = false;

                            //bloqueamos el menu para que no modifiquen la configuracion
                            configuracionToolStripMenuItem.Enabled = false;
                        }
                    }

                }
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("Interfaz.ConectarCNC: IniciarTransmision: CNC.PrepararComandos: Comando no soportado:"))
                {
                    string mensaje = ex.Message.Replace("Interfaz.ConectarCNC: IniciarTransmision: CNC.PrepararComandos: ", "");

                    //existen comandos no válidos
                    MessageBox.Show("Error: " + mensaje, "Comando no soportado", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #2
0
ファイル: Principal.cs プロジェクト: echicerman/cncmatic
        private void dToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            G01_Cuadrado g;

            FrmDibujoParams dibujoParams = new FrmDibujoParams(out g);
            dibujoParams.ShowDialog();

            if (dibujoParams.modificado)
            {
                AgregaTextoEditor(false, g.ToString());

                //Muestra figura en el previsualizador
                PrevisualizarFigurasManual();
            }
        }
コード例 #3
0
ファイル: Principal.cs プロジェクト: echicerman/cncmatic
        private void btnArco_Click(object sender, EventArgs e)
        {
            G02_ArcoH g;

            FrmDibujoParams dibujoParams = new FrmDibujoParams(out g);
            dibujoParams.ShowDialog();

            if (dibujoParams.modificado)
            {
                AgregaTextoEditor(false, g.ToString2());

                //Muestra figura en el previsualizador
                PrevisualizarFigurasManual();
            }
        }