void simboloInicioLinha_Click(object sender, MouseEventArgs e) { ControleLivre _cL = (ControleLivre)sender; CodigosInterpretaveis _cI = _cL.getCI(); DiagramaLadder _frmDL; _frmDL = (DiagramaLadder)_cL.Parent; if (e.Button == MouseButtons.Right) { if (_cI == CodigosInterpretaveis.INICIO_DA_LINHA) { _frmDL.menuEnderecamento.Enabled = false; _frmDL.menuInsereLinha.Enabled = true; /// Extensao de paralelo - acima/abaixo /// somente sobre simbolos de paralelo _frmDL.menuEstenderParaleloAcima.Enabled = false; _frmDL.menuEstenderParaleloAcima.Visible = false; _frmDL.menuEstenderParaleloAbaixo.Enabled = false; _frmDL.menuEstenderParaleloAbaixo.Visible = false; _frmDL.menuControle.Show(_cL.PointToScreen(e.Location)); } } }
public List <SimboloBasico> VariosSelecionados(ControleLivre _cL, LinhaCompletaVisual _lCL) { CodigosInterpretaveis _cI = _cL.getCI(); List <SimboloBasico> _lstSB = new List <SimboloBasico>(); List <ControleLivre> _lstCL = null; switch (_cI) { case CodigosInterpretaveis.PARALELO_INICIAL: case CodigosInterpretaveis.PARALELO_PROXIMO: case CodigosInterpretaveis.PARALELO_FINAL: int _indicePosInicial = 0; int _indicePosFinal = 0; /// verifica em qual lista o controle esta presente (simbolos/saida) if (LinhaSelecionada.simbolos.Contains(_cL)) { _lstCL = LinhaSelecionada.simbolos; } else if (LinhaSelecionada.saida.Contains(_cL)) { _lstCL = LinhaSelecionada.saida; } else { return(_lstSB); } /// define a posicao inicial a partir da posicao /// do controle na lista _indicePosInicial = _lstCL.IndexOf(_cL); if (_cI == CodigosInterpretaveis.PARALELO_FINAL) { /// se for paralelo final, inverte a posicial inicial/final _indicePosFinal = _indicePosInicial; /// se for paralelo final, a posicao inicial e /// o paralelo inical _indicePosInicial = _lstCL.IndexOf(_cL.Aponta2PI); } else { /// senao for final aponta para o proximo item de paralelo _indicePosFinal = _lstCL.IndexOf(_cL.Aponta2proxPP); } /// pega todos os controles dentro da faixa inicial / final for (int i = _indicePosInicial; i <= _indicePosFinal; i++) { _lstSB.Add(_lstCL[i].SimboloBasico); } break; default: _lstSB.Add(_cL.SimboloBasico); break; } return(_lstSB); }
public virtual void setCI(CodigosInterpretaveis codInterpretavelNovo) { //// salva o simbolo anterior para suas informacoes //// (ex. codigo inter., operandos) sejam utilizados quando necessario //SimboloBasico salvaCodigoAnterior =new SimboloBasico(); //// para aqueles codigos ou simbos que precisam salvam o simbolo anterior //if (((codInterpretavelNovo == CodigosInterpretaveis.PARALELO_INICIAL || // codInterpretavelNovo == CodigosInterpretaveis.PARALELO_FINAL || // codInterpretavelNovo == CodigosInterpretaveis.PARALELO_PROXIMO || // codInterpretavelNovo == CodigosInterpretaveis.JUNCAO_VEM_PARALELO_FINAL) && // (getCI() == CodigosInterpretaveis.JUNCAO_OU)) || // (codInterpretavelNovo == CodigosInterpretaveis.CONTATO_NA || // codInterpretavelNovo == CodigosInterpretaveis.CONTATO_NF)) //{ // salvaCodigoAnterior.codigoInterpretavel = getCI(); // salvaCodigoAnterior.Operandos = getOperandos(); //} //if (editSimbolo == true || (codInterpretavelNovo != CodigosInterpretaveis.INICIO_DA_LINHA || // codInterpretavelNovo != CodigosInterpretaveis.INICIO_DA_LINHA_EXECUTAVEL || // codInterpretavelNovo != CodigosInterpretaveis.INICIO_DA_LINHA_COMPLEMENTO || // codInterpretavelNovo != CodigosInterpretaveis.FIM_DA_LINHA)) codigoInterpretavel.setCI(codInterpretavelNovo); //switch (getCI()) //{ // case CodigosInterpretaveis.NENHUM: // break; // case CodigosInterpretaveis.INICIO_DA_LINHA: // case CodigosInterpretaveis.INICIO_DA_LINHA_EXECUTAVEL: // case CodigosInterpretaveis.INICIO_DA_LINHA_COMPLEMENTO: // break; // case CodigosInterpretaveis.FIM_DA_LINHA: // break; // case CodigosInterpretaveis.LINHA_HORIZONTAL: // break; // case CodigosInterpretaveis.CONTATO_NA: // break; // case CodigosInterpretaveis.CONTATO_NF: // break; // case CodigosInterpretaveis.BOBINA_SAIDA: // break; // case CodigosInterpretaveis.TEMPORIZADOR: // break; // case CodigosInterpretaveis.CONTADOR: // break; // case CodigosInterpretaveis.PARALELO_INICIAL: // case CodigosInterpretaveis.PARALELO_FINAL: // case CodigosInterpretaveis.PARALELO_PROXIMO: // case CodigosInterpretaveis.JUNCAO_VEM_PARALELO_FINAL: // break; // default: // break; //} ////DesenhaSimbolo(); }
/// <summary> /// Verifica se a lista contem o codigointerpretavel do parametro /// </summary> /// <param name="value">codigo interpretavel a ser verificado na lista</param> /// <returns>true - codigo encontrado na lista / false - codigno nao encontrado na lista</returns> public bool Contains(CodigosInterpretaveis value) { ciLocal = value; bool _bResult = this.Exists(ProcuraCodigoInterpretavel); ciLocal = CodigosInterpretaveis.NENHUM; return(_bResult); }
public AlteraTemporizadorContador(CodigosInterpretaveis funcao) { InitializeComponent(); switch (funcao) { case CodigosInterpretaveis.CONTADOR: case CodigosInterpretaveis.TEMPORIZADOR: Funcao = funcao; break; } }
private void menuLimparEndereco_Click(object sender, EventArgs e) { CodigosInterpretaveis _cI = controleSelecionado.getCI(); if ((!controleSelecionado.IsDisposed) && (_cI != CodigosInterpretaveis.INICIO_DA_LINHA && _cI != CodigosInterpretaveis.PARALELO_INICIAL && _cI != CodigosInterpretaveis.PARALELO_FINAL)) { controleSelecionado.setOperando(0, null); controleSelecionado.Refresh(); } }
private void CopyToolStripMenuItem_Click(object sender, EventArgs e) { // TODO: Use System.Windows.Forms.Clipboard to insert the selected text or images into the clipboard List <SimboloBasico> _lstSB = null; //SimboloBasico _sB = null; if (IsDiagramaAberto()) { if (frmProj.frmDiagLadder.ControleSelecionado != null) { if (!frmProj.frmDiagLadder.ControleSelecionado.IsDisposed) { CodigosInterpretaveis _cI = frmProj.frmDiagLadder.ControleSelecionado.getCI(); switch (_cI) { case CodigosInterpretaveis.PARALELO_INICIAL: case CodigosInterpretaveis.PARALELO_PROXIMO: case CodigosInterpretaveis.PARALELO_FINAL: _lstSB = frmProj.frmDiagLadder.VariosSelecionados(frmProj.frmDiagLadder.ControleSelecionado, frmProj.frmDiagLadder.LinhaSelecionada); break; default: _lstSB = frmProj.frmDiagLadder.VariosSelecionados(frmProj.frmDiagLadder.ControleSelecionado, frmProj.frmDiagLadder.LinhaSelecionada); break; } DataFormats.Format myFormat = DataFormats.GetFormat("List<SimboloBasico>"); try { // Insert code to set properties and fields of the object. XmlSerializer mySerializer = new XmlSerializer(typeof(List <SimboloBasico>)); XmlSerializer mySerializer2 = new XmlSerializer(typeof(DispositivoLadder)); // To write to a file, create a StreamWriter object. StreamWriter myWriter = new StreamWriter("myFileName.xml"); StreamWriter myWriter2 = new StreamWriter("myDevice.xml"); mySerializer.Serialize(myWriter, _lstSB); mySerializer2.Serialize(myWriter2, frmProj.programa.dispositivo); myWriter.Close(); myWriter2.Close(); Clipboard.SetData(myFormat.Name, _lstSB); } catch (InvalidOperationException ex) { MessageBox.Show(ex.InnerException.Message); } } } } }
public Int32 NumeroOperandos(CodigosInterpretaveis _ci) { int iNumOperandos = -1; switch (_ci) { case CodigosInterpretaveis.NENHUM: iNumOperandos = 0; break; case CodigosInterpretaveis.FIM_DA_LINHA: iNumOperandos = 0; break; case CodigosInterpretaveis.CONTATO_NA: case CodigosInterpretaveis.CONTATO_NF: iNumOperandos = 2; break; case CodigosInterpretaveis.BOBINA_SAIDA: case CodigosInterpretaveis.RESET: iNumOperandos = 2; break; case CodigosInterpretaveis.PARALELO_INICIAL: case CodigosInterpretaveis.PARALELO_FINAL: case CodigosInterpretaveis.PARALELO_PROXIMO: iNumOperandos = 0; break; case CodigosInterpretaveis.CONTADOR: iNumOperandos = 3; break; case CodigosInterpretaveis.TEMPORIZADOR: iNumOperandos = 4; break; default: iNumOperandos = 0; break; } return(iNumOperandos); }
internal void Insert(CodigosInterpretaveis _ci) { Insert((Int32)_ci); }
public void Add(CodigosInterpretaveis _ci) { Add((Int32)_ci); }
public List <EnderecamentoLadder> ListaNomes(CodigosInterpretaveis _ci) { List <EnderecamentoLadder> _listaEnderecos = new List <EnderecamentoLadder>(); List <TipoEnderecamentoDispositivo> tiposListados = new List <TipoEnderecamentoDispositivo>(); List <EnderecamentoLadder> _lstGenerica; switch (_ci) { case CodigosInterpretaveis.CONTATO_NA: case CodigosInterpretaveis.CONTATO_NF: tiposListados.Add(TipoEnderecamentoDispositivo.DIGITAL_ENTRADA); tiposListados.Add(TipoEnderecamentoDispositivo.DIGITAL_MEMORIA); tiposListados.Add(TipoEnderecamentoDispositivo.DIGITAL_MEMORIA_CONTADOR); tiposListados.Add(TipoEnderecamentoDispositivo.DIGITAL_MEMORIA_TEMPORIZADOR); break; case CodigosInterpretaveis.TEMPORIZADOR: tiposListados.Add(TipoEnderecamentoDispositivo.DIGITAL_MEMORIA_TEMPORIZADOR); break; case CodigosInterpretaveis.CONTADOR: tiposListados.Add(TipoEnderecamentoDispositivo.DIGITAL_MEMORIA_CONTADOR); break; case CodigosInterpretaveis.BOBINA_SAIDA: tiposListados.Add(TipoEnderecamentoDispositivo.DIGITAL_MEMORIA); tiposListados.Add(TipoEnderecamentoDispositivo.DIGITAL_SAIDA); break; } foreach (TipoEnderecamentoDispositivo _cadaTipo in tiposListados) { switch (_cadaTipo) { case TipoEnderecamentoDispositivo.DIGITAL_MEMORIA: _lstGenerica = lstMemoria; break; case TipoEnderecamentoDispositivo.DIGITAL_MEMORIA_CONTADOR: _lstGenerica = lstContador; break; case TipoEnderecamentoDispositivo.DIGITAL_MEMORIA_TEMPORIZADOR: _lstGenerica = lstTemporizador; break; case TipoEnderecamentoDispositivo.DIGITAL_ENTRADA: _lstGenerica = lstIOEntrada; break; case TipoEnderecamentoDispositivo.DIGITAL_SAIDA: _lstGenerica = lstIOSaida; break; default: return(null); } foreach (EnderecamentoLadder _endCada in _lstGenerica) { _listaEnderecos.Add(_endCada); } } return(_listaEnderecos); }
public void setCI(CodigosInterpretaveis codigo) { codigoInterpretavel = codigo; RealocaOperandos(); }
public SimboloBasico(CodigosInterpretaveis _ci) { codigoInterpretavel = _ci; }
private ProgramaBasico LerExecutavel(String strNomeProjeto) { List <int> lstCodigosLidos = new List <int>(); CodigosInterpretaveis guarda = CodigosInterpretaveis.NENHUM; if (this.ExisteCodigoInterpretavel()) { Int32 intContaFim = 0; Int32 intIndiceLinha = 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 = this.PosInicial; i < DadosConvertidosChar.Length; i++) { guarda = LeCodigoInterpretavel(i); i++; switch (guarda) { case CodigosInterpretaveis.NENHUM: intContaFim++; break; case CodigosInterpretaveis.FIM_DA_LINHA: intContaFim++; if (LeCodigoInterpretavel(i + 1) != CodigosInterpretaveis.NENHUM) { intIndiceLinha = programa.InsereLinhaNoFinal(new LinhaCompleta()); } break; case CodigosInterpretaveis.CONTATO_NA: case CodigosInterpretaveis.CONTATO_NF: intContaFim = 0; { SimboloBasico _sb = new SimboloBasico((CodigosInterpretaveis)guarda); _tpEndLido = LeTipoEnderecamento(i); i++; _iIndiceEndLido = LeInteiro(i); i++; _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; { 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; programa.linhas[intIndiceLinha].simbolos.Add(new SimboloBasico((CodigosInterpretaveis)guarda)); break; case CodigosInterpretaveis.CONTADOR: intContaFim = 0; { 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; { 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; } } return(programa); } return(null); }
void Simbolo_Click(object sender, MouseEventArgs e) { ControleLivre _cL = (ControleLivre)sender; CodigosInterpretaveis _cI = _cL.getCI(); ProjetoLadder _frmPL; _frmPL = frmDiag.linkProjeto; if (e.Button == MouseButtons.Right) { if (_cI != CodigosInterpretaveis.INICIO_DA_LINHA) { frmDiag.menuInsereLinha.Enabled = false; frmDiag.menuToggleBit.Enabled = false; if (_cI == CodigosInterpretaveis.PARALELO_INICIAL || _cI == CodigosInterpretaveis.PARALELO_FINAL || _cI == CodigosInterpretaveis.PARALELO_PROXIMO) { frmDiag.menuEnderecamento.Enabled = false; frmDiag.menuEnderecamento.Visible = false; /// Extensao de paralelo - acima/abaixo /// somente sobre simbolos de paralelo frmDiag.menuEstenderParaleloAcima.Enabled = true; frmDiag.menuEstenderParaleloAcima.Visible = true; frmDiag.menuEstenderParaleloAbaixo.Enabled = true; frmDiag.menuEstenderParaleloAbaixo.Visible = true; } else { frmDiag.menuEnderecamento.Enabled = true; frmDiag.menuEnderecamento.Visible = true; if (_cL.getOperandos(0) != null) { frmDiag.menuToggleBit.Enabled = true; } else { frmDiag.menuToggleBit.Enabled = false; } TreeNode _NoEnderecamento = _frmPL.ArvoreProjeto.Nodes["NoProjeto"].Nodes["NoEnderecamento"]; ToolStripMenuItem _mnu = null; //ToolStripMenuItem _mnuSub = null; foreach (TreeNode _NoEnd in _NoEnderecamento.Nodes) { //_mnu = new ToolStripMenuItem(_end.Nome); switch (_NoEnd.Text) { case "Memoria": _mnu = frmDiag.menuMemoria; break; case "Temporizadores": _mnu = frmDiag.menuTemporizador; break; case "Contadores": _mnu = frmDiag.menuContador; break; case "Entradas": _mnu = frmDiag.menuEntrada; break; case "Saidas": _mnu = frmDiag.menuSaida; break; } EnderecamentoLadder _end = null; if (_cL.getOperandos(0) != null) { Object obj = _cL.getOperandos(0); if (obj.GetType().ToString() == "LadderApp1.EnderecamentoLadder") { _end = (LadderApp.EnderecamentoLadder)obj; } } _mnu.DropDownItems.Clear(); foreach (TreeNode _NoEndSub in _NoEnd.Nodes) { _mnu.DropDownItems.Add(_NoEndSub.Text); if (_end != null) { if (_end.Nome == _NoEndSub.Text) { _mnu.DropDownItems[_mnu.DropDownItems.Count - 1].Select(); } } _mnu.DropDownItems[_mnu.DropDownItems.Count - 1].Name = _NoEndSub.Text; _mnu.DropDownItems[_mnu.DropDownItems.Count - 1].Tag = _NoEndSub.Tag; _mnu.DropDownItems[_mnu.DropDownItems.Count - 1].Click += new EventHandler(LinhaCompletaLivre_Click); } } } } frmDiag.menuControle.Show(_cL.PointToScreen(e.Location)); } }