Imports CesnaActiveX
Public Class Form1
    Dim WithEvents MyCesna As New CesnaActiveX.Cesna

    'Estados das Bombas
    Public Const ESTADO_INDEFINIDO As Byte = 1
    Public Const BOMBA_PRONTA As Byte = 2
    Public Const BOMBA_PEDE_AUTORIZACAO As Byte = 3
    Public Const BOMBA_LIBERADA As Byte = 5
    Public Const BOMBA_ABASTECENDO As Byte = 6
    Public Const BOMBA_ABASTECEU As Byte = 7
    Public Const BOMBA_TROCOU_PRECO_POR_LITRO As Byte = 8
    Public Const BOMBA_RESERVADA_PRE_PAGO As Byte = 9
    Public Const BOMBA_BLOQUEADA As Byte = 10
    Public Const BOMBA_DESBLOQUEADA As Byte = 11
    Public Const BOMBA_INFORMOU_FALHA As Byte = 12
    Public Const BOMBA_NAO_RESPONDE As Byte = 13

    'Estados do Concentrador
    Public Const CONCENTRADOR_INFORMOU_VERSAO As Byte = 14
    Public Const CONCENTRADOR_ACEITOU_CONFIGURACAO As Byte = 15
    Public Const FALHA_COMUNICACAO_CONCENTRADOR As Byte = 16
    Public Const CONCENTRADOR_INFORMOU_EVENTO As Byte = 17
    

    Public Sub Imprime(ByVal Texto As String)

        If (RchTxtBoxDisplay.Lines.Count > 999) Then
            RchTxtBoxDisplay.Clear()
        End If

        RchTxtBoxDisplay.Text = RchTxtBoxDisplay.Text & Format(RchTxtBoxDisplay.Lines.Count(), "0000: ") & Texto & Chr(13) & Chr(10)

        RchTxtBoxDisplay.SelectionStart = RchTxtBoxDisplay.TextLength
        RchTxtBoxDisplay.ScrollToCaret()

    End Sub
    Public Sub ObtemEnderecos(ByRef EndSlave As Byte, ByRef EndBomba As Byte, ByRef EndBico As Byte)
        EndSlave = Convert.ToByte(CmbBoxEndSlave.SelectedIndex + 1)
        EndBomba = Convert.ToByte(CmbBoxEndBomba.SelectedIndex + 1)
        EndBico = Convert.ToByte(CmbBoxEndBico.SelectedIndex + 1)
    End Sub

    Private Sub BtnOpen1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOpen1.Click
        Dim Retorno As Integer
        Dim Slave As Byte
        Dim Bomba As Byte
        Dim FormatoMsg As Byte

        Slave = 1
        Bomba = Convert.ToByte(CmbBoxBomba.SelectedIndex + 1)
        FormatoMsg = Convert.ToByte(CmbBoxFormatoMsg.SelectedIndex + 1)

        'Abre Comunicação
        Retorno = MyCesna.FcmOpen(Slave)
        If Retorno = 1 Then
            'Seta número da Slave
            Retorno = MyCesna.FcmSetNumSlaves(Slave)
            If Retorno = 1 Then
                'Configura Concentrador
                Retorno = MyCesna.FcmConfigConcentrador(Slave, Bomba, 0, FormatoMsg) 'Modo de Operação zerado mantem o modo anterior
                If Retorno = 1 Then
                    Imprime("Open: Ok")
                Else
                    Imprime("Open: Erro " + Retorno.ToString())
                End If
            Else
                Imprime("Open: Erro " + Retorno.ToString())
            End If
        Else
            Imprime("Open: Erro " + Retorno.ToString())
        End If

    End Sub
    Private Sub BtnOpen2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOpen2.Click
        Dim Retorno As Integer
        Dim Slave As Byte
        Dim Bomba As Byte
        Dim FormatoMsg As Byte

        Slave = 2
        Bomba = Convert.ToByte(CmbBoxBomba.SelectedIndex + 1)
        FormatoMsg = Convert.ToByte(CmbBoxFormatoMsg.SelectedIndex + 1)

        'Abre Comunicação
        Retorno = MyCesna.FcmOpen(Slave)
        If Retorno = 1 Then
            'Seta número da Slave
            Retorno = MyCesna.FcmSetNumSlaves(Slave)
            If Retorno = 1 Then
                'Configura Concentrador
                Retorno = MyCesna.FcmConfigConcentrador(Slave, Bomba, 0, FormatoMsg) 'Modo de Operação zerado mantem o modo anterior
                If Retorno = 1 Then
                    Imprime("Open: Ok")
                Else
                    Imprime("Open: Erro " + Retorno.ToString())
                End If
            Else
                Imprime("Open: Erro " + Retorno.ToString())
            End If
        Else
            Imprime("Open: Erro " + Retorno.ToString())
        End If
    End Sub
    Private Sub BtnOpen3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOpen3.Click
        Dim Retorno As Integer
        Dim Slave As Byte
        Dim Bomba As Byte
        Dim FormatoMsg As Byte

        Slave = 3
        Bomba = Convert.ToByte(CmbBoxBomba.SelectedIndex + 1)
        FormatoMsg = Convert.ToByte(CmbBoxFormatoMsg.SelectedIndex + 1)

        'Abre Comunicação
        Retorno = MyCesna.FcmOpen(Slave)
        If Retorno = 1 Then
            'Seta número da Slave
            Retorno = MyCesna.FcmSetNumSlaves(Slave)
            If Retorno = 1 Then
                'Configura Concentrador
                Retorno = MyCesna.FcmConfigConcentrador(Slave, Bomba, 0, FormatoMsg) 'Modo de Operação zerado mantem o modo anterior
                If Retorno = 1 Then
                    Imprime("Open: Ok")
                Else
                    Imprime("Open: Erro " + Retorno.ToString())
                End If
            Else
                Imprime("Open: Erro " + Retorno.ToString())
            End If
        Else
            Imprime("Open: Erro " + Retorno.ToString())
        End If
    End Sub
    Private Sub BtnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClose.Click
        Dim Retorno As Integer
        Retorno = MyCesna.FcmClose()
        If Retorno = 1 Then
            Imprime("Close: Ok")
        Else
            Imprime("Close: Erro " + Retorno.ToString())
        End If
    End Sub
    Private Sub BtnVersaoDll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnVersaoDll.Click
        Dim Retorno As Integer
        Retorno = MyCesna.FcmVersaoFcmMaster()
        Imprime("Versão Dll: " + Retorno.ToString())
    End Sub
    Private Sub BtnEnviaConfiguracao_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEnviaConfiguracao.Click
        Dim Retorno As Integer
        Dim Slave As Byte
        Dim Bomba As Byte
        Dim FormatoMsg As Byte
        Dim ModoOperacao As Byte

        Slave = Convert.ToByte(CmbBoxSlave.SelectedIndex + 1)
        Bomba = Convert.ToByte(CmbBoxBomba.SelectedIndex + 1)
        FormatoMsg = Convert.ToByte(CmbBoxFormatoMsg.SelectedIndex + 1)
        ModoOperacao = Convert.ToByte(CmbBoxModoOperacao.SelectedIndex + 10) 'Somado mais 10 para acertar o caracter depois da conversão para hexadecimal: 0x0A, 0x0B ou 0x0C

        Retorno = MyCesna.FcmConfigConcentrador(Slave, Bomba, ModoOperacao, FormatoMsg)
        If Retorno = 1 Then
            Imprime("Envia Configuração: Ok")
        Else
            Imprime("Envia Configuração: Erro " + Retorno.ToString())
        End If
    End Sub
    Private Sub BtnVersaoFcmSlave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnVersaoFcmSlave.Click
        Dim Retorno As Integer
        Dim Slave As Byte

        Slave = Convert.ToByte(CmbBoxSlave.SelectedIndex + 1)
        Retorno = MyCesna.FcmSolicitaVersaoSlave(Slave)
        If Retorno <> 1 Then
            Imprime("Obtém Número Abastecimentos Off-line: Erro " + Retorno.ToString())
        End If
    End Sub
    Private Sub BtnEstado_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEstado.Click
        Dim Retorno As Integer
        Dim Slave As Byte
        Dim Bomba As Byte

        ObtemEnderecos(Slave, Bomba, 0)
        If ChkBoxTodasBombas.Checked = True Then
            Retorno = MyCesna.FcmObtemStatusBomba(Slave, 0)
        Else
            Retorno = MyCesna.FcmObtemStatusBomba(Slave, Bomba)
        End If

        If Retorno <> 1 Then
            Imprime("Obtém Estado: Erro " + Retorno.ToString())
        End If
    End Sub
    Private Sub BtnTotalizador_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnTotalizador.Click
        Dim Retorno As Integer
        Dim Slave As Byte
        Dim Bomba As Byte
        Dim Bico As Byte

        ObtemEnderecos(Slave, Bomba, Bico)
        Retorno = MyCesna.FcmSolicitaTotalizador(Slave, Bomba, Bico)
        If Retorno <> 1 Then
            Imprime("Obtém Totalizador: Erro " + Retorno.ToString())
        End If
    End Sub
    Private Sub BtnUltimoVolume_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnUltimoVolume.Click
        Dim Retorno As Integer
        Dim Slave As Byte
        Dim Bomba As Byte
        Dim Bico As Byte

        ObtemEnderecos(Slave, Bomba, Bico)
        Retorno = MyCesna.FcmSolicitaUltimoVolume(Slave, Bomba, Bico)
        If Retorno <> 1 Then
            Imprime("Último Volume: Erro " + Retorno.ToString())
        End If
    End Sub
    Private Sub BtnObtemPreco_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnObtemPreco.Click
        Dim Retorno As Integer
        Dim Slave As Byte
        Dim Bomba As Byte
        Dim Bico As Byte

        ObtemEnderecos(Slave, Bomba, Bico)
        Retorno = MyCesna.FcmSolicitaPrecoPorLitro(Slave, Bomba, Bico)
        If Retorno <> 1 Then
            Imprime("Preço Por Litro: Erro " + Retorno.ToString())
        End If
    End Sub
    Private Sub BtnTravaBomba_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnTravaBomba.Click
        Dim Retorno As Integer
        Dim Slave As Byte
        Dim Bomba As Byte

        ObtemEnderecos(Slave, Bomba, 0)
        Retorno = MyCesna.FcmTravaBomba(Slave, Bomba)
        If Retorno <> 1 Then
            Imprime("Trava Bomba: Erro " + Retorno.ToString())
        End If
    End Sub
    Private Sub BtnDestravaBomba_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDestravaBomba.Click
        Dim Retorno As Integer
        Dim Slave As Byte
        Dim Bomba As Byte

        ObtemEnderecos(Slave, Bomba, 0)
        Retorno = MyCesna.FcmDesTravaBomba(Slave, Bomba)
        If Retorno <> 1 Then
            Imprime("Destrava Bomba: Erro " + Retorno.ToString())
        End If
    End Sub
    Private Sub BtnAutorizaBomba_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAutorizaBomba.Click
        Dim Retorno As Integer
        Dim Slave As Byte
        Dim Bomba As Byte
        Dim Bico As Byte

        ObtemEnderecos(Slave, Bomba, Bico)
        Retorno = MyCesna.FcmAutorizaAbastecimento(Slave, Bomba, Bico)
        If Retorno <> 1 Then
            Imprime("Autoriza Abastecimento: Erro " + Retorno.ToString())
        End If
    End Sub
    Private Sub BtnPrePago_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPrePago.Click
        Dim Retorno As Integer
        Dim Slave As Byte
        Dim Bomba As Byte
        Dim Bico As Byte
        Dim Volume As Integer
        Dim Aux As String

        ObtemEnderecos(Slave, Bomba, Bico)
   
        Aux = MskBoxPrePago.Text
        Aux = Replace(Aux, ",", "") 'Remove a virgula para passar o valor como inteiro
        Volume = Convert.ToInt32(Aux)

        Retorno = MyCesna.FcmProgramaPrePago(Slave, Bomba, Bico, Volume, 3)    'Número de casas decimais fixado como 3
        If Retorno <> 1 Then
            Imprime("Pré-pago: Erro " + Retorno.ToString())
        End If
    End Sub
    Private Sub BtnTrocaPreco_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnTrocaPreco.Click
        Dim Retorno As Integer
        Dim Slave As Byte
        Dim Bomba As Byte
        Dim Bico As Byte
        Dim Preco As Integer
        Dim Aux As String

        ObtemEnderecos(Slave, Bomba, Bico)
        Aux = MskBoxTrocaPreco.Text
        Aux = Replace(Aux, ",", "")
        Preco = Convert.ToInt32(Aux)

        Retorno = MyCesna.FcmTrocaPreco(Slave, Bomba, Bico, Preco, 3) 'Número de casas decimais fixado como 3
        If Retorno <> 1 Then
            Imprime("Troca Preço: Erro " + Retorno.ToString())
        End If
    End Sub
    Sub MyCesna_FcmMudancaDeEstado(ByVal Slave As Byte, ByVal Bomba As Byte, ByVal Bico As Byte, ByVal Estado As Byte) Handles MyCesna.FcmMudancaDeEstado
        Dim Retorno As Integer
        Select Case Estado
            Case ESTADO_INDEFINIDO
                Imprime("Sl: " + Convert.ToString(Slave) + " Bo: " + Convert.ToString(Bomba) + " Bi: " + Convert.ToString(Bico) + " - ESTADO_INDEFINIDO")
            Case BOMBA_PRONTA
                Imprime("Sl: " + Convert.ToString(Slave) + " Bo: " + Convert.ToString(Bomba) + " Bi: " + Convert.ToString(Bico) + " - BOMBA_PRONTA")
            Case BOMBA_PEDE_AUTORIZACAO
                Imprime("Sl: " + Convert.ToString(Slave) + " Bo: " + Convert.ToString(Bomba) + " Bi: " + Convert.ToString(Bico) + " - BOMBA_PEDE_AUTORIZACAO")
                If ChkBoxAutorizacaoAutomatica.Checked = True Then  'Autoriza abastecimento automaticamente
                    Retorno = MyCesna.FcmAutorizaAbastecimento(Slave, Bomba, Bico)
                    If Retorno <> 1 Then
                        Imprime("Autoriza Abastecimento: Erro " + Retorno.ToString())
                    End If
                End If
            Case BOMBA_LIBERADA
                Imprime("Sl: " + Convert.ToString(Slave) + " Bo: " + Convert.ToString(Bomba) + " Bi: " + Convert.ToString(Bico) + " - BOMBA_LIBERADA")
            Case BOMBA_ABASTECENDO
                Imprime("Sl: " + Convert.ToString(Slave) + " Bo: " + Convert.ToString(Bomba) + " Bi: " + Convert.ToString(Bico) + " - BOMBA_ABASTECENDO")
            Case BOMBA_ABASTECEU
                Imprime("Sl: " + Convert.ToString(Slave) + " Bo: " + Convert.ToString(Bomba) + " Bi: " + Convert.ToString(Bico) + " - BOMBA_ABASTECEU")
            Case BOMBA_TROCOU_PRECO_POR_LITRO
                Imprime("Sl: " + Convert.ToString(Slave) + " Bo: " + Convert.ToString(Bomba) + " Bi: " + Convert.ToString(Bico) + " - BOMBA_TROCOU_PRECO_POR_LITRO")
            Case BOMBA_RESERVADA_PRE_PAGO
                Imprime("Sl: " + Convert.ToString(Slave) + " Bo: " + Convert.ToString(Bomba) + " Bi: " + Convert.ToString(Bico) + " - BOMBA_RESERVADA_PRE_PAGO")
            Case BOMBA_BLOQUEADA
                Imprime("Sl: " + Convert.ToString(Slave) + " Bo: " + Convert.ToString(Bomba) + " Bi: " + Convert.ToString(Bico) + " - BOMBA_BLOQUEADA")
            Case BOMBA_DESBLOQUEADA
                Imprime("Sl: " + Convert.ToString(Slave) + " Bo: " + Convert.ToString(Bomba) + " Bi: " + Convert.ToString(Bico) + " - BOMBA_DESBLOQUEADA")
            Case BOMBA_INFORMOU_FALHA
                Imprime("Sl: " + Convert.ToString(Slave) + " Bo: " + Convert.ToString(Bomba) + " Bi: " + Convert.ToString(Bico) + " - BOMBA_INFORMOU_FALHA")
            Case BOMBA_NAO_RESPONDE
                Imprime("Sl: " + Convert.ToString(Slave) + " Bo: " + Convert.ToString(Bomba) + " Bi: " + Convert.ToString(Bico) + " - BOMBA_NAO_RESPONDE")
            Case CONCENTRADOR_ACEITOU_CONFIGURACAO
                Imprime("Sl: " + Convert.ToString(Slave) + " Bo: " + Convert.ToString(Bomba) + " Bi: " + Convert.ToString(Bico) + " - CONCENTRADOR_ACEITOU_CONFIGURACAO")
            Case FALHA_COMUNICACAO_CONCENTRADOR
                Imprime("Sl: " + Convert.ToString(Slave) + " Bo: " + Convert.ToString(Bomba) + " Bi: " + Convert.ToString(Bico) + " - FALHA_COMUNICACAO_CONCENTRADOR")
        End Select

    End Sub
    Sub MyCesna_FcmAbasteceu(ByVal Slave As Byte, ByVal Bomba As Byte, ByVal Bico As Byte, ByVal Volume As Integer, ByVal TotalInicial As Integer, ByVal TotalFinal As Integer, ByVal PrecoPorLitro As Integer,
                             ByVal VolumeCasaDecimal As Byte, ByVal TotalInicialCasaDecimal As Byte, ByVal TotalFinalCasaDecimal As Byte, ByVal PrecoPorLitroCasaDecimal As Byte, ByVal Hora As Integer, ByVal Data As Integer) Handles MyCesna.FcmAbasteceu
        Dim VolumeAbast As String
        Dim PrecoAbast As String
        Dim TotalIniAbast As String
        Dim TotalFinAbast As String
        Dim DataAbast As String
        Dim HoraAbast As String


        Select Case VolumeCasaDecimal
            Case 0
                VolumeAbast = Volume.ToString("0.0")
            Case 1
                VolumeAbast = (Volume / 10).ToString("0.0")
            Case 2
                VolumeAbast = (Volume / 100).ToString("0.00")
            Case 3
                VolumeAbast = (Volume / 1000).ToString("0.000")
            Case Else
                VolumeAbast = Volume.ToString("0.0")
        End Select

        Select Case TotalInicialCasaDecimal
            Case 0
                TotalIniAbast = TotalInicial.ToString("0.0")
            Case 1
                TotalIniAbast = (TotalInicial / 10).ToString("0.0")
            Case 2
                TotalIniAbast = (TotalInicial / 100).ToString("0.00")
            Case 3
                TotalIniAbast = (TotalInicial / 1000).ToString("0.000")
            Case Else
                TotalIniAbast = TotalInicial.ToString("0.0")
        End Select

        Select Case TotalFinalCasaDecimal
            Case 0
                TotalFinAbast = TotalFinal.ToString("0.0")
            Case 1
                TotalFinAbast = (TotalFinal / 10).ToString("0.0")
            Case 2
                TotalFinAbast = (TotalFinal / 100).ToString("0.00")
            Case 3
                TotalFinAbast = (TotalFinal / 1000).ToString("0.000")
            Case Else
                TotalFinAbast = TotalFinal.ToString("0.0")
        End Select

        Select Case PrecoPorLitroCasaDecimal
            Case 0
                PrecoAbast = PrecoPorLitro.ToString("0.0")
            Case 1
                PrecoAbast = (PrecoPorLitro / 10).ToString("0.0")
            Case 2
                PrecoAbast = (PrecoPorLitro / 100).ToString("0.00")
            Case 3
                PrecoAbast = (PrecoPorLitro / 1000).ToString("0.000")
            Case Else
                PrecoAbast = PrecoPorLitro.ToString("0.0")
        End Select

        DataAbast = Convert.ToString(Data)
        If DataAbast.Length < 6 Then
            DataAbast = "0" + DataAbast
        End If
        DataAbast = DataAbast.Substring(0, 2) + "/" + DataAbast.Substring(2, 2) + "/" + DataAbast.Substring(4, 2)

        HoraAbast = Convert.ToString(Hora)
        Select Case HoraAbast.Length
            Case 1
                HoraAbast = "00000" + HoraAbast
                HoraAbast = HoraAbast.Substring(0, 2) + ":" + HoraAbast.Substring(2, 2) + ":" + HoraAbast.Substring(4, 2)
            Case 2
                HoraAbast = "0000" + HoraAbast
                HoraAbast = HoraAbast.Substring(0, 2) + ":" + HoraAbast.Substring(2, 2) + ":" + HoraAbast.Substring(4, 2)
            Case 3
                HoraAbast = "000" + HoraAbast
                HoraAbast = HoraAbast.Substring(0, 2) + ":" + HoraAbast.Substring(2, 2) + ":" + HoraAbast.Substring(4, 2)
            Case 4
                HoraAbast = "00" + HoraAbast
                HoraAbast = HoraAbast.Substring(0, 2) + ":" + HoraAbast.Substring(2, 2) + ":" + HoraAbast.Substring(4, 2)
            Case 5
                HoraAbast = "0" + HoraAbast
                HoraAbast = HoraAbast.Substring(0, 2) + ":" + HoraAbast.Substring(2, 2) + ":" + HoraAbast.Substring(4, 2)
            Case Else
                HoraAbast = HoraAbast.Substring(0, 2) + ":" + HoraAbast.Substring(2, 2) + ":" + HoraAbast.Substring(4, 2)
        End Select

        Imprime("Total Inicia: " + TotalIniAbast)
        Imprime("Total Final: " + TotalFinAbast)
        Imprime("Volume: " + VolumeAbast)
        Imprime("Preço Por Litro: " + PrecoAbast)
        Imprime("Data: " + DataAbast)
        Imprime("Hora: " + HoraAbast)

    End Sub
    Sub MyCesna_FcmVersaoFcmSlave(ByVal Slave As Byte, ByVal Versao As Integer) Handles MyCesna.FcmVersaoFcmSlave
        Imprime("Sl: " + Convert.ToString(Slave) + " Versão FcmSlave: " + Convert.ToString(Versao))
    End Sub
    Sub MyCesna_FcmTotalizador(ByVal Slave As Byte, ByVal Bomba As Byte, ByVal Bico As Byte, ByVal Totalizador As Integer, ByVal TotalizadorCasaDecimal As Byte) Handles MyCesna.FcmTotalizador
        Dim Total As String

        Select Case TotalizadorCasaDecimal
            Case 0
                Total = Totalizador.ToString("0.0")
            Case 1
                Total = (Totalizador / 10).ToString("0.0")
            Case 2
                Total = (Totalizador / 100).ToString("0.00")
            Case 3
                Total = (Totalizador / 1000).ToString("0.000")
            Case Else
                Total = Totalizador.ToString("0.0")
        End Select

        Imprime("Sl: " + Convert.ToString(Slave) + " Bo: " + Convert.ToString(Bomba) + " Bi: " + Convert.ToString(Bico) + " Totalizador: " + Total)
    End Sub
    Sub MyCesna_FcmVolume(ByVal Slave As Byte, ByVal Bomba As Byte, ByVal Bico As Byte, ByVal Volume As Integer, ByVal VolumeCasaDecimal As Byte) Handles MyCesna.FcmVolume
        Dim Vol As String

        Select Case VolumeCasaDecimal
            Case 0
                Vol = Volume.ToString("0.0")
            Case 1
                Vol = (Volume / 10).ToString("0.0")
            Case 2
                Vol = (Volume / 100).ToString("0.00")
            Case 3
                Vol = (Volume / 1000).ToString("0.000")
            Case Else
                Vol = Volume.ToString("0.0")
        End Select

        Imprime("Sl: " + Convert.ToString(Slave) + " Bo: " + Convert.ToString(Bomba) + " Bi: " + Convert.ToString(Bico) + " Último Volume: " + Vol)
    End Sub
    Sub MyCesna_FcmPrecoPorLitro(ByVal Slave As Byte, ByVal Bomba As Byte, ByVal Bico As Byte, ByVal PrecoPorLitro As Integer, ByVal PrecoPorLitroCasaDecimal As Byte) Handles MyCesna.FcmPrecoPorLitro
        Dim Preco As String

        Select Case PrecoPorLitroCasaDecimal
            Case 0
                Preco = PrecoPorLitro.ToString("0.0")
            Case 1
                Preco = (PrecoPorLitro / 10).ToString("0.0")
            Case 2
                Preco = (PrecoPorLitro / 100).ToString("0.00")
            Case 3
                Preco = (PrecoPorLitro / 1000).ToString("0.000")
            Case Else
                Preco = PrecoPorLitro.ToString("0.0")
        End Select

        Imprime("Sl: " + Convert.ToString(Slave) + " Bo: " + Convert.ToString(Bomba) + " Bi: " + Convert.ToString(Bico) + " Preço: " + Preco)
    End Sub
    Sub MyCesna_FcmEventoFcmSlave(ByVal Slave As Byte, ByVal Bomba As Byte, ByVal Bico As Byte, ByVal Evento As Integer) Handles MyCesna.FcmEventoSlave
        Imprime("Sl: " + Convert.ToString(Slave) + " Bo: " + Convert.ToString(Bomba) + " Bi: " + Convert.ToString(Bico) + " Evento: " + Convert.ToString(Evento))
    End Sub
    Sub MyCesna_FcmErroDll(ByVal Erro As Byte) Handles MyCesna.FcmErroDLL
        Imprime("Erro Dll: " + Convert.ToString(Erro))
    End Sub



End Class


