@@ -127,34 +127,37 @@ private Stream<SclReportItem> configureNetworkForControlBlocks(SCL scl, Map<CbKe
127127 .flatMap (tied -> {
128128 List <Long > excludedMacAddresses = findExcludedMacAddresses (scl , tied , tcbType );
129129 Iterator <Long > authorizedMacAdressList = macAddresseList .stream ().filter (mac -> !excludedMacAddresses .contains (mac )).iterator ();
130- return ldeviceService .getLdevices (tied )
131- .flatMap (lDevice -> controlService .getControls (lDevice .getLN0 (), ControlBlockEnum .from (tcbType ).getControlBlockClass ())
132- .map (tControl -> {
133- TAccessPoint accessPoint = tied .getAccessPoint ().stream ().filter (ap -> ap .getServer ().getLDevice ().stream ().anyMatch (tlDevice -> tlDevice .getLdName ().equals (lDevice .getLdName ()))).findFirst ().orElseThrow ();
134- String apName = accessPoint .getName ();
135- IedApLd iedApLd = new IedApLd (tied , apName , lDevice );
136- CriteriaOrError criteriaOrError = getCriteria (tied , tcbType , tControl .getName ());
137- if (criteriaOrError .errorMessage != null ) {
138- return Optional .of (SclReportItem .error ("""
139- /SCL/IED[@name="%s"]""" .formatted (tied .getName ()), criteriaOrError .errorMessage ));
140- }
141-
142- Settings settings = cbComSettings .settingsByCriteria .get (criteriaOrError .criteria );
143- if (settings == null ) {
144- return newError (iedApLd , tControl , "Cannot configure communication for this ControlBlock because: No controlBlock communication settings found with these " + criteriaOrError .criteria );
145- }
146- AppId reuseAppId = appIdsToReuse .get (new CbKey (tied .getName (), lDevice .getInst (), tControl .getName ()));
147- Mac reuseMac = macsToReuse .get (new CbKey (tied .getName (), lDevice .getInst (), tControl .getName ()));
148- TCommunication tCommunication = scl .getCommunication ();
149-
150- Optional <TConnectedAP > optionalTConnectedAP = subNetworkService .getSubNetworks (tCommunication )
151- .flatMap (tSubNetwork -> connectedAPService .getFilteredConnectedAP (tSubNetwork , connectedAP -> tied .getName ().equals (connectedAP .getIedName ()) && apName .equals (connectedAP .getApName ())))
152- .findFirst ();
153- if (optionalTConnectedAP .isEmpty ()) {
154- return newError (iedApLd , tControl , "Cannot configure communication for ControlBlock because no ConnectedAP found for AccessPoint" );
155- }
156- return configureControlBlockNetwork (tCommunication , settings , appIdIterator , authorizedMacAdressList , tControl , iedApLd , reuseAppId , reuseMac );
157- }).flatMap (Optional ::stream ));
130+ return tied .getAccessPoint ().stream ()
131+ .filter (TAccessPoint ::isSetServer )
132+ .flatMap (tAccessPoint -> tAccessPoint .getServer ().getLDevice ().stream ()
133+ .flatMap (lDevice ->
134+ controlService .getControls (lDevice .getLN0 (), ControlBlockEnum .from (tcbType ).getControlBlockClass ())
135+ .map (tControl -> {
136+ String apName = tAccessPoint .getName ();
137+ IedApLd iedApLd = new IedApLd (tied , apName , lDevice );
138+ CriteriaOrError criteriaOrError = getCriteria (tied , tcbType , tControl .getName ());
139+ if (criteriaOrError .errorMessage != null ) {
140+ return Optional .of (SclReportItem .error ("""
141+ /SCL/IED[@name="%s"]""" .formatted (tied .getName ()), criteriaOrError .errorMessage ));
142+ }
143+
144+ Settings settings = cbComSettings .settingsByCriteria .get (criteriaOrError .criteria );
145+ if (settings == null ) {
146+ return newError (iedApLd , tControl , "Cannot configure communication for this ControlBlock because: No controlBlock communication settings found with these " + criteriaOrError .criteria );
147+ }
148+ AppId reuseAppId = appIdsToReuse .get (new CbKey (tied .getName (), lDevice .getInst (), tControl .getName ()));
149+ Mac reuseMac = macsToReuse .get (new CbKey (tied .getName (), lDevice .getInst (), tControl .getName ()));
150+ TCommunication tCommunication = scl .getCommunication ();
151+
152+ Optional <TConnectedAP > optionalTConnectedAP = subNetworkService .getSubNetworks (tCommunication )
153+ .flatMap (tSubNetwork -> connectedAPService .getFilteredConnectedAP (tSubNetwork , connectedAP -> tied .getName ().equals (connectedAP .getIedName ()) && apName .equals (connectedAP .getApName ())))
154+ .findFirst ();
155+ if (optionalTConnectedAP .isEmpty ()) {
156+ return newError (iedApLd , tControl , "Cannot configure communication for ControlBlock because no ConnectedAP found for AccessPoint" );
157+ }
158+ return configureControlBlockNetwork (tCommunication , settings , appIdIterator , authorizedMacAdressList , tControl , iedApLd , reuseAppId , reuseMac );
159+ })
160+ .flatMap (Optional ::stream )));
158161 });
159162 }
160163
@@ -196,9 +199,8 @@ private Stream<Long> getExtRefAddress(SCL scl, TIED tied) {
196199 .flatMap (tConnectedAP -> Stream .concat (tConnectedAP .getGSE ().stream (), tConnectedAP .getSMV ().stream ()))
197200 .filter (cBlock -> cBlock .getCbName ().equals (cbKey .cbName ()) && cBlock .getLdInst ().equals (cbKey .LDInst ()))))
198201 .filter (TControlBlock ::isSetAddress )
199- .flatMap (cBlock -> {
200- return Utils .extractFromP (MAC_ADDRESS_P_TYPE , cBlock .getAddress ().getP ()).stream ();
201- })
202+ .map (cBlock -> Utils .extractFromP (MAC_ADDRESS_P_TYPE , cBlock .getAddress ().getP ()))
203+ .flatMap (Optional ::stream )
202204 .map (Utils ::macAddressToLong );
203205 }
204206
@@ -299,7 +301,7 @@ private Map<CbKey, AppId> computeAppIdsToReuse(SCL scd, List<TSubNetwork> subnet
299301 .flatMap (tSubNetwork -> tSubNetwork .getConnectedAP ().stream ())
300302 .flatMap (tConnectedAP -> Stream .concat (tConnectedAP .getGSE ().stream (), tConnectedAP .getSMV ().stream ())
301303 .flatMap (tControlBlock -> AppId .from (tControlBlock .getAddress ())
302- .map (appId -> new SimpleEntry <>(new CbKey (tConnectedAP .getIedName (), tControlBlock .getLdInst (), tControlBlock .getCbName ()), appId ))
304+ .map (appId -> new SimpleEntry <>(new CbKey (tConnectedAP .getIedName (), tControlBlock .getLdInst (), tControlBlock .getCbName ()), appId ))
303305 .stream ()
304306 )
305307 )
@@ -379,7 +381,7 @@ public CriteriaOrError getCriteria(TIED tied, TCBType cbType, String cbName) {
379381 return new CriteriaOrError (null , "No private COMPAS-SystemVersion found in this IED" );
380382 }
381383 if (StringUtils .isBlank (compasSystemVersion .get ().getMainSystemVersion ())
382- || (StringUtils .isBlank (compasSystemVersion .get ().getMinorSystemVersion ()))) {
384+ || (StringUtils .isBlank (compasSystemVersion .get ().getMinorSystemVersion ()))) {
383385 return new CriteriaOrError (null , "Missing MainSystemVersion or MinorSystemVersion attribute in COMPAS-SystemVersion private of IED" );
384386 }
385387 String systemVersionWithoutV = removeVFromSystemVersion (compasSystemVersion .get ());
@@ -554,23 +556,23 @@ static Optional<AppId> from(TAddress address) {
554556 }
555557 return Utils .extractFromP (APPID_P_TYPE , address .getP ())
556558 .map (appId -> Integer .parseInt (appId , HEXADECIMAL_BASE ))
557- .map (AppId ::new );
559+ .map (AppId ::new );
558560 }
559561 }
560562
561563 /**
562564 * MAC-Address
563565 *
564- * @param mac MAC-Address
566+ * @param mac MAC-Address
565567 */
566568 record Mac (long mac ) {
567569 static Optional <Mac > from (TAddress address ) {
568570 if (address == null ) {
569571 return Optional .empty ();
570572 }
571573 return Utils .extractFromP (MAC_ADDRESS_P_TYPE , address .getP ())
572- .map (Utils ::macAddressToLong )
573- .map (Mac ::new );
574+ .map (Utils ::macAddressToLong )
575+ .map (Mac ::new );
574576 }
575577 }
576578}
0 commit comments