|
|
|
@ -71,8 +71,19 @@ def _selection_ex():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AutoRoutingController:
|
|
|
|
class AutoRoutingController:
|
|
|
|
def __init__(self):
|
|
|
|
def __init__(self, options=None):
|
|
|
|
self.last_report = None
|
|
|
|
self.last_report = None
|
|
|
|
|
|
|
|
self.options = dict(options or {})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def routing_options(self):
|
|
|
|
|
|
|
|
return dict(self.options)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_adjoining_duct_tolerance(self, value):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
tolerance = float(value)
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
|
|
|
|
tolerance = RoutingNetwork.DEFAULT_ADJOINING_DUCT_TOLERANCE
|
|
|
|
|
|
|
|
self.options["adjoining_duct_tolerance"] = max(tolerance, 0.0)
|
|
|
|
|
|
|
|
|
|
|
|
def summary(self):
|
|
|
|
def summary(self):
|
|
|
|
doc = _active_document()
|
|
|
|
doc = _active_document()
|
|
|
|
@ -109,6 +120,7 @@ class AutoRoutingController:
|
|
|
|
self.last_report = AutoRouting.generate_eplan_routing_path_network(
|
|
|
|
self.last_report = AutoRouting.generate_eplan_routing_path_network(
|
|
|
|
doc,
|
|
|
|
doc,
|
|
|
|
project_uuid=project_uuid,
|
|
|
|
project_uuid=project_uuid,
|
|
|
|
|
|
|
|
options=self.routing_options(),
|
|
|
|
selection_ex=selection_ex,
|
|
|
|
selection_ex=selection_ex,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
self.last_report["source_mode"] = source_mode
|
|
|
|
self.last_report["source_mode"] = source_mode
|
|
|
|
@ -120,6 +132,7 @@ class AutoRoutingController:
|
|
|
|
self.last_report = AutoRouting.check_eplan_routing_path_network(
|
|
|
|
self.last_report = AutoRouting.check_eplan_routing_path_network(
|
|
|
|
doc,
|
|
|
|
doc,
|
|
|
|
project_uuid=project_uuid,
|
|
|
|
project_uuid=project_uuid,
|
|
|
|
|
|
|
|
options=self.routing_options(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
return self.last_report
|
|
|
|
return self.last_report
|
|
|
|
|
|
|
|
|
|
|
|
@ -141,6 +154,7 @@ class AutoRoutingController:
|
|
|
|
report = AutoRouting.route_eplan_connections(
|
|
|
|
report = AutoRouting.route_eplan_connections(
|
|
|
|
doc,
|
|
|
|
doc,
|
|
|
|
payload=payload if isinstance(payload, dict) and payload.get("wires") else None,
|
|
|
|
payload=payload if isinstance(payload, dict) and payload.get("wires") else None,
|
|
|
|
|
|
|
|
options=self.routing_options(),
|
|
|
|
project_uuid=project_uuid,
|
|
|
|
project_uuid=project_uuid,
|
|
|
|
update_network=True,
|
|
|
|
update_network=True,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
@ -183,6 +197,22 @@ class AutoRoutingTaskPanel:
|
|
|
|
|
|
|
|
|
|
|
|
layout = QtWidgets.QVBoxLayout(self.form)
|
|
|
|
layout = QtWidgets.QVBoxLayout(self.form)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
options_layout = QtWidgets.QHBoxLayout()
|
|
|
|
|
|
|
|
options_layout.addWidget(QtWidgets.QLabel("线槽桥接容差 mm"))
|
|
|
|
|
|
|
|
self.adjoining_duct_tolerance_spin = QtWidgets.QDoubleSpinBox()
|
|
|
|
|
|
|
|
self.adjoining_duct_tolerance_spin.setRange(0.0, 1000.0)
|
|
|
|
|
|
|
|
self.adjoining_duct_tolerance_spin.setDecimals(1)
|
|
|
|
|
|
|
|
self.adjoining_duct_tolerance_spin.setSingleStep(1.0)
|
|
|
|
|
|
|
|
self.adjoining_duct_tolerance_spin.setValue(
|
|
|
|
|
|
|
|
float(
|
|
|
|
|
|
|
|
self.controller.routing_options().get(
|
|
|
|
|
|
|
|
"adjoining_duct_tolerance",
|
|
|
|
|
|
|
|
RoutingNetwork.DEFAULT_ADJOINING_DUCT_TOLERANCE,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
options_layout.addWidget(self.adjoining_duct_tolerance_spin)
|
|
|
|
|
|
|
|
|
|
|
|
self.generate_layout_button = QtWidgets.QPushButton("准备布线布局空间")
|
|
|
|
self.generate_layout_button = QtWidgets.QPushButton("准备布线布局空间")
|
|
|
|
self.generate_layout_button.setToolTip(
|
|
|
|
self.generate_layout_button.setToolTip(
|
|
|
|
"按 EPLAN 布局空间语义识别线槽、安装面、工程端子和障碍处理方式,不生成导线。"
|
|
|
|
"按 EPLAN 布局空间语义识别线槽、安装面、工程端子和障碍处理方式,不生成导线。"
|
|
|
|
@ -221,6 +251,7 @@ class AutoRoutingTaskPanel:
|
|
|
|
):
|
|
|
|
):
|
|
|
|
layout.addWidget(widget)
|
|
|
|
layout.addWidget(widget)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
layout.addLayout(options_layout)
|
|
|
|
layout.addWidget(self.status_label)
|
|
|
|
layout.addWidget(self.status_label)
|
|
|
|
|
|
|
|
|
|
|
|
self.generate_paths_button.clicked.connect(self.generate_routing_paths)
|
|
|
|
self.generate_paths_button.clicked.connect(self.generate_routing_paths)
|
|
|
|
@ -247,8 +278,12 @@ class AutoRoutingTaskPanel:
|
|
|
|
self.status_label.setText(message)
|
|
|
|
self.status_label.setText(message)
|
|
|
|
_console_error(message)
|
|
|
|
_console_error(message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _sync_options_from_widgets(self):
|
|
|
|
|
|
|
|
self.controller.set_adjoining_duct_tolerance(self.adjoining_duct_tolerance_spin.value())
|
|
|
|
|
|
|
|
|
|
|
|
def generate_routing_paths(self):
|
|
|
|
def generate_routing_paths(self):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
|
|
|
|
self._sync_options_from_widgets()
|
|
|
|
result = self.controller.generate_routing_paths()
|
|
|
|
result = self.controller.generate_routing_paths()
|
|
|
|
wire_ducts = result.get("wire_duct_carriers", 0)
|
|
|
|
wire_ducts = result.get("wire_duct_carriers", 0)
|
|
|
|
surfaces = result.get("surface_carriers", 0)
|
|
|
|
surfaces = result.get("surface_carriers", 0)
|
|
|
|
@ -274,6 +309,7 @@ class AutoRoutingTaskPanel:
|
|
|
|
|
|
|
|
|
|
|
|
def check_routing_path_network(self):
|
|
|
|
def check_routing_path_network(self):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
|
|
|
|
self._sync_options_from_widgets()
|
|
|
|
result = self.controller.check_routing_path_network()
|
|
|
|
result = self.controller.check_routing_path_network()
|
|
|
|
diagnostic = result.get("diagnostic", {}) if isinstance(result.get("diagnostic", {}), dict) else {}
|
|
|
|
diagnostic = result.get("diagnostic", {}) if isinstance(result.get("diagnostic", {}), dict) else {}
|
|
|
|
self._set_status(
|
|
|
|
self._set_status(
|
|
|
|
@ -310,6 +346,7 @@ class AutoRoutingTaskPanel:
|
|
|
|
|
|
|
|
|
|
|
|
def route_eplan_connections(self):
|
|
|
|
def route_eplan_connections(self):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
|
|
|
|
self._sync_options_from_widgets()
|
|
|
|
report = self.controller.route_eplan_connections()
|
|
|
|
report = self.controller.route_eplan_connections()
|
|
|
|
self._set_status(AutoRouting.format_eplan_connection_route_report(report))
|
|
|
|
self._set_status(AutoRouting.format_eplan_connection_route_report(report))
|
|
|
|
except Exception as exc:
|
|
|
|
except Exception as exc:
|
|
|
|
|