|
| 1 | +// SPDX-FileCopyrightText: 2023 RTE FRANCE |
| 2 | +// |
| 3 | +// SPDX-License-Identifier: Apache-2.0 |
| 4 | + |
| 5 | +package org.lfenergy.compas.sct.commons.dto; |
| 6 | + |
| 7 | +import com.opencsv.bean.CsvBindByPosition; |
| 8 | +import lombok.AllArgsConstructor; |
| 9 | +import lombok.Builder; |
| 10 | +import lombok.Getter; |
| 11 | +import lombok.NoArgsConstructor; |
| 12 | +import org.lfenergy.compas.scl2007b4.model.TCompasFlowKind; |
| 13 | +import org.lfenergy.compas.scl2007b4.model.TExtRef; |
| 14 | +import org.lfenergy.compas.sct.commons.util.Utils; |
| 15 | + |
| 16 | +import java.math.BigInteger; |
| 17 | + |
| 18 | +/** |
| 19 | + * A representation of settings made for LDEPF LDevice |
| 20 | + * |
| 21 | + * @see <a href="https://github.com/com-pas/compas-sct/issues/256" target="_blank">Issue !256</a> |
| 22 | + */ |
| 23 | +@Getter |
| 24 | +@AllArgsConstructor |
| 25 | +@NoArgsConstructor |
| 26 | +@Builder |
| 27 | +public class LDEPFSettingData { |
| 28 | + |
| 29 | + @CsvBindByPosition(position = 0) |
| 30 | + private TCompasFlowKind bayScope; |
| 31 | + @CsvBindByPosition(position = 1) |
| 32 | + private String iedType; |
| 33 | + @CsvBindByPosition(position = 2) |
| 34 | + private String iedRedundancy; |
| 35 | + @CsvBindByPosition(position = 3) |
| 36 | + private BigInteger iedInstance; |
| 37 | + @CsvBindByPosition(position = 4) |
| 38 | + private String channelShortLabel; |
| 39 | + @CsvBindByPosition(position = 5) |
| 40 | + private String channelMREP; |
| 41 | + @CsvBindByPosition(position = 6) |
| 42 | + private String channelLevModQ; |
| 43 | + @CsvBindByPosition(position = 7) |
| 44 | + private String channelLevModLevMod; |
| 45 | + @CsvBindByPosition(position = 8) |
| 46 | + private String bapVariant; |
| 47 | + @CsvBindByPosition(position = 9) |
| 48 | + private String bapIgnoredValue; |
| 49 | + @CsvBindByPosition(position = 10) |
| 50 | + private String ldInst; |
| 51 | + @CsvBindByPosition(position = 11) |
| 52 | + private String lnPrefix; |
| 53 | + @CsvBindByPosition(position = 12) |
| 54 | + private String lnClass; |
| 55 | + @CsvBindByPosition(position = 13) |
| 56 | + private String lnInst; |
| 57 | + @CsvBindByPosition(position = 14) |
| 58 | + private String doName; |
| 59 | + @CsvBindByPosition(position = 15) |
| 60 | + private String doInst; |
| 61 | + @CsvBindByPosition(position = 16) |
| 62 | + private String sdoName; |
| 63 | + @CsvBindByPosition(position = 17) |
| 64 | + private String daName; |
| 65 | + @CsvBindByPosition(position = 18) |
| 66 | + private String daType; |
| 67 | + @CsvBindByPosition(position = 19) |
| 68 | + private String dabType; |
| 69 | + @CsvBindByPosition(position = 20) |
| 70 | + private String bdaName; |
| 71 | + @CsvBindByPosition(position = 21) |
| 72 | + private String sbdaName; |
| 73 | + @CsvBindByPosition(position = 22) |
| 74 | + private Integer channelAnalogNum; |
| 75 | + @CsvBindByPosition(position = 23) |
| 76 | + private Integer channelDigitalNum; |
| 77 | + @CsvBindByPosition(position = 24) |
| 78 | + private String opt; |
| 79 | + |
| 80 | + /** |
| 81 | + * verify if an Extref matches the Analog type or not. |
| 82 | + */ |
| 83 | + private Boolean isAnalogTypeMatchDesc(TExtRef extRef) { |
| 84 | + return getChannelAnalogNum() != null && getChannelDigitalNum() == null |
| 85 | + && extRef.getDesc().startsWith("DYN_LDEPF_ANALOG CHANNEL " + getChannelAnalogNum()+"_1_AnalogueValue") |
| 86 | + && extRef.getDesc().endsWith("_" + getDaName() + "_1"); |
| 87 | + } |
| 88 | + |
| 89 | + /** |
| 90 | + * verify if an Extref matches the Digital type or not. |
| 91 | + */ |
| 92 | + private Boolean isDigitalTypeMatchDesc(TExtRef extRef) { |
| 93 | + return getChannelDigitalNum() != null && getChannelAnalogNum() == null |
| 94 | + && extRef.getDesc().startsWith("DYN_LDEPF_DIGITAL CHANNEL " + getChannelDigitalNum()+"_1_BOOLEEN") |
| 95 | + && extRef.getDesc().endsWith("_" + getDaName() + "_1"); |
| 96 | + } |
| 97 | + |
| 98 | + /** |
| 99 | + * verify if an Extref matches the LDEPFSettingData or not. |
| 100 | + */ |
| 101 | + public Boolean isMatchExtRef(TExtRef extRef) { |
| 102 | + return extRef.isSetDesc() && (isAnalogTypeMatchDesc(extRef) || isDigitalTypeMatchDesc(extRef)) |
| 103 | + && extRef.isSetPLN() && Utils.lnClassEquals(extRef.getPLN(), getLnClass()) |
| 104 | + && extRef.isSetPDO() && extRef.getPDO().equals(getDoName()); |
| 105 | + } |
| 106 | + |
| 107 | +} |
0 commit comments