Skip to content

Commit

Permalink
Merge pull request #100 from com-pas/develop
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
Flurb authored Sep 20, 2021
2 parents 02c4787 + 540fa4e commit 944ab86
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 15 deletions.
3 changes: 2 additions & 1 deletion MAPPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ ProtectedSwitch.These classes are all mapped in the same way on IEC 61850
| CIM Class | IEC Class | Remark |
| -------------------------------- | -------------------------------- | --------- |
| *cim:PowerTransformerEnd* | *TTransformerWinding* | |
| name or id | name | |
| name or id (PowerTransformer) + | | |
| '_' + endNumber | name | |
| 'PTW' | type | |
| Terminal | List<TTerminal> | (1) |

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The Mapping between IEC CIM and IEC 61850 is described in [Mapping](MAPPING.md).
You can run your application in dev mode that enables live coding using:

```shell script
./mvnw package io.quarkus:quarkus-maven-plugin:2.0.0.Final:dev
./mvnw package io.quarkus:quarkus-maven-plugin:2.2.3.Final:dev
```

> **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.
Expand Down
2 changes: 1 addition & 1 deletion app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ SPDX-License-Identifier: Apache-2.0
<packaging>jar</packaging>

<properties>
<quarkus.platform.version>2.2.2.Final</quarkus.platform.version>
<quarkus.platform.version>2.2.3.Final</quarkus.platform.version>
</properties>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ protected void afterTransformerToTPowerTransformer(CgmesTransformer transformer,
.forEach(tTransformerWinding -> tPowerTransformer.getTransformerWinding().add(tTransformerWinding));
}

