|
|
|
|
@ -281,6 +281,55 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
self.assertEqual("WireDuct", payload["route_track"]["segments"][0]["carrier"]["kind"])
|
|
|
|
|
self.assertTrue(json.loads(wire.QetRouteTrackJson)["carrier_names"])
|
|
|
|
|
|
|
|
|
|
def test_route_track_preserves_generated_carrier_source_metadata(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")
|
|
|
|
|
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))
|
|
|
|
|
duct = doc.addObject("Part::Feature", "WireDuctA")
|
|
|
|
|
duct.Label = "线槽A"
|
|
|
|
|
duct.Shape = FakeShape(FakeBoundBox(0, 100, -5, 5, 15, 25))
|
|
|
|
|
|
|
|
|
|
auto_routing_panel.AutoRoutingController().generate_routing_paths()
|
|
|
|
|
result = auto_routing.route_eplan_connection_between_terminals(doc, start, end)
|
|
|
|
|
route_track = json.loads(result["wire"].QetRouteTrackJson)
|
|
|
|
|
wire_duct_carriers = [
|
|
|
|
|
segment["carrier"]
|
|
|
|
|
for segment in route_track["segments"]
|
|
|
|
|
if segment["carrier"]["kind"] == "WireDuct"
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
self.assertTrue(wire_duct_carriers)
|
|
|
|
|
self.assertEqual("WireDuctA", wire_duct_carriers[0].get("source_name"))
|
|
|
|
|
self.assertEqual("线槽A", wire_duct_carriers[0].get("source_label"))
|
|
|
|
|
self.assertEqual("WireDuct", wire_duct_carriers[0].get("source_kind"))
|
|
|
|
|
|
|
|
|
|
def test_route_track_records_carrier_capacity(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(100, 0, 20)],
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
capacity=3,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
result = auto_routing.route_eplan_connection_between_terminals(doc, start, end)
|
|
|
|
|
route_track = json.loads(result["wire"].QetRouteTrackJson)
|
|
|
|
|
|
|
|
|
|
self.assertEqual(3, route_track["segments"][0]["carrier"]["capacity"])
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
@ -715,6 +764,37 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
self.assertEqual("network-dijkstra-v1", result["algorithm"])
|
|
|
|
|
self.assertEqual("Routed", result["route_status"])
|
|
|
|
|
|
|
|
|
|
def test_auto_routing_respects_adjoining_duct_tolerance_option(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(44, 0, 20)],
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
)
|
|
|
|
|
routing_network.create_route_carrier(
|
|
|
|
|
doc,
|
|
|
|
|
[app.Vector(56, 0, 20), app.Vector(100, 0, 20)],
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
result = auto_routing.route_eplan_connection_between_terminals(
|
|
|
|
|
doc,
|
|
|
|
|
start,
|
|
|
|
|
end,
|
|
|
|
|
options={"adjoining_duct_tolerance": 15.0},
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
self.assertEqual("Routed", result["route_status"])
|
|
|
|
|
self.assertEqual(1, result["network"]["bridged_segments"])
|
|
|
|
|
|
|
|
|
|
def test_connect_point_to_network_replaces_bridged_edge_without_stale_reverse_edge(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
_terminal_objects, _wiring_objects, routing_network, _auto_routing = _reload_modules()
|
|
|
|
|
@ -851,6 +931,151 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
self.assertFalse(hasattr(cabinet, "QetRoutingSourceKind"))
|
|
|
|
|
self.assertFalse(hasattr(duct, "QetRoutingSourceKind"))
|
|
|
|
|
|
|
|
|
|
def test_auto_detect_support_surface_refreshes_routing_range_geometry(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, _auto_routing = _reload_modules()
|
|
|
|
|
doc = FakeDocument()
|
|
|
|
|
terminal_objects.ensure_root_group(doc, "project-1")
|
|
|
|
|
panel = doc.addObject("Part::Feature", "MountingPlateA")
|
|
|
|
|
panel.Label = "安装板A"
|
|
|
|
|
panel.Shape = FakeShape(FakeBoundBox(0, 120, 0, 5, 0, 100))
|
|
|
|
|
|
|
|
|
|
created = routing_network.create_surface_carriers_from_document(
|
|
|
|
|
doc,
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
spacing=60.0,
|
|
|
|
|
offset=5.0,
|
|
|
|
|
margin=0.0,
|
|
|
|
|
)
|
|
|
|
|
panel.Shape = FakeShape(FakeBoundBox(20, 140, 0, 5, 0, 100))
|
|
|
|
|
created_again = routing_network.create_surface_carriers_from_document(
|
|
|
|
|
doc,
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
spacing=60.0,
|
|
|
|
|
offset=5.0,
|
|
|
|
|
margin=0.0,
|
|
|
|
|
)
|
|
|
|
|
carriers = routing_network.collect_route_carriers(doc)
|
|
|
|
|
x_values = [
|
|
|
|
|
point.x
|
|
|
|
|
for carrier in carriers
|
|
|
|
|
if getattr(carrier, "QetRouteCarrierKind", "") == "RoutingRange"
|
|
|
|
|
for point in carrier.Points
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
self.assertEqual(6, len(created))
|
|
|
|
|
self.assertEqual(0, len(created_again))
|
|
|
|
|
self.assertEqual(6, len([carrier for carrier in carriers if carrier.QetRouteCarrierKind == "RoutingRange"]))
|
|
|
|
|
self.assertEqual(20.0, min(x_values))
|
|
|
|
|
self.assertEqual(140.0, max(x_values))
|
|
|
|
|
|
|
|
|
|
def test_auto_detect_support_surface_adds_missing_routing_range_lanes_after_resize(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, _auto_routing = _reload_modules()
|
|
|
|
|
doc = FakeDocument()
|
|
|
|
|
terminal_objects.ensure_root_group(doc, "project-1")
|
|
|
|
|
panel = doc.addObject("Part::Feature", "MountingPlateA")
|
|
|
|
|
panel.Label = "安装板A"
|
|
|
|
|
panel.Shape = FakeShape(FakeBoundBox(0, 120, 0, 5, 0, 100))
|
|
|
|
|
|
|
|
|
|
created = routing_network.create_surface_carriers_from_document(
|
|
|
|
|
doc,
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
spacing=60.0,
|
|
|
|
|
offset=5.0,
|
|
|
|
|
margin=0.0,
|
|
|
|
|
)
|
|
|
|
|
panel.Shape = FakeShape(FakeBoundBox(0, 180, 0, 5, 0, 120))
|
|
|
|
|
created_again = routing_network.create_surface_carriers_from_document(
|
|
|
|
|
doc,
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
spacing=60.0,
|
|
|
|
|
offset=5.0,
|
|
|
|
|
margin=0.0,
|
|
|
|
|
)
|
|
|
|
|
carriers = [
|
|
|
|
|
carrier
|
|
|
|
|
for carrier in routing_network.collect_route_carriers(doc)
|
|
|
|
|
if getattr(carrier, "QetRouteCarrierKind", "") == "RoutingRange"
|
|
|
|
|
]
|
|
|
|
|
x_values = [point.x for carrier in carriers for point in carrier.Points]
|
|
|
|
|
z_values = [point.z for carrier in carriers for point in carrier.Points]
|
|
|
|
|
|
|
|
|
|
self.assertEqual(6, len(created))
|
|
|
|
|
self.assertEqual(1, len(created_again))
|
|
|
|
|
self.assertEqual(7, len(carriers))
|
|
|
|
|
self.assertEqual(180.0, max(x_values))
|
|
|
|
|
self.assertEqual(120.0, max(z_values))
|
|
|
|
|
|
|
|
|
|
def test_auto_detect_support_surface_removes_stale_routing_range_lanes_after_resize(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, _auto_routing = _reload_modules()
|
|
|
|
|
doc = FakeDocument()
|
|
|
|
|
terminal_objects.ensure_root_group(doc, "project-1")
|
|
|
|
|
panel = doc.addObject("Part::Feature", "MountingPlateA")
|
|
|
|
|
panel.Label = "安装板A"
|
|
|
|
|
panel.Shape = FakeShape(FakeBoundBox(0, 120, 0, 5, 0, 100))
|
|
|
|
|
|
|
|
|
|
created = routing_network.create_surface_carriers_from_document(
|
|
|
|
|
doc,
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
spacing=60.0,
|
|
|
|
|
offset=5.0,
|
|
|
|
|
margin=0.0,
|
|
|
|
|
)
|
|
|
|
|
panel.Shape = FakeShape(FakeBoundBox(0, 60, 0, 5, 0, 60))
|
|
|
|
|
created_again = routing_network.create_surface_carriers_from_document(
|
|
|
|
|
doc,
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
spacing=60.0,
|
|
|
|
|
offset=5.0,
|
|
|
|
|
margin=0.0,
|
|
|
|
|
)
|
|
|
|
|
carriers = [
|
|
|
|
|
carrier
|
|
|
|
|
for carrier in routing_network.collect_route_carriers(doc)
|
|
|
|
|
if getattr(carrier, "QetRouteCarrierKind", "") == "RoutingRange"
|
|
|
|
|
]
|
|
|
|
|
x_values = [point.x for carrier in carriers for point in carrier.Points]
|
|
|
|
|
z_values = [point.z for carrier in carriers for point in carrier.Points]
|
|
|
|
|
|
|
|
|
|
self.assertEqual(6, len(created))
|
|
|
|
|
self.assertEqual(0, len(created_again))
|
|
|
|
|
self.assertEqual(4, len(carriers))
|
|
|
|
|
self.assertEqual(60.0, max(x_values))
|
|
|
|
|
self.assertEqual(60.0, max(z_values))
|
|
|
|
|
|
|
|
|
|
def test_auto_detect_support_surface_removes_carriers_and_obstacle_mode_when_source_invalid(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, _auto_routing = _reload_modules()
|
|
|
|
|
doc = FakeDocument()
|
|
|
|
|
terminal_objects.ensure_root_group(doc, "project-1")
|
|
|
|
|
panel = doc.addObject("Part::Feature", "MountingPlateA")
|
|
|
|
|
panel.Label = "安装板A"
|
|
|
|
|
panel.Shape = FakeShape(FakeBoundBox(0, 120, 0, 5, 0, 100))
|
|
|
|
|
|
|
|
|
|
created = routing_network.create_surface_carriers_from_document(
|
|
|
|
|
doc,
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
spacing=60.0,
|
|
|
|
|
offset=5.0,
|
|
|
|
|
margin=0.0,
|
|
|
|
|
)
|
|
|
|
|
panel.Shape = FakeShape(FakeBoundBox(0, 120, 0, 120, 0, 120))
|
|
|
|
|
created_again = routing_network.create_surface_carriers_from_document(
|
|
|
|
|
doc,
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
spacing=60.0,
|
|
|
|
|
offset=5.0,
|
|
|
|
|
margin=0.0,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
self.assertEqual(6, len(created))
|
|
|
|
|
self.assertEqual(0, len(created_again))
|
|
|
|
|
self.assertEqual([], routing_network.collect_route_carriers(doc))
|
|
|
|
|
self.assertEqual("", getattr(panel, "QetRoutingObstacleMode", ""))
|
|
|
|
|
self.assertEqual("", getattr(panel, "QetRouteCarrierNamesJson", ""))
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
@ -979,6 +1204,30 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
self.assertEqual([(20.0, 0.0, 10.0), (200.0, 0.0, 10.0)], [(p.x, p.y, p.z) for p in main.Points])
|
|
|
|
|
self.assertEqual([20.0, 20.0, 200.0, 200.0], open_end_x_values)
|
|
|
|
|
|
|
|
|
|
def test_generate_routing_paths_removes_generated_wire_duct_carriers_after_source_deleted(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")
|
|
|
|
|
duct = doc.addObject("Part::Feature", "WireDuctA")
|
|
|
|
|
duct.Label = "Wire Duct A"
|
|
|
|
|
duct.Shape = FakeShape(FakeBoundBox(0, 160, -10, 10, 0, 20))
|
|
|
|
|
|
|
|
|
|
auto_routing_panel.AutoRoutingController().generate_routing_paths()
|
|
|
|
|
generated = [
|
|
|
|
|
item
|
|
|
|
|
for item in routing_network.collect_route_carriers(doc)
|
|
|
|
|
if getattr(item, "QetRouteSourceName", "") == "WireDuctA"
|
|
|
|
|
]
|
|
|
|
|
doc.removeObject("WireDuctA")
|
|
|
|
|
auto_routing_panel.AutoRoutingController().generate_routing_paths()
|
|
|
|
|
|
|
|
|
|
self.assertEqual(3, len(generated))
|
|
|
|
|
self.assertEqual([], routing_network.collect_route_carriers(doc))
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
@ -1102,59 +1351,145 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
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):
|
|
|
|
|
def test_generate_routing_path_network_refreshes_wiring_cut_out_geometry(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
|
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, "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",
|
|
|
|
|
)
|
|
|
|
|
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.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)
|
|
|
|
|
first = auto_routing_panel.AutoRoutingController().generate_routing_paths()
|
|
|
|
|
cut_out.Shape = FakeShape(FakeBoundBox(65, 75, -2, 2, 15, 25))
|
|
|
|
|
second = 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.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"])
|
|
|
|
|
message = auto_routing.format_routing_path_network_report(result["diagnostic"])
|
|
|
|
|
self.assertIn("端子未接入", message)
|
|
|
|
|
self.assertIn("terminal-far", message)
|
|
|
|
|
self.assertIn("4900.0 mm", message)
|
|
|
|
|
self.assertIn("补一段线槽/辅助路径", message)
|
|
|
|
|
self.assertEqual(1, first["wiring_cut_out_carriers"])
|
|
|
|
|
self.assertEqual(0, second["wiring_cut_out_carriers"])
|
|
|
|
|
self.assertEqual(1, len(cut_out_carriers))
|
|
|
|
|
self.assertEqual([(70.0, -22.0, 20.0), (70.0, 22.0, 20.0)], [(p.x, p.y, p.z) for p in cut_out_carriers[0].Points])
|
|
|
|
|
|
|
|
|
|
def test_format_routing_path_network_report_tolerates_malformed_samples(self):
|
|
|
|
|
def test_wiring_cut_out_source_bridge_extension_controls_generated_path_length(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
_terminal_objects, _wiring_objects, _routing_network, auto_routing = _reload_modules()
|
|
|
|
|
diagnostic = {
|
|
|
|
|
"issues": [{"code": "external_issue", "count": 1}],
|
|
|
|
|
"unconnected_terminals": ["bad-terminal-sample"],
|
|
|
|
|
"possible_breaks": ["bad-break-sample"],
|
|
|
|
|
"isolated_components": ["bad-component-sample"],
|
|
|
|
|
}
|
|
|
|
|
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 = "过线孔A"
|
|
|
|
|
cut_out.Shape = FakeShape(FakeBoundBox(45, 55, -2, 2, 15, 25))
|
|
|
|
|
cut_out.QetWiringCutOutBridgeExtensionMm = 8.0
|
|
|
|
|
|
|
|
|
|
message = auto_routing.format_routing_path_network_report(diagnostic)
|
|
|
|
|
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.assertIn("布线路径网络检查发现", message)
|
|
|
|
|
self.assertIn("首个问题:external_issue", message)
|
|
|
|
|
self.assertEqual(1, len(cut_out_carriers))
|
|
|
|
|
self.assertIn("QetWiringCutOutBridgeExtensionMm", cut_out.PropertiesList)
|
|
|
|
|
self.assertEqual(8.0, cut_out.QetWiringCutOutBridgeExtensionMm)
|
|
|
|
|
self.assertEqual([(50.0, -10.0, 20.0), (50.0, 10.0, 20.0)], [(p.x, p.y, p.z) for p in cut_out_carriers[0].Points])
|
|
|
|
|
|
|
|
|
|
def test_format_routing_path_network_report_calls_out_wire_duct_break_point(self):
|
|
|
|
|
def test_wiring_cut_out_bridges_nearby_ducts_on_both_sides_of_panel(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")
|
|
|
|
|
start = _terminal(doc, terminal_objects, "TerminalStart", "terminal-start", app.Vector(0, -20, 0))
|
|
|
|
|
end = _terminal(doc, terminal_objects, "TerminalEnd", "terminal-end", app.Vector(100, 20, 0))
|
|
|
|
|
routing_network.create_route_carrier(
|
|
|
|
|
doc,
|
|
|
|
|
[app.Vector(0, 0, 20), app.Vector(100, 0, 20)],
|
|
|
|
|
[app.Vector(0, -20, 20), app.Vector(50, -20, 20)],
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
)
|
|
|
|
|
routing_network.create_route_carrier(
|
|
|
|
|
doc,
|
|
|
|
|
[app.Vector(50, 20, 20), app.Vector(100, 20, 20)],
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
)
|
|
|
|
|
cut_out = doc.addObject("Part::Feature", "WiringCutoutA")
|
|
|
|
|
cut_out.Label = "过线孔A"
|
|
|
|
|
cut_out.Shape = FakeShape(FakeBoundBox(45, 55, -2, 2, 15, 25))
|
|
|
|
|
|
|
|
|
|
auto_routing_panel.AutoRoutingController().generate_routing_paths()
|
|
|
|
|
result = auto_routing.route_eplan_connection_between_terminals(doc, start, end)
|
|
|
|
|
|
|
|
|
|
self.assertEqual("Routed", result["route_status"])
|
|
|
|
|
self.assertIn("WiringCutOut", result["route_track"]["carrier_kinds"])
|
|
|
|
|
self.assertEqual(0, result["collision_count"])
|
|
|
|
|
|
|
|
|
|
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"])
|
|
|
|
|
self.assertEqual(1000.0, payload["unconnected_terminals"][0]["terminal_access_max_distance_mm"])
|
|
|
|
|
message = auto_routing.format_routing_path_network_report(result["diagnostic"])
|
|
|
|
|
self.assertIn("端子未接入", message)
|
|
|
|
|
self.assertIn("terminal-far", message)
|
|
|
|
|
self.assertIn("4900.0 mm", message)
|
|
|
|
|
self.assertIn("端子接入最大距离 1000.0 mm", message)
|
|
|
|
|
self.assertIn("补一段线槽/辅助路径", message)
|
|
|
|
|
|
|
|
|
|
def test_format_routing_path_network_report_tolerates_malformed_samples(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
_terminal_objects, _wiring_objects, _routing_network, auto_routing = _reload_modules()
|
|
|
|
|
diagnostic = {
|
|
|
|
|
"issues": [{"code": "external_issue", "count": 1}],
|
|
|
|
|
"unconnected_terminals": ["bad-terminal-sample"],
|
|
|
|
|
"possible_breaks": ["bad-break-sample"],
|
|
|
|
|
"isolated_components": ["bad-component-sample"],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
message = auto_routing.format_routing_path_network_report(diagnostic)
|
|
|
|
|
|
|
|
|
|
self.assertIn("布线路径网络检查发现", message)
|
|
|
|
|
self.assertIn("首个问题:external_issue", message)
|
|
|
|
|
|
|
|
|
|
def test_format_routing_path_network_report_calls_out_wire_duct_break_point(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")
|
|
|
|
|
routing_network.create_route_carrier(
|
|
|
|
|
doc,
|
|
|
|
|
[app.Vector(0, 0, 20), app.Vector(100, 0, 20)],
|
|
|
|
|
label="线槽A",
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
@ -1168,6 +1503,58 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
self.assertIn("(0.0, 0.0, 20.0)", message)
|
|
|
|
|
self.assertIn("补齐相邻线槽", message)
|
|
|
|
|
|
|
|
|
|
def test_format_routing_path_network_report_includes_bridged_segment_count(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
_terminal_objects, _wiring_objects, _routing_network, auto_routing = _reload_modules()
|
|
|
|
|
diagnostic = {
|
|
|
|
|
"summary": {
|
|
|
|
|
"carriers": 5,
|
|
|
|
|
"segments": 6,
|
|
|
|
|
"nodes": 5,
|
|
|
|
|
"bridged_segments": 1,
|
|
|
|
|
},
|
|
|
|
|
"issues": [],
|
|
|
|
|
"ok": True,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
message = auto_routing.format_routing_path_network_report(diagnostic)
|
|
|
|
|
|
|
|
|
|
self.assertIn("桥接 1 段", message)
|
|
|
|
|
|
|
|
|
|
def test_check_routing_path_network_uses_adjoining_duct_tolerance_option(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")
|
|
|
|
|
for index, points in enumerate(
|
|
|
|
|
(
|
|
|
|
|
[app.Vector(0, 0, 20), app.Vector(44, 0, 20)],
|
|
|
|
|
[app.Vector(56, 0, 20), app.Vector(100, 0, 20)],
|
|
|
|
|
[app.Vector(100, 0, 20), app.Vector(100, 100, 20)],
|
|
|
|
|
[app.Vector(100, 100, 20), app.Vector(0, 100, 20)],
|
|
|
|
|
[app.Vector(0, 100, 20), app.Vector(0, 0, 20)],
|
|
|
|
|
),
|
|
|
|
|
start=1,
|
|
|
|
|
):
|
|
|
|
|
routing_network.create_route_carrier(
|
|
|
|
|
doc,
|
|
|
|
|
points,
|
|
|
|
|
label="线槽{0}".format(index),
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
result = auto_routing.check_eplan_routing_path_network(
|
|
|
|
|
doc,
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
options={"adjoining_duct_tolerance": 15.0},
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
self.assertTrue(result["ok"])
|
|
|
|
|
self.assertEqual(1, result["diagnostic"]["summary"]["bridged_segments"])
|
|
|
|
|
self.assertEqual([], result["diagnostic"]["possible_breaks"])
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
@ -1187,6 +1574,55 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
self.assertEqual(2, result["wire_duct_open_end_carriers"])
|
|
|
|
|
self.assertEqual(0, result["terminal_access_carriers"])
|
|
|
|
|
|
|
|
|
|
def test_auto_routing_controller_exposes_terminal_access_max_distance(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, "TerminalStart", "terminal-start", app.Vector(0, 0, 0))
|
|
|
|
|
duct = doc.addObject("Part::Feature", "WireDuctFar")
|
|
|
|
|
duct.Label = "Wire Duct Far"
|
|
|
|
|
duct.Shape = FakeShape(FakeBoundBox(5000, 5100, -5, 5, 15, 25))
|
|
|
|
|
|
|
|
|
|
controller = auto_routing_panel.AutoRoutingController()
|
|
|
|
|
controller.set_terminal_access_max_distance(6000.0)
|
|
|
|
|
result = controller.generate_routing_paths()
|
|
|
|
|
|
|
|
|
|
self.assertEqual(1, result["terminal_access_carriers"])
|
|
|
|
|
self.assertEqual(6000.0, controller.routing_options()["terminal_access_max_distance"])
|
|
|
|
|
|
|
|
|
|
def test_auto_routing_controller_exposes_terminal_exit_length(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, "TerminalStart", "terminal-start", app.Vector(50, 0, 0))
|
|
|
|
|
duct = doc.addObject("Part::Feature", "WireDuctA")
|
|
|
|
|
duct.Label = "Wire Duct A"
|
|
|
|
|
duct.Shape = FakeShape(FakeBoundBox(0, 100, -5, 5, 15, 25))
|
|
|
|
|
|
|
|
|
|
controller = auto_routing_panel.AutoRoutingController()
|
|
|
|
|
controller.set_terminal_exit_length(40.0)
|
|
|
|
|
controller.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))
|
|
|
|
|
self.assertEqual(
|
|
|
|
|
(50.0, 0.0, 40.0),
|
|
|
|
|
tuple(getattr(access_carriers[0].Points[0], axis) for axis in ("x", "y", "z")),
|
|
|
|
|
)
|
|
|
|
|
self.assertEqual(40.0, controller.routing_options()["terminal_exit_length"])
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
@ -1226,6 +1662,158 @@ 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_routing_controller_passes_adjoining_duct_tolerance_to_batch_route(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, "TerminalStart", "terminal-start", app.Vector(0, 0, 0))
|
|
|
|
|
_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(44, 0, 20)],
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
)
|
|
|
|
|
routing_network.create_route_carrier(
|
|
|
|
|
doc,
|
|
|
|
|
[app.Vector(56, 0, 20), app.Vector(100, 0, 20)],
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
)
|
|
|
|
|
app._qet_exchange_payload = {
|
|
|
|
|
"project_uuid": "project-1",
|
|
|
|
|
"wires": [
|
|
|
|
|
{
|
|
|
|
|
"wire_id": "wire-1",
|
|
|
|
|
"start_terminal_uuid": "terminal-start",
|
|
|
|
|
"end_terminal_uuid": "terminal-end",
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
report = auto_routing_panel.AutoRoutingController(
|
|
|
|
|
options={"adjoining_duct_tolerance": 15.0}
|
|
|
|
|
).route_eplan_connections()
|
|
|
|
|
|
|
|
|
|
self.assertEqual(1, report["routed"])
|
|
|
|
|
self.assertEqual(1, report["routes"][0]["network"]["bridged_segments"])
|
|
|
|
|
|
|
|
|
|
def test_auto_routing_controller_summary_uses_adjoining_duct_tolerance(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")
|
|
|
|
|
routing_network.create_route_carrier(
|
|
|
|
|
doc,
|
|
|
|
|
[app.Vector(0, 0, 20), app.Vector(44, 0, 20)],
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
)
|
|
|
|
|
routing_network.create_route_carrier(
|
|
|
|
|
doc,
|
|
|
|
|
[app.Vector(56, 0, 20), app.Vector(100, 0, 20)],
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
summary = auto_routing_panel.AutoRoutingController(
|
|
|
|
|
options={"adjoining_duct_tolerance": 15.0}
|
|
|
|
|
).summary()
|
|
|
|
|
|
|
|
|
|
self.assertIn("桥接:1", summary)
|
|
|
|
|
|
|
|
|
|
def test_auto_routing_controller_exposes_lane_spacing(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, "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))
|
|
|
|
|
routing_network.create_route_carrier(
|
|
|
|
|
doc,
|
|
|
|
|
[app.Vector(0, 0, 20), app.Vector(100, 0, 20)],
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
)
|
|
|
|
|
app._qet_exchange_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",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
controller = auto_routing_panel.AutoRoutingController()
|
|
|
|
|
controller.set_lane_spacing(14.0)
|
|
|
|
|
report = controller.route_eplan_connections()
|
|
|
|
|
|
|
|
|
|
self.assertEqual(14.0, controller.routing_options()["lane_spacing"])
|
|
|
|
|
self.assertEqual(14.0, report["routes"][1]["lane"]["spacing_mm"])
|
|
|
|
|
self.assertEqual(14.0, report["routes"][1]["lane"]["offset_mm"])
|
|
|
|
|
|
|
|
|
|
def test_auto_routing_controller_exposes_lane_axis(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, "TerminalStartA", "terminal-start-a", app.Vector(0, 0, 0))
|
|
|
|
|
_terminal(doc, terminal_objects, "TerminalEndA", "terminal-end-a", app.Vector(0, 100, 0))
|
|
|
|
|
_terminal(doc, terminal_objects, "TerminalStartB", "terminal-start-b", app.Vector(0, 0, 0))
|
|
|
|
|
_terminal(doc, terminal_objects, "TerminalEndB", "terminal-end-b", app.Vector(0, 100, 0))
|
|
|
|
|
routing_network.create_route_carrier(
|
|
|
|
|
doc,
|
|
|
|
|
[app.Vector(0, 0, 20), app.Vector(0, 100, 20)],
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
kind="WireDuct",
|
|
|
|
|
)
|
|
|
|
|
app._qet_exchange_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",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
controller = auto_routing_panel.AutoRoutingController()
|
|
|
|
|
controller.set_lane_spacing(8.0)
|
|
|
|
|
controller.set_lane_axis("z")
|
|
|
|
|
report = controller.route_eplan_connections()
|
|
|
|
|
|
|
|
|
|
self.assertEqual("z", controller.routing_options()["lane_axis"])
|
|
|
|
|
self.assertEqual("z", report["routes"][1]["lane"]["axis"])
|
|
|
|
|
self.assertEqual(8.0, report["routes"][1]["lane"]["offset_mm"])
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
@ -1367,6 +1955,26 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
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])
|
|
|
|
|
|
|
|
|
|
def test_wire_duct_source_end_margin_controls_generated_centerline_length(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, _auto_routing = _reload_modules()
|
|
|
|
|
doc = FakeDocument()
|
|
|
|
|
terminal_objects.ensure_root_group(doc, "project-1")
|
|
|
|
|
duct = doc.addObject("Part::Feature", "WireDuctA")
|
|
|
|
|
duct.Label = "线槽A"
|
|
|
|
|
duct.Shape = FakeShape(FakeBoundBox(0, 120, -10, 10, 5, 25))
|
|
|
|
|
duct.QetWireDuctEndMarginMm = 5.0
|
|
|
|
|
|
|
|
|
|
created = routing_network.create_wire_duct_carriers_from_document(
|
|
|
|
|
doc,
|
|
|
|
|
project_uuid="project-1",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
carrier = [item for item in created if item.QetRouteCarrierKind == "WireDuct"][0]
|
|
|
|
|
self.assertIn("QetWireDuctEndMarginMm", duct.PropertiesList)
|
|
|
|
|
self.assertEqual(5.0, duct.QetWireDuctEndMarginMm)
|
|
|
|
|
self.assertEqual([(5.0, 0.0, 15.0), (115.0, 0.0, 15.0)], [(p.x, p.y, p.z) for p in carrier.Points])
|
|
|
|
|
|
|
|
|
|
def test_wire_duct_source_capacity_is_copied_to_generated_carriers(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, _auto_routing = _reload_modules()
|
|
|
|
|
@ -1660,6 +2268,125 @@ class AutoRoutingTest(unittest.TestCase):
|
|
|
|
|
self.assertEqual(report["total_length_mm"], report["routes"][0]["length_mm"])
|
|
|
|
|
self.assertIn("总长度", message)
|
|
|
|
|
|
|
|
|
|
def test_route_report_includes_route_source_sample_when_available(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
_terminal_objects, _wiring_objects, _routing_network, auto_routing = _reload_modules()
|
|
|
|
|
report = {
|
|
|
|
|
"routed": 1,
|
|
|
|
|
"collision_warnings": 0,
|
|
|
|
|
"skipped_missing_terminal": 0,
|
|
|
|
|
"routes": [
|
|
|
|
|
{
|
|
|
|
|
"wire_label": "N4111",
|
|
|
|
|
"route_track": {
|
|
|
|
|
"segments": [
|
|
|
|
|
{"carrier": {"kind": "TerminalAccess", "source_label": "QF1:A1"}},
|
|
|
|
|
{"carrier": {"kind": "WireDuct", "source_label": "线槽A"}},
|
|
|
|
|
{"carrier": {"kind": "WiringCutOut", "source_label": "过线孔A"}},
|
|
|
|
|
{"carrier": {"kind": "WireDuct", "source_label": "线槽A"}},
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
message = auto_routing.format_eplan_connection_route_report(report)
|
|
|
|
|
|
|
|
|
|
self.assertIn("路径示例:导线 N4111 经过 QF1:A1、线槽A、过线孔A。", message)
|
|
|
|
|
|
|
|
|
|
def test_route_report_includes_network_bridge_and_blocked_segment_counts(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
_terminal_objects, _wiring_objects, _routing_network, auto_routing = _reload_modules()
|
|
|
|
|
report = {
|
|
|
|
|
"routed": 1,
|
|
|
|
|
"collision_warnings": 0,
|
|
|
|
|
"skipped_missing_terminal": 0,
|
|
|
|
|
"routes": [
|
|
|
|
|
{
|
|
|
|
|
"network": {
|
|
|
|
|
"bridged_segments": 1,
|
|
|
|
|
"blocked_segments": 2,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
message = auto_routing.format_eplan_connection_route_report(report)
|
|
|
|
|
|
|
|
|
|
self.assertIn("路径网络:自动桥接 1 段相邻线槽,避障屏蔽 2 段。", message)
|
|
|
|
|
|
|
|
|
|
def test_route_report_includes_parallel_lane_summary(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
_terminal_objects, _wiring_objects, _routing_network, auto_routing = _reload_modules()
|
|
|
|
|
report = {
|
|
|
|
|
"routed": 2,
|
|
|
|
|
"collision_warnings": 0,
|
|
|
|
|
"skipped_missing_terminal": 0,
|
|
|
|
|
"routes": [
|
|
|
|
|
{"lane": {"index": 0, "axis": "y", "spacing_mm": 10.0, "offset_mm": 0.0}},
|
|
|
|
|
{"lane": {"index": 2, "axis": "y", "spacing_mm": 10.0, "offset_mm": -10.0}},
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
message = auto_routing.format_eplan_connection_route_report(report)
|
|
|
|
|
|
|
|
|
|
self.assertIn("并行错位:最大 lane 2,间距 10.0 mm。", message)
|
|
|
|
|
|
|
|
|
|
def test_route_report_warns_when_parallel_lanes_exceed_track_capacity(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
_terminal_objects, _wiring_objects, _routing_network, auto_routing = _reload_modules()
|
|
|
|
|
report = {
|
|
|
|
|
"routed": 3,
|
|
|
|
|
"collision_warnings": 0,
|
|
|
|
|
"skipped_missing_terminal": 0,
|
|
|
|
|
"routes": [
|
|
|
|
|
{
|
|
|
|
|
"lane": {"index": 2, "spacing_mm": 10.0},
|
|
|
|
|
"route_track": {
|
|
|
|
|
"segments": [
|
|
|
|
|
{"carrier": {"kind": "WireDuct", "capacity": 2}},
|
|
|
|
|
{"carrier": {"kind": "WireDuct", "capacity": 4}},
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
message = auto_routing.format_eplan_connection_route_report(report)
|
|
|
|
|
|
|
|
|
|
self.assertIn("容量提示:最大并行线数 3,路径最小容量 2。", message)
|
|
|
|
|
|
|
|
|
|
def test_route_report_capacity_pressure_is_checked_per_route(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
_terminal_objects, _wiring_objects, _routing_network, auto_routing = _reload_modules()
|
|
|
|
|
report = {
|
|
|
|
|
"routed": 2,
|
|
|
|
|
"collision_warnings": 0,
|
|
|
|
|
"skipped_missing_terminal": 0,
|
|
|
|
|
"routes": [
|
|
|
|
|
{
|
|
|
|
|
"lane": {"index": 2, "spacing_mm": 10.0},
|
|
|
|
|
"route_track": {
|
|
|
|
|
"segments": [
|
|
|
|
|
{"carrier": {"kind": "WireDuct", "capacity": 4}},
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"lane": {"index": 0, "spacing_mm": 10.0},
|
|
|
|
|
"route_track": {
|
|
|
|
|
"segments": [
|
|
|
|
|
{"carrier": {"kind": "WireDuct", "capacity": 1}},
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
message = auto_routing.format_eplan_connection_route_report(report)
|
|
|
|
|
|
|
|
|
|
self.assertNotIn("容量提示", message)
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
|