Publicado el Dejar un comentario

MAGELLAN384 Bascula magellan 384 de un puerto

'----**** 
'----**** MyBusiness POS V20
'----**** Version del script: 1.0
'----**** 19/02/2020
'----**** 
Public Sub Main()

    ' Si la mauiquina pide configurar el puerto
    if Ambiente.Tag = "CONFIGURANDO" Then
       Configuracion
    else
       TraePeso       
    end if

End Sub


Public Sub Configuracion()

       if Ambiente.Lector.PortOpen Then
          Exit Sub
       end if

       if Ambiente.Lector.PortOpen Then
          Ambiente.Lector.PortOpen = False       
       end if 

       Select Case Trim(Ambiente.rstEstacion("pbascula"))
              Case "COM1"
                   Ambiente.Lector.CommPort = 1
               Case "COM2"  
                   Ambiente.Lector.CommPort = 2
               Case "COM3"  
                   Ambiente.Lector.CommPort = 3
               Case "COM4"  
                   Ambiente.Lector.CommPort = 4
               Case "COM5"  
                   Ambiente.Lector.CommPort = 5            
               Case else
                   Ambiente.Lector.CommPort = 1            
        End Select

        if Ambiente.Lector.PortOpen Then
           Exit Sub
        end if 

        Ambiente.Lector.Settings = "9600,O,7,1"
        Ambiente.Lector.RTSEnable = True    
        Ambiente.Lector.PortOpen = True

        Ambiente.Tag = ""

        Exit Sub

End Sub


Public Sub TraePeso

    ' Si el puerto no esta abierto salimos del procedimiento
    if Ambiente.Lector.PortOpen = False Then
       Exit Sub
    end if 

    a = Ambiente.Lector.Input
    a = ""

    For n = 1 to 50

        Ambiente.Lector.OutPut = Chr(83) & Chr( 49 ) & Chr( 49 ) & Chr( 13 )
    
        ' Si lo que obtenemos es el valor del lector de código de barras
        a = Ambiente.Lector.Input

        if Len( a ) > 0 Then
           a = Replace( Trim( a ), Chr(13), "" )
           a = Val2( Mid( a, 4) ) / 1000
           txtFields(0) = Formato( a, "###,###.0000" )
           AceptaPeso  
           Exit For 
        end if

        Eventos

    Next
 
End Sub
Deja un comentario