feat: add selectable demo flow tasks
This commit is contained in:
@@ -155,23 +155,53 @@ def main() -> int:
|
||||
offset_right = 700.0 * _math.tan(_math.radians(raw_right)) if 'raw_right' in dir() else 700.0 * _math.tan(_math.radians(theta_right))
|
||||
offset_ref = 375.0 * _math.tan(_math.radians(raw_ref)) if 'raw_ref' in dir() else 375.0 * _math.tan(_math.radians(theta_ref))
|
||||
|
||||
measurements = [
|
||||
{
|
||||
inspection_object = str((payload.get("context") or {}).get("inspectionObject") or "unknown")
|
||||
longitudinal_task_no = "10" if inspection_object == "head" else "12" if inspection_object == "middle" else None
|
||||
reference_task_no = "8" if inspection_object == "head" else "9" if inspection_object == "middle" else None
|
||||
raw_selected_task_nos = config.get("demoTaskNos")
|
||||
selected_task_nos = (
|
||||
{str(int(value)) for value in raw_selected_task_nos if isinstance(value, (int, float)) and float(value).is_integer()}
|
||||
if isinstance(raw_selected_task_nos, list)
|
||||
else None
|
||||
)
|
||||
|
||||
def _selected(task_no: str | None) -> bool:
|
||||
return selected_task_nos is None or (task_no is not None and task_no in selected_task_nos)
|
||||
|
||||
measurements = []
|
||||
if _selected(longitudinal_task_no):
|
||||
longitudinal_measurement = {
|
||||
"name": "车钩面板距纵向中心的右偏转角",
|
||||
"value": round(offset_right, 6),
|
||||
"unit": "mm",
|
||||
"baseline": 700.0,
|
||||
"tolerance": 1.0,
|
||||
"status": _status_for(offset_right, 1.0),
|
||||
},
|
||||
{
|
||||
}
|
||||
if longitudinal_task_no:
|
||||
longitudinal_measurement.update({
|
||||
"taskNo": longitudinal_task_no,
|
||||
"metricCode": "coupler.longitudinal_right_offset",
|
||||
"name": "纵向中心右偏转",
|
||||
})
|
||||
measurements.append(longitudinal_measurement)
|
||||
if _selected(reference_task_no):
|
||||
reference_measurement = {
|
||||
"name": "车钩面板距参考面的右偏转角",
|
||||
"value": round(offset_ref, 6),
|
||||
"unit": "mm",
|
||||
"baseline": 375.0,
|
||||
"tolerance": 0.8,
|
||||
"status": _status_for(offset_ref, 0.8),
|
||||
},
|
||||
}
|
||||
if reference_task_no:
|
||||
reference_measurement.update({
|
||||
"taskNo": reference_task_no,
|
||||
"metricCode": "coupler.reference_right_offset",
|
||||
"name": "参考面右偏转",
|
||||
})
|
||||
measurements.append(reference_measurement)
|
||||
measurements.extend([
|
||||
{
|
||||
"name": "最大 x 偏差 dx_y",
|
||||
"value": dx_y,
|
||||
@@ -198,7 +228,7 @@ def main() -> int:
|
||||
"unit": "mm",
|
||||
"status": "info",
|
||||
},
|
||||
]
|
||||
])
|
||||
|
||||
payload_out = {
|
||||
"schemaVersion": getattr(result, "schema_version", "1.1"),
|
||||
|
||||
Reference in New Issue
Block a user