ModBus Coding Example VB
ModBus Coding Example VB
ModBus Coding Example VB
Imports System.Data.SqlClient
MyBase .Finalize()
End Sub
Private Sub Form_VisibleChanged( ByVal sender As Object , ByVal e As System .EventArgs ) Handles Me .VisibleChanged
'* Do not start comms on first show in case it was set to disable in design mode
If NotFirstShow Then
NotFirstShow = True
End If
End Sub
'***************************************************************
'* .NET does not close hidden forms, so do it here
'* to make sure forms are disposed and drivers close
'***************************************************************
My .Application.OpenForms(index).Close()
End If
index += 1
End While
End Sub
Private Sub MainForm_Load(sender As Object , e As EventArgs ) Handles MyBase .Load
GroupPanel1.Location = point1
GroupPanel2.Location = point2
point21.X = myWidth + 10
SevenSegment21.Location = point21
SevenSegment22.Location = point22
SevenSegment23.Location = point23
SevenSegment24.Location = point24
SevenSegment25.Location = point25
SevenSegment26.Location = point26
SevenSegment27.Location = point27
SevenSegment28.Location = point28
SevenSegment29.Location = point29
myHeight = 150
point21.Y = myHeight
point22.Y = myHeight
point23.Y = myHeight
point24.Y = myHeight
point25.Y = myHeight
point26.Y = myHeight
point27.Y = myHeight
point28.Y = myHeight
point29.Y = myHeight
myWidth = 10
Label6.Location = point21
Label8.Location = point22
Label11.Location = point23
Label12.Location = point24
Label13.Location = point25
Label14.Location = point26
Label15.Location = point27
Label16.Location = point28
Label17.Location = point29
'TextBox1.Text = ModbusTCPCom1.IPAddress
SevenSegment210.Value = 732 / 3
End Sub
Private Sub ToolStripStatusLabel2_Click(sender As Object , e As EventArgs ) Handles ToolStripStatusLabel2.Click
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'This will execute when the user clicks the button or at specific intervals from the Timer1
Try
Label10.ForeColor = Color.Red
End Try
Label10.ForeColor = Color.Black
Label10.Text = "Logging..."
'We will use a SQL instruction to insert a record into the table
Dim SQL As String 'SQL Command String
Try
Con.Open() 'Open the database connection
'MsgBox(SQL)
'MsgBox(objCmd)
Label10.ForeColor = Color.Red
'MessageBox.Show(ex.InnerException.Message)
End Try
End If
End Sub
Private Sub Timer1_Tick(sender As Object , e As EventArgs ) Handles Timer1.Tick
Timer1.Enabled = True
Call Sub() Me.Button1_Click(sender, e) 'Call the routine to get the PLC information and store in a database
End Sub
Private Sub GroupPanel1_Paint(sender As Object, e As PaintEventArgs) Handles GroupPanel1.Paint
' Definitions
'
' Actual
' This Is how much has been produced.
' >This can be incremented by pushing the up Or down buttons in the run screen.
' >The sensor port will increment up even when in the menus.
'
' Goal
' This Is how many should be produced right now.
' >It follows the concept Of takt time, it will increment up one every takt.
'
' Takt Time
' Takt Is a German word that means beat Or rhythm.
' >Takt Time Is calculated by dividing the shift goal by the hours, minutes, Or seconds per shift.
' >Example: If the Then shift goal Is 900 units And the shift has 7.5 working hours (450 minutes) the takt ' >time would be 900 units/450
minutes which equals a takt Of 2 units per minute.
' >LeanTempo Basic will compute this automatically And will increment the goal up by 1 unit every 30 seconds.
'
' Shift Length
' This Is how many hours are worked In the shift.
' >Take total shift length And subtract out any breaks, lunches, Or 5S time allocated to the employees.
' >Keep things Like changeover time Or other non-value added time in the shift length.
' >The LeanTempo Basic Production timer will highlight when the team Is behind Or ahead of goal.
'
' Shift Goal
' This Is how many units should be produced during the shift.
'
' Efficiency
' Efficiency Is Actual / Goal
'
' Time Left
' This Is how much time Is left in the shift
'
End Sub
End Class