Exemple #1
0
 public static void LimparSerial()
 {
     if (Estruturas.BaixarDll("companytec.dll"))
     {
         LimpaSerial();
     }
 }
Exemple #2
0
 public static bool LiberarBico(string bico)
 {
     if (Estruturas.BaixarDll("companytec.dll"))
     {
         string comando = "&M" + bico.Trim() + "L";
         comando = "(" + comando + CalcularChecksum(comando) + ")";
         if (EnviarComandoPlaca(comando) == 1)
         {
             LerRetornoPlaca(ref comando);
             if (comando.Length.Equals(5))
             {
                 return(comando.Substring(2, 2).Equals(bico));
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
Exemple #3
0
 public static void ProximoAbastecimento()
 {
     if (Estruturas.BaixarDll("companytec.dll"))
     {
         Incrementa();
     }
 }
Exemple #4
0
 public static void LerAbastecimentoOnLine(ref string Abast)
 {
     if (Estruturas.BaixarDll("companytec.dll"))
     {
         visualizacao aux = new visualizacao();
         CobLeVis(ref aux);
         Abast = aux.stfull;
     }
 }
Exemple #5
0
 public static void LerAbastecimentoMemoria(ref string st)
 {
     if (Estruturas.BaixarDll("companytec.dll"))
     {
         retorno2 aux = new retorno2();
         LeStringX(ref aux);
         st = aux.value;
     }
 }
Exemple #6
0
 public static int LerRetornoPlaca(ref string retorno)
 {
     if (Estruturas.BaixarDll("companytec.dll"))
     {
         return(VB_ReceiveText(ref retorno));
     }
     else
     {
         return(0);
     }
 }
Exemple #7
0
 public static int EnviarComandoPlaca(string comando)
 {
     if (Estruturas.BaixarDll("companytec.dll"))
     {
         return(VB_SendText(comando));
     }
     else
     {
         return(0);
     }
 }
Exemple #8
0
 public static int FecharPorta()
 {
     if (Estruturas.BaixarDll("ControlTech32.dll"))
     {
         return(FinalizaCom());
     }
     else
     {
         return(255);//Erro
     }
 }
Exemple #9
0
 public static int StatusPorta()
 {
     if (Estruturas.BaixarDll("ControlTech32.dll"))
     {
         return(StatusCom());
     }
     else
     {
         return(255);//Erro
     }
 }
Exemple #10
0
 public static int AbrirPortaSerial(int np)
 {
     if (Estruturas.BaixarDll("companytec.dll"))
     {
         return(InicializaSerial(Convert.ToByte(np)));
     }
     else
     {
         return(0);
     }
 }
Exemple #11
0
 public static int AtualizaDiaHoraConcentrador(DateTime Data)
 {
     if (Estruturas.BaixarDll("companytec.dll"))
     {
         return(EnviarComandoPlaca("(&H" + Data.Day.ToString().PadLeft(2, '0') + Data.Hour.ToString().PadLeft(2, '0') + Data.Minute.ToString().PadLeft(2, '0') + ")"));
     }
     else
     {
         return(0);
     }
 }
Exemple #12
0
 public static int AlterarPreco(int nBico, string sPreco)
 {
     if (Estruturas.BaixarDll("ControlTech32.dll"))
     {
         return(AlteraPreco(nBico, sPreco));
     }
     else
     {
         return(255);//Erro
     }
 }
Exemple #13
0
 public static int ApagaAbastecimentoMemoria(int nIdAbast)
 {
     if (Estruturas.BaixarDll("ControlTech32.dll"))
     {
         return(ApagaAbastecimento(nIdAbast));
     }
     else
     {
         return(255);//Erro
     }
 }
Exemple #14
0
 public static int FecharPortaSerial()
 {
     if (Estruturas.BaixarDll("companytec.dll"))
     {
         return(FechaSerial());
     }
     else
     {
         return(0);
     }
 }
Exemple #15
0
 public static int LerEncerrantes(int nBico, ref string DadosEncerrante)
 {
     if (Estruturas.BaixarDll("ControlTech32.dll"))
     {
         int ret = GetEncerrantes(nBico, ref DadosEncerrante);
         return(ret);
     }
     else
     {
         return(255);//Erro
     }
 }
Exemple #16
0
 public static int LerAbastecimentosOnLine(int nBico, ref string DadosDisplay)
 {
     if (Estruturas.BaixarDll("ControlTech32.dll"))
     {
         DadosDisplay = new string('\x20', 20);
         return(GetDisplay(nBico, ref DadosDisplay));
     }
     else
     {
         return(255);//Erro
     }
 }
Exemple #17
0
 public static int AbrirPorta(int PortaCom, string Host_IP, int PortaIP)
 {
     if (Estruturas.BaixarDll("ControlTech32.dll"))
     {
         int ret = InicializaCom(PortaCom, Host_IP, PortaIP);
         return(ret);
     }
     else
     {
         return(255);//Erro
     }
 }
Exemple #18
0
 public static int AlterarDataHora(string DataHora)
 {
     if (Estruturas.BaixarDll("ControlTech32.dll"))
     {
         int ret = SetRelogio(DataHora);
         return(ret);
     }
     else
     {
         return(255);//Erro
     }
 }
Exemple #19
0
 public static int LerAbastecimento(ref string Abastecimento)
 {
     if (Estruturas.BaixarDll("ControlTech32.dll"))
     {
         Abastecimento = new string('\x20', 91);
         int ret = GetAbastecimento(ref Abastecimento);
         return(ret);
     }
     else
     {
         return(255);//Erro
     }
 }
Exemple #20
0
 public static int LerStatusPista(int nBicoInicial, int nBicoFinal, ref string Status)
 {
     if (Estruturas.BaixarDll("ControlTech32.dll"))
     {
         Status = new string('\x20', 16);
         int ret = GetStatusPista(nBicoInicial, nBicoFinal, ref Status);
         return(ret);
     }
     else
     {
         return(255);//Erro
     }
 }
Exemple #21
0
        private void tmpPeso_Tick(object sender, EventArgs e)
        {
            tmpPeso.Stop();
            try
            {
                string peso = new string(' ', 30);
                if (Estruturas.BaixarDll(rProtocolo.Nm_dll.Contains(".dll") ? rProtocolo.Nm_dll : rProtocolo.Nm_dll.Trim() + ".dll"))
                {
                    int ret = LePeso(ref peso);

                    if (ret.Equals(1))
                    {
                        pesocapturado.Value = decimal.Parse(peso.Substring(0, 7));
                    }
                    else if (peso.Trim().ToUpper().Equals("ERRO 1"))
                    {
                        MessageBox.Show("Não foi possivel abrir a porta serial " + rProtocolo.Ds_porta.Trim() + " especificada.\r\n" +
                                        "Ela esta sendo usada por outro aplicativo ou não existe no computador.", "Mensagem", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                        DialogResult = DialogResult.Cancel;
                    }
                    else if (peso.Trim().ToUpper().Equals("ERRO 2"))
                    {
                        MessageBox.Show("Não foi possivel montar a estrutura de configuração da serial.\r\n" +
                                        "Verifique o cadastro do protocolo e tente novamente.", "Mensagem",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                        DialogResult = DialogResult.Cancel;
                    }
                    else if (peso.Trim().ToUpper().Equals("ERRO 3"))
                    {
                        MessageBox.Show("Não foi possivel configurar a serial.\r\n" +
                                        "Verifique o cadastro do protocolo e tente novamente.", "Mensagem",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                        DialogResult = DialogResult.Cancel;
                    }
                }
                else
                {
                    MessageBox.Show("Dll do modulo balança não disponivel para download.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DialogResult = DialogResult.Cancel;
                }
            }
            catch { }
            finally
            { tmpPeso.Start(); }
        }
Exemple #22
0
 public static string AlterarPrecoUnitBomba(string bico,
                                            decimal preco)
 {
     if (Estruturas.BaixarDll("companytec.dll"))
     {
         string comando = "&U" + bico.Trim() + "00" + preco.ToString("N3", new System.Globalization.CultureInfo("pt-BR")).SoNumero();
         comando = "(" + comando + CalcularChecksum(comando) + ")";
         if (EnviarComandoPlaca(comando) == 1)
         {
             LerRetornoPlaca(ref comando);
             return(comando);
         }
         else
         {
             return(string.Empty);
         }
     }
     else
     {
         return(string.Empty);
     }
 }
Exemple #23
0
 public static decimal LerEncerranteBico(string bico,
                                         string Tp_leitura)
 {
     if (Estruturas.BaixarDll("companytec.dll"))
     {
         string comando = "&T" + bico.Trim() + Tp_leitura.Trim();
         comando = "(" + comando + CalcularChecksum(comando) + ")";
         if (EnviarComandoPlaca(comando) == 1)
         {
             LerRetornoPlaca(ref comando);
             if (!string.IsNullOrEmpty(comando))
             {
                 if (comando.Trim().Length.Equals(16))
                 {
                     return(decimal.Parse(comando.Substring(5, 8)) / 100);
                 }
                 else
                 {
                     return(decimal.Zero);
                 }
             }
             else
             {
                 return(decimal.Zero);
             }
         }
         else
         {
             return(decimal.Zero);
         }
     }
     else
     {
         return(decimal.Zero);
     }
 }
Exemple #24
0
 private void TFLeituraSerial_Load(object sender, EventArgs e)
 {
     if (rProtocolo != null)
     {
         if (rProtocolo.St_utilizardllbool)
         {
             if (Estruturas.BaixarDll(rProtocolo.Nm_dll.Contains(".dll") ? rProtocolo.Nm_dll : rProtocolo.Nm_dll.Trim() + ".dll"))
             {
                 int ret = ConfiguraRs(rProtocolo.Ds_porta.Trim() + ":" +
                                       rProtocolo.Baudrate.ToString() + "," +
                                       "n," +
                                       rProtocolo.Databits.ToString() + "," +
                                       rProtocolo.Stopbits.ToString());
                 if (ret.Equals(1))
                 {
                     tmpPeso.Start();
                     st_detalhes.Visible = false;
                 }
                 else
                 {
                     MessageBox.Show("Erro configurar protocolo componente, verifique o cadastro protocolo e tente novamente.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     DialogResult = DialogResult.Cancel;
                 }
             }
             else
             {
                 MessageBox.Show("Dll do modulo balança não disponivel para download.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 DialogResult = DialogResult.Cancel;
             }
         }
         else
         {
             //Porta de comunicacao
             serial.PortName = rProtocolo.Ds_porta;
             //Velocidade de Leitura
             serial.BaudRate = rProtocolo.Baudrate;
             //Bit de Dados
             serial.DataBits    = rProtocolo.Databits;
             serial.DiscardNull = rProtocolo.St_discartarnullbool;
             serial.DtrEnable   = rProtocolo.Dtrenabledbool;
             serial.Handshake   = rProtocolo.Handshake.Trim().Equals("1") ? System.IO.Ports.Handshake.RequestToSend :
                                  rProtocolo.Handshake.Trim().Equals("2") ? System.IO.Ports.Handshake.RequestToSendXOnXOff :
                                  rProtocolo.Handshake.Trim().Equals("3") ? System.IO.Ports.Handshake.XOnXOff : System.IO.Ports.Handshake.None;
             //Paridade
             serial.Parity = rProtocolo.Parity.Trim().Equals("1") ? System.IO.Ports.Parity.Mark :
                             rProtocolo.Parity.Trim().Equals("2") ? System.IO.Ports.Parity.Even :
                             rProtocolo.Parity.Trim().Equals("3") ? System.IO.Ports.Parity.Odd :
                             rProtocolo.Parity.Trim().Equals("4") ? System.IO.Ports.Parity.Space : System.IO.Ports.Parity.None;
             serial.ReceivedBytesThreshold = rProtocolo.ReceivedBytes.Equals(0) ? 1 : rProtocolo.ReceivedBytes;
             serial.ReadBufferSize         = rProtocolo.Tam_bufferread.Equals(0) ? 4096 : rProtocolo.Tam_bufferread;
             //Bit de Parada
             serial.StopBits = rProtocolo.Stopbits.Trim().ToUpper().Equals("1") ?
                               System.IO.Ports.StopBits.One : rProtocolo.Stopbits.Trim().ToUpper().Equals("1.5") ?
                               System.IO.Ports.StopBits.OnePointFive : rProtocolo.Stopbits.Trim().ToUpper().Equals("2") ?
                               System.IO.Ports.StopBits.Two : System.IO.Ports.StopBits.None;
             serial.ReadTimeout  = 2000;
             serial.WriteTimeout = 2000;
             try
             {
                 serial.Open();
                 serial.WriteLine("ENQ");
                 string a = serial.ReadExisting();
             }
             catch
             {
                 MessageBox.Show("Erro de leitura na porta serial. Tente novamente.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 DialogResult = DialogResult.Cancel;
             }
         }
     }
     else
     {
         MessageBox.Show("Obrigatorio informar protocolo para capturar peso balança.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
         DialogResult = DialogResult.Cancel;
     }
 }