VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form frmComm 
   BackColor       =   &H00404040&
   BorderStyle     =   0  'None
   Caption         =   "Comunicação"
   ClientHeight    =   4020
   ClientLeft      =   5685
   ClientTop       =   8820
   ClientWidth     =   4695
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   268
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   313
   ShowInTaskbar   =   0   'False
   Begin VB.Timer tmrTick 
      Interval        =   50
      Left            =   3690
      Top             =   315
   End
   Begin MSWinsockLib.Winsock wskPort 
      Left            =   3690
      Top             =   765
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
      Protocol        =   1
      LocalPort       =   82
   End
   Begin Synapsis.MicroFooter mcfMain 
      Align           =   2  'Align Bottom
      Height          =   195
      Left            =   0
      TabIndex        =   0
      Top             =   3825
      Width           =   4695
      _ExtentX        =   8281
      _ExtentY        =   344
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Small Fonts"
         Size            =   6.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "In     Out"
   End
   Begin Synapsis.MicroHeader mchMain 
      Align           =   1  'Align Top
      Height          =   255
      Left            =   0
      TabIndex        =   1
      Top             =   0
      Width           =   4695
      _ExtentX        =   8281
      _ExtentY        =   450
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "Comunicação"
      UseIcons        =   0   'False
   End
   Begin Synapsis.MicroFooter mftDeco 
      Align           =   2  'Align Bottom
      Height          =   195
      Left            =   0
      TabIndex        =   6
      Top             =   3255
      Width           =   4695
      _ExtentX        =   8281
      _ExtentY        =   344
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Small Fonts"
         Size            =   6.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "Histórico                            Console"
      UseIcons        =   0   'False
   End
   Begin VB.PictureBox picHolder 
      Align           =   2  'Align Bottom
      BackColor       =   &H00404040&
      BorderStyle     =   0  'None
      Height          =   375
      Left            =   0
      ScaleHeight     =   25
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   313
      TabIndex        =   2
      Top             =   3450
      Width           =   4695
      Begin VB.TextBox txtConsole 
         Appearance      =   0  'Flat
         BackColor       =   &H00101010&
         BeginProperty Font 
            Name            =   "Terminal"
            Size            =   9
            Charset         =   255
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H0000FF00&
         Height          =   285
         Left            =   1530
         TabIndex        =   8
         Top             =   45
         Width           =   1140
      End
      Begin VB.CommandButton cmdExpand 
         BackColor       =   &H00808080&
         Caption         =   "&Menos"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   720
         MaskColor       =   &H00808080&
         Style           =   1  'Graphical
         TabIndex        =   3
         Top             =   45
         Width           =   735
      End
      Begin Synapsis.LED LedIn 
         Height          =   330
         Left            =   45
         TabIndex        =   4
         Tag             =   "&H00FFA080&"
         Top             =   45
         Width           =   330
         _ExtentX        =   582
         _ExtentY        =   582
         BorderColor     =   9461840
         FillColor       =   16752768
      End
      Begin Synapsis.LED ledOut 
         Height          =   330
         Left            =   360
         TabIndex        =   5
         Tag             =   "&H00FFA080&"
         Top             =   45
         Width           =   330
         _ExtentX        =   582
         _ExtentY        =   582
         BorderColor     =   9461840
         FillColor       =   16752768
      End
   End
   Begin VB.ListBox lstIn 
      Appearance      =   0  'Flat
      BackColor       =   &H00101010&
      BeginProperty Font 
         Name            =   "Terminal"
         Size            =   9
         Charset         =   255
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H0000FF00&
      Height          =   2880
      IntegralHeight  =   0   'False
      Left            =   45
      TabIndex        =   7
      Top             =   315
      Width           =   3570
   End
End
Attribute VB_Name = "frmComm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim EventIn As Byte, EventOut As Byte, uCompact As Boolean
Private Sub txtConsole_KeyPress(KeyAscii As Integer)

    If KeyAscii = 13 Then
    SendBroadcast Me.txtConsole.Text
    End If
    
End Sub
Private Sub cmdExpand_Click()

StoreFormPos Me, CStr(uCompact)
uCompact = Not uCompact
RestoreFormPos Me, CStr(uCompact)

Call ManageInterface

End Sub
Private Sub Form_Load()

ApplyLanguage Me

Me.wskPort.Bind 82
RestoreFormPos Me
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

    If UnloadMode = 1 Then
    Cancel = True
    Me.Visible = False
    End If

End Sub
Private Sub Form_Resize()

Call ManageInterface

End Sub
Private Sub tmrTick_Timer()
Dim uNewEventIn As Byte, uNewEventOut As Byte

uNewEventIn = EventIn
uNewEventOut = EventOut

    If uNewEventIn < 100 Then uNewEventIn = uNewEventIn + 10
    If uNewEventOut < 100 Then uNewEventOut = uNewEventOut + 10
    
    If uNewEventOut = EventOut And uNewEventIn = EventIn Then Exit Sub
    
EventOut = uNewEventOut
EventIn = uNewEventIn

Call CalcLEDS

End Sub
Private Sub wskPort_DataArrival(ByVal bytesTotal As Long)
On Error GoTo pswskPort_DataArrivalErr 'EHCG.UID.pswskPort_DataArrival

Dim lsCommBuffer As String

frmComm.wskPort.GetData lsCommBuffer, , bytesTotal

gsCommBuffer = gsCommBuffer & lsCommBuffer

Call ProccessBuffer
EventIn = 0
Call CalcLEDS

Exit Sub
pswskPort_DataArrivalErr:
ErrH , "ps.wskPort_DataArrival:" & vbCrLf & "Error: " & Err.number & vbCrLf & "Description: " & Err.Description & vbCrLf, , False

End Sub
Sub Sent()
EventOut = 0
Call CalcLEDS
End Sub
Sub CalcLEDS()
Dim uBaseColor As OLE_COLOR, uR As Byte, uG As Byte, uB As Byte, uIndex As Single
uBaseColor = Val(Me.LedIn.Tag)
ParseColor uBaseColor, uR, uG, uB
uIndex = (100 - EventIn) / 100
Me.LedIn.FillColor = ComposeColor(uIndex * uR, uIndex * uG, uIndex * uB)

uBaseColor = Val(Me.ledOut.Tag)
ParseColor uBaseColor, uR, uG, uB
uIndex = (100 - EventOut) / 100
Me.ledOut.FillColor = ComposeColor(uIndex * uR, uIndex * uG, uIndex * uB)

End Sub
Sub ManageInterface()
Dim uInit As Long, uSpacing As Long, uSpace As Long
On Error Resume Next

    If uCompact Then
    Me.Width = 1500
    Me.Height = 825
    Me.mcfMain.UseIcons = False
    Me.cmdExpand.Caption = "&Mais"
    Me.txtConsole.Visible = False
    
    Else
    Me.mcfMain.UseIcons = True
    Me.cmdExpand.Caption = "&Menos"
    uSpacing = 5
    uInit = Me.mchMain.Height
    uSpace = Me.mftDeco.Top - uInit
    Me.txtConsole.Visible = True
        
        With Me.lstIn
        .Left = 0 'uSpacing
        .Width = Me.ScaleWidth '- uSpacing * 2
        .Top = uInit '+ uSpacing
        .Height = uSpace
        '.Height = (uSpace - uSpacing * 2)
        End With
    
    Me.txtConsole.Width = Me.picHolder.Width - Me.txtConsole.Left - Me.txtConsole.Top
    
    End If

End Sub
