Showing results 1 to 1 of 1

Thread: VBA - New Online Container in zenOn 6.22 (BulkMode)

  1. #1
    Join Date
    30.05.2007
    Location
    Salzburg
    Posts
    877

    Idee VBA - New Online Container in zenOn 6.22 (BulkMode)

    With zenOn 6.22 SP0 a new kind of Variable Online Container has been implemented.
    Using this "Bulk Mode" a faster start of the zenOn Runtime can be guaranteed in comparison to the "normal" Variable Online Container.

    With the "normal" Variable Online Container for every new value of the variable a Change Event is fired -> Private Sub zOLV_VariableChange(ByVal obVar As IVariable)
    So when starting the zenOn Runtime this event will be fired as often as variables have been defined in the Online Container.

    With the "Bulk Mode" -> Private Sub zOLV_VariableBulkChange(....) an array with the changed variables will be returned.

    See below a VBA sample how to do.
    -> if you do not want to add all variables to the Container it is possible to add only those variables which do have a certain pattern within the variablename. I.e. you have 50 variables with the variablename
    - MyS7TCPIP_VAR_1
    - MyS7TCPIP_VAR_2
    .....
    - MyS7TCPIP_VAR_50



    Option Explicit
    
    Dim WithEvents zOLV As OnlineVariable
    Dim strVariables() As String
    
    Const strVarNamePart As String = "MyS7TCPIP_VAR_" 'Pattern of the VariableName
    
    Private Sub Project_Active()
    
    Dim iVar As Integer
      
      
    '    '#######################################
    '    'this would add all variables existing in the project to the Online Container (array)
    '    '#######################################
    '    'create array of all existing variables within the project
    '    ReDim strVariables(thisProject.Variables.Count)
    '    For iVar = 0 To thisProject.Variables.Count - 1
    '        strVariables(iVar) = thisProject.Variables.Item(iVar).Name
    '    Next iVar
    '    '#######################################
    
      
        '#######################################
        'this would add all variables in the project to the Online Container (array)
        '-> which matches the given pattern in the VariableName
        '#######################################
        ReDim strVariables(thisProject.Variables.Count)
        For iVar = 0 To thisProject.Variables.Count - 1
            'search for the pattern within the VariableName (strVarNamePart)
            If InStr(1, thisProject.Variables.Item(iVar).Name, strVarNamePart) <> 0 Then
                strVariables(iVar) = thisProject.Variables.Item(iVar).Name
            End If
        Next iVar
        '#######################################
      
      'get/create onlinevariable - container
      Set zOLV = thisProject.OnlineVariables.Item("myOLV")
      If zOLV Is Nothing Then
        Set zOLV = thisProject.OnlineVariables.CreateOnlineVariables("myOLV")
      End If
      'add variables (array) as bulk to the online container
      zOLV.AddBulk strVariables()
      'activate BULK Mode
      zOLV.ActivateBulkMode
      'activate VariableBulkChange - Event
      zOLV.Define
    End Sub
    
    '#######################################
    'to react on the VariableBulkChange for a specific variable it would be necessary to run through the array
    'if a reaction on a Variable Change should be available it is better to create an additional OnlineContainer with "OnlineVariable.VariableChange"
    '#######################################
    
    'Private Sub zOLV_VariableBulkChange(pvVars As Variant, pvPvIDs As Variant, pvValues As Variant, pvStatesLo As Variant, pvStatesHi As Variant, pvTimes As Variant)
    '
    'Dim i As Integer
    '
    '    Debug.Print "Changed Variables: " & UBound(pvVars)
    '    For i = 0 To UBound(pvVars)
    '        Debug.Print " - [" & pvPvIDs(i) & "] " & pvVars(i).Name & " = " & pvValues(i)
    '    Next i
    '    Debug.Print "----------------------------------------------------------------"
    'End Sub
    
    
    Private Sub Project_Inactive()
        'relase objects
        If Not zOLV Is Nothing Then
            zOLV.Undefine
        End If
        
        thisProject.OnlineVariables.DeleteOnlineVariables ("myOLV")
        Set zOLV = Nothing
    End Sub
    Last edited by herberto : 10th February 2009 at 13:56 Reason: removed debug.print message...

Similar Threads

  1. Dynamische Onlinevariablen im Container
    By bzoller in forum VBA
    Replies: 10
    Last Post: 25th September 2008, 15:45
  2. Replies: 0
    Last Post: 19th September 2007, 12:06
  3. Replies: 0
    Last Post: 21st August 2007, 10:35

Posting Rules

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