|
|
|
@ -214,6 +214,18 @@ def _device_label_text(display_tag, instance_id, element_uuid):
|
|
|
|
return "QET Device"
|
|
|
|
return "QET Device"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _device_warning_subject(display_tag, element_uuid):
|
|
|
|
|
|
|
|
label = (display_tag or "").strip()
|
|
|
|
|
|
|
|
element_uuid = (element_uuid or "").strip()
|
|
|
|
|
|
|
|
if label and element_uuid:
|
|
|
|
|
|
|
|
return "设备 {0} ({1})".format(label, element_uuid)
|
|
|
|
|
|
|
|
if label:
|
|
|
|
|
|
|
|
return "设备 {0}".format(label)
|
|
|
|
|
|
|
|
if element_uuid:
|
|
|
|
|
|
|
|
return "设备 {0}".format(element_uuid)
|
|
|
|
|
|
|
|
return "设备"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _ensure_device_group(doc, root_group, element_uuid, instance_id, model_path, display_tag, layout_index):
|
|
|
|
def _ensure_device_group(doc, root_group, element_uuid, instance_id, model_path, display_tag, layout_index):
|
|
|
|
created_now = False
|
|
|
|
created_now = False
|
|
|
|
device_group = _find_device_group(doc, element_uuid)
|
|
|
|
device_group = _find_device_group(doc, element_uuid)
|
|
|
|
@ -438,21 +450,29 @@ def import_devices_from_payload(payload, scene_path=""):
|
|
|
|
if not resolved_model_path:
|
|
|
|
if not resolved_model_path:
|
|
|
|
report["skipped_missing_model"] += 1
|
|
|
|
report["skipped_missing_model"] += 1
|
|
|
|
report["warnings"].append(
|
|
|
|
report["warnings"].append(
|
|
|
|
"设备 {0} 缺少 resolved_model_path,已跳过。".format(element_uuid)
|
|
|
|
"{0} 缺少 resolved_model_path,已跳过。".format(
|
|
|
|
|
|
|
|
_device_warning_subject(display_tag, element_uuid)
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
if not os.path.isfile(resolved_model_path):
|
|
|
|
if not os.path.isfile(resolved_model_path):
|
|
|
|
report["skipped_missing_file"] += 1
|
|
|
|
report["skipped_missing_file"] += 1
|
|
|
|
report["warnings"].append(
|
|
|
|
report["warnings"].append(
|
|
|
|
"设备 {0} 的模型文件不存在:{1}".format(element_uuid, resolved_model_path)
|
|
|
|
"{0} 的模型文件不存在:{1}".format(
|
|
|
|
|
|
|
|
_device_warning_subject(display_tag, element_uuid),
|
|
|
|
|
|
|
|
resolved_model_path,
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
if not _supported_for_import(resolved_model_path):
|
|
|
|
if not _supported_for_import(resolved_model_path):
|
|
|
|
report["skipped_unsupported_format"] += 1
|
|
|
|
report["skipped_unsupported_format"] += 1
|
|
|
|
report["warnings"].append(
|
|
|
|
report["warnings"].append(
|
|
|
|
"设备 {0} 的模型格式暂不支持:{1}".format(element_uuid, resolved_model_path)
|
|
|
|
"{0} 的模型格式暂不支持:{1}".format(
|
|
|
|
|
|
|
|
_device_warning_subject(display_tag, element_uuid),
|
|
|
|
|
|
|
|
resolved_model_path,
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
@ -481,7 +501,10 @@ def import_devices_from_payload(payload, scene_path=""):
|
|
|
|
except Exception as exc:
|
|
|
|
except Exception as exc:
|
|
|
|
report["skipped_import_error"] += 1
|
|
|
|
report["skipped_import_error"] += 1
|
|
|
|
report["warnings"].append(
|
|
|
|
report["warnings"].append(
|
|
|
|
"设备 {0} 导入失败:{1}".format(element_uuid, exc)
|
|
|
|
"{0} 导入失败:{1}".format(
|
|
|
|
|
|
|
|
_device_warning_subject(display_tag, element_uuid),
|
|
|
|
|
|
|
|
exc,
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
_append_debug_log(
|
|
|
|
_append_debug_log(
|
|
|
|
"DeviceImport import failed for element_uuid={0}: {1}".format(
|
|
|
|
"DeviceImport import failed for element_uuid={0}: {1}".format(
|
|
|
|
|