pygui: changes to display both link and asym link options on edges in canvas
This commit is contained in:
parent
06563d5953
commit
2aeb119b04
2 changed files with 42 additions and 16 deletions
|
@ -8,7 +8,7 @@ from core.gui.dialogs.linkconfig import LinkConfigurationDialog
|
||||||
from core.gui.frames.link import EdgeInfoFrame, WirelessEdgeInfoFrame
|
from core.gui.frames.link import EdgeInfoFrame, WirelessEdgeInfoFrame
|
||||||
from core.gui.graph import tags
|
from core.gui.graph import tags
|
||||||
from core.gui.nodeutils import NodeUtils
|
from core.gui.nodeutils import NodeUtils
|
||||||
from core.gui.utils import bandwidth_text
|
from core.gui.utils import bandwidth_text, delay_jitter_text
|
||||||
from core.gui.wrappers import Interface, Link
|
from core.gui.wrappers import Interface, Link
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
@ -419,21 +419,35 @@ class CanvasEdge(Edge):
|
||||||
if not self.link.options:
|
if not self.link.options:
|
||||||
return
|
return
|
||||||
options = self.link.options
|
options = self.link.options
|
||||||
|
asym_options = None
|
||||||
|
if self.asymmetric_link and self.asymmetric_link.options:
|
||||||
|
asym_options = self.asymmetric_link.options
|
||||||
lines = []
|
lines = []
|
||||||
bandwidth = options.bandwidth
|
# bandwidth
|
||||||
if bandwidth > 0:
|
if options.bandwidth > 0:
|
||||||
lines.append(bandwidth_text(bandwidth))
|
bandwidth_line = bandwidth_text(options.bandwidth)
|
||||||
delay = options.delay
|
if asym_options and asym_options.bandwidth > 0:
|
||||||
jitter = options.jitter
|
bandwidth_line += f" / {bandwidth_text(asym_options.bandwidth)}"
|
||||||
if delay > 0 and jitter > 0:
|
lines.append(bandwidth_line)
|
||||||
lines.append(f"{delay} us (\u00B1{jitter} us)")
|
# delay/jitter
|
||||||
elif jitter > 0:
|
dj_line = delay_jitter_text(options.delay, options.jitter)
|
||||||
lines.append(f"0 us (\u00B1{jitter} us)")
|
if dj_line and asym_options:
|
||||||
loss = options.loss
|
asym_dj_line = delay_jitter_text(asym_options.delay, asym_options.jitter)
|
||||||
if loss > 0:
|
if asym_dj_line:
|
||||||
lines.append(f"loss={loss}%")
|
dj_line += f" / {asym_dj_line}"
|
||||||
dup = options.dup
|
if dj_line:
|
||||||
if dup > 0:
|
lines.append(dj_line)
|
||||||
lines.append(f"dup={dup}%")
|
# loss
|
||||||
|
if options.loss > 0:
|
||||||
|
loss_line = f"loss={options.loss}%"
|
||||||
|
if asym_options and asym_options.loss > 0:
|
||||||
|
loss_line += f" / loss={asym_options.loss}%"
|
||||||
|
lines.append(loss_line)
|
||||||
|
# duplicate
|
||||||
|
if options.dup > 0:
|
||||||
|
dup_line = f"dup={options.dup}%"
|
||||||
|
if asym_options and asym_options.dup > 0:
|
||||||
|
dup_line += f" / dup={asym_options.dup}%"
|
||||||
|
lines.append(dup_line)
|
||||||
label = "\n".join(lines)
|
label = "\n".join(lines)
|
||||||
self.middle_label_text(label)
|
self.middle_label_text(label)
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
def bandwidth_text(bandwidth: int) -> str:
|
def bandwidth_text(bandwidth: int) -> str:
|
||||||
size = {0: "bps", 1: "Kbps", 2: "Mbps", 3: "Gbps"}
|
size = {0: "bps", 1: "Kbps", 2: "Mbps", 3: "Gbps"}
|
||||||
unit = 1000
|
unit = 1000
|
||||||
|
@ -8,3 +11,12 @@ def bandwidth_text(bandwidth: int) -> str:
|
||||||
if i == 3:
|
if i == 3:
|
||||||
break
|
break
|
||||||
return f"{bandwidth} {size[i]}"
|
return f"{bandwidth} {size[i]}"
|
||||||
|
|
||||||
|
|
||||||
|
def delay_jitter_text(delay: int, jitter: int) -> Optional[str]:
|
||||||
|
line = None
|
||||||
|
if delay > 0 and jitter > 0:
|
||||||
|
line = f"{delay} us (\u00B1{jitter} us)"
|
||||||
|
elif jitter > 0:
|
||||||
|
line = f"0 us (\u00B1{jitter} us)"
|
||||||
|
return line
|
||||||
|
|
Loading…
Add table
Reference in a new issue