AdvancedHMI Software
General Category => Open Discussion => Topic started by: bob1371 on November 30, 2017, 09:57:34 PM
-
Hello,
Working on a new application for data collection. I've tried this a couple different times on 2 different computers and always get the same fault.
From my output screen.
About to read the data
Exception thrown: 'MfgControl.AdvancedHMI.Drivers.Common.PLCDriverException' in MfgControl.AdvancedHMI.Drivers.dll
Here is the actual code. I've double checked my tags and looks like I have everything correct.
Any Idea's?
Thanks
Private Sub DataSubscriber1_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged
If e.ErrorId = 0 AndAlso e.Values.Count > 0 AndAlso e.Values(0) = "True" Then
Console.WriteLine("About to read the data")
Dim MyValues0() As String = EthernetIPforCLXCom1.Read("look_doser_sn_pn_array[0]", 999)
Dim MyValues8 As String = EthernetIPforCLXCom1.Read("MDY10")
Console.WriteLine("All Data Read")
'*Transfer the values to Excel
'*Creates Excel file
Using ExcelPackage As New OfficeOpenXml.ExcelPackage(New IO.FileInfo("C:\2220\Doser.xlsx"))
ExcelPackage.Workbook.Worksheets.Add(MyValues8)
Console.WriteLine("ws creation ok")
'*Writes the Headers in Row 1
ExcelPackage.Workbook.Worksheets(MyValues8).Cells("A1").Value = "...................................DOSER.................................."
Console.WriteLine("header creation ok")
ExcelPackage.Workbook.Worksheets(MyValues8).Cells("A1").AutoFitColumns()
'*Loops to write data in correct columns
For Index = 0 To MyValues0.Length - 1
Console.WriteLine("Element " & Index & "=" & MyValues0(Index))
Dim ws As OfficeOpenXml.ExcelWorksheet = ExcelPackage.Workbook.Worksheets(MyValues8)
Dim CellNum As String = "A" & (Index + 3)
ws.Cells(CellNum).Value = MyValues0(Index)
Next
Console.WriteLine("Doser OK")
'*Saves.xlsl file
ExcelPackage.Save()
End Using
End If
End Sub
-
Archie, or somebody else, will probably have a better understanding of your code and possible cause for the exception.
For now, I would suggest that you try to catch that exception in a Try/Catch and display it, similar to this:
Try
Dim MyValues0() As String = EthernetIPforCLXCom1.Read("look_doser_sn_pn_array[0]", 999)
Dim MyValues8 As String = EthernetIPforCLXCom1.Read("MDY10")
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.ToString)
End Try
This might provide more info for the exception itself.
Breakpoints at the above two "Dim" lines would also work.
Could also place a BasicLabel on the form and set its PLCAddressValue to MDY10 and comment out the above two "Dim" lines.
-
999 may be too drastic, try changing to much less or different tag.
-
Thanks guys.
Using the Try/Catch routine it showed PLC losing connection. I then took my array size down to 700 elements and all working good.