|
|
|
@ -2035,6 +2035,79 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
self.assertIn("Alternate Duct", second_labels)
|
|
|
|
self.assertIn("Alternate Duct", second_labels)
|
|
|
|
self.assertNotIn("Direct Duct", second_labels)
|
|
|
|
self.assertNotIn("Direct Duct", second_labels)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_route_eplan_connections_respects_route_segment_capacity_before_detouring(self):
|
|
|
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
|
|
|
doc = FakeDocument()
|
|
|
|
|
|
|
|
terminal_objects.ensure_root_group(doc, "project-1")
|
|
|
|
|
|
|
|
_terminal(doc, terminal_objects, "TerminalStartA", "terminal-start-a", app.Vector(0, 0, 0))
|
|
|
|
|
|
|
|
_terminal(doc, terminal_objects, "TerminalEndA", "terminal-end-a", app.Vector(100, 0, 0))
|
|
|
|
|
|
|
|
_terminal(doc, terminal_objects, "TerminalStartB", "terminal-start-b", app.Vector(0, 0, 0))
|
|
|
|
|
|
|
|
_terminal(doc, terminal_objects, "TerminalEndB", "terminal-end-b", app.Vector(100, 0, 0))
|
|
|
|
|
|
|
|
_terminal(doc, terminal_objects, "TerminalStartC", "terminal-start-c", app.Vector(0, 0, 0))
|
|
|
|
|
|
|
|
_terminal(doc, terminal_objects, "TerminalEndC", "terminal-end-c", app.Vector(100, 0, 0))
|
|
|
|
|
|
|
|
direct = routing_network.create_route_carrier(
|
|
|
|
|
|
|
|
doc,
|
|
|
|
|
|
|
|
[app.Vector(0, 0, 20), app.Vector(100, 0, 20)],
|
|
|
|
|
|
|
|
label="Direct Duct",
|
|
|
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
direct.QetRouteCarrierCapacity = 2
|
|
|
|
|
|
|
|
routing_network.create_route_carrier(
|
|
|
|
|
|
|
|
doc,
|
|
|
|
|
|
|
|
[app.Vector(0, 0, 20), app.Vector(0, 40, 20)],
|
|
|
|
|
|
|
|
label="Left Bridge",
|
|
|
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
routing_network.create_route_carrier(
|
|
|
|
|
|
|
|
doc,
|
|
|
|
|
|
|
|
[app.Vector(0, 40, 20), app.Vector(100, 40, 20)],
|
|
|
|
|
|
|
|
label="Alternate Duct",
|
|
|
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
routing_network.create_route_carrier(
|
|
|
|
|
|
|
|
doc,
|
|
|
|
|
|
|
|
[app.Vector(100, 40, 20), app.Vector(100, 0, 20)],
|
|
|
|
|
|
|
|
label="Right Bridge",
|
|
|
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
payload = {
|
|
|
|
|
|
|
|
"project_uuid": "project-1",
|
|
|
|
|
|
|
|
"wires": [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"wire_id": "wire-a",
|
|
|
|
|
|
|
|
"start_terminal_uuid": "terminal-start-a",
|
|
|
|
|
|
|
|
"end_terminal_uuid": "terminal-end-a",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"wire_id": "wire-b",
|
|
|
|
|
|
|
|
"start_terminal_uuid": "terminal-start-b",
|
|
|
|
|
|
|
|
"end_terminal_uuid": "terminal-end-b",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"wire_id": "wire-c",
|
|
|
|
|
|
|
|
"start_terminal_uuid": "terminal-start-c",
|
|
|
|
|
|
|
|
"end_terminal_uuid": "terminal-end-c",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
report = auto_routing.route_eplan_connections_from_payload(doc, payload)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
route_labels = [
|
|
|
|
|
|
|
|
[segment["carrier"]["label"] for segment in route["route_track"]["segments"]]
|
|
|
|
|
|
|
|
for route in report["routes"]
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
self.assertIn("Direct Duct", route_labels[0])
|
|
|
|
|
|
|
|
self.assertIn("Direct Duct", route_labels[1])
|
|
|
|
|
|
|
|
self.assertIn("Alternate Duct", route_labels[2])
|
|
|
|
|
|
|
|
self.assertNotIn("Direct Duct", route_labels[2])
|
|
|
|
|
|
|
|
|
|
|
|
def test_route_eplan_connections_prefers_unused_segments_occupied_by_existing_wires(self):
|
|
|
|
def test_route_eplan_connections_prefers_unused_segments_occupied_by_existing_wires(self):
|
|
|
|
_install_fake_freecad()
|
|
|
|
_install_fake_freecad()
|
|
|
|
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
|