Exemplo n.º 1
0
        private void InicializaDesenhosSimbolos4()
        {
            // Inicio de Linha
            simboloInicioLinha.setCI(CodigosInterpretaveis.INICIO_DA_LINHA);

            SimboloBasico ex1 = null;

            ex1 = new SimboloBasico();
            ex1.setCI(CodigosInterpretaveis.CONTATO_NA);
            simbolos.Add(ex1);

            ex1 = new SimboloBasico();
            ex1.setCI(CodigosInterpretaveis.PARALELO_INICIAL);
            saida.Add(ex1);

            ex1 = new SimboloBasico();
            ex1.setCI(CodigosInterpretaveis.BOBINA_SAIDA);
            saida.Add(ex1);

            ex1 = new SimboloBasico();
            ex1.setCI(CodigosInterpretaveis.PARALELO_PROXIMO);
            saida.Add(ex1);

            ex1 = new SimboloBasico();
            ex1.setCI(CodigosInterpretaveis.BOBINA_SAIDA);
            saida.Add(ex1);

            ex1 = new SimboloBasico();
            ex1.setCI(CodigosInterpretaveis.PARALELO_FINAL);
            saida.Add(ex1);

            // Fim de Linha
            simboloFimLinha.setCI(CodigosInterpretaveis.FIM_DA_LINHA);
        }
Exemplo n.º 2
0
        private void InicializaDesenhosSimbolos3()
        {
            // Inicio de Linha
            simboloInicioLinha.setCI(CodigosInterpretaveis.INICIO_DA_LINHA);

            SimboloBasico ex1 = null;

            ex1 = new SimboloBasico();
            ex1.setCI(CodigosInterpretaveis.CONTATO_NA);
            ex1.setOperando(0, endereco.lstMemoria[1]);
            simbolos.Add(ex1);

            ex1 = new SimboloBasico();
            ex1.setCI(CodigosInterpretaveis.CONTATO_NF);
            ex1.setOperando(0, endereco.lstTemporizador[2]);
            simbolos.Add(ex1);


            //saida
            ex1 = new SimboloBasico();
            ex1.setCI(CodigosInterpretaveis.BOBINA_SAIDA);
            ex1.setOperando(0, endereco.lstMemoria[1]);
            saida.Add(ex1);

            // Fim de Linha
            simboloFimLinha.setCI(CodigosInterpretaveis.FIM_DA_LINHA);
        }
