VBA - New Online Container in zenOn 6.22 (BulkMode)

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

VBA Code:

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


This is a migrated post! Originally posted on 10.02.2009 by user herberto. Please be aware that information can be outdated.

    Disclaimer

    This document governs the use of our Community Forum. By registering and using the platform, you accept these conditions.

    The COPA-DATA Community Forum serves to encourage the exchange of information and experience about the zenon software between forum users respectively zenon users.

    Please mind that any published information on the Community Forum is the subjective opinion and view based on the experience and the level of knowledge of the author. COPA-DATA does not overtake any responsibility for the content and the accuracy of the shared information.

    Users of the Community Forum are encouraged to share only well-founded experiences and to point out any risks associated with the implementation of proposed solutions to problems. COPA-DATA at its absolute discretion, reserves the right to moderate the forum. In this connection COPA-DATA may remove any information containing false facts, potentially dangerous solutions, bad language or content that may insult, degrade or discriminate others. COPA-DATA may block a non-complying user from forum access if the user violated this provision.

    COPA-DATA reserves the right to change this document from time to time at own discretion.


    Ing. Punzenberger COPA-DATA GmbH
    Karolingerstraße 7b · 5020 Salzburg · Austria
    www.copadata.com