I think the Problem is that MicroLogix is not connected directly to the SQL server but its connected through a network interface module.
My service stops responding once it goes to the Step PLC_Read() and its not even going to next step as my PLC is powered off, but when the PLC is back UP and running again, still the service is not responding.
Please see My code
Imports System.Data.SqlClient
Imports ABLink
Public Class Form1
Public PLC_Compactor As New Controller
Public MyTag As New Tag
'**********************************
'* initialize Threading Timer
Private oTimer As Threading.Timer
'**********************************
'* Define Registers
Dim length, breakpoint As Integer
Dim DayValueHold As Integer = 1
Dim DateStored, TimeStored, DateTimeCurrent, DateOfDumpFormatted, TimeOfDumpFormatted As String
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Add code here to start your service. This method should set things
' in motion so your service can do its work.
'**********************************
'* CONNECT TO PLC
PLC_Compactor.CPUType = Controller.CPU.SLC
PLC_Compactor.DriverType = Controller.Driver.NETENI
PLC_Compactor.IPAddress = "192.168.4.190"
' PLC_Compactor.Path = "0.0.0.0"
PLC_Compactor.Timeout = 3000
PLC_Compactor.Connect()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Try
If (PLC_Compactor.Connect() = ResultCode.E_SUCCESS) Then
PLC_Read()
If PLC_Trigger <> 0 Then
WriteToPLC_UpdateTime()
ConvertToDateFormat(DateOfDump, DateOfDumpFormatted)
ConvertToTimeFormat(TimeOfDump, TimeOfDumpFormatted)
WriteToSQL()
WriteToPLC_ZeroTrigger()
End If
End If
Catch ex As Exception
ErrorMessageAdd("PLC Connect Fail, " & ex.Message)
End Try
End Sub
Thank you