Exemplo n.º 3
0
        private void mnuEditarComentário_Click(object sender, EventArgs e)
        {
            if (IsDiagramaAberto())
            {
                if (frmProj.frmDiagLadder.ControleSelecionado != null)
                {
                    if (!frmProj.frmDiagLadder.ControleSelecionado.IsDisposed)
                    {
                        SimboloBasico _sb = frmProj.frmDiagLadder.ControleSelecionado.SimboloBasico;
                        if (_sb.getOperandos(0) != null)
                        {
                            if ((_sb.getOperandos(0).GetType().Name == "EnderecamentoLadder"))
                            {
                                frmAlteraComentario frmAltComent = new frmAlteraComentario();

                                frmAltComent.txtComentario.Text = ((EnderecamentoLadder)_sb.getOperandos(0)).Apelido.Trim();
                                frmAltComent.Text = frmAltComent.Text.Replace("#ENDERECO#", ((EnderecamentoLadder)_sb.getOperandos(0)).Nome);

                                DialogResult _result = frmAltComent.ShowDialog();
                                if (_result == DialogResult.OK)
                                {
                                    ((EnderecamentoLadder)_sb.getOperandos(0)).Apelido = frmAltComent.txtComentario.Text;
                                    frmProj.frmDiagLadder.Invalidate(true);
                                }
                            }
                        }
                    }
                }
            }
        }
        public void Add(SimboloBasico _sb)
        {
            Add(_sb.getCI());

            switch (_sb.getCI())
            {
            case CodigosInterpretaveis.CONTADOR:
                if (_sb.iNumOperandos > 0)
                {
                    if (_sb.getOperandos(0) != null)
                    {
                        if (_sb.getOperandos(0).GetType().Name == EnderecamentoLadder.ClassName())
                        {
                            Add(((EnderecamentoLadder)_sb.getOperandos(0)).Indice);
                            Add(((EnderecamentoLadder)_sb.getOperandos(0)).Contador.Tipo);
                            Add(((EnderecamentoLadder)_sb.getOperandos(0)).Contador.Preset);
                        }
                    }
                }
                break;

            case CodigosInterpretaveis.TEMPORIZADOR:
                if (_sb.iNumOperandos > 0)
                {
                    if (_sb.getOperandos(0) != null)
                    {
                        if (_sb.getOperandos(0).GetType().Name == EnderecamentoLadder.ClassName())
                        {
                            Add(((EnderecamentoLadder)_sb.getOperandos(0)).Indice);
                            Add(((EnderecamentoLadder)_sb.getOperandos(0)).Temporizador.Tipo);
                            Add(((EnderecamentoLadder)_sb.getOperandos(0)).Temporizador.BaseTempo);
                            Add(((EnderecamentoLadder)_sb.getOperandos(0)).Temporizador.Preset);
                        }
                    }
                }
                break;

            default:
                if (_sb.iNumOperandos > 0)
                {
                    for (int i = 0; i < _sb.iNumOperandos; i++)
                    {
                        if (_sb.getOperandos(i) != null)
                        {
                            if (_sb.getOperandos(i).GetType().Name == EnderecamentoLadder.ClassName())
                            {
                                Add((EnderecamentoLadder)_sb.getOperandos(i));
                            }
                        }
                    }
                }
                break;
            }
        }
Exemplo n.º 5
0
        private void InicializaDesenhosSimbolos5()
        {
            // Inicio de Linha
            simboloInicioLinha.setCI(CodigosInterpretaveis.INICIO_DA_LINHA);

            SimboloBasico ex1 = null;

            ex1 = new SimboloBasico();
            ex1.setCI(CodigosInterpretaveis.CONTATO_NA);
            ex1.setOperando(0, endereco.lstMemoria[0]);
            endereco.lstMemoria[0].EmUso = true;
            simbolos.Add(ex1);

            ex1 = new SimboloBasico();
            ex1.setCI(CodigosInterpretaveis.PARALELO_INICIAL);
            saida.Add(ex1);

            ex1 = new SimboloBasico();
            ex1.setCI(CodigosInterpretaveis.BOBINA_SAIDA);
            saida.Add(ex1);

            ex1 = new SimboloBasico();
            ex1.setCI(CodigosInterpretaveis.PARALELO_PROXIMO);
            saida.Add(ex1);

            ex1 = new SimboloBasico();
            ex1.setCI(CodigosInterpretaveis.BOBINA_SAIDA);
            saida.Add(ex1);

            ex1 = new SimboloBasico();
            ex1.setCI(CodigosInterpretaveis.PARALELO_PROXIMO);
            saida.Add(ex1);

            ex1 = new SimboloBasico();
            ex1.setCI(CodigosInterpretaveis.BOBINA_SAIDA);
            saida.Add(ex1);

            ex1 = new SimboloBasico();
            ex1.setCI(CodigosInterpretaveis.PARALELO_FINAL);
            saida.Add(ex1);

            // Fim de Linha
            simboloFimLinha.setCI(CodigosInterpretaveis.FIM_DA_LINHA);
            //simboloFimLinha.TabStop = false;
        }
