Class AbstractLNAdapter<T extends TAnyLN>

java.lang.Object
org.lfenergy.compas.sct.commons.scl.SclElementAdapter<LDeviceAdapter,T>
org.lfenergy.compas.sct.commons.scl.ied.AbstractLNAdapter<T>
Direct Known Subclasses:
LN0Adapter, LNAdapter

public abstract class AbstractLNAdapter<T extends TAnyLN> extends SclElementAdapter<LDeviceAdapter,T>
See Also:
  • Field Details

    • MOD_DO_TYPE_NAME

      public static final DoTypeName MOD_DO_TYPE_NAME
    • STVAL_DA_TYPE_NAME

      public static final DaTypeName STVAL_DA_TYPE_NAME
  • Constructor Details

    • AbstractLNAdapter

      protected AbstractLNAdapter(LDeviceAdapter parentAdapter, T currentElem)
      Constructor
      Parameters:
      parentAdapter - Parent container reference
      currentElem - Current reference
  • Method Details

    • builder

      public static LNAdapterBuilder builder()
    • getElementClassType

      protected abstract Class<T> getElementClassType()
    • getLNClass

      public abstract String getLNClass()
    • getLNInst

      public abstract String getLNInst()
    • getPrefix

      public abstract String getPrefix()
    • getEnumValues

      public Set<String> getEnumValues(String enumType)
      Returns sets of enum value for given DataAttributeRef object
      Parameters:
      enumType - enum Type
      Returns:
      Enum value list
    • findDataSetByName

      public Optional<DataSetAdapter> findDataSetByName(String dataSetName)
    • findDoiAdapterByName

      public Optional<DOIAdapter> findDoiAdapterByName(String doiName)
      Find DOI in this LN/LN0 by name
      Parameters:
      doiName - name of the DOI to look for
      Returns:
      DOIAdapter when found or else empty Optional.
    • getDOIAdapterByName

      public DOIAdapter getDOIAdapterByName(String doiName) throws ScdException
      Get DOI in this LN/LN0 by name
      Parameters:
      doiName - name of the DOI to look for
      Returns:
      DOIAdapter when found or else empty Optional.
      Throws:
      ScdException - when DOI not found
    • getDOIAdapters

      public List<DOIAdapter> getDOIAdapters()
    • getLnType

      public String getLnType()
    • getExtRefs

      public List<TExtRef> getExtRefs()
      Gets all ExtRefs
      Returns:
      list of LNode ExtRefs elements
    • getExtRefs

      public List<TExtRef> getExtRefs(ExtRefSignalInfo filter)
      Gets all ExtRefs matches specified ExtRef info
      Parameters:
      filter - ExtRef filter value
      Returns:
      list of TExtRef
    • hasInputs

      public boolean hasInputs()
      Check whether the LN has an Inputs node
      Returns:
      true if the LN has an Inputs node
    • isExtRefExist

      public void isExtRefExist(ExtRefSignalInfo signalInfo)
      Checks for ExtRef signal existence in target LN
      Parameters:
      signalInfo - ExtRef signal data to check
    • updateExtRefBinders

      public void updateExtRefBinders(ExtRefInfo extRefInfo) throws ScdException
      Update LNode ExtRefs data with ExtRefInfo data
      Parameters:
      extRefInfo - contains new data for LNode ExtREf update
      Throws:
      ScdException - throws when mandatory data are missing
    • updateExtRefBindingInfo

      protected void updateExtRefBindingInfo(TExtRef extRef, ExtRefInfo extRefInfo)
      Updates ExtRef with data from ExtRefInfo
      Parameters:
      extRef - ExtRef to update
      extRefInfo - contains new data for LNode ExtREf update
    • getControlBlocksForMatchingFCDA

      public List<ControlBlock> getControlBlocksForMatchingFCDA(@NonNull @NonNull ExtRefInfo extRefInfo)
      Gets Control Blocks matching FCDA compatible with specified in extRefInfo
      Parameters:
      extRefInfo - ExtRef signal data for which Control Blocks should be found (contain binding info to match with FCDA)
      Returns:
      list of ControlBlock object as ControlBlocks of LNode matching FCDA and ExtRef
    • getControlBlocks

      protected List<ControlBlock> getControlBlocks(List<TDataSet> tDataSets, TServiceType serviceType)
      Gets all Control Blocks from LNode for specified Service Type (GOOSE, SMV and REPORT) and Data Sets
      Parameters:
      tDataSets - Data Sets for which Control Blocks are needed
      serviceType - Service Type of Control Blocks needed
      Returns:
      list of ControlBlock objects
    • getTControlsByType

      public <V extends TControl> List<V> getTControlsByType(Class<V> cls)
      finds all Control Blocks by Service Type (GOOSE, SampleValue, Report).
      Type Parameters:
      V - inference parameter for Type of Control Block to find
      Parameters:
      cls - Type of Control Block
      Returns:
      all Control Blocks matching a Service Type
    • hasControlBlock

      public boolean hasControlBlock(String cbName, ControlBlockEnum controlBlockEnum)
      Checks if specified Control Block is present in LN
      Parameters:
      cbName - name of the control block to look for
      controlBlockEnum - type of control block to look for
      Returns:
      true if a ControlBlock of type controlBlockEnum named cbName exists in LN, else false
    • getDataSetMatchingExtRefInfo

      public List<TDataSet> getDataSetMatchingExtRefInfo(ExtRefInfo filter)
      retrieves all DataSets for which at least one FCDA matches with data given in ExtRefInfo for external binding
      Parameters:
      filter - contains data for external binding which should match with FCDAs values
      Returns:
      list of Data for which at least one FCDA matches with filter datas
    • updateExtRefSource

      public TExtRef updateExtRefSource(ExtRefInfo extRefInfo) throws ScdException
      Updates ExtRef source binding data's based on given data in extRefInfo
      Parameters:
      extRefInfo - new data for ExtRef source binding data
      Returns:
      TExtRef object as update ExtRef with new source binding data
      Throws:
      ScdException - throws when mandatory data of ExtRef are missing
    • checkExtRefInfoCoherence

      public void checkExtRefInfoCoherence(ExtRefInfo extRefInfo)
      Verify the coherence of ExtRef info. This method look up the TExtRef that matches the signal info in this LNode. Then verify the coherence between the ExtRef's binding info and the given binding info. If the ExtRef info contains a source information ( ControlBlock info),it verifies that the CB and dataset it points to, exists within and existing binder IED.
      Parameters:
      extRefInfo - ExtRef information (signal, binding and source info)
      Throws:
      ScdException - throws exception if
      • the given binding info doesn't match the found TExtRef's binding info.
      • the given binding info doesn't refer to an existing IED, LDevice and LNode in the SCL
      • given source info references unknown control block
    • extractExtRefFromExtRefInfo

      public TExtRef extractExtRefFromExtRefInfo(@NonNull @NonNull ExtRefInfo extRefInfo)
      Finds ExtRef from LN
      Parameters:
      extRefInfo - ExtRef information (signal, binding and source info)
      Returns:
      TExtRef matching given
    • getDAI

      public List<DataAttributeRef> getDAI(DataAttributeRef dataAttributeRef, boolean updatableOnly) throws ScdException
      Returns a list of Data Attribute Reference for DataAttribute (updatable or not)
      Parameters:
      dataAttributeRef - Data Attribute Reference (used as filter)
      updatableOnly - true to retrieve DataTypeTemplate's related to only updatable DAI, false to retrieve all
      Returns:
      List of Data Attribute Reference (updatable or not)
      Throws:
      ScdException - SCD illegal arguments exception
    • overrideAttributesFromDAI

      protected void overrideAttributesFromDAI(DataAttributeRef dataAttributeRef)
      Update given DataAttributeRef DAI datas from LNode
      Parameters:
      dataAttributeRef - summarized Data Type Template object to update DAI datas
    • getParentLDevice

      public LDeviceAdapter getParentLDevice()
      Gets linked LDevice as parent
      Returns:
      IEDAdapter object
    • getParentIed

      public IEDAdapter getParentIed()
      Gets linked IED as parent
      Returns:
      IEDAdapter object
    • getCurrentScd

      protected SclRootAdapter getCurrentScd()
      Gets root Scd
      Returns:
      SclRootAdapter object
    • getDataTypeTemplateAdapter

      public DataTypeTemplateAdapter getDataTypeTemplateAdapter()
      Gets SCL DataTypeTemplate
      Returns:
      DataTypeTemplateAdapter object
    • findMatch

      protected Optional<IDataAdapter> findMatch(DoTypeName doTypeName, DaTypeName daTypeName)
      Search for DAI that match the given defined-DO (do.sdo1[.sdo2 ...sdo_n]) and defined-DA (da.bda1[.bda2...bda_n]) where 'sdo_n' points to a DOType that contains 'da'
      Parameters:
      doTypeName - defined-DO (do.sdo1[.sdo2 ...sdo_n])
      daTypeName - defined-DA (da.bda1[.bda2...bda_n])
      Returns:
      Optional of DAIAdapter for the matched DAI
    • updateDAI

      public void updateDAI(@NonNull @NonNull DataAttributeRef dataAttributeRef) throws ScdException
      Updates DAI in LN/LN0 section. It will create the missing DOI/SDI/DAI in this LN/LN0 if needed. Be careful, this method does not check that the given dataAttributeRef is allowed by the lnType of this LN/LN0. It does not even check if dataAttributeRef exists in DataTypeTemplate section. That means that it will create the missing DOI/SDI/DAI, even if it is not consistent with DataTypeTemplate section. It is the caller responsibility to ensure the consistency between the given dataAttributeRef and the lnType of this LN/LN0 (which points to DataTypeTemplate section). See 9.3.5 "LN0 and other Logical Nodes" of IEC 61850-6. If given dataAttributeRef.isUpdatable() is false, the method does nothing (it will not check if DA/BDA is updatable in DataTypeTemplate section). This method will not remove any Val, it will only create new Val or replace existing Val (for example if dataAttributeRef.getDaName().getDaiValues() is empty, it does nothing)
      Parameters:
      dataAttributeRef - summarized Data Type Temple containing new DA val
      Throws:
      ScdException - when given dataAttributeRef is missing DoName or DaName
    • createDoiSdiDaiChainIfNotExists

      public Object createDoiSdiDaiChainIfNotExists(String dataTypeRef, boolean setValImportOnCreate)
      Return the DAI (in DOI/SDI/DAI chain) matching the given data reference name If it does not exist, create the missing DOI/SDI/DAI elements in this LN/LN0 if needed, based on the given parameters DOI is the equivalent of the DO SDI is the equivalent of a type with bType="Struct". It can be a SDO, DA or BDA. DOI is the equivalent of the final leaf : DA or BDA with bType != "Struct". Be careful, this method does not check that the given data type is allowed by the lnType of this LN/LN0. It does not even check if the data type exists in DataTypeTemplate section. That means that it will create the missing DOI/SDI/DAI, even if it is not consistent with DataTypeTemplate section. It is the caller responsibility to ensure the consistency between the given data type and the lnType of this LN/LN0 (which refer to DataTypeTemplate section). See 9.3.5 "LN0 and other Logical Nodes" of IEC 61850-6.
      Parameters:
      dataTypeRef - Reference name of data : DO/SDO/DA/BDA names, in order from parent to child, separated by a period (Ex: "Do1.da1", "Do2.sdoA.sdoB.da2.bdaA.bdaB")
      setValImportOnCreate - when this method creates the DAI, it will set DAI.valImport attribute with this parameter
      Returns:
      adapter for existing DAI or created DAI.
    • addDOI

      protected DOIAdapter addDOI(String name)
      Adds DO in LNode
      Parameters:
      name - DOI name
      Returns:
      added DOIAdapter object
    • getLNodeName

      public String getLNodeName()
    • matches

      public boolean matches(ObjectReference objRef)
      Checks given reference matches with DataSet or ReportControl or DataTypeTemplate element for calling LNode in SCL file
      Parameters:
      objRef - reference to compare with LNode datas
      Returns:
      Boolean value of check result
    • matchesDataAttributes

      protected boolean matchesDataAttributes(String dataAttribute)
      Checks if given attibrute corresponds to DataSet or ReportControl in LNode
      Parameters:
      dataAttribute - attribute to check
      Returns:
      Boolean value of check result
    • getDataSetByName

      public Optional<DataSetInfo> getDataSetByName(String dataSetName)
      Gets Data Set in LNode by its name
      Parameters:
      dataSetName - Data Set name
      Returns:
      optional of DataSetInfo
    • getDAIValues

      public Map<Long,String> getDAIValues(DataAttributeRef dataAttributeRef)
      Gets DAI values for specified DA in summaraized Data Type Template
      Parameters:
      dataAttributeRef - summaraized Data Type Template containing DA datas
      Returns:
      map of Setting Group and it's VAL
    • removeAllControlBlocksAndDatasets

      public void removeAllControlBlocksAndDatasets()
      Removes all ControlBlocks and DataSets from current LN
    • removeAllExtRefSourceBindings

      public void removeAllExtRefSourceBindings()
      Removes all ExtRefs source binding data's
    • createDataSetIfNotExists

      public DataSetAdapter createDataSetIfNotExists(String dataSetName, ControlBlockEnum controlBlockEnum)
      Adds DataSet in specified LNode in current IED/AccessPoint. The AccessPoint must have DataSet creation capabilities
      Parameters:
      dataSetName - Name of the dataSet
      controlBlockEnum - GOOSE, SMV or REPORT service type
      Throws:
      ScdException - throws when IED does not have DataSet creation capabilities
      See Also:
    • addControlBlock

      public ControlBlockAdapter addControlBlock(ControlBlock controlBlock)
      Creates Control Block in specified LNode in current IED
      Parameters:
      controlBlock - Control Block data to add to this LN
      Returns:
      created ControlBlockAdapter object
      Throws:
      ScdException - throws when inconsistency between given ControlBlock and IED configuration
    • findControlBlock

      public Optional<ControlBlockAdapter> findControlBlock(String name, ControlBlockEnum controlBlockEnum)
    • streamControlBlocks

      public Stream<ControlBlockAdapter> streamControlBlocks(ControlBlockEnum controlBlockEnum)
    • createControlBlockIfNotExists

      public ControlBlockAdapter createControlBlockIfNotExists(String cbName, String id, String datSet, ControlBlockEnum controlBlockEnum)
      Create ControlBlock if there is no ControlBlock of the same type (controlBlockEnum) and with the same cbName in this LN/LN0. When the controlBlock already exists, the id and datSet attributes are NOT updated with the given values.
      Parameters:
      cbName - cbName of the controlBlock to look for. When not found, the cbName of the controlBlock to create.
      id - When controlBlock not found, the id of the controlBlock to create
      datSet - the datSet of the controlBlock to create
      controlBlockEnum - the type of ControlBlock to create
      Returns:
      existing controlBlock if a controlBlock of the same type and with same cbName was found in this LN/LN0, otherwise the created ControlBlock. The returned ControlBlock is always a child of this LN/LN0.
    • generateControlBlockId

      public String generateControlBlockId(String ldName, String cbName)
      Generate a ControlBlock Id based on the current LN and the given ldName (ldName can be different from the parent LD.name)
      Parameters:
      ldName - LD name to use for generating the id
      cbName - name of the ControlBlock
      Returns:
      "ldName/LnPrefixLnClassLnInst.cbName". Blank values are omitted (e.g "IEDNAME1LD1/LLN0.CBNAME1")
    • getFCDAs

      public List<TFCDA> getFCDAs(TExtRef tExtRef)
      Finds all FCDAs in DataSet of Control Block feeding ExtRef
      Parameters:
      tExtRef - Fed ExtRef
      Returns:
      list of all FCDA in DataSet of Control Block
    • getDaiModStValValue

      public Optional<String> getDaiModStValValue()
      Get the value of "Mod.stVal" of the current LN
      Returns:
      Mod.stVal value if present, else empty Optional
    • getDaiModStVal

      protected Optional<DataAttributeRef> getDaiModStVal()