Hi, i ve a little problem with a UDT i defined.
This are the UDTs i am using:
This is the part where i fill the Udts. If i call them here they are working as they should, eg when i call Goose.GooseData(2).NodeAttributes(1, 5) i get the correct value.
But when i call it outside of the function i m filling it, it wont work.
e.g. when i define XML = xXMLR and call XML(399).GooseData(2).NodeAttributes(1,5) the array is empty. I figuered allready out, that he is interpreting it as an onedimensional Array,
so the value that should be at position (0,1) is instead at position (2,0).
Can someone tell me where my mistake is?
Best regards
Sascha
This are the UDTs i am using:
Code:
Public Type GooseData
NodeAttributes(1,20) As String
EndReached As Boolean
End Type
Public Type Goose
GooseData(50) As GooseData
EndReached As Boolean
End Type
This is the part where i fill the Udts. If i call them here they are working as they should, eg when i call Goose.GooseData(2).NodeAttributes(1, 5) i get the correct value.
But when i call it outside of the function i m filling it, it wont work.
e.g. when i define XML = xXMLR and call XML(399).GooseData(2).NodeAttributes(1,5) the array is empty. I figuered allready out, that he is interpreting it as an onedimensional Array,
so the value that should be at position (0,1) is instead at position (2,0).
Can someone tell me where my mistake is?
Best regards
Sascha
Code:
' ************************************************************
' This is module *Module6 .
' Automatically generated uses comments are placed here.
' Don't edit these lines.
' {BEGINUSES}
'#Uses "*Module1"
'#Uses "*Module2"
'#Uses "*Module3"
'#Uses "*Module4"
'#Uses "*Module5"
'#Uses "*Module6"
'#Uses "*Module7"
' {ENDUSES}
' ************************************************************
'-->function for parsing and searching through XML Documents
Public Function xXMLR(FilePath As String) As Variant()
Set objParser = CreateObject("Microsoft.XMLDOM")
Dim xDoc As MSXML2.DOMDocument
Dim ObjTmpArray(400) As Variant
Dim ExitTemplate As NameTemplate
Dim NameTemplate As NameTemplate
Dim Manufacturer As MSXML2.IXMLDOMElement
'initialize ObjTempArray
ExitTemplate.ModuleName = "End"
For j=0 To 400
ObjTmpArray(j) = ExitTemplate
Next
Dim NodeListLN As IXMLDOMNodeList
Dim NodeLN As MSXML2.IXMLDOMElement
Dim PrimaryCurrent As Double
Dim SecondaryCurrent As Double
Dim TransRatioCT As Double
Dim TransRatioVT As Double
Dim OCC As String
Dim i As Integer
Dim PTOC As PTOC
Dim tPTOC(5) As String
Dim ProtectedObject As MSXML2.IXMLDOMElement
Dim PDIS As PDIS
Dim PDISZone As PDISZone
Dim PDISFound As Boolean
Dim PDISinst As Integer
Dim PDIF As PDIF
Dim PDIFType As PDIFType
Dim PDIFFound As Boolean
Dim GooseDataPTOC As GooseData
Dim GooseDataPDIS As GooseData
Dim GooseDataPDIF As GooseData
Dim Goose As Goose
PDISFound = False
OCC = "OMICRON Control Center"
i = 0
j = 0
k = 0
l = 0
Set xDoc = New MSXML2.DOMDocument
'-->Prooves whether the document is a valid XML Document.
xDoc.validateOnParse = True
'-->DTD = Document Type Definition
If xDoc.load(FilePath) = False Then
MsgBox ("Unable to load File.",vbExclamation,OCC)
Else
MsgBox("File: " & Right(FilePath, Len(FilePath) - InStrRev(FilePath, "\")) & vbNewLine & "succesfully loaded!",vbInformation,OCC)
'-->Siemens Relais
Set Manufacturer = xDoc.selectSingleNode("//IED[@manufacturer]") '--> evlt noch documentElement. dazwischen
'-->Reading the *.cid file
Set NodeListLN = xDoc.documentElement.selectNodes("//LDevice/LN")
If Manufacturer.getAttribute("manufacturer")= "SIEMENS" Then
NameTemplate.RType = Manufacturer.getAttribute("type")
NameTemplate.ModuleName = "SIEMENS"
ObjTmpArray(400) = NameTemplate
'-->Transmition Ratio
PrimCT = CDbl(xDoc.selectSingleNode("//LN[@lnType='SIPROTEC5_LNType_GAPC_FB0_MUCurrent_3ph']/DOI[@name='ARtgINsens']/SDI[@name='setMag']").lastChild.Text)
SecCT = CDbl(xDoc.selectSingleNode("//LN[@lnType='SIPROTEC5_LNType_GAPC_FB0_MUCurrent_3ph']/DOI[@name='ARtgSecINs']/SDI[@name='setMag']").lastChild.Text)
PrimVT = CDbl(xDoc.selectSingleNode("//LN[@lnType='SIPROTEC5_LNType_TVTR'][@inst='1']/DOI[@name='VRtg']/SDI[@name='setMag']").lastChild.Text)*1000
SecVT = CDbl(xDoc.selectSingleNode("//LN[@lnType='SIPROTEC5_LNType_GAPC_FB0_MUVoltage_3ph']/DOI[@name='VRtgSec']/SDI[@name='setMag']").lastChild.Text)
ElseIf Manufacturer.getAttribute("manufacturer")= "ABB" Then
NameTemplate.RType =Manufacturer.getAttribute("type")
NameTemplate.ModuleName = "ABB"
ObjTmpArray(400) = NameTemplate
PrimCT = CDbl(xDoc.selectSingleNode("//LN[@lnType='RESTCTR1_B_3']/DOI[@name='ARtg']/SDI[@name='setMag']").lastChild.Text)
'-->Replace, because ABB saves value and unity in the same Node
SecCT = CDbl(Replace(xDoc.selectSingleNode("//LN[@lnType='RESTCTR1_B_3']/DOI[@name='ARtgSec']/DAI[@name='setVal']").lastChild.Text,"A",""))
PrimVT = CDbl(xDoc.selectSingleNode("//LN[@lnType='RESTVTR1_C_1']/DOI[@name='VRtg']/SDI[@name='setMag']").lastChild.Text)
SecVT = CDbl(Replace(xDoc.selectSingleNode("//LN[@lnType='RESTVTR1_C_1']/DOI[@name='VRtgScy']/DAI[@name='setVal']").lastChild.Text,"A",""))
End If
'-->Transmission Ratio
TransRatioCT = PrimCT/SecCT
TransRatioVT = PrimVT/SecVT
MsgBox(ObjTmpArray(400).ModuleName & "-Relais Type: " & ObjTmpArray(400).RType & vbNewLine & vbNewLine & "Transmission Ratio (Current): " & CStr(TransRatioCT)& vbNewLine & "Transmission Ratio (Voltage): " &CStr(TransRatioVT),OCC )
For Each NodeLN In NodeListLN
'-->Siemens Relais
If Manufacturer.getAttribute("manufacturer")= "SIEMENS" Then
'-->Find all PTOC in the SCL File
If NodeLN.getAttribute("lnClass") = "PTOC" Then
Set NodeLNParent = NodeLN.parentNode
PTOC.Threshold = CDbl(NodeLN.selectSingleNode("DOI[@name='StrVal']/SDI[@name='setMag']").lastChild.Text)/TransRatioCT
PTOC.Mode = NodeLN.selectSingleNode("DOI[@name='Mode']").lastChild.Text
PTOC.Delay = CDbl(NodeLN.selectSingleNode("DOI[@name='OpDlTmms']/DAI[@name='setVal']").lastChild.Text)/1000
PTOC.DropOutRate = CDbl(NodeLN.selectSingleNode("DOI[@name='DrpoutRat']/SDI[@name='setMag']").lastChild.Text)
PTOC.desc = NodeLNParent.getAttribute("inst")
PTOC.Zone = NodeLN.getAttribute("inst")
PTOC.ModuleName = "PTOC"
ObjTmpArray(i)=PTOC
'-->Goose
GooseDataPTOC.NodeAttributes(0,0) = "ldInst"
GooseDataPTOC.NodeAttributes(1,0) = NodeLNParent.getAttribute("inst")
GooseDataPTOC.NodeAttributes(0,1) = "lnClass"
GooseDataPTOC.NodeAttributes(1,1) = "PTOC"
GooseDataPTOC.NodeAttributes(0,2) = "prefix"
GooseDataPTOC.NodeAttributes(1,2) = NodeLN.getAttribute("prefix")
GooseDataPTOC.NodeAttributes(0,3) = "InInst"
GooseDataPTOC.NodeAttributes(1,3) = NodeLN.getAttribute("inst")
GooseDataPTOC.NodeAttributes(0,4) = "fc"
GooseDataPTOC.NodeAttributes(1,4) = "ST"
GooseDataPTOC.NodeAttributes(0,5) = "daName"
GooseDataPTOC.NodeAttributes(1,5) = ""
GooseDataPTOC.NodeAttributes(0,6) = "doName"
GooseDataPTOC.NodeAttributes(1,6) = "Str"
Goose.GooseData(l)=GooseDataPTOC
l=l+1
i=i+1
'-->Find all PDIS in the SCL File
ElseIf NodeLN.getAttribute("lnClass") = "PDIS" Then
Set NodeLNParent = NodeLN.parentNode
PDISFound = True
PDISZone.Name = NodeLN.getAttribute("desc")
PDISinst = NodeLN.getAttribute("inst")
PDISZone.Mode = NodeLN.selectSingleNode("DOI[@name='Mode']/DAI[@name='setVal']").lastChild.Text
PDISZone.FunctionMode = NodeLN.selectSingleNode("DOI[@name='ZoneMod']/DAI[@name='setVal']").lastChild.Text
PDISZone.XR=CDbl(NodeLN.selectSingleNode("DOI[@name='X1']/SDI[@name='setMag']").lastChild.Text)*(TransRatioCT/TransRatioVT)
PDISZone.RGnd=CDbl(NodeLN.selectSingleNode("DOI[@name='RisGndRch']/SDI[@name='setMag']").lastChild.Text)*(TransRatioCT/TransRatioVT)
PDISZone.RPh=CDbl(NodeLN.selectSingleNode("DOI[@name='RisPhRch']/SDI[@name='setMag']").lastChild.Text)*(TransRatioCT/TransRatioVT)
PDISZone.incAngle=CDbl(NodeLN.selectSingleNode("DOI[@name='ZnRedAng']/SDI[@name='setMag']").lastChild.Text)
PDISZone.Direction = NodeLN.selectSingleNode("DOI[@name='DirMod']").lastChild.Text
PDISZone.DelaytimePh = CDbl(NodeLN.selectSingleNode("DOI[@name='PhDlTmms']/DAI[@name='setVal']").lastChild.Text)
PDISZone.DelaytimeGnd = CDbl(NodeLN.selectSingleNode("DOI[@name='GndDlTmms']/DAI[@name='setVal']").lastChild.Text)
PDISZone.KFactor = CDbl(NodeLN.selectSingleNode("DOI[@name='K0Fact']/SDI[@name='setMag']").lastChild.Text)
PDIS.Zones(j) = PDISZone
'-->Goose
GooseDataPDIS.NodeAttributes(0,0) = "ldInst"
GooseDataPDIS.NodeAttributes(1,0) = NodeLNParent.getAttribute("inst")
GooseDataPDIS.NodeAttributes(0,1) = "lnClass"
GooseDataPDIS.NodeAttributes(1,1) = "PDIS"
GooseDataPDIS.NodeAttributes(0,2) = "prefix"
GooseDataPDIS.NodeAttributes(1,2) = NodeLN.getAttribute("prefix")
GooseDataPDIS.NodeAttributes(0,3) = "InInst"
GooseDataPDIS.NodeAttributes(1,3) = NodeLN.getAttribute("inst")
GooseDataPDIS.NodeAttributes(0,4) = "fc"
GooseDataPDIS.NodeAttributes(1,4) = "ST"
GooseDataPDIS.NodeAttributes(0,5) = "daName"
GooseDataPDIS.NodeAttributes(1,5) = ""
GooseDataPDIS.NodeAttributes(0,6) = "doName"
GooseDataPDIS.NodeAttributes(1,6) = "Str"
Goose.GooseData(l)=GooseDataPDIS
l=l+1
j=j+1
'-->Find all PDIF in the SCL File
ElseIf NodeLN.getAttribute("lnClass") = "PDIF" Then
Set NodeLNParent = NodeLN.parentNode
PDIFFound = True
PDIFType.Mode = NodeLN.selectSingleNode("DOI[@name='Mode']/DAI[@name='setVal']").lastChild.Text
PDIFType.OperationType = Replace(NodeLN.getAttribute("prefix"),"_","")
PDIFType.Threshold = CDbl(NodeLN.selectSingleNode("DOI[@name='StrVal']/SDI[@name='setMag']").lastChild.Text)/TransRatioCT
PDIFType.ThresholdSOF = CDbl(NodeLN.selectSingleNode("DOI[@name='StrValSwCd']/SDI[@name='setMag']").lastChild.Text)/TransRatioCT
PDIFType.Delay = CDbl(NodeLN.selectSingleNode("DOI[@name='OpDlTmms']/DAI[@name='setVal']").lastChild.Text)
PDIF.Mode = NodeLNParent.selectSingleNode("LN[@lnClass='GAPC']/DOI[@name='Mode']/DAI[@name='setVal']").lastChild.Text
PDIF.IDIFF(k) = PDIFType
k = k+1
Else
If PDISFound = True Then
PDIS.Manufacturer = "SIEMENS"
PDIS.ModuleName = "PDIS"
PDIS.ZoneCount = j
'--> Protected Object
Set ProtectedObject = xDoc.selectSingleNode("//LDevice[@inst='Ln1']/LN[@lnClass='ZLIN']")
PDIS.LineAngle = CDbl(ProtectedObject.selectSingleNode("DOI[@name='ZPsAng']/SDI[@name='setMag']/DAI/Val").Text)
PDIS.LineLength = CDbl(ProtectedObject.selectSingleNode("DOI[@name='LineLength']/SDI[@name='setMag']").lastChild.Text)
PDIS.LineReact = CDbl(ProtectedObject.selectSingleNode("DOI[@name='LineReact']/SDI[@name='setMag']").lastChild.Text)*(TransRatioCT/TransRatioVT)
'-->K-Faktor
' PDIS.KX = CDbl(ProtectedObject.selectSingleNode("DOI[@name='Km0Fact']").lastChild.Text)
' PDIS.KR = CDbl(ProtectedObject.selectSingleNode("DOI[@name='Km0FactAng']").lastChild.Text)
ObjTmpArray(i)=PDIS
i=i+1
j=0
PDISFound = False
End If
If PDIFFound = True Then
PDIF.ModuleName = "PDIF"
ObjTmpArray(i)=PDIF
i=i+1
k = 0
PDIFFound = False
End If
End If
'-->ABB Relais
ElseIf Manufacturer.getAttribute("manufacturer")= "ABB" Then
If NodeLN.getAttribute("lnClass") = "PTOC" Then
PTOC.Threshold = CDbl(NodeLN.selectSingleNode("DOI[@name='StrVal']/SDI[@name='setMag']").lastChild.Text)*SecCt
PTOC.Delay = CDbl(NodeLN.selectSingleNode("DOI[@name='OpDlTmms']/DAI[@name='setVal']").lastChild.Text)/1000
'Curve Parameters
tPTOC(0) = NodeLN.selectSingleNode("DOI[@name='TmACrv']/DAI[@name='setCharact']").lastChild.Text
tPTOC(1) = NodeLN.selectSingleNode("DOI[@name='TmACrv']/DAI[@name='setParA']").lastChild.Text
tPTOC(2) = NodeLN.selectSingleNode("DOI[@name='TmACrv']/DAI[@name='setParB']").lastChild.Text
tPTOC(3) = NodeLN.selectSingleNode("DOI[@name='TmACrv']/DAI[@name='setParC']").lastChild.Text
tPTOC(4) = NodeLN.selectSingleNode("DOI[@name='TmACrv']/DAI[@name='setParD']").lastChild.Text
tPTOC(5) = NodeLN.selectSingleNode("DOI[@name='TmACrv']/DAI[@name='setParE']").lastChild.Text
PTOC.Curve = tmpArray
PTOC.desc = NodeLN.getAttribute("lnType")
PTOC.Zone = NodeLN.getAttribute("inst")
PTOC.ModuleName = "PTOC"
ObjTmpArray(i)=PTOC
i=i+1
End If
End If
Next
ObjTmpArray(399) = Goose
End If
xXMLR = ObjTmpArray
'-->Clear all Lists
Set NodeListLN = Nothing
Set NodeListDOI = Nothing
Set NodeListSDI = Nothing
Set xDoc = Nothing
End Function