@Mapping(target = "name", source = "nameOrId")
@Mapping(target = "name", source = "uniqueName")
@Mapping(target = "type", constant = "PTW")
protected abstract TTransformerWinding mapTransformerEndToTTransformerWinding(CgmesTransformerEnd transformerEnd,
@Context CimToSclMapperContext context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class CimToSclMapperContext {
public static final String DESCRIPTION_PROP = "description";
public static final String NOMINAL_VOLTAGE_PROP = "nominalVoltage";
public static final String TYPE_PROP = "type";
public static final String ENDNUMBER_PROP = "endNumber";
public static final String TERMINAL_1_PROP = "Terminal1";
public static final String TERMINAL_2_PROP = "Terminal2";

Expand Down Expand Up @@ -131,7 +132,8 @@ public List<CgmesTransformerEnd> getTransformerEnds(String powerTransformerId) {
.map(propertyBag -> new CgmesTransformerEnd(
propertyBag.getId(TRANSFORMER_END_PROP),
propertyBag.get(NAME_PROP),
propertyBag.getId(TERMINAL_PROP)))
propertyBag.getId(TERMINAL_PROP),
propertyBag.get(ENDNUMBER_PROP)))
.collect(Collectors.toList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@

public class CgmesTransformerEnd extends AbstractCgmesEntity {
private String terminalId;
private String endNumber;

public CgmesTransformerEnd(String id, String name, String terminalId) {
public CgmesTransformerEnd(String id, String name, String terminalId, String endNumber) {
super(id, name);
this.terminalId = terminalId;
this.endNumber = endNumber;
}

public String getUniqueName() {
return getNameOrId() + "_" + getEndNumber();
}

public String getTerminalId() {
Expand All @@ -18,4 +24,12 @@ public String getTerminalId() {
public void setTerminalId(String terminalId) {
this.terminalId = terminalId;
}

public String getEndNumber() {
return endNumber;
}

public void setEndNumber(String endNumber) {
this.endNumber = endNumber;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public SCL map(List<CimData> cimData, String who) {
* @return The created SCL Model.
*/
SCL createBasicSCL(List<CimData> cimData, String who) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ssXXX");
ObjectFactory factory = new ObjectFactory();
var formatter = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ssXXX");
var factory = new ObjectFactory();

// Create the SCL and set some default values.
var scl = factory.createSCL();
Expand All @@ -76,7 +76,7 @@ SCL createBasicSCL(List<CimData> cimData, String who) {
scl.setRelease((short) 4);

// Create the Header and set some default values.
THeader header = factory.createTHeader();
var header = factory.createTHeader();
header.setId(UUID.randomUUID().toString());
header.setVersion(INITIAL_VERSION);
header.setRevision(INITIAL_REVISION);
Expand All @@ -91,7 +91,7 @@ SCL createBasicSCL(List<CimData> cimData, String who) {
item.setWho(who);

// Add all CIM filenames that where used to create the SCL Content.
String what = "SCL created from CIM File(s)";
var what = "SCL created from CIM File(s)";
if (cimData != null && !cimData.isEmpty()) {
what += ": " + cimData.stream()
.map(CimData::getName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,22 @@ void getTransformerEnds_WhenCalledWithKnownId_ThenPropertyBagsIsFilteredOnIdAndC
var tfeName = "Name Tfe";
var terminalId = "Known Terminal ID";
var tfId = "Known Transformer ID";
var endNumber = "1";
var bags = new PropertyBags();
var bag = new PropertyBag(List.of(TRANSFORMER_END_PROP, NAME_PROP, POWER_TRANSFORMER_PROP, TERMINAL_PROP));
var bag = new PropertyBag(List.of(TRANSFORMER_END_PROP, NAME_PROP, POWER_TRANSFORMER_PROP, TERMINAL_PROP, ENDNUMBER_PROP));
bag.put(TRANSFORMER_END_PROP, tfeId);
bag.put(NAME_PROP, tfeName);
bag.put(POWER_TRANSFORMER_PROP, tfId);
bag.put(TERMINAL_PROP, terminalId);
bag.put(ENDNUMBER_PROP, endNumber);
bags.add(bag);

bag = new PropertyBag(List.of(TRANSFORMER_END_PROP, NAME_PROP, POWER_TRANSFORMER_PROP, TERMINAL_PROP));
bag.put(TRANSFORMER_END_PROP, "Other ID");
bag.put(NAME_PROP, "Other Name");
bag.put(POWER_TRANSFORMER_PROP, "Unknown Transformer ID");
bag.put(TERMINAL_PROP, "Other Terminal ID");
bag.put(ENDNUMBER_PROP, "2");
bags.add(bag);

when(cgmesModel.transformerEnds()).thenReturn(bags);
Expand All @@ -161,8 +164,10 @@ void getTransformerEnds_WhenCalledWithKnownId_ThenPropertyBagsIsFilteredOnIdAndC
assertEquals(1, result.size());
var ccn = result.get(0);
assertEquals(tfeId, ccn.getId());
assertEquals(tfeName + "_" + endNumber, ccn.getUniqueName());
assertEquals(tfeName, ccn.getName());
assertEquals(terminalId, ccn.getTerminalId());
assertEquals(endNumber, ccn.getEndNumber());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private void assertPowerTransformer(TPowerTransformer powerTransformer) {

private void assertTransformerWinding(TTransformerWinding powerTransformerEnd) {
assertNotNull(powerTransformerEnd);
assertEquals("T3", powerTransformerEnd.getName());
assertEquals("T3_1", powerTransformerEnd.getName());
assertEquals(TTransformerWindingEnum.PTW, powerTransformerEnd.getType());
}

Expand Down Expand Up @@ -241,16 +241,17 @@ void mapTransformerToTPowerTransformer_WhenCalledWithCgmesTransformer_ThenProper
@Test
void mapTransformerEndToTTransformerWinding_WhenCalledWithCgmesTransformerEnd_ThenPropertiesMappedToTTransformerWinding() {
var expectedName = "TheName";
var expectedEndNumber = "1";

when(cgmesTransformerEnd.getNameOrId()).thenReturn(expectedName);
when(cgmesTransformerEnd.getUniqueName()).thenReturn(expectedName + "_" + expectedEndNumber);

var sclTransformerWinding = mapper.mapTransformerEndToTTransformerWinding(cgmesTransformerEnd, context);

assertNotNull(sclTransformerWinding);
assertEquals(expectedName, sclTransformerWinding.getName());
assertEquals(expectedName + "_" + expectedEndNumber, sclTransformerWinding.getName());
assertEquals(TTransformerWindingEnum.PTW, sclTransformerWinding.getType());
verify(cgmesTransformerEnd, times(1)).getId();
verify(cgmesTransformerEnd, times(1)).getNameOrId();
verify(cgmesTransformerEnd, times(1)).getUniqueName();
verify(cgmesTransformerEnd, times(1)).getTerminalId();
verifyNoMoreInteractions(cgmesTransformerEnd);
}
Expand Down

0 comments on commit 944ab86

Please sign in to comment.