Exemplo n.º 6
0
        private void LerExecutavel(String DadosConvertidosChar, String strNomeProjeto)
        {
            List <int>            lstCodigosLidos = new List <int>();
            CodigosInterpretaveis guarda          = CodigosInterpretaveis.NENHUM;

            if (DadosConvertidosChar.IndexOf("@laddermic.com") != -1)
            {
                Int32 intContaFim    = 0;
                Int32 intIndiceLinha = 0;
                Int32 iNumOperandos  = 0;
                EnderecamentoLadder          _endLido;
                TipoEnderecamentoDispositivo _tpEndLido;
                Int32 _iIndiceEndLido = 0;


                /// Cria um programa novo vazio
                ProgramaBasico programa = new ProgramaBasico();
                programa.StsPrograma = ProgramaBasico.StatusPrograma.NOVO;
                programa.Nome        = strNomeProjeto;
                programa.dispositivo = new DispositivoLadder(1);
                programa.endereco.AlocaEnderecamentoIO(programa.dispositivo);
                programa.endereco.AlocaEnderecamentoMemoria(programa.dispositivo, programa.endereco.lstMemoria, TipoEnderecamentoDispositivo.DIGITAL_MEMORIA, 10);
                programa.endereco.AlocaEnderecamentoMemoria(programa.dispositivo, programa.endereco.lstTemporizador, TipoEnderecamentoDispositivo.DIGITAL_MEMORIA_TEMPORIZADOR, 10);
                programa.endereco.AlocaEnderecamentoMemoria(programa.dispositivo, programa.endereco.lstContador, TipoEnderecamentoDispositivo.DIGITAL_MEMORIA_CONTADOR, 10);
                intIndiceLinha = programa.InsereLinhaNoFinal(new LinhaCompleta());

                for (int i = DadosConvertidosChar.IndexOf("@laddermic.com") + 15; i < DadosConvertidosChar.Length; i++)
                {
                    guarda = (CodigosInterpretaveis)Convert.ToChar(DadosConvertidosChar.Substring(i, 1));

                    switch (guarda)
                    {
                    case CodigosInterpretaveis.NENHUM:
                        intContaFim++;
                        iNumOperandos = 0;
                        break;

                    case CodigosInterpretaveis.FIM_DA_LINHA:
                        intContaFim++;
                        iNumOperandos = 0;
                        if ((CodigosInterpretaveis)Convert.ToChar(DadosConvertidosChar.Substring(i + 1, 1)) != CodigosInterpretaveis.NENHUM)
                        {
                            intIndiceLinha = programa.InsereLinhaNoFinal(new LinhaCompleta());
                        }
                        break;

                    //case CodigosInterpretaveis.INICIO_DA_LINHA:
                    case CodigosInterpretaveis.CONTATO_NA:
                    case CodigosInterpretaveis.CONTATO_NF:
                        intContaFim   = 0;
                        iNumOperandos = 2;
                        {
                            SimboloBasico _sb = new SimboloBasico((CodigosInterpretaveis)guarda);
                            //_sb.setOperando(0, programa.endereco.Find((TipoEnderecamentoDispositivo)Convert.ToChar(DadosConvertidosChar.Substring(i + 1, 1)), (Int32)Convert.ToChar(DadosConvertidosChar.Substring(i + 2, 1))));

                            _tpEndLido      = (TipoEnderecamentoDispositivo)Convert.ToChar(DadosConvertidosChar.Substring(i + 1, 1));
                            _iIndiceEndLido = (Int32)Convert.ToChar(DadosConvertidosChar.Substring(i + 2, 1));
                            _endLido        = programa.endereco.Find(_tpEndLido, _iIndiceEndLido);
                            if (_endLido == null)
                            {
                                programa.dispositivo.lstBitPorta[_iIndiceEndLido - 1].TipoDefinido = _tpEndLido;
                                programa.dispositivo.RealocaEnderecoDispositivo();
                                programa.endereco.AlocaEnderecamentoIO(programa.dispositivo);
                                _endLido = programa.endereco.Find(_tpEndLido, _iIndiceEndLido);
                            }
                            _sb.setOperando(0, _endLido);

                            i += 2;
                            programa.linhas[intIndiceLinha].simbolos.Add(_sb);
                        }
                        break;

                    case CodigosInterpretaveis.BOBINA_SAIDA:
                    case CodigosInterpretaveis.RESET:
                        intContaFim   = 0;
                        iNumOperandos = 2;
                        {
                            ListaSimbolo _lstSB = new ListaSimbolo();
                            _lstSB.Add(new SimboloBasico((CodigosInterpretaveis)guarda));
                            _tpEndLido      = (TipoEnderecamentoDispositivo)Convert.ToChar(DadosConvertidosChar.Substring(i + 1, 1));
                            _iIndiceEndLido = (Int32)Convert.ToChar(DadosConvertidosChar.Substring(i + 2, 1));
                            _endLido        = programa.endereco.Find(_tpEndLido, _iIndiceEndLido);
                            if (_endLido == null)
                            {
                                programa.dispositivo.lstBitPorta[_iIndiceEndLido - 1].TipoDefinido = _tpEndLido;
                                programa.dispositivo.RealocaEnderecoDispositivo();
                                programa.endereco.AlocaEnderecamentoIO(programa.dispositivo);
                                _endLido = programa.endereco.Find(_tpEndLido, _iIndiceEndLido);
                            }
                            _lstSB[_lstSB.Count - 1].setOperando(0, _endLido);
                            i += 2;
                            programa.linhas[intIndiceLinha].Insere2Saida(_lstSB);
                            _lstSB.Clear();
                        }
                        break;

                    case CodigosInterpretaveis.PARALELO_INICIAL:
                    case CodigosInterpretaveis.PARALELO_FINAL:
                    case CodigosInterpretaveis.PARALELO_PROXIMO:
                        intContaFim   = 0;
                        iNumOperandos = 0;
                        programa.linhas[intIndiceLinha].simbolos.Add(new SimboloBasico((CodigosInterpretaveis)guarda));
                        break;

                    case CodigosInterpretaveis.CONTADOR:
                        intContaFim   = 0;
                        iNumOperandos = 3;
                        {
                            ListaSimbolo _lstSB = new ListaSimbolo();
                            _lstSB.Add(new SimboloBasico((CodigosInterpretaveis)guarda));
                            _lstSB[_lstSB.Count - 1].setOperando(0, programa.endereco.Find(TipoEnderecamentoDispositivo.DIGITAL_MEMORIA_CONTADOR, (Int32)Convert.ToChar(DadosConvertidosChar.Substring(i + 1, 1))));
                            ((EnderecamentoLadder)_lstSB[_lstSB.Count - 1].getOperandos(0)).Contador.Tipo   = (Int32)Convert.ToChar(DadosConvertidosChar.Substring(i + 2, 1));
                            ((EnderecamentoLadder)_lstSB[_lstSB.Count - 1].getOperandos(0)).Contador.Preset = (Int32)Convert.ToChar(DadosConvertidosChar.Substring(i + 3, 1));

                            _lstSB[_lstSB.Count - 1].setOperando(1, ((EnderecamentoLadder)_lstSB[_lstSB.Count - 1].getOperandos(0)).Contador.Tipo);
                            _lstSB[_lstSB.Count - 1].setOperando(2, ((EnderecamentoLadder)_lstSB[_lstSB.Count - 1].getOperandos(0)).Contador.Preset);
                            i += 3;
                            programa.linhas[intIndiceLinha].Insere2Saida(_lstSB);
                            _lstSB.Clear();
                        }
                        break;

                    case CodigosInterpretaveis.TEMPORIZADOR:
                        intContaFim   = 0;
                        iNumOperandos = 4;
                        {
                            ListaSimbolo _lstSB = new ListaSimbolo();
                            _lstSB.Add(new SimboloBasico((CodigosInterpretaveis)guarda));
                            _lstSB[_lstSB.Count - 1].setOperando(0, programa.endereco.Find(TipoEnderecamentoDispositivo.DIGITAL_MEMORIA_TEMPORIZADOR, (Int32)Convert.ToChar(DadosConvertidosChar.Substring(i + 1, 1))));
                            ((EnderecamentoLadder)_lstSB[_lstSB.Count - 1].getOperandos(0)).Temporizador.Tipo      = (Int32)Convert.ToChar(DadosConvertidosChar.Substring(i + 2, 1));
                            ((EnderecamentoLadder)_lstSB[_lstSB.Count - 1].getOperandos(0)).Temporizador.BaseTempo = (Int32)Convert.ToChar(DadosConvertidosChar.Substring(i + 3, 1));
                            ((EnderecamentoLadder)_lstSB[_lstSB.Count - 1].getOperandos(0)).Temporizador.Preset    = (Int32)Convert.ToChar(DadosConvertidosChar.Substring(i + 4, 1));

                            _lstSB[_lstSB.Count - 1].setOperando(1, ((EnderecamentoLadder)_lstSB[_lstSB.Count - 1].getOperandos(0)).Temporizador.Tipo);
                            _lstSB[_lstSB.Count - 1].setOperando(2, ((EnderecamentoLadder)_lstSB[_lstSB.Count - 1].getOperandos(0)).Temporizador.Preset);
                            _lstSB[_lstSB.Count - 1].setOperando(4, ((EnderecamentoLadder)_lstSB[_lstSB.Count - 1].getOperandos(0)).Temporizador.BaseTempo);

                            i += 4;
                            programa.linhas[intIndiceLinha].Insere2Saida(_lstSB);
                            _lstSB.Clear();
                        }
                        break;
                    }

                    /// fim dos códigos
                    if (intContaFim >= 2)
                    {
                        /// grava os dados lidos do codigo intepretavel
                        ModuloIntegracaoMSP430 p = new ModuloIntegracaoMSP430();
                        p.CriaArquivo("codigosinterpretaveis.txt", DadosConvertidosChar.Substring(DadosConvertidosChar.IndexOf("@laddermic.com"), i - DadosConvertidosChar.IndexOf("@laddermic.com") + 1));

                        /// força saída do loop
                        i = DadosConvertidosChar.Length;
                    }
                }
                frmProj           = new ProjetoLadder(programa);
                frmProj.MdiParent = this;
                frmProj.Show();
                frmProj.SetText();
            }
            else
            {
                MessageBox.Show("O arquivo não foi reconhecido pelo sistema!", "Abrir Arquivos ...", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 7
0
        private ControleLivre InsereSimboloUnicoVisual(int _indiceSimbolo, List <ControleLivre> _lstCL, SimboloBasico _sB)
        {
            /// Visual
            _lstCL.Insert(_indiceSimbolo, new ControleLivre(_sB));
            _lstCL[_indiceSimbolo].linhaAtual             = this;
            _lstCL[_indiceSimbolo].TabStop                = true;
            _lstCL[_indiceSimbolo].ControleSelecionado   += new ControleSelecionadoEventHandler(frmDiag.Simbolo_ControleSelecionado);
            _lstCL[_indiceSimbolo].MouseClick            += new MouseEventHandler(Simbolo_Click);
            _lstCL[_indiceSimbolo].KeyDown               += new KeyEventHandler(frmDiag.Simbolo_KeyDown);
            _lstCL[_indiceSimbolo].SolicitaMudarEndereco += new SolicitaMudarEnderecoEventHandler(frmDiag.ControleSelecionado_SolicitaMudarEndereco);
            _lstCL[_indiceSimbolo].Parent  = this.frmDiag;
            _lstCL[_indiceSimbolo].Visible = false;
            _lstCL[_indiceSimbolo].CreateControl();
            _lstCL[_indiceSimbolo].BringToFront();

            if (_sB.getCI() == CodigosInterpretaveis.TEMPORIZADOR ||
                _sB.getCI() == CodigosInterpretaveis.CONTADOR)
            {
                _lstCL[_indiceSimbolo].MouseHover += new EventHandler(frmDiag.SimboloQuadroSaida_MouseHover);
            }

            return(_lstCL[_indiceSimbolo]);
        }