Appendix A
RELEVANT SOURCE CODE
Imports [Link]
Public Class Form4
Dim da As New OleDbDataAdapter
Dim dset As New DataSet
Private Sub Form4_Load(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
da = New OleDbDataAdapter("Select * from account", conn)
dset = New DataSet
[Link](dset, "account")
[Link] = [Link]("account").DefaultView
End Sub
Function populate()
da = New OleDbDataAdapter("Select * from account", conn)
dset = New DataSet
[Link](dset, "account")
[Link] = [Link]("account").DefaultView
Return True
End Function
Private Sub btnAdd_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
Dim comm As OleDbCommand
connect()
comm = New OleDbCommand
[Link] = conn
[Link] = "Insert into account values('" & [Link] & "', '" & [Link]
& "', '" & [Link] & "','" & [Link] & "' , '" & [Link] & "')"
[Link]()
populate()
[Link]("Successfully Added")
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
End Sub
Private Sub dgv_CellClick(ByVal sender As Object, ByVal e As
[Link]) Handles [Link]
[Link] = [Link]([Link]).Cells(0).[Link]
[Link] = [Link]([Link]).Cells(1).[Link]
[Link] = [Link]([Link]).Cells(2).[Link]
[Link] = [Link]([Link]).Cells(3).[Link]
[Link] = [Link]([Link]).Cells(4).[Link]
End Sub
Private Sub dgv_CellContentClick(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
End Sub
Private Sub btnUpdate_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
Dim comm As OleDbCommand
connect()
comm = New OleDbCommand
[Link] = conn
[Link] = "Update account set Fname='" & [Link] & "',Lname ='" &
[Link] & " ', Uname= '" & [Link] & "',Passwd='" & [Link] & "'
where ID='" & [Link] & "'"
[Link]()
populate()
[Link]("Account Updated")
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
End Sub
Private Sub btnDelete_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
Dim comm As OleDbCommand
connect()
comm = New OleDbCommand
[Link] = conn
[Link] = "Delete from account where ID='" & [Link] & "'"
[Link]()
[Link]("Successfully Deleted")
populate()
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
End Sub
Private Sub btnCancel_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
End Sub
End Class
Imports System
Imports [Link]
Public Class Form1
Dim vpb_sy, vpb_ly As Integer
Dim TempL, HumL As Integer
Dim Temp, Hum, TempResult, HumResult As String
Dim TempToProgressBar As Single
Dim ChartLimit As Integer = 30
Dim StrSerialIn, StrSerialInRam, value As String
Dim currenttime As String
Dim messagetime, messagetime1, messagetime2, messagetime3, messagetime4,
messagetime5 As String
Dim connect As Boolean
Private Sub Form1_Load(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
[Link] = True
[Link]()
[Link]()
[Link] = 0
[Link] = 0
[Link] = False
[Link] = False
For i = 0 To 30 Step 1
[Link]("Humidity ").[Link](0)
If [Link](0).[Link] = ChartLimit Then
[Link](0).[Link](0)
End If
[Link]("Temperature").[Link](0)
If [Link](0).[Link] = ChartLimit Then
[Link](0).[Link](0)
End If
Next
[Link](0).[Link] = 180
[Link](0).[Link] = -20
[Link]("ChartArea1").[Link] = False
[Link](0).[Link] = 70
[Link](0).[Link] = -30
[Link]("ChartArea1").[Link] = False
[Link] = 0
End Sub
Private Sub ComboBoxPort_Click(ByVal sender As Object, ByVal e As [Link])
Handles [Link]
If [Link] = "Status : Connected" Then
MsgBox("Conncetion in progress, please Disconnect to change COM.",
[Link], "Warning !!!")
Return
End If
End Sub
Private Sub ComboBoxPort_DropDown(ByVal sender As Object, ByVal e As
[Link]) Handles [Link]
[Link]()
End Sub
Private Sub ComboBoxPort_SelectedIndexChanged(ByVal sender As Object, ByVal e As
[Link]) Handles [Link]
[Link]()
End Sub
Private Sub ComboBoxBaudRate_Click(ByVal sender As Object, ByVal e As
[Link]) Handles [Link]
If [Link] = "Status : Connected" Then
MsgBox("Conncetion in progress, please Disconnect to change Baud Rate.",
[Link], "Warning !!!")
Return
End If
End Sub
Private Sub ComboBoxBaudRate_DropDown(ByVal sender As Object, ByVal e As
[Link]) Handles [Link]
[Link]()
End Sub
Private Sub ComboBoxBaudRate_SelectedIndexChanged(ByVal sender As Object, ByVal e
As [Link]) Handles [Link]
[Link]()
End Sub
Private Sub ButtonScanPort_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
[Link]()
If [Link] = "Status : Connected" Then
MsgBox("Conncetion in progress, please Disconnect to scan the new port.",
[Link], "Warning !!!")
Return
End If
[Link]()
Dim myPort As Array
Dim i As Integer
myPort = [Link]()
[Link](myPort)
i = [Link]
i=i-i
Try
[Link] = i
[Link] = True
Catch ex As Exception
MsgBox("Com port not detected", [Link], "Warning !!!")
[Link] = ""
[Link]()
Return
End Try
[Link] = True
End Sub
Private Sub ButtonConnect_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
[Link]()
Try
[Link] = [Link]
[Link] = [Link]
[Link]()
[Link]()
[Link] = "Status : Connected"
[Link]()
[Link]()
[Link] = [Link]
Catch ex As Exception
MsgBox("Please check the Hardware, COM, Baud Rate and try again.",
[Link], "Connection failed !!!")
End Try
End Sub
Private Sub ButtonDisconnect_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
[Link] = "Status : Disconnect"
[Link] = True
[Link] = [Link]
End Sub
Function MapVPB(ByVal X As Single, ByVal In_min As Single, ByVal In_max As Single,
ByVal Out_min As Single, ByVal Out_max As Single) As Integer
Dim A As Single
Dim B As Single
A = X - In_min
B = Out_max - Out_min
A=A*B
B = In_max - In_min
A=A/B
MapVPB = A + Out_min
End Function
Private Sub TimerSerial_Tick(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
Try
StrSerialIn = [Link]
Dim TB As New TextBox
[Link] = True
[Link] = StrSerialIn
If [Link] > 0 Then
If [Link](0) = "Failed to read from DHT sensor!" Then
[Link]()
[Link]()
[Link] = "Status : Disconnect"
[Link]()
[Link]()
[Link] = True
[Link] = [Link]
MsgBox("Failed to read from DHT sensor !!!, Please check the Hardware and
Please connect again.", [Link], "Connection failed !!!")
Return
End If
StrSerialInRam = [Link](0).Substring(0, 1)
If StrSerialInRam = "H" Then
Hum = [Link](0)
HumL = [Link]
Else
Hum = Hum
End If
StrSerialInRam = [Link](1).Substring(0, 1)
If StrSerialInRam = "T" Then
Temp = [Link](1)
TempL = [Link]
Else
Temp = Temp
End If
HumResult = Mid(Hum, 2, HumL)
TempResult = Mid(Temp, 2, TempL)
TempToProgressBar = TempResult
[Link] = HumResult
[Link] = [Link] & " %"
[Link] = TempResult & " °C"
vpb_sy = MapVPB(TempToProgressBar, -20.0, 60.0, 0, 120)
If vpb_sy > 120 Then
vpb_sy = 120
End If
If vpb_sy < 0 Then
vpb_sy = 0
End If
[Link] = [Link] * vpb_sy / 120
vpb_ly = ([Link] - vpb_sy) +
[Link].Y
[Link] = New Point([Link].X, vpb_ly)
[Link]("Humidity ").[Link](HumResult)
If [Link](0).[Link] = ChartLimit Then
[Link](0).[Link](0)
End If
[Link]("Temperature").[Link](TempResult)
If [Link](0).[Link] = ChartLimit Then
[Link](0).[Link](0)
End If
If [Link] = True Then
[Link] = False
ElseIf [Link] = False Then
[Link] = True
End If
End If
Catch ex As Exception
[Link]()
[Link]()
[Link] = "Status : Disconnect"
[Link]()
[Link]()
[Link] = [Link]
MsgBox("Please check the Hardware and Please connect again." & [Link],
[Link], "Connection failed !!!")
Return
End Try
End Sub
Private Sub RdTemp_CheckedChanged(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
[Link] = False
[Link] = False
[Link] = False
[Link] = False
If [Link] = True Then
[Link] = True
[Link] = True
[Link] = True
[Link] = True
End If
End Sub
Private Sub RdTime_CheckedChanged(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
If [Link] = True Then
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
End If
End Sub
Private Sub BtnTemp_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
Try
If ([Link] >= [Link] And [Link] <=
[Link]) Then
connect = True
value = "1"
[Link](value)
[Link]()
Else
value = "0"
[Link](value)
[Link]()
End If
Catch ex As Exception
MsgBox("Please check the Hardware and Please connect again." & [Link],
[Link], "Connection failed !!!")
End Try
[Link] = False
[Link] = False
End Sub
Public Sub Timer1_Tick(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
[Link] = [Link]("MMM dd yyyy")
currenttime = [Link]("hh:mm:ss tt")
[Link] = currenttime
messagetime = [Link] + " " + [Link]
messagetime1 = [Link] + " " + [Link]
If [Link] = messagetime Then
connect = True
value = "1"
[Link](value)
[Link]()
ElseIf [Link] = messagetime1 Then
[Link]()
value = "0"
[Link](value)
[Link]()
End If
messagetime2 = [Link] + " " + [Link]
messagetime3 = [Link] + " " + [Link]
If [Link] = messagetime2 Then
connect = True
value = "1"
[Link](value)
[Link]()
ElseIf [Link] = messagetime3 Then
[Link]()
value = "0"
[Link](value)
[Link]()
End If
messagetime4 = [Link] + " " + [Link]
messagetime5 = [Link] + " " + [Link]
If [Link] = messagetime4 Then
connect = True
value = "1"
[Link](value)
[Link]()
ElseIf [Link] = messagetime5 Then
[Link]()
value = "0"
[Link](value)
[Link]()
End If
End Sub
Private Sub btnReset_Click(ByVal sender As [Link], ByVal e As [Link])
[Link] = True
[Link] = True
End Sub
Private Sub Timer2_Tick(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
End Sub
Public Sub btnMist1_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
[Link] = False
[Link] = False
[Link] = False
[Link] = False
End Sub
Private Sub btnConnect_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
If connect = False Then
For Each PortDispose As String In
[Link]
[Link](PortDispose)
Next
If [Link] > 0 Then
[Link] = [Link](0)
[Link]()
[Link] = True
[Link] = True
[Link] = False
MsgBox("CONNECTED")
[Link] = "Status : Connected"
[Link]()
[Link]()
[Link] = [Link]
connect = True
Else
MsgBox("NO PORT FOUND")
End If
Else
[Link]()
MsgBox("DISCONECTED")
connect = False
End If
End Sub
Private Sub btnON_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
If connect = True Then
value = "1"
[Link](value)
[Link]()
End If
End Sub
Private Sub btnOFF_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
If connect = True Then
value = "0"
[Link](value)
[Link]()
End If
End Sub
Private Sub btnMotorScan_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
[Link]()
If [Link] = "Status : Connected" Then
MsgBox("Conncetion in progress, please Disconnect to scan the new port.",
[Link], "Warning !!!")
Return
End If
[Link]()
Dim myPort1 As Array
Dim motor As Integer
myPort1 = [Link]()
[Link](myPort1)
motor = [Link]
motor = motor - motor
Try
[Link] = motor
[Link] = True
Catch ex As Exception
MsgBox("Com port not detected", [Link], "Warning !!!")
[Link] = ""
[Link]()
Return
End Try
[Link] = True
End Sub
Private Sub btnDisconnect1_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
[Link]()
[Link]()
[Link]()
[Link] = "Status : Disconnect"
[Link] = True
[Link] = [Link]
End Sub
Private Sub btnResTemp_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
[Link] = True
[Link] = True
End Sub
Private Sub ManageUserToolStripMenuItem_Click(ByVal sender As [Link], ByVal e
As [Link]) Handles [Link]
[Link]()
End Sub
Private Sub LogoutToolStripMenuItem_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
Dim ask As MsgBoxResult = MsgBox("Are you sure you want to logout?",
[Link])
If ask = [Link] Then
[Link]()
[Link]()
ElseIf ask = [Link] Then
[Link]()
End If
End Sub
Private Sub btnMist2_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
[Link] = False
[Link] = False
[Link] = False
[Link] = False
End Sub
Private Sub btnMist3_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
[Link] = False
[Link] = False
[Link] = False
[Link] = False
End Sub
Private Sub btnResMist1_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
[Link] = True
[Link] = True
[Link] = True
[Link] = True
End Sub
Private Sub btnResMist2_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
[Link] = True
[Link] = True
[Link] = True
[Link] = True
End Sub
Private Sub btnResMist3_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
[Link] = True
[Link] = True
[Link] = True
[Link] = True
End Sub
End Class