|
|
|
|
@ -210,7 +210,7 @@ def _terminal(doc, terminal_objects, name, terminal_uuid, point):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
def test_auto_route_selected_terminals_requires_supported_route_by_default(self):
|
|
|
|
|
def test_eplan_connection_route_selected_terminals_requires_supported_route_by_default(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, _routing_network, auto_routing = _reload_modules()
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
@ -220,33 +220,9 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
end = _terminal(doc, terminal_objects, "TerminalEnd", "terminal-end", app.Vector(100, 20, 0))
|
|
|
|
|
|
|
|
|
|
with self.assertRaises(auto_routing.AutoRoutingError):
|
|
|
|
|
auto_routing.route_between_terminals(doc, start, end)
|
|
|
|
|
auto_routing.route_eplan_connection_between_terminals(doc, start, end)
|
|
|
|
|
|
|
|
|
|
def test_auto_route_can_still_use_explicit_floating_fallback_for_debug(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")
|
|
|
|
|
start = _terminal(doc, terminal_objects, "TerminalStart", "terminal-start", app.Vector(0, 0, 0))
|
|
|
|
|
end = _terminal(doc, terminal_objects, "TerminalEnd", "terminal-end", app.Vector(100, 20, 0))
|
|
|
|
|
|
|
|
|
|
result = auto_routing.route_between_terminals(
|
|
|
|
|
doc,
|
|
|
|
|
start,
|
|
|
|
|
end,
|
|
|
|
|
options={"allow_floating_fallback": True},
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
wire = result["wire"]
|
|
|
|
|
self.assertEqual("orthogonal-v1", result["algorithm"])
|
|
|
|
|
self.assertEqual("AutoSuggested", wire.RouteType)
|
|
|
|
|
self.assertEqual("Auto", wire.RouteMode)
|
|
|
|
|
self.assertEqual("Routed", wire.RouteStatus)
|
|
|
|
|
self.assertGreaterEqual(len(wire.Points), 4)
|
|
|
|
|
self.assertIn(wire, doc.getObject("QETWiring_04_Routed").Group)
|
|
|
|
|
|
|
|
|
|
def test_auto_route_prefers_user_route_carrier_network(self):
|
|
|
|
|
def test_eplan_connection_route_prefers_user_route_carrier_network(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
@ -265,13 +241,13 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
result = auto_routing.route_between_terminals(doc, start, end)
|
|
|
|
|
result = auto_routing.route_eplan_connection_between_terminals(doc, start, end)
|
|
|
|
|
|
|
|
|
|
self.assertEqual("network-dijkstra-v1", result["algorithm"])
|
|
|
|
|
self.assertEqual("Routed", result["route_status"])
|
|
|
|
|
self.assertTrue(any(point.y == 30.0 for point in result["points"]))
|
|
|
|
|
|
|
|
|
|
def test_auto_route_stores_length_and_wire_style_diagnostics(self):
|
|
|
|
|
def test_eplan_connection_route_stores_length_and_wire_style_diagnostics(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
@ -286,7 +262,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
result = auto_routing.route_between_terminals(
|
|
|
|
|
result = auto_routing.route_eplan_connection_between_terminals(
|
|
|
|
|
doc,
|
|
|
|
|
start,
|
|
|
|
|
end,
|
|
|
|
|
@ -295,14 +271,17 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
options={"wire_style_id": "42"},
|
|
|
|
|
)
|
|
|
|
|
wire = result["wire"]
|
|
|
|
|
payload = json.loads(wire.QetAutoRouteDiagnosticsJson)
|
|
|
|
|
payload = json.loads(wire.QetRouteDiagnosticsJson)
|
|
|
|
|
|
|
|
|
|
self.assertGreater(float(wire.QetAutoRouteLengthMm), 0.0)
|
|
|
|
|
self.assertGreater(float(wire.QetRouteLengthMm), 0.0)
|
|
|
|
|
self.assertEqual("42", wire.QetWireStyleId)
|
|
|
|
|
self.assertEqual("42", payload["wire_style_id"])
|
|
|
|
|
self.assertGreater(payload["length_mm"], 0.0)
|
|
|
|
|
self.assertTrue(payload["route_track"]["segments"])
|
|
|
|
|
self.assertEqual("WireDuct", payload["route_track"]["segments"][0]["carrier"]["kind"])
|
|
|
|
|
self.assertTrue(json.loads(wire.QetRouteTrackJson)["carrier_names"])
|
|
|
|
|
|
|
|
|
|
def test_network_auto_route_offsets_lane_by_route_index(self):
|
|
|
|
|
def test_network_eplan_connection_route_offsets_lane_by_route_index(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
@ -317,7 +296,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
first = auto_routing.route_between_terminals(
|
|
|
|
|
first = auto_routing.route_eplan_connection_between_terminals(
|
|
|
|
|
doc,
|
|
|
|
|
start,
|
|
|
|
|
end,
|
|
|
|
|
@ -325,7 +304,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
wire_uuid="wire-1",
|
|
|
|
|
options={"lane_spacing": 12.0, "lane_axis": "y"},
|
|
|
|
|
)
|
|
|
|
|
second = auto_routing.route_between_terminals(
|
|
|
|
|
second = auto_routing.route_eplan_connection_between_terminals(
|
|
|
|
|
doc,
|
|
|
|
|
start,
|
|
|
|
|
end,
|
|
|
|
|
@ -333,7 +312,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
wire_uuid="wire-2",
|
|
|
|
|
options={"lane_spacing": 12.0, "lane_axis": "y"},
|
|
|
|
|
)
|
|
|
|
|
payload = json.loads(second["wire"].QetAutoRouteDiagnosticsJson)
|
|
|
|
|
payload = json.loads(second["wire"].QetRouteDiagnosticsJson)
|
|
|
|
|
|
|
|
|
|
self.assertTrue(any(abs(point.y - 0.0) <= 0.001 for point in first["points"][1:-1]))
|
|
|
|
|
self.assertTrue(any(abs(point.y - 12.0) <= 0.001 for point in second["points"][1:-1]))
|
|
|
|
|
@ -341,7 +320,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
self.assertEqual("y", payload["lane"]["axis"])
|
|
|
|
|
self.assertEqual(12.0, payload["lane"]["offset_mm"])
|
|
|
|
|
|
|
|
|
|
def test_auto_route_replaces_existing_wire_uuid_when_endpoints_change(self):
|
|
|
|
|
def test_eplan_connection_route_replaces_existing_wire_uuid_when_endpoints_change(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
@ -363,8 +342,8 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
auto_routing.route_between_terminals(doc, start_old, end_old, wire_uuid="wire-1")
|
|
|
|
|
auto_routing.route_between_terminals(doc, start_new, end_new, wire_uuid="wire-1")
|
|
|
|
|
auto_routing.route_eplan_connection_between_terminals(doc, start_old, end_old, wire_uuid="wire-1")
|
|
|
|
|
auto_routing.route_eplan_connection_between_terminals(doc, start_new, end_new, wire_uuid="wire-1")
|
|
|
|
|
routed_wires = list(wiring_objects.iter_routed_wire_objects(doc))
|
|
|
|
|
|
|
|
|
|
self.assertEqual(1, len(routed_wires))
|
|
|
|
|
@ -426,7 +405,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
network = routing_network.build_route_graph(doc)
|
|
|
|
|
result = auto_routing.route_between_terminals(doc, start, end)
|
|
|
|
|
result = auto_routing.route_eplan_connection_between_terminals(doc, start, end)
|
|
|
|
|
|
|
|
|
|
self.assertEqual(5, len(network["nodes"]))
|
|
|
|
|
self.assertEqual("network-dijkstra-v1", result["algorithm"])
|
|
|
|
|
@ -454,14 +433,42 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
network = routing_network.build_route_graph(doc)
|
|
|
|
|
result = auto_routing.route_between_terminals(doc, start, end)
|
|
|
|
|
result = auto_routing.route_eplan_connection_between_terminals(doc, start, end)
|
|
|
|
|
|
|
|
|
|
self.assertEqual("network-dijkstra-v1", result["algorithm"])
|
|
|
|
|
self.assertIn((40.0, 0.0, 0.0), [(point.x, point.y, point.z) for point in result["points"]])
|
|
|
|
|
self.assertIn((80.0, 0.0, 0.0), [(point.x, point.y, point.z) for point in result["points"]])
|
|
|
|
|
self.assertGreaterEqual(network["segment_count"], 3)
|
|
|
|
|
|
|
|
|
|
def test_auto_route_prefers_wire_duct_over_auxiliary_range(self):
|
|
|
|
|
def test_route_graph_bridges_adjoining_wire_duct_gap_with_eplan_tolerance(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")
|
|
|
|
|
start = _terminal(doc, terminal_objects, "TerminalStart", "terminal-start", app.Vector(0, 0, 0))
|
|
|
|
|
end = _terminal(doc, terminal_objects, "TerminalEnd", "terminal-end", app.Vector(100, 0, 0))
|
|
|
|
|
routing_network.create_route_carrier(
|
|
|
|
|
doc,
|
|
|
|
|
[app.Vector(0, 0, 20), app.Vector(50, 0, 20)],
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
)
|
|
|
|
|
routing_network.create_route_carrier(
|
|
|
|
|
doc,
|
|
|
|
|
[app.Vector(54, 0, 20), app.Vector(100, 0, 20)],
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
network = routing_network.build_route_graph(doc)
|
|
|
|
|
result = auto_routing.route_eplan_connection_between_terminals(doc, start, end)
|
|
|
|
|
|
|
|
|
|
self.assertEqual(1, network["bridged_segment_count"])
|
|
|
|
|
self.assertEqual("network-dijkstra-v1", result["algorithm"])
|
|
|
|
|
self.assertEqual("Routed", result["route_status"])
|
|
|
|
|
|
|
|
|
|
def test_eplan_connection_route_prefers_wire_duct_over_auxiliary_range(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
@ -487,7 +494,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
result = auto_routing.route_between_terminals(doc, start, end)
|
|
|
|
|
result = auto_routing.route_eplan_connection_between_terminals(doc, start, end)
|
|
|
|
|
|
|
|
|
|
self.assertEqual("network-dijkstra-v1", result["algorithm"])
|
|
|
|
|
self.assertTrue(any(point.y == 40.0 for point in result["points"]))
|
|
|
|
|
@ -513,7 +520,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
offset=5.0,
|
|
|
|
|
margin=0.0,
|
|
|
|
|
)
|
|
|
|
|
result = auto_routing.route_between_terminals(doc, start, end)
|
|
|
|
|
result = auto_routing.route_eplan_connection_between_terminals(doc, start, end)
|
|
|
|
|
|
|
|
|
|
self.assertGreater(len(created), 0)
|
|
|
|
|
self.assertEqual("RoutingRange", getattr(created[0], "QetRouteCarrierKind", ""))
|
|
|
|
|
@ -558,7 +565,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
self.assertFalse(hasattr(cabinet, "QetRoutingSourceKind"))
|
|
|
|
|
self.assertFalse(hasattr(duct, "QetRoutingSourceKind"))
|
|
|
|
|
|
|
|
|
|
def test_auto_route_can_use_auto_detected_support_surface(self):
|
|
|
|
|
def test_eplan_connection_route_can_use_auto_detected_support_surface(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
@ -577,7 +584,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
offset=5.0,
|
|
|
|
|
margin=0.0,
|
|
|
|
|
)
|
|
|
|
|
result = auto_routing.route_between_terminals(doc, start, end)
|
|
|
|
|
result = auto_routing.route_eplan_connection_between_terminals(doc, start, end)
|
|
|
|
|
|
|
|
|
|
self.assertGreater(len(created), 0)
|
|
|
|
|
self.assertEqual("network-dijkstra-v1", result["algorithm"])
|
|
|
|
|
@ -585,7 +592,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
self.assertEqual(0, result["collision_count"])
|
|
|
|
|
self.assertTrue(any(point.y == 10.0 for point in result["points"]))
|
|
|
|
|
|
|
|
|
|
def test_generate_layout_space_auto_detects_support_surface(self):
|
|
|
|
|
def test_prepare_layout_space_auto_detects_support_surface_sources(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, _routing_network, _auto_routing = _reload_modules()
|
|
|
|
|
auto_routing_panel = importlib.import_module("AutoRoutingPanel")
|
|
|
|
|
@ -599,7 +606,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
result = auto_routing_panel.AutoRoutingController().generate_layout_space()
|
|
|
|
|
|
|
|
|
|
self.assertGreater(result["surface_carriers"], 0)
|
|
|
|
|
self.assertGreater(result["support_surface_sources"], 0)
|
|
|
|
|
self.assertEqual("document", result["source_mode"])
|
|
|
|
|
|
|
|
|
|
def test_generate_routing_paths_uses_selected_wire_duct_entity(self):
|
|
|
|
|
@ -623,7 +630,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
self.assertEqual(1, result["wire_duct_carriers"])
|
|
|
|
|
self.assertEqual("selection", result["source_mode"])
|
|
|
|
|
|
|
|
|
|
def test_generate_layout_space_uses_whole_document_not_selected_face_workflow(self):
|
|
|
|
|
def test_prepare_layout_space_uses_whole_document_not_selected_face_workflow(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, _routing_network, _auto_routing = _reload_modules()
|
|
|
|
|
auto_routing_panel = importlib.import_module("AutoRoutingPanel")
|
|
|
|
|
@ -642,10 +649,10 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
result = auto_routing_panel.AutoRoutingController().generate_layout_space()
|
|
|
|
|
|
|
|
|
|
self.assertGreater(result["surface_carriers"], 0)
|
|
|
|
|
self.assertGreater(result["support_surface_sources"], 0)
|
|
|
|
|
self.assertEqual("document", result["source_mode"])
|
|
|
|
|
|
|
|
|
|
def test_generate_layout_space_adds_terminal_access_to_route_network(self):
|
|
|
|
|
def test_generate_routing_path_network_adds_terminal_access_to_route_network(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, _auto_routing = _reload_modules()
|
|
|
|
|
auto_routing_panel = importlib.import_module("AutoRoutingPanel")
|
|
|
|
|
@ -659,8 +666,8 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
duct.Label = "Wire Duct A"
|
|
|
|
|
duct.Shape = FakeShape(FakeBoundBox(0, 100, -5, 5, 15, 25))
|
|
|
|
|
|
|
|
|
|
result = auto_routing_panel.AutoRoutingController().generate_layout_space()
|
|
|
|
|
result_again = auto_routing_panel.AutoRoutingController().generate_layout_space()
|
|
|
|
|
result = auto_routing_panel.AutoRoutingController().generate_routing_paths()
|
|
|
|
|
result_again = auto_routing_panel.AutoRoutingController().generate_routing_paths()
|
|
|
|
|
access_carriers = [
|
|
|
|
|
carrier
|
|
|
|
|
for carrier in routing_network.collect_route_carriers(doc)
|
|
|
|
|
@ -668,13 +675,86 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
self.assertEqual(1, result["wire_duct_carriers"])
|
|
|
|
|
self.assertEqual(2, result["wire_duct_open_end_carriers"])
|
|
|
|
|
self.assertEqual(2, result["terminal_access_carriers"])
|
|
|
|
|
self.assertEqual(0, result_again["wire_duct_carriers"])
|
|
|
|
|
self.assertEqual(0, result_again["wire_duct_open_end_carriers"])
|
|
|
|
|
self.assertEqual(2, result_again["terminal_access_carriers"])
|
|
|
|
|
self.assertEqual(2, len(access_carriers))
|
|
|
|
|
self.assertGreater(result["network"]["segments"], 0)
|
|
|
|
|
|
|
|
|
|
def test_generate_layout_space_skips_far_terminal_access_to_protect_view_bbox(self):
|
|
|
|
|
def test_generate_routing_path_network_connects_terminal_access_to_nearest_segment_point(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, _auto_routing = _reload_modules()
|
|
|
|
|
auto_routing_panel = importlib.import_module("AutoRoutingPanel")
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
doc = FakeDocument()
|
|
|
|
|
app.ActiveDocument = doc
|
|
|
|
|
terminal_objects.ensure_root_group(doc, "project-1")
|
|
|
|
|
_terminal(doc, terminal_objects, "TerminalMid", "terminal-mid", app.Vector(50, 30, 0))
|
|
|
|
|
duct = doc.addObject("Part::Feature", "WireDuctA")
|
|
|
|
|
duct.Label = "Wire Duct A"
|
|
|
|
|
duct.Shape = FakeShape(FakeBoundBox(0, 100, -5, 5, 15, 25))
|
|
|
|
|
|
|
|
|
|
auto_routing_panel.AutoRoutingController().generate_routing_paths()
|
|
|
|
|
access_carriers = [
|
|
|
|
|
carrier
|
|
|
|
|
for carrier in routing_network.collect_route_carriers(doc)
|
|
|
|
|
if getattr(carrier, "QetRouteCarrierKind", "") == "TerminalAccess"
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
self.assertEqual(1, len(access_carriers))
|
|
|
|
|
end_point = access_carriers[0].Points[-1]
|
|
|
|
|
self.assertEqual((50.0, 0.0, 20.0), (end_point.x, end_point.y, end_point.z))
|
|
|
|
|
|
|
|
|
|
def test_generate_routing_path_network_adds_wiring_cut_out_carrier(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, _auto_routing = _reload_modules()
|
|
|
|
|
auto_routing_panel = importlib.import_module("AutoRoutingPanel")
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
doc = FakeDocument()
|
|
|
|
|
app.ActiveDocument = doc
|
|
|
|
|
terminal_objects.ensure_root_group(doc, "project-1")
|
|
|
|
|
cut_out = doc.addObject("Part::Feature", "WiringCutoutA")
|
|
|
|
|
cut_out.Label = "Wiring Cut-Out A"
|
|
|
|
|
cut_out.Shape = FakeShape(FakeBoundBox(45, 55, -2, 2, 15, 25))
|
|
|
|
|
|
|
|
|
|
result = auto_routing_panel.AutoRoutingController().generate_routing_paths()
|
|
|
|
|
cut_out_carriers = [
|
|
|
|
|
carrier
|
|
|
|
|
for carrier in routing_network.collect_route_carriers(doc)
|
|
|
|
|
if getattr(carrier, "QetRouteCarrierKind", "") == "WiringCutOut"
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
self.assertEqual(1, result["wiring_cut_out_carriers"])
|
|
|
|
|
self.assertEqual(1, len(cut_out_carriers))
|
|
|
|
|
self.assertEqual("PassThrough", cut_out.QetRoutingObstacleMode)
|
|
|
|
|
|
|
|
|
|
def test_check_routing_path_network_writes_diagnostic_for_unconnected_terminal(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
doc = FakeDocument()
|
|
|
|
|
app.ActiveDocument = doc
|
|
|
|
|
terminal_objects.ensure_root_group(doc, "project-1")
|
|
|
|
|
_terminal(doc, terminal_objects, "TerminalFar", "terminal-far", app.Vector(5000, 0, 0))
|
|
|
|
|
routing_network.create_route_carrier(
|
|
|
|
|
doc,
|
|
|
|
|
[app.Vector(0, 0, 20), app.Vector(100, 0, 20)],
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
result = auto_routing.check_eplan_routing_path_network(doc, project_uuid="project-1")
|
|
|
|
|
diagnostic_group = doc.getObject("QETWiring_05_Diagnostics")
|
|
|
|
|
payload = json.loads(diagnostic_group.Group[0].QetDiagnosticJson)
|
|
|
|
|
|
|
|
|
|
self.assertFalse(result["ok"])
|
|
|
|
|
self.assertEqual("RoutingPathNetwork", diagnostic_group.Group[0].QetDiagnosticKind)
|
|
|
|
|
self.assertEqual(1, len(payload["unconnected_terminals"]))
|
|
|
|
|
self.assertEqual("terminal-far", payload["unconnected_terminals"][0]["terminal_uuid"])
|
|
|
|
|
|
|
|
|
|
def test_generate_routing_path_network_skips_far_terminal_access_to_protect_view_bbox(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, _routing_network, _auto_routing = _reload_modules()
|
|
|
|
|
auto_routing_panel = importlib.import_module("AutoRoutingPanel")
|
|
|
|
|
@ -687,12 +767,13 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
duct.Label = "Wire Duct Far"
|
|
|
|
|
duct.Shape = FakeShape(FakeBoundBox(5000, 5100, -5, 5, 15, 25))
|
|
|
|
|
|
|
|
|
|
result = auto_routing_panel.AutoRoutingController().generate_layout_space()
|
|
|
|
|
result = auto_routing_panel.AutoRoutingController().generate_routing_paths()
|
|
|
|
|
|
|
|
|
|
self.assertEqual(1, result["wire_duct_carriers"])
|
|
|
|
|
self.assertEqual(2, result["wire_duct_open_end_carriers"])
|
|
|
|
|
self.assertEqual(0, result["terminal_access_carriers"])
|
|
|
|
|
|
|
|
|
|
def test_route_all_prepares_layout_space_like_one_click_routing(self):
|
|
|
|
|
def test_route_eplan_connections_prepares_layout_space_like_eplan_route(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, _routing_network, _auto_routing = _reload_modules()
|
|
|
|
|
auto_routing_panel = importlib.import_module("AutoRoutingPanel")
|
|
|
|
|
@ -716,10 +797,13 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
report = auto_routing_panel.AutoRoutingController().route_all()
|
|
|
|
|
report = auto_routing_panel.AutoRoutingController().route_eplan_connections()
|
|
|
|
|
|
|
|
|
|
self.assertEqual(1, report["routed"])
|
|
|
|
|
self.assertEqual("eplan-route-v1", report["routing_method"])
|
|
|
|
|
self.assertTrue(report["routing_path_network_updated"])
|
|
|
|
|
self.assertEqual(1, report["prepared_layout"]["wire_duct_carriers"])
|
|
|
|
|
self.assertEqual(1, report["routing_path_network"]["wire_duct_carriers"])
|
|
|
|
|
self.assertEqual(2, report["prepared_layout"]["terminal_access_carriers"])
|
|
|
|
|
diagnostic_group = doc.getObject("QETWiring_05_Diagnostics")
|
|
|
|
|
self.assertIsNotNone(diagnostic_group)
|
|
|
|
|
@ -728,7 +812,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
self.assertEqual(1, diagnostic_payload["prepared_layout"]["wire_duct_carriers"])
|
|
|
|
|
self.assertEqual(2, diagnostic_payload["prepared_layout"]["terminal_access_carriers"])
|
|
|
|
|
|
|
|
|
|
def test_auto_route_rejects_far_network_entry_to_avoid_huge_render_bbox(self):
|
|
|
|
|
def test_eplan_connection_route_rejects_far_network_entry_to_avoid_huge_render_bbox(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
@ -744,9 +828,9 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
with self.assertRaises(auto_routing.AutoRoutingError):
|
|
|
|
|
auto_routing.route_between_terminals(doc, start, end)
|
|
|
|
|
auto_routing.route_eplan_connection_between_terminals(doc, start, end)
|
|
|
|
|
|
|
|
|
|
def test_route_between_terminals_fails_without_network(self):
|
|
|
|
|
def test_route_eplan_connection_between_terminals_fails_without_network(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, wiring_objects, _routing_network, auto_routing = _reload_modules()
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
@ -757,7 +841,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
end = _terminal(doc, terminal_objects, "TerminalEnd", "terminal-end", app.Vector(120, 30, 0))
|
|
|
|
|
|
|
|
|
|
with self.assertRaises(auto_routing.AutoRoutingError):
|
|
|
|
|
auto_routing.route_between_terminals(doc, start, end)
|
|
|
|
|
auto_routing.route_eplan_connection_between_terminals(doc, start, end)
|
|
|
|
|
self.assertEqual(0, len(wiring_objects.iter_routed_wire_objects(doc)))
|
|
|
|
|
|
|
|
|
|
def test_surface_carrier_grid_uses_actual_rotated_face_plane(self):
|
|
|
|
|
@ -861,9 +945,11 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
margin=20.0,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
self.assertEqual(1, len(created))
|
|
|
|
|
carrier = created[0]
|
|
|
|
|
self.assertEqual(3, len(created))
|
|
|
|
|
carrier = [item for item in created if item.QetRouteCarrierKind == "WireDuct"][0]
|
|
|
|
|
open_ends = [item for item in created if item.QetRouteCarrierKind == "WireDuctOpenEnd"]
|
|
|
|
|
self.assertEqual("WireDuct", carrier.QetRouteCarrierKind)
|
|
|
|
|
self.assertEqual(2, len(open_ends))
|
|
|
|
|
self.assertEqual("PassThrough", duct.QetRoutingObstacleMode)
|
|
|
|
|
self.assertEqual([(20.0, 0.0, 15.0), (100.0, 0.0, 15.0)], [(p.x, p.y, p.z) for p in carrier.Points])
|
|
|
|
|
|
|
|
|
|
@ -888,9 +974,10 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
self.assertEqual(1, len(created))
|
|
|
|
|
self.assertEqual(3, len(created))
|
|
|
|
|
self.assertEqual(0, len(created_again))
|
|
|
|
|
self.assertEqual("WireDuct", created[0].QetRouteCarrierKind)
|
|
|
|
|
self.assertEqual(1, len([item for item in created if item.QetRouteCarrierKind == "WireDuct"]))
|
|
|
|
|
self.assertEqual(2, len([item for item in created if item.QetRouteCarrierKind == "WireDuctOpenEnd"]))
|
|
|
|
|
self.assertEqual("PassThrough", duct.QetRoutingObstacleMode)
|
|
|
|
|
self.assertFalse(hasattr(cabinet, "QetRoutingObstacleMode"))
|
|
|
|
|
|
|
|
|
|
@ -911,13 +998,13 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
margin=0.0,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
result = auto_routing.route_between_terminals(doc, start, end)
|
|
|
|
|
result = auto_routing.route_eplan_connection_between_terminals(doc, start, end)
|
|
|
|
|
|
|
|
|
|
self.assertEqual("network-dijkstra-v1", result["algorithm"])
|
|
|
|
|
self.assertEqual("Routed", result["route_status"])
|
|
|
|
|
self.assertEqual(0, result["collision_count"])
|
|
|
|
|
|
|
|
|
|
def test_auto_route_uses_alternate_carrier_to_avoid_obstacle(self):
|
|
|
|
|
def test_eplan_connection_route_uses_alternate_carrier_to_avoid_obstacle(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
@ -945,7 +1032,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
obstacle = doc.addObject("Part::Feature", "CabinetObstacle")
|
|
|
|
|
obstacle.Shape = FakeShape(FakeBoundBox(40, 60, -10, 10, 15, 25))
|
|
|
|
|
|
|
|
|
|
result = auto_routing.route_between_terminals(doc, start, end)
|
|
|
|
|
result = auto_routing.route_eplan_connection_between_terminals(doc, start, end)
|
|
|
|
|
|
|
|
|
|
self.assertEqual("network-dijkstra-v1", result["algorithm"])
|
|
|
|
|
self.assertEqual("Routed", result["route_status"])
|
|
|
|
|
@ -954,15 +1041,15 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
self.assertGreaterEqual(result["network"]["blocked_segments"], 1)
|
|
|
|
|
self.assertIn(50.0, [point.y for point in result["points"]])
|
|
|
|
|
|
|
|
|
|
def test_auto_route_marks_collision_warning_against_obstacle_bbox(self):
|
|
|
|
|
def test_eplan_connection_route_marks_collision_warning_against_obstacle_bbox(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, _routing_network, auto_routing = _reload_modules()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
doc = FakeDocument()
|
|
|
|
|
terminal_objects.ensure_root_group(doc, "project-1")
|
|
|
|
|
start = _terminal(doc, terminal_objects, "TerminalStart", "terminal-start", app.Vector(0, 0, 0))
|
|
|
|
|
end = _terminal(doc, terminal_objects, "TerminalEnd", "terminal-end", app.Vector(100, 0, 0))
|
|
|
|
|
_routing_network.create_route_carrier(
|
|
|
|
|
routing_network.create_route_carrier(
|
|
|
|
|
doc,
|
|
|
|
|
[app.Vector(0, 0, 100), app.Vector(100, 0, 100)],
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
@ -970,13 +1057,13 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
obstacle = doc.addObject("Part::Feature", "Obstacle")
|
|
|
|
|
obstacle.Shape = FakeShape(FakeBoundBox(40, 60, -10, 10, 90, 110))
|
|
|
|
|
|
|
|
|
|
result = auto_routing.route_between_terminals(doc, start, end)
|
|
|
|
|
result = auto_routing.route_eplan_connection_between_terminals(doc, start, end)
|
|
|
|
|
|
|
|
|
|
self.assertEqual("CollisionWarning", result["route_status"])
|
|
|
|
|
self.assertEqual("CollisionWarning", result["wire"].RouteStatus)
|
|
|
|
|
self.assertEqual(1, result["collision_count"])
|
|
|
|
|
|
|
|
|
|
def test_auto_route_ignores_terminal_exit_segment_collision(self):
|
|
|
|
|
def test_eplan_connection_route_ignores_terminal_exit_segment_collision(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
@ -992,12 +1079,12 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
terminal_body = doc.addObject("Part::Feature", "UngroupedTerminalBody")
|
|
|
|
|
terminal_body.Shape = FakeShape(FakeBoundBox(-5, 5, -5, 5, -5, 15))
|
|
|
|
|
|
|
|
|
|
result = auto_routing.route_between_terminals(doc, start, end)
|
|
|
|
|
result = auto_routing.route_eplan_connection_between_terminals(doc, start, end)
|
|
|
|
|
|
|
|
|
|
self.assertEqual("Routed", result["route_status"])
|
|
|
|
|
self.assertEqual(0, result["collision_count"])
|
|
|
|
|
|
|
|
|
|
def test_auto_route_ignores_endpoint_device_body_as_obstacle(self):
|
|
|
|
|
def test_eplan_connection_route_ignores_endpoint_device_body_as_obstacle(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
@ -1017,12 +1104,12 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
result = auto_routing.route_between_terminals(doc, start, end)
|
|
|
|
|
result = auto_routing.route_eplan_connection_between_terminals(doc, start, end)
|
|
|
|
|
|
|
|
|
|
self.assertEqual("Routed", result["route_status"])
|
|
|
|
|
self.assertEqual(0, result["collision_count"])
|
|
|
|
|
|
|
|
|
|
def test_route_all_from_payload_skips_missing_terminal(self):
|
|
|
|
|
def test_route_eplan_connections_from_payload_skips_missing_terminal(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, _routing_network, auto_routing = _reload_modules()
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
@ -1039,7 +1126,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
report = auto_routing.route_all_from_payload(doc, payload)
|
|
|
|
|
report = auto_routing.route_eplan_connections_from_payload(doc, payload)
|
|
|
|
|
|
|
|
|
|
self.assertEqual(0, report["routed"])
|
|
|
|
|
self.assertEqual(1, report["skipped_missing_terminal"])
|
|
|
|
|
@ -1050,7 +1137,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
self.assertTrue(report["missing_endpoint_samples"][0]["start_found"])
|
|
|
|
|
self.assertFalse(report["missing_endpoint_samples"][0]["end_found"])
|
|
|
|
|
|
|
|
|
|
def test_route_all_writes_diagnostic_object_for_missing_terminal(self):
|
|
|
|
|
def test_route_eplan_connections_writes_diagnostic_object_for_missing_terminal(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, _routing_network, auto_routing = _reload_modules()
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
@ -1068,17 +1155,17 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
report = auto_routing.route_all_from_payload(doc, payload)
|
|
|
|
|
report = auto_routing.route_eplan_connections_from_payload(doc, payload)
|
|
|
|
|
diagnostic_group = doc.getObject("QETWiring_05_Diagnostics")
|
|
|
|
|
|
|
|
|
|
self.assertEqual(1, report["skipped_missing_terminal"])
|
|
|
|
|
self.assertIsNotNone(diagnostic_group)
|
|
|
|
|
self.assertEqual(1, len(diagnostic_group.Group))
|
|
|
|
|
diagnostic = diagnostic_group.Group[0]
|
|
|
|
|
self.assertEqual("AutoRouteBatch", diagnostic.QetDiagnosticKind)
|
|
|
|
|
self.assertEqual("RoutingConnectionBatch", diagnostic.QetDiagnosticKind)
|
|
|
|
|
self.assertIn("terminal-missing", diagnostic.QetDiagnosticJson)
|
|
|
|
|
|
|
|
|
|
def test_route_all_reports_total_auto_route_length(self):
|
|
|
|
|
def test_route_eplan_connections_reports_total_connection_route_length(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
@ -1103,14 +1190,14 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
report = auto_routing.route_all_from_payload(doc, payload)
|
|
|
|
|
message = auto_routing.format_route_all_report(report)
|
|
|
|
|
report = auto_routing.route_eplan_connections_from_payload(doc, payload)
|
|
|
|
|
message = auto_routing.format_eplan_connection_route_report(report)
|
|
|
|
|
|
|
|
|
|
self.assertGreater(report["total_length_mm"], 0.0)
|
|
|
|
|
self.assertEqual(report["total_length_mm"], report["routes"][0]["length_mm"])
|
|
|
|
|
self.assertIn("总长度", message)
|
|
|
|
|
|
|
|
|
|
def test_route_all_report_keeps_route_identity_and_diagnostics(self):
|
|
|
|
|
def test_route_eplan_connections_report_keeps_route_identity_and_diagnostics(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
@ -1137,7 +1224,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
report = auto_routing.route_all_from_payload(
|
|
|
|
|
report = auto_routing.route_eplan_connections_from_payload(
|
|
|
|
|
doc,
|
|
|
|
|
payload,
|
|
|
|
|
options={"lane_spacing": 12.0, "lane_axis": "y"},
|
|
|
|
|
@ -1152,8 +1239,9 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
self.assertEqual(0, route["lane"]["index"])
|
|
|
|
|
self.assertEqual("network-dijkstra-v1", route["algorithm"])
|
|
|
|
|
self.assertEqual(1, route["network"]["carriers"])
|
|
|
|
|
self.assertEqual("WireDuct", route["route_track"]["segments"][0]["carrier"]["kind"])
|
|
|
|
|
|
|
|
|
|
def test_route_all_report_includes_collision_samples(self):
|
|
|
|
|
def test_route_eplan_connections_report_includes_collision_samples(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
@ -1181,8 +1269,8 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
report = auto_routing.route_all_from_payload(doc, payload)
|
|
|
|
|
message = auto_routing.format_route_all_report(report)
|
|
|
|
|
report = auto_routing.route_eplan_connections_from_payload(doc, payload)
|
|
|
|
|
message = auto_routing.format_eplan_connection_route_report(report)
|
|
|
|
|
|
|
|
|
|
self.assertEqual(1, report["collision_warnings"])
|
|
|
|
|
self.assertEqual("wire-1", report["collision_samples"][0]["wire_uuid"])
|
|
|
|
|
@ -1192,7 +1280,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
self.assertIn("碰撞示例", message)
|
|
|
|
|
self.assertIn("Middle Obstacle", message)
|
|
|
|
|
|
|
|
|
|
def test_route_all_report_calls_out_local_unbound_terminals(self):
|
|
|
|
|
def test_route_eplan_connections_report_calls_out_local_unbound_terminals(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, _routing_network, auto_routing = _reload_modules()
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
@ -1215,8 +1303,8 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
report = auto_routing.route_all_from_payload(doc, payload)
|
|
|
|
|
message = auto_routing.format_route_all_report(report)
|
|
|
|
|
report = auto_routing.route_eplan_connections_from_payload(doc, payload)
|
|
|
|
|
message = auto_routing.format_eplan_connection_route_report(report)
|
|
|
|
|
|
|
|
|
|
self.assertEqual(0, report["routed"])
|
|
|
|
|
self.assertEqual(1, report["available_terminals"])
|
|
|
|
|
@ -1224,7 +1312,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
self.assertIn("端子匹配失败", message)
|
|
|
|
|
self.assertIn("local:", message)
|
|
|
|
|
|
|
|
|
|
def test_route_all_report_includes_network_and_first_error(self):
|
|
|
|
|
def test_route_eplan_connections_report_includes_network_and_first_error(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
_terminal_objects, _wiring_objects, _routing_network, auto_routing = _reload_modules()
|
|
|
|
|
report = {
|
|
|
|
|
@ -1246,7 +1334,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
"errors": ["没有可用的线槽/路由路径网络"],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
message = auto_routing.format_route_all_report(report)
|
|
|
|
|
message = auto_routing.format_eplan_connection_route_report(report)
|
|
|
|
|
|
|
|
|
|
self.assertIn("routed=1", message)
|
|
|
|
|
self.assertIn("线槽路径 2 条", message)
|
|
|
|
|
@ -1318,9 +1406,9 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
self.assertEqual([], wiring_objects.iter_routed_wire_objects(doc))
|
|
|
|
|
self.assertEqual("qet", indexed["qet-terminal-p1"].QetTerminalBindingMode)
|
|
|
|
|
|
|
|
|
|
def test_route_all_rebinds_local_template_terminals_from_wire_endpoints(self):
|
|
|
|
|
def test_route_eplan_connections_rebinds_local_template_terminals_from_wire_endpoints(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, _routing_network, auto_routing = _reload_modules()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
|
app = sys.modules["FreeCAD"]
|
|
|
|
|
doc = FakeDocument()
|
|
|
|
|
root = terminal_objects.ensure_root_group(doc, "project-1")
|
|
|
|
|
@ -1357,6 +1445,12 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
slot_name=slot_name,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
routing_network.create_route_carrier(
|
|
|
|
|
doc,
|
|
|
|
|
[app.Vector(0, 0, 20), app.Vector(100, 0, 20)],
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
payload = {
|
|
|
|
|
"project_uuid": "project-1",
|
|
|
|
|
"wires": [
|
|
|
|
|
@ -1374,10 +1468,9 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
report = auto_routing.route_all_from_payload(
|
|
|
|
|
report = auto_routing.route_eplan_connections_from_payload(
|
|
|
|
|
doc,
|
|
|
|
|
payload,
|
|
|
|
|
options={"allow_floating_fallback": True},
|
|
|
|
|
)
|
|
|
|
|
indexed = auto_routing.index_terminals(doc)
|
|
|
|
|
|
|
|
|
|
@ -1401,7 +1494,7 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
[app.Vector(0, 0, 20), app.Vector(100, 0, 20)],
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
)
|
|
|
|
|
wire = auto_routing.route_between_terminals(doc, start, end)["wire"]
|
|
|
|
|
wire = auto_routing.route_eplan_connection_between_terminals(doc, start, end)["wire"]
|
|
|
|
|
|
|
|
|
|
removed = routing_network.clear_route_carriers(doc)
|
|
|
|
|
|
|
|
|
|
|