@@ -321,12 +321,26 @@ private void SubstationInternalPowerTransformerTrace()
321321 false
322322 ) . ToList ( ) ;
323323
324+ BusbarSectionExt busbar = null ;
325+
324326 foreach ( var cimObj in traceResult )
325327 {
328+
329+ if ( cimObj is ConnectivityNode )
330+ {
331+ var connections = _cimContext . GetConnections ( ( ConnectivityNode ) cimObj ) ;
332+
333+ var busbarFound = connections . FirstOrDefault ( c => c . ConductingEquipment is BusbarSectionExt ) . ConductingEquipment as BusbarSectionExt ;
334+
335+ if ( busbarFound != null )
336+ busbar = busbarFound ;
337+ }
338+
326339 if ( cimObj is ConnectivityNode && _connectionPoints . ContainsKey ( ( ConnectivityNode ) cimObj ) )
327340 {
328341 var cp = _connectionPoints [ ( ConnectivityNode ) cimObj ] ;
329342 cp . PowerTransformer = pt ;
343+ cp . BusbarSection = busbar ;
330344 }
331345 }
332346 }
@@ -416,6 +430,7 @@ ce is PowerTransformer // because power transformers sometimes has no base volta
416430
417431 bool customerCableFound = false ;
418432 Guid customerCableId = Guid . Empty ;
433+ Guid parentBusbarId = Guid . Empty ;
419434
420435 int traversalOrder = 0 ;
421436
@@ -475,7 +490,9 @@ ce is PowerTransformer // because power transformers sometimes has no base volta
475490
476491 busbarProcessed . Add ( ( BusbarSection ) busbar ) ;
477492
478- AssignFeederToConductingEquipment ( busbar , feeder , traversalOrder , stationHop , customerCableId ) ;
493+ AssignFeederToConductingEquipment ( busbar , feeder , traversalOrder , stationHop , customerCableId , parentBusbarId ) ;
494+
495+ parentBusbarId = Guid . Parse ( busbar . mRID ) ;
479496 }
480497 }
481498
@@ -487,10 +504,12 @@ ce is PowerTransformer // because power transformers sometimes has no base volta
487504 if ( ce is BusbarSection )
488505 {
489506 if ( ! busbarProcessed . Contains ( ce ) )
490- AssignFeederToConductingEquipment ( ce , feeder , traversalOrder , cimObj . stationHop , customerCableId ) ;
507+ AssignFeederToConductingEquipment ( ce , feeder , traversalOrder , cimObj . stationHop , customerCableId , parentBusbarId ) ;
508+
509+ parentBusbarId = Guid . Parse ( ce . mRID ) ;
491510 }
492511 else
493- AssignFeederToConductingEquipment ( ce , feeder , traversalOrder , cimObj . stationHop , customerCableId ) ;
512+ AssignFeederToConductingEquipment ( ce , feeder , traversalOrder , cimObj . stationHop , customerCableId , parentBusbarId ) ;
494513
495514 // If a busbar or powertransformer inside substation container add feeder to substation as well
496515 if ( ( ce is BusbarSection || ce is PowerTransformer ) && ce . IsInsideSubstation ( _cimContext ) )
@@ -513,6 +532,8 @@ ce is PowerTransformer // because power transformers sometimes has no base volta
513532 // power transformer feeders
514533 if ( cp . Kind == ConnectionPointKind . PowerTranformer )
515534 {
535+ Guid parentBusbarId = Guid . Empty ;
536+
516537 foreach ( var feeder in cp . Feeders )
517538 {
518539 var pt = feeder . ConductingEquipment as PowerTransformer ;
@@ -531,6 +552,17 @@ ce is PowerTransformer // because power transformers sometimes has no base volta
531552 {
532553 int traversalOrder = 0 ;
533554
555+ if ( cimObj is ConnectivityNode )
556+ {
557+ var connections = _cimContext . GetConnections ( ( ConnectivityNode ) cimObj ) ;
558+ var busbar = connections . FirstOrDefault ( c => c . ConductingEquipment is BusbarSection ) . ConductingEquipment ;
559+
560+ if ( busbar != null )
561+ {
562+ parentBusbarId = Guid . Parse ( busbar . mRID ) ;
563+ }
564+ }
565+
534566 if ( cimObj is ConductingEquipment )
535567 {
536568 traversalOrder ++ ;
@@ -539,19 +571,19 @@ ce is PowerTransformer // because power transformers sometimes has no base volta
539571
540572 // We don't want to add feeder to power transformers and ac line segments outsit station.
541573 if ( ! ( ce is PowerTransformer ) && ! ( ce is ACLineSegment && ! ce . IsInsideSubstation ( _cimContext ) ) )
542- AssignFeederToConductingEquipment ( ce , feeder , traversalOrder , 0 , Guid . Empty ) ;
574+ AssignFeederToConductingEquipment ( ce , feeder , traversalOrder , 0 , Guid . Empty , parentBusbarId ) ;
543575 }
544576 }
545577 }
546578 }
547579 }
548580 }
549581
550- private void AssignFeederToConductingEquipment ( ConductingEquipment ce , Feeder feeder , int traversalOrder , int substationHop , Guid customerCableId )
582+ private void AssignFeederToConductingEquipment ( ConductingEquipment ce , Feeder feeder , int traversalOrder , int substationHop , Guid customerCableId , Guid parentBusbarId )
551583 {
552584 if ( ! _conductingEquipmentFeeders . ContainsKey ( ce ) )
553585 {
554- _conductingEquipmentFeeders [ ce ] = new ConductingEquipmentFeederInfo ( ) { SubstationHop = substationHop , TraversalOrder = traversalOrder , FirstCustomerCableId = customerCableId } ;
586+ _conductingEquipmentFeeders [ ce ] = new ConductingEquipmentFeederInfo ( ) { SubstationHop = substationHop , TraversalOrder = traversalOrder , FirstCustomerCableId = customerCableId , ParentBusbarId = parentBusbarId } ;
555587 _conductingEquipmentFeeders [ ce ] . Feeders . Add ( feeder ) ;
556588 }
557589 else
0 commit comments