|
|
|
|
@ -281,6 +281,34 @@ 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_network_eplan_connection_route_offsets_lane_by_route_index(self):
|
|
|
|
|
_install_fake_freecad()
|
|
|
|
|
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()
|
|
|
|
|
|