extractPanelNames static method

Map<String, String> extractPanelNames(
  1. ElectricalNode? root
)

Extract panel names from tree

Implementation

static Map<String, String> extractPanelNames(ElectricalNode? root) {
  final Map<String, String> names = {};
  if (root == null) return names;

  final allNodes = flattenElectricalNodes(root);
  for (final node in allNodes) {
    node.map(
      panel: (panel) {
        final panelName = panel.name.isNotEmpty ? panel.name : 'Cuadro';
        names[panel.id] = panelName;
      },
      source: (_) {},
      protection: (_) {},
      load: (_) {},
    );
  }
  return names;
}