From a8b477978d4b73ac3b7362bd6e89872ffcbac087 Mon Sep 17 00:00:00 2001 From: Guillaume Raffy Date: Thu, 11 Dec 2025 14:23:07 +0100 Subject: [PATCH] now powermap draws redundant cables as dash lines. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes - Bug 4250 - incohérence des consommations affichées par powermap --- cocluto/PowerDiagram.py | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/cocluto/PowerDiagram.py b/cocluto/PowerDiagram.py index 9965469..13ad735 100644 --- a/cocluto/PowerDiagram.py +++ b/cocluto/PowerDiagram.py @@ -501,25 +501,29 @@ def power_config_to_svg(power_config: PowerConfig, svg_file_path: Path, worst_ca for con in power_config.connections: # print(con.from_plug.machine.name, con.to_plug.machine.name) - if not con.is_redundancy_cable(): # don't display redundancy cables, as they might overlap and hide the main one - power_consumption = con.get_power_consumption(worst_case_scenario=worst_case_scenario) - amperes = power_consumption / 220.0 - color = '/svg/green' - capacity = con.get_max_amperes() - penwidth_scaler = 0.25 - if capacity is None: - max_amp = '? A' - color = '/svg/red' - penwidth = 100.0 * penwidth_scaler # make the problem clearly visible - else: - max_amp = str(capacity) + 'A' - color = cable_colorer.get_cable_color(con, worst_case_scenario=worst_case_scenario) - penwidth = capacity * penwidth_scaler - label = "%.1f/%s" % (amperes, max_amp) - # color='//%d' % int(9.0-amperes/capacity*8) + power_consumption = con.get_power_consumption(worst_case_scenario=worst_case_scenario) + amperes = power_consumption / 220.0 + color = '/svg/green' + capacity = con.get_max_amperes() + penwidth_scaler = 0.25 + if capacity is None: + max_amp = '? A' + color = '/svg/red' + penwidth = 100.0 * penwidth_scaler # make the problem clearly visible + else: + max_amp = str(capacity) + 'A' + color = cable_colorer.get_cable_color(con, worst_case_scenario=worst_case_scenario) + penwidth = capacity * penwidth_scaler + label = "%.1f/%s" % (amperes, max_amp) + # color='//%d' % int(9.0-amperes/capacity*8) - # graph.add_edge(con.from_plug.machine.name, con.to_plug.machine.name, color="%s:%s" % (color, wsc_color), label=label, penwidth="%s:%s" % (penwidth, penwidth)) - graph.add_edge(con.from_plug.machine.name, con.to_plug.machine.name, color=color, label=label, penwidth=penwidth) + if con.is_redundancy_cable(): + edge_style = 'dashed' + else: + edge_style = 'solid' + + # graph.add_edge(con.from_plug.machine.name, con.to_plug.machine.name, color="%s:%s" % (color, wsc_color), label=label, penwidth="%s:%s" % (penwidth, penwidth)) + graph.add_edge(con.from_plug.machine.name, con.to_plug.machine.name, color=color, label=label, penwidth=penwidth, style=edge_style) for rack_id, rack in racks.items(): # sub = graph.add_subgraph(rack, name='cluster_%s' % rack_id, rank='same') @@ -534,3 +538,4 @@ def power_config_to_svg(power_config: PowerConfig, svg_file_path: Path, worst_ca graph.layout(prog='dot') graph.draw(svg_file_path) +