fix(gui,cli,gcode): 元数据默认累加模式,格式化Unknown→未知
- BuildOptions.metadata_mode 默认 sum(累加预测和耗材用量) - CLI --metadata-mode 默认 sum - GUI 设置回退值默认 sum - format_duration/format_filament 空值返回 未知 而非 Unknown
This commit is contained in:
@@ -151,7 +151,7 @@ def create_parser() -> argparse.ArgumentParser:
|
||||
build.add_argument("--show-plate-number", action="store_true", help="每板号向 M73 R 值增加 100 小时。")
|
||||
# 行为开关
|
||||
build.add_argument("--no-swap-after-final", action="store_true", help="最后一块板后不执行换料 G-code。")
|
||||
build.add_argument("--metadata-mode", choices=("source", "sum"), default="source", help="如何写入 slice_info 的 prediction 和 weight。")
|
||||
build.add_argument("--metadata-mode", choices=("source", "sum"), default="sum", help="如何写入 slice_info 的 prediction 和 weight。")
|
||||
build.add_argument("--line-ending", choices=("lf", "crlf"), default="crlf", help="生成 G-code 的换行符。")
|
||||
build.add_argument("--zip-level", type=int, choices=range(1, 10), default=DEFAULT_ZIP_COMPRESS_LEVEL, metavar="1-9", help="输出 3MF 的 zlib-ng Deflate 压缩级别。默认值:7。")
|
||||
build.add_argument("--no-preview-label", action="store_true", help="不重写预览图标签/合成图。")
|
||||
|
||||
@@ -117,10 +117,10 @@ def format_duration(seconds: float | None) -> str:
|
||||
seconds: 秒数,可为 None。
|
||||
|
||||
返回:
|
||||
格式化后的时间字符串,如 "2h 30m"、"5m 20s"、"45s",未知则返回 "Unknown"。
|
||||
格式化后的时间字符串,如 "2h 30m"、"5m 20s"、"45s",未知则返回 "未知"。
|
||||
"""
|
||||
if seconds is None:
|
||||
return "Unknown"
|
||||
return "未知"
|
||||
total = max(0, int(round(seconds)))
|
||||
hours, rem = divmod(total, 3600)
|
||||
minutes, secs = divmod(rem, 60)
|
||||
@@ -139,10 +139,10 @@ def format_filament(weight_grams: float | None, used_m: float | None = None) ->
|
||||
used_m: 耗材使用长度(米),可为 None。
|
||||
|
||||
返回:
|
||||
格式化后的耗材信息字符串,未知则返回 "Unknown"。
|
||||
格式化后的耗材信息字符串,未知则返回 "未知"。
|
||||
"""
|
||||
if weight_grams is None and used_m is None:
|
||||
return "Unknown"
|
||||
return "未知"
|
||||
parts: list[str] = []
|
||||
if weight_grams is not None:
|
||||
parts.append(f"{weight_grams:.2f} g")
|
||||
|
||||
@@ -738,7 +738,7 @@ class MainWindow(QMainWindow):
|
||||
self.skip_duplicates_check.setChecked(bool(options.get("skip_duplicates", True)))
|
||||
self.output_dir_edit.setText(str(options.get("output_directory", "")))
|
||||
self.output_name_edit.setText(str(options.get("output_filename_rule", DEFAULT_OUTPUT_PATTERN)))
|
||||
metadata_mode = options.get("metadata_mode", "source")
|
||||
metadata_mode = options.get("metadata_mode", "sum")
|
||||
metadata_index = self.metadata_combo.findData(metadata_mode)
|
||||
if metadata_index >= 0:
|
||||
self.metadata_combo.setCurrentIndex(metadata_index)
|
||||
|
||||
@@ -93,7 +93,7 @@ class BuildOptions:
|
||||
wait_after_eject_seconds: int = 45 # 推板完成后等待时间
|
||||
show_plate_number: bool = True # 是否显示板件编号到屏幕
|
||||
swap_after_final: bool = True # 最后一块是否也换板
|
||||
metadata_mode: MetadataMode = "source" # 元数据计算模式
|
||||
metadata_mode: MetadataMode = "sum" # 元数据计算模式
|
||||
line_ending: LineEnding = "crlf" # 输出换行符
|
||||
add_preview_label: bool = True # 是否添加预览注释
|
||||
apply_gcode_patches: bool = True # 是否启用 G-code 补丁
|
||||
|
||||
Reference in New Issue
Block a user