VBA Code:
Dim zOLVSub As OnlineVariable
Const strOLVSub As String = "OnlineVariablesSub"
Public Sub CreateOVL(sArr)
Dim StrVariables() As String
On Error GoTo ERROR_HANDLING
ReDim StrVariables(UBound(sArr))
For i = 0 To UBound(sArr)
StrVariables(i) = sArr(i)
Next i
'deactivate 'VariableChange' event
If Not zOLVSub Is Nothing Then zOLVSub.Undefine
thisProject.OnlineVariables.DeleteOnlineVariables (strOLVSub)
Set zOLVSub = Nothing
'get object if already exists
Set zOLVSub = thisProject.OnlineVariables.Item(strOLVSub)
If zOLVSub Is Nothing Then
'if not exitst, create a new OnlineVariable container
Set zOLVSub = thisProject.OnlineVariables.CreateOnlineVariables(strOLVSub)
'add variables (array) as bulk to the online container
zOLVSub.AddBulk StrVariables()
End If
'activate OnlineContainer
zOLVSub.Define
Exit Sub
ERROR_HANDLING:
'deactivate 'VariableChange' event
zOLVSub.Undefine
thisProject.OnlineVariables.DeleteOnlineVariables (strOLVSub)
Set zOLVSub = Nothing
MsgBox ("Skriptfehler")
End Sub
VBA Code:
Public Sub TerminateOVL()
On Error GoTo ERROR_HANDLING
'deactivate 'VariableChange' event
zOLVSub.Undefine
thisProject.OnlineVariables.DeleteOnlineVariables (strOLVSub)
Set zOLVSub = Nothing
Exit Sub
ERROR_HANDLING:
MsgBox ("Skriptfehler")
End Sub
VBA Code:
Public Sub MouseOver_Index_EnergieZaehler_Setzen(obElem As Element, vPosX As Variant, vPosY As Variant)
'Declarations
Dim nIndex As Integer
Dim sArr(1) As String
On Error GoTo ERROR_HANDLING
'Index aus verknüpfter Variable bestimmen
nIndex = Val(Mid(obElem.ItemVariable(0).Name, InStr(1, obElem.ItemVariable(0).Name, "[") + 1, (InStr(1, obElem.ItemVariable(0).Name, "]") - 1 - InStr(1, obElem.ItemVariable(0).Name, "[") + 1))) 'CStr(obElem.Name)
sArr(0) = "S0_.InitializeVariablesEnergyCounter[" & nIndex & "].adrSlave"
sArr(1) = "S0_.InitializeVariablesEnergyCounter[" & nIndex & "].adrEnergyArrayElementSlave"
'OnlineContainer mit den Benötigten Variablen erstellen, damit die Werte vom Treiber verfügbar sind
Call CreateOVL(sArr)
'Mit ermitteltem Index im Master den Slave und den Index im Slave bestimmen
'....
thisProject.Variables.Item("Visu_int_Index_Energiezähler").Value = zOLVSub.Item("S0_.InitializeVariablesEnergyCounter[" & nIndex & "].adrEnergyArrayElementSlave").Value
'Löschen des erstellten OnlineContainers um die Abfrage durch den Treiber von nicht benötigten Variablen zu stoppen
Call TerminateOVL
Exit Sub
ERROR_HANDLING:
'deactivate 'VariableChange' event
zOLVSub.Undefine
thisProject.OnlineVariables.DeleteOnlineVariables (strOLVSub)
Set zOLVSub = Nothing
End Sub
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