Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents AnalogMeter1 As Emant.AnalogMeter
    Friend WithEvents LineGraph1 As Emant.LineGraph
    Friend WithEvents Led1 As Emant.Led
    Friend WithEvents NumericUpDown1 As System.Windows.Forms.NumericUpDown
    Friend WithEvents Timer1 As System.Windows.Forms.Timer
    Friend WithEvents Emant3001 As Emant.Emant300
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Me.Label1 = New System.Windows.Forms.Label
        Me.AnalogMeter1 = New Emant.AnalogMeter
        Me.LineGraph1 = New Emant.LineGraph
        Me.Led1 = New Emant.Led
        Me.NumericUpDown1 = New System.Windows.Forms.NumericUpDown
        Me.Emant3001 = New Emant.Emant300(Me.components)
        Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
        CType(Me.NumericUpDown1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(13, 22)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(100, 23)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Label1"
        '
        'AnalogMeter1
        '
        Me.AnalogMeter1.Location = New System.Drawing.Point(16, 48)
        Me.AnalogMeter1.MaximumValue = 500
        Me.AnalogMeter1.MinimumValue = 0
        Me.AnalogMeter1.Name = "AnalogMeter1"
        Me.AnalogMeter1.Size = New System.Drawing.Size(160, 45)
        Me.AnalogMeter1.TabIndex = 1
        Me.AnalogMeter1.Value = 0
        '
        'LineGraph1
        '
        Me.LineGraph1.BackColor = System.Drawing.SystemColors.Control
        Me.LineGraph1.Location = New System.Drawing.Point(16, 112)
        Me.LineGraph1.Name = "LineGraph1"
        Me.LineGraph1.Size = New System.Drawing.Size(400, 250)
        Me.LineGraph1.TabIndex = 2
        Me.LineGraph1.Value = 0
        Me.LineGraph1.XMax = 100
        Me.LineGraph1.YMax = 500
        Me.LineGraph1.YMin = 0
        '
        'Led1
        '
        Me.Led1.ColorOff = System.Drawing.Color.Green
        Me.Led1.ColorOn = System.Drawing.Color.Red
        Me.Led1.Location = New System.Drawing.Point(200, 56)
        Me.Led1.Name = "Led1"
        Me.Led1.Size = New System.Drawing.Size(24, 24)
        Me.Led1.TabIndex = 3
        Me.Led1.Value = True
        '
        'NumericUpDown1
        '
        Me.NumericUpDown1.Location = New System.Drawing.Point(256, 56)
        Me.NumericUpDown1.Maximum = New Decimal(New Integer() {500, 0, 0, 0})
        Me.NumericUpDown1.Name = "NumericUpDown1"
        Me.NumericUpDown1.Size = New System.Drawing.Size(120, 20)
        Me.NumericUpDown1.TabIndex = 4
        '
        'Emant3001
        '
        Me.Emant3001.Simulation = False
        '
        'Timer1
        '
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(440, 374)
        Me.Controls.Add(Me.NumericUpDown1)
        Me.Controls.Add(Me.Led1)
        Me.Controls.Add(Me.LineGraph1)
        Me.Controls.Add(Me.AnalogMeter1)
        Me.Controls.Add(Me.Label1)
        Me.Name = "Form1"
        Me.Text = "Light Intensity Logger"
        CType(Me.NumericUpDown1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs)

    End Sub

    Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        Timer1.Enabled = False
        Emant3001.Close()
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Emant3001.Open()
        Timer1.Enabled = True
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim volt, lux As Double
        volt = Emant3001.ReadAnalog(Emant.Emant300.AIN.AIN0, Emant.Emant300.AIN.COM)
        lux = 1333 * volt
        AnalogMeter1.Value = lux
        LineGraph1.Value = lux
        Led1.Value = lux > NumericUpDown1.Value
        Label1.Text = lux.ToString("0.0 Lux")
    End Sub
End Class
