VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form DataLogging 
   Caption         =   "Data Logging"
   ClientHeight    =   7710
   ClientLeft      =   165
   ClientTop       =   855
   ClientWidth     =   10080
   Icon            =   "Data Logging.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   7710
   ScaleWidth      =   10080
   StartUpPosition =   3  'Windows Default
   Begin VB.Frame Frame13 
      BackColor       =   &H00FF8080&
      Caption         =   "Log"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   4575
      Index           =   0
      Left            =   8330
      TabIndex        =   1
      Top             =   0
      Width           =   1720
      Begin VB.CheckBox AutoClearLog 
         BackColor       =   &H00FF8080&
         Caption         =   "  Auto Clear      Once  &Full"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   480
         Left            =   120
         TabIndex        =   14
         Top             =   1880
         Value           =   1  'Checked
         Width           =   1560
      End
      Begin VB.CheckBox EnableLogTime 
         BackColor       =   &H00FF8080&
         Caption         =   "  Log &Time"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   360
         Left            =   120
         TabIndex        =   13
         Top             =   1560
         Value           =   1  'Checked
         Width           =   1560
      End
      Begin VB.CommandButton ClearLog 
         Caption         =   "&Clear Log"
         Height          =   330
         Left            =   120
         TabIndex        =   21
         Top             =   4080
         Width           =   1525
      End
      Begin VB.Frame Frame2 
         BackColor       =   &H00FF8080&
         Height          =   135
         Index           =   2
         Left            =   120
         TabIndex        =   20
         Top             =   3570
         Width           =   1500
      End
      Begin VB.Frame Frame2 
         BackColor       =   &H00FF8080&
         Height          =   135
         Index           =   1
         Left            =   120
         TabIndex        =   19
         Top             =   2320
         Width           =   1500
      End
      Begin VB.TextBox AutoSaveUpdateInterval 
         Alignment       =   2  'Center
         BackColor       =   &H000000FF&
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FFFFFF&
         Height          =   300
         Left            =   675
         MaxLength       =   3
         TabIndex        =   16
         Text            =   "60"
         Top             =   3240
         Width           =   500
      End
      Begin VB.CheckBox EnableAutoLogSave 
         BackColor       =   &H00FF8080&
         Caption         =   "&Auto Save To File Called Auto Log "
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   705
         Left            =   120
         TabIndex        =   15
         Top             =   2520
         Width           =   1500
      End
      Begin VB.CheckBox EnableLogDate 
         BackColor       =   &H00FF8080&
         Caption         =   "  Log &Date"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   360
         Left            =   120
         TabIndex        =   12
         Top             =   1200
         Value           =   1  'Checked
         Width           =   1560
      End
      Begin VB.Frame Frame2 
         BackColor       =   &H00FF8080&
         Height          =   135
         Index           =   0
         Left            =   120
         TabIndex        =   11
         Top             =   960
         Width           =   1500
      End
      Begin VB.ComboBox LogVariable 
         Height          =   315
         ItemData        =   "Data Logging.frx":030A
         Left            =   120
         List            =   "Data Logging.frx":031D
         TabIndex        =   4
         Text            =   "Temp"
         Top             =   240
         Width           =   855
      End
      Begin VB.CheckBox EnableLog 
         BackColor       =   &H00FF8080&
         Caption         =   "&ON"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   360
         Left            =   1080
         TabIndex        =   3
         Top             =   240
         Width           =   600
      End
      Begin VB.TextBox LogUpdateInterval 
         Alignment       =   2  'Center
         BackColor       =   &H000000FF&
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FFFFFF&
         Height          =   300
         Left            =   680
         MaxLength       =   3
         TabIndex        =   2
         Text            =   "2"
         Top             =   650
         Width           =   500
      End
      Begin VB.Image LogFullLEDON 
         Height          =   225
         Left            =   1200
         Picture         =   "Data Logging.frx":033F
         Top             =   3780
         Visible         =   0   'False
         Width           =   225
      End
      Begin VB.Label SecsLabel 
         BackStyle       =   0  'Transparent
         Caption         =   "< Log  Full >"
         Height          =   255
         Index           =   2
         Left            =   280
         TabIndex        =   22
         Top             =   3790
         Width           =   900
      End
      Begin VB.Image LogFullLEDOff 
         Height          =   225
         Left            =   1200
         Picture         =   "Data Logging.frx":0653
         Top             =   3780
         Width           =   225
      End
      Begin VB.Label SecsLabel 
         BackStyle       =   0  'Transparent
         Caption         =   "Secs"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   1
         Left            =   1215
         TabIndex        =   18
         Top             =   3270
         Width           =   420
      End
      Begin VB.Label EveryLabel 
         BackStyle       =   0  'Transparent
         Caption         =   "Every"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   1
         Left            =   120
         TabIndex        =   17
         Top             =   3270
         Width           =   645
      End
      Begin VB.Label SecsLabel 
         BackStyle       =   0  'Transparent
         Caption         =   "Secs"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   0
         Left            =   1220
         TabIndex        =   6
         Top             =   675
         Width           =   420
      End
      Begin VB.Label EveryLabel 
         BackStyle       =   0  'Transparent
         Caption         =   "Every"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   0
         Left            =   120
         TabIndex        =   5
         Top             =   680
         Width           =   645
      End
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   2880
      Top             =   6240
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
      FontName        =   "Courier New"
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H00FF8080&
      Height          =   3000
      Left            =   8330
      TabIndex        =   7
      Top             =   4540
      Width           =   1720
      Begin VB.Timer ShowLogFull 
         Enabled         =   0   'False
         Interval        =   500
         Left            =   1080
         Top             =   2520
      End
      Begin VB.CommandButton PrintLog 
         Height          =   645
         Left            =   120
         Picture         =   "Data Logging.frx":0967
         Style           =   1  'Graphical
         TabIndex        =   10
         Top             =   1530
         Width           =   1525
      End
      Begin VB.CommandButton SaveLog 
         Height          =   645
         Left            =   120
         Picture         =   "Data Logging.frx":0C71
         Style           =   1  'Graphical
         TabIndex        =   9
         Top             =   870
         Width           =   1525
      End
      Begin VB.CommandButton OpenLog 
         Height          =   645
         Left            =   120
         Picture         =   "Data Logging.frx":0F7B
         Style           =   1  'Graphical
         TabIndex        =   8
         Top             =   210
         Width           =   1525
      End
      Begin VB.Image SCLogo 
         Height          =   600
         Left            =   110
         Picture         =   "Data Logging.frx":1285
         Stretch         =   -1  'True
         Top             =   2250
         Width           =   1500
      End
   End
   Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
      Height          =   7550
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   8295
      _ExtentX        =   14631
      _ExtentY        =   13309
      _Version        =   327680
      Rows            =   2048
      Cols            =   4
      FixedCols       =   0
      BackColor       =   16777215
      ForeColor       =   0
      BackColorFixed  =   8388608
      ForeColorFixed  =   16777215
      GridColorFixed  =   8421504
      AllowBigSelection=   0   'False
      ScrollTrack     =   -1  'True
      HighLight       =   0
      ScrollBars      =   2
      SelectionMode   =   1
   End
   Begin VB.Menu Logger 
      Caption         =   "&Logger"
      Begin VB.Menu FileStartNew 
         Caption         =   "Start New"
         Shortcut        =   ^N
      End
      Begin VB.Menu FileOpen 
         Caption         =   "Open"
         Shortcut        =   ^O
      End
      Begin VB.Menu Bar3 
         Caption         =   "-"
      End
      Begin VB.Menu FileSave 
         Caption         =   "Save..."
         Shortcut        =   ^S
      End
      Begin VB.Menu FileSaveAs 
         Caption         =   "Save As"
      End
      Begin VB.Menu Bar1 
         Caption         =   "-"
      End
      Begin VB.Menu FilePrint 
         Caption         =   "Print..."
         Shortcut        =   ^P
      End
      Begin VB.Menu Bar2 
         Caption         =   "-"
      End
      Begin VB.Menu FileExit 
         Caption         =   "           < Exit >"
      End
   End
End
Attribute VB_Name = "DataLogging"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
   MSFlexGrid1.ColWidth(0) = 3075
   MSFlexGrid1.ColWidth(1) = 1600
   MSFlexGrid1.ColWidth(2) = 1600
   MSFlexGrid1.ColWidth(3) = 1600

   MSFlexGrid1.CellAlignment = 0
   MSFlexGrid1.Col = 0
   MSFlexGrid1.Row = 0
   MSFlexGrid1.Text = "Variable Data Type"

   MSFlexGrid1.Col = 1
   MSFlexGrid1.Row = 0
   MSFlexGrid1.Text = "Value"

   MSFlexGrid1.Col = 2
   MSFlexGrid1.Row = 0
   MSFlexGrid1.Text = "Date"

   MSFlexGrid1.Col = 3
   MSFlexGrid1.Row = 0
   MSFlexGrid1.Text = "Time"
End Sub

Private Sub Form_Resize()
   On Error Resume Next
   If DataLogging.Width > 10200 Then DataLogging.Width = 10200
   If DataLogging.Height > 8400 Then DataLogging.Height = 8400
End Sub

Private Sub ClearLog_Click()
   Call ClearLogProc
   ShowLogFull.Enabled = False
   LogFullLEDON.Visible = False
   LogFullLEDOff.Visible = True
End Sub

Private Sub EnableLog_Click()
   If GUI.LogTimer.Enabled = False Then
      GUI.LogTimer.Enabled = True
   Else
      GUI.LogTimer.Enabled = False
   End If
End Sub

Private Sub EnableAutoLogSave_Click()
   If GUI.AutoLog.Enabled = False Then
      GUI.AutoLog.Enabled = True
   Else
      GUI.AutoLog.Enabled = False
   End If
End Sub

Private Sub LogUpdateInterval_Change()
   LogTimerLoop = Val(LogUpdateInterval.Text) - 1
   LogTimerCount = LogTimerLoop
End Sub

Private Sub ShowLogFull_Timer()
   If LogFullLEDON.Visible = True Then
      LogFullLEDON.Visible = False
      LogFullLEDOff.Visible = True
   Else
      LogFullLEDON.Visible = True
      LogFullLEDOff.Visible = False
   End If
End Sub

Private Sub LogUpdateInterval_KeyPress(KeyAscii As Integer)
   If Not ((KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = 8)) Then KeyAscii = 0
End Sub

Private Sub AutoSaveUpdateInterval_KeyPress(KeyAscii As Integer)
   If Not ((KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = 8)) Then KeyAscii = 0
End Sub

Private Sub FileStartNew_Click()
   Call ClearLogProc
   ShowLogFull.Enabled = False
   LogFullLEDON.Visible = False
   LogFullLEDOff.Visible = True
End Sub

Private Sub OpenLog_Click()
   Call OpenProc
End Sub

Private Sub SaveLog_Click()
   Call SaveProc
End Sub

Private Sub PrintLog_Click()
   Call PrintLogProc
End Sub

Private Sub FileOpen_Click()
   Call OpenProc
End Sub

Private Sub FilePrint_Click()
   Call PrintProc
End Sub

Private Sub FileSave_Click()
   Call SaveProc
End Sub

Private Sub FileExit_Click()
   Me.Hide
End Sub

Private Sub FileSaveAs_Click()
   Call SaveProc
End Sub

Public Sub PrintLogProc()
   Call PrintProc
End Sub

Public Sub SaveProc()
   On Error GoTo UserCanceled 'User click cancel?
   CommonDialog1.Filter = "Log Files (*.log)|*.log|"
   CommonDialog1.Flags = 0: CommonDialog1.CancelError = True
   CommonDialog1.DialogTitle = "Log File To Save"
   CommonDialog1.ShowSave
   LogFileName = CommonDialog1.filename

   Open LogFileName For Output As #1
        For LoopX = 1 To MSFlexGrid1.Row
            For LoopZ = 0 To 3
                Print #1, MSFlexGrid1.TextMatrix(LoopX, LoopZ)
            Next
        Next
   Close #1
'============
UserCanceled:
'============
End Sub

Public Sub OpenProc()
   On Error GoTo UserCanceled 'User click cancel?
   CommonDialog1.Filter = "Log Files (*.log)|*.log|"
   CommonDialog1.Flags = 0: CommonDialog1.CancelError = True
   CommonDialog1.DialogTitle = "Log File To Load"
   CommonDialog1.ShowOpen
   LogFileName = CommonDialog1.filename
   Call ClearLogProc
   LogCol = 0
   LogRow = 1

   Open LogFileName For Input As #1
        Do Until EOF(1)
           Line Input #1, StrBuffer
           DataLogging.MSFlexGrid1.Col = LogCol
           DataLogging.MSFlexGrid1.Row = LogRow
           DataLogging.MSFlexGrid1.CellAlignment = 3
           MSFlexGrid1.TextMatrix(LogRow, LogCol) = StrBuffer
'Increment col
           LogCol = LogCol + 1
'Increment row after 4 cols
           If LogCol = 4 Then LogRow = LogRow + 1: LogCol = 0
        Loop
   Close #1
'Scroll to last page
   MSFlexGrid1.TopRow = LogRow - 29
'============
UserCanceled:
'============
End Sub

Public Sub PrintProc()
   On Error GoTo UserCanceled 'User click cancel?
   CommonDialog1.CancelError = True
   CommonDialog1.DialogTitle = "Print Log"
   CommonDialog1.Flags = cdlPDReturnDC + cdlPDNoPageNums
   CommonDialog1.Flags = CommonDialog1.Flags + cdlPDAllPages
   CommonDialog1.Flags = CommonDialog1.Flags + cdlPDSelection
   CommonDialog1.ShowPrinter

   Printer.FontName = "Courier New"
   Printer.FontSize = 8
   Printer.FontBold = True
   StrBuffer = ""

   Printer.Print ""
   Printer.Print ""

   Printer.Print "        ------------------------------------------------------------------------------------------------------"
   Printer.Print "        --------- DATA LOG ------------------------------ " + Date$ + " -------------- " + Time$ + " -----------------"
   Printer.Print "        ------------------------------------------------------------------------------------------------------"
   Printer.Print ""
   Printer.Print "                  Variable Type                 Value                   Date                  Time"
   Printer.Print ""
   Printer.FontBold = False
   
   For LoopX = 1 To MSFlexGrid1.Row
       For LoopZ = 0 To 3
           If LoopZ = 0 Then StrBuffer = StrBuffer + Space(18)
           If LoopZ = 1 Then StrBuffer = StrBuffer + Space(30 - Len(Trim(MSFlexGrid1.TextMatrix(LoopX, 0))))
           If LoopZ = 2 Then StrBuffer = StrBuffer + Space(24 - Len(Trim(MSFlexGrid1.TextMatrix(LoopX, 1))))
           If LoopZ = 3 Then StrBuffer = StrBuffer + Space(22 - Len(Trim(MSFlexGrid1.TextMatrix(LoopX, 2))))
           StrBuffer = StrBuffer + Trim(MSFlexGrid1.TextMatrix(LoopX, LoopZ))
       Next
       Printer.Print StrBuffer
       StrBuffer = ""
   Next
   Printer.EndDoc
'============
UserCanceled:
'============
End Sub

Private Sub AutoSaveUpdateInterval_Change()
   AutoLogTimerLoop = Val(AutoSaveUpdateInterval.Text) - 1
   AutoLogTimerCount = AutoLogTimerLoop
End Sub

Private Sub Form_Unload(Cancel As Integer)
   Me.Hide
   Cancel = True
End Sub

