Skip to content

Commit b588629

Browse files
committed
tips on memory consumption for large file processing
Signed-off-by: Mohamed Sylla <[email protected]>
1 parent 10c426b commit b588629

File tree

1 file changed

+52
-11
lines changed

1 file changed

+52
-11
lines changed

doc/compas-sct.md

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,36 @@ abstraction defined below :
3838
protected P parentAdapter;
3939
protected T currentElem;
4040

41-
public SclElementAdapter(P parentAdapter) {
41+
protected SclElementAdapter(P parentAdapter) {
4242
this.parentAdapter = parentAdapter;
4343
}
4444

45-
public SclElementAdapter(P parentAdapter, T currentElem) {
45+
protected SclElementAdapter(P parentAdapter, T currentElem) {
46+
if(currentElem == null){
47+
throw new IllegalArgumentException("The SCL element to adapt must be defined");
48+
}
4649
this.parentAdapter = parentAdapter;
50+
this.customInit();
4751
setCurrentElem(currentElem);
4852
}
4953

54+
55+
protected boolean amRootElement(){
56+
return parentAdapter == null;
57+
}
58+
59+
protected void customInit() {
60+
// do nothing
61+
}
5062
public final void setCurrentElem(T currentElem){
51-
Assert.isTrue(amChildElementRef(currentElem),"No relation between SCL parent and child elements");
5263
this.currentElem = currentElem;
64+
if(!amRootElement() && !amChildElementRef()){
65+
throw new IllegalArgumentException("No relation between SCL parent element and child");
66+
}
5367
}
5468

55-
protected abstract boolean amChildElementRef(T sclElement);
69+
protected abstract boolean amChildElementRef();
70+
5671
}
5772

5873
The root element adapter (entry point) is special as it does not have any parent adapter, hence, its method `amChildElementRef(T)`
@@ -120,28 +135,31 @@ one can implement the connector to have the below output (with the constraint of
120135

121136
## SCT APPLICATION
122137
**TODO**
138+
> In progress
123139
124140
### Tips for memory consumption's optimization
125-
For large SCL file, it will not be a good idea to load the whole file in memory. JAXB is capable of processing XML file by chunks.
141+
For large SCL file, it is not a good idea to load the whole file in memory. JAXB is capable of processing XML file by chunks.
126142
The need to load the whole SCL file relies on the fact that XML validation processes needs the entire file content.
127-
To go through that processes we must take advantage on the XSD and build minimal SCL file from the large one.
128-
The most "important" tags in the SCL file : Header, Substation, Communication, IED and DataTypeTemplate. By looking closely in the XSD file, one can realize
143+
To go through that process we must take advantage of the XSD constraints and build minimal SCL file from the large one.
144+
The most "important" tags in the SCL file are: Header, Substation, Communication, IED and DataTypeTemplate. By looking closely in the XSD file, one can realize
129145
the below dependencies' logic :
146+
* Substation is grammatically independent
130147
* IED depends on DataTypeTemplate
131-
* Communication depends on IED (IED name, Access Point)
148+
* Communication depends on IED (IED name, Access Point, ...)
132149

133150
Hence, with this in mind, one can reconstruct a minimal SCL file by focusing on the chunk of interest then realize creation/update operations
134151
on the file and validate it against the XSD file.
135152

136153
For example: Updating IED
137154

138-
From SCD header's information, create a minimal SCD file
155+
From SCD header's information, create a minimal valid SCD file
139156
```
140157
<SCL version="2007" revision="B" release="4" xmlns="http://www.iec.ch/61850/2003/SCL">
141158
<Header id="hId" version="2007" revision="B" toolID="COMPAS"/>
142159
</SCL>
143160
```
144-
As IED depends on DataTypeTemplate, extract the IED chunk and the whole DataTypeTemplate chunk
161+
As IED depends on DataTypeTemplate, extract the IED chunk with the whole DataTypeTemplate chunk from the large file and
162+
import it in the temporary SCD file
145163
```
146164
<SCL version="2007" revision="B" release="4" xmlns="http://www.iec.ch/61850/2003/SCL">
147165
<Header id="hId" version="2007" revision="B" toolID="COMPAS"/>
@@ -151,5 +169,28 @@ As IED depends on DataTypeTemplate, extract the IED chunk and the whole DataType
151169
<DataTypeTemplate>....</DataTypeTemplate>
152170
</SCL>
153171
```
154-
Operations can be realized and validated on this minimal file (Which has the same structure as ICD file).
172+
Operations can now be realized and validated on this minimal file (which has the same structure as an ICD file).
173+
Any validation on the minimal file guaranties a valid integration of those chunks into the large file.
174+
175+
> **WARNING:** This concern only update/creation operations on SCL file.
176+
177+
Operations on the tag Substation are not complicated (those are similar to SSD files).
178+
179+
For Communication tag, a minimal valid IED tag with child tag Access point can suffice. If the IED's logical nodes
180+
are concerned in the process, one should think of bringing along the DataTypeTemplate chunk.
181+
182+
```
183+
<SCL xmlns="http://www.iec.ch/61850/2003/SCL" version="2007" revision="B" release="4">
184+
<Header id="cccc"></Header>
185+
<Communication>
186+
<SubNetwork name="tt">
187+
<ConnectedAP iedName="IED" apName="AP"></ConnectedAP>
188+
</SubNetwork>
189+
</Communication>
190+
<IED name="IED"> <!-- minimal valid IED to avoid using DataTypeTemplate-->
191+
<AccessPoint name="AP"></AccessPoint>
192+
</IED>
193+
</SCL>
194+
```
195+
Combination like this can heavily optimize memory consumption while manipulating large SCD file.
155196

0 commit comments

Comments
 (0)