Hello!
I am trying to log some data and would like to include a description along with the tag name and value. I have tried a couple of ways with out any luck.
Currently I am stuck on Error BC30469 Reference to a non-shared member requires an object reference.
Does anyone have a better way to do this?
The text document is formated:
TagName,ScaleFactor,ScaleOfset,Description
Most of this code is from the documentation page under Configuring a DataSubscriber2 with a CSV file.
Private Sub DataSubscriber21_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber21.DataChanged
DataSubscriber21.BeginInit()
Using sw As New System.IO.StreamReader("MyConfigFile.txt")
Dim LineFromFile As String
Dim Settings() As String
Dim NewPLCAddressItem As MfgControl.AdvancedHMI.Drivers.PLCAddressItem
While Not sw.EndOfStream
LineFromFile = sw.ReadLine
Settings = LineFromFile.Split(",")
NewPLCAddressItem = New MfgControl.AdvancedHMI.Drivers.PLCAddressItem
NewPLCAddressItem.PLCAddress = Settings(0)
If Settings.Length > 1 Then
NewPLCAddressItem.ScaleFactor = CDbl(Settings(1))
End If
If Settings.Length > 2 Then
NewPLCAddressItem.ScaleOffset = CDbl(Settings(2))
End If
If Settings.Length > 3 Then
NewPLCAddressItem.Description = Settings(3)
End If
DataSubscriber21.PLCAddressValueItems.Add(NewPLCAddressItem)
End While
End Using
DataSubscriber21.EndInit()
Using sw As New System.IO.StreamWriter("LogFile.txt", True)
sw.WriteLine(Now & " - " & e.PlcAddress & " " & e.Values(0) & MfgControl.AdvancedHMI.Drivers.PLCAddressItem.Description)
End Using
End Sub
Thanks!