1
Support Questions / Re: Changing a sub property
« on: January 14, 2019, 12:59:20 PM »
Archie,
This worked out well. I had to add some code to get by the headers, to eliminate the quotes in the files, and also not to process any lines without Modbus addresses.
Thanks for all of the help.
This worked out well. I had to add some code to get by the headers, to eliminate the quotes in the files, and also not to process any lines without Modbus addresses.
Code: [Select]
If Not TagAliasFileRead Then
If (System.IO.File.Exists(".\PLC Tags_basic.csv")) Then
TagAlias = New Dictionary(Of String, String)
Using sr As New System.IO.StreamReader(".\PLC Tags_basic.csv")
Dim Line As String
Dim Items() As String
While Not sr.EndOfStream
Line = sr.ReadLine()
Items = Line.Split(","c)
If Items(0).Substring(1, 1) <> "#" AndAlso Items(4) <> "" Then
If Items.Count > 1 Then
'* Item(0)=Alias, Item(1)=PLC Address
Dim MbAddress As String = Items(4)
Dim MOD_Prefix As String = ""
Dim myType As String = Items(0)
myType = myType.Substring(0, myType.IndexOf("-"))
Select Case myType
Case "F32"
MOD_Prefix = "F"
Case "S32"
MOD_Prefix = "L"
Case Else
MOD_Prefix = ""
End Select
'put all of the tagnames in the Dictionary object in Upper case to prevent mismatch due to case
'add leading 0s to contacts adressed 1,2... etc
'Dim ModAddress As String = (myRow("MODBUS Start Address"))
Dim x As Byte = 0
If MbAddress.Length < 5 Then
For x = 1 To 4
If MbAddress.Length < 5 Then
MbAddress = "0" & MbAddress
End If
Next
End If
MbAddress = MOD_Prefix & MbAddress
TagAlias.Add(Items(1).Substring(1, Items(1).Length - 2), MbAddress) ' Items(4))
End If
End If
End While
End Using
End If
TagAliasFileRead = True
End If
Thanks for all of the help.