Publicado el Dejar un comentario

MAGELLAN Basculas magellan de dos puertos

'----**** 
'----**** 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
       ConfiguraPuerto
    else
       TraePeso
    end if


End Sub



Public Sub ConfiguraPuerto()

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

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

        if Ambiente.Bascula.PortOpen Then
           Exit Sub
        end if 

        Ambiente.Bascula.Settings = "9600,E,7,1"
        Ambiente.Bascula.RTSEnable = True    
        Ambiente.Bascula.PortOpen = True

        Ambiente.Tag = ""

End Sub


Public Sub TraePeso

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

    ' Vaciamos el bufer
    a = Ambiente.Bascula.Input
    a = ""

    Eventos

    Ambiente.Bascula.OutPut = Chr(87)

    For n = 1 To 50
        a = Ambiente.Bascula.Input

        if Len( a ) > 0 Then
           a = Replace( Trim( a ), Chr(13), "" )
           txtFields(0) = a 
           AceptaPeso  
           Exit For
        end if

        Eventos   
 
    Next

End Sub

Deja un comentario