Showing results 1 to 4 of 4

Thread: Renaming Variable Name in DNP3.0 Driver

  1. #1
    Join Date
    07.09.2016
    Posts
    2

    Frage Renaming Variable Name in DNP3.0 Driver

    Hi Guys!

    I have like 1200 tags that I imported from a DNP3.0 driver and I want to rename the variables. Is there any other way to rename it so it will not take me so much time?

    thanks in advance for those who can help.

    Edit: I need to rename the whole string of the name.
    Last edited by randyvalino : 6th April 2019 at 21:00

  2. #2

    Default Re: Renaming Variable Name in DNP3.0 Driver

    Hi randyvalino,

    You could do a CSV export of all imported variables, then open the .csv file e.g. with Excel, and use the column labelled KANAL_R for the original name of the variable and VariableName for the new name of the variable, after CSV import.

    Best regards,
    Mark

  3. #3
    Join Date
    07.09.2016
    Posts
    2

    Default Re: Renaming Variable Name in DNP3.0 Driver

    Hi Marc,

    thank you for your feedback.

    however, while doing CSV export I dont have the extension “.csv” and only have “.txt”. And it doesn’t seem to have the column “KANAL_R”.
    I did try to put “.csv” at the end of the file to save it as comma separated value file and still the column labelled KANAL_R is not there.

    one more thing is that most of this variables are linked to functions, dynamic elements, etc. I think csv import will not retain the link to this elements.

  4. #4
    Join Date
    01.07.2008
    Location
    Salzburg, AT
    Posts
    744

    Default Re: Renaming Variable Name in DNP3.0 Driver

    In zenon Editor, in the variable list, you can use "replace text in selected column" - from context menu. Unfortunately in version 8.00 we have an issue there, not fixed yet.
    Or you can write small VBA macro (in Workspace) accessing all variables of particular driver in current active project and renaming them; according maybe some complex rules.
    I have an example for renaming of imported IEC870 variables, I suppose for DNP3 could be similar:

    Private Sub RenameVars()

    'this is the driver identification (not driver name) for which we care about
    Const strDriverIdent As String = "iec870_to_IED01"

    Dim obVars As Variables
    Dim obVar As Variable
    Dim lVars As Long
    Dim obVarType As VarType
    Dim str1, str2 As String
    Dim tagnumS As String
    Dim tagnum As Integer
    Dim pos0 As Variant

        'create object of the variable collection
        Set obVars = MyWorkspace.ActiveDocument.Variables
        'loop through all variables
        tagnum = 0
        For lVars = 0 To obVars.Count - 1
            'create object of the given variable
            Set obVar = obVars.Item(lVars)
            'create object of the datatype of the variable
            Set obVarType = obVar.BaseType
            'check if the datatype is complex or not
            If obVarType.IsSimple = True Then
                'check if the variable is linked to the given driver
                If obVar.Driver.Identification = strDriverIdent Then
                    If obVar.Name Like "*T11 1.*" Then
                        'is: "[IED01] T11 1.1"
                        pos0 = InStr(1, obVar.Name, " 1.", vbTextCompare)
                        tagnumS = Right("0000" & Mid(obVar.Name, pos0 + 3, 5), 5)
                        obVar.Name = "IED01_tag" & tagnumS
                        obVar.Tagname = obVar.Name
                        'update addressing  
                        obVar.DynProperties("IEC870_TYPE") = 35

                        tagnum = tagnum + 1

                        'entry each 500 renamed variables to follow the progress
                        If (tagnum Mod 500) = 0 Then
                            Debug.Print (CStr(tagnum))
                        End If
                End If
            Else
                'it is a complex type - no need to go further on here...
            End If
            'release created objects
            Set obVarType = Nothing
            Set obVar = Nothing
        Next lVars
        'release created objects
        Set obVars = Nothing
    End Sub


Similar Threads

  1. Version 7.0 To 7.11 - Dnp3 Driver Enhancement
    By daujivar in forum zenon Energy Edition
    Replies: 1
    Last Post: 27th May 2015, 06:20
  2. Version 7.0 To 7.11 - Dnp3 Driver Enhancement
    By daujivar in forum Drivers
    Replies: 1
    Last Post: 27th May 2015, 06:20
  3. Polling DNP3 variable from straton
    By ansab.tp in forum straton / zenon Logic
    Replies: 1
    Last Post: 2nd April 2012, 22:45
  4. timeout in dnp3 driver
    By roberto1978 in forum Drivers
    Replies: 1
    Last Post: 16th April 2010, 00:08
  5. Renaming Variable name for OPC Connection
    By hoscillada in forum Drivers
    Replies: 12
    Last Post: 9th November 2009, 20:42

Tags for this Thread

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •