Skip to main content
Loading navigation
Back to prompt library

Build an OPC UA Shift Handover Telemetry and Event Packager — implementation

Linked challenge: Build an OPC UA Shift Handover Telemetry and Event Packager

Prompt source

implementation104 lines11 sectionsNo variables1 code block
## Build
Extract production counts, alarm histories, and operating states from open62541 OPC UA server logs. Compile a structured shift handover digest highlighting unresolved interlocks for incoming operating personnel.

## User
Manufacturing Shift Supervisor

## Workflow
1. Read open62541 telemetry summaries and discrete node state change records from the shift operating window.
2. Detect abnormal stop events, recurrent high-priority alarm nodes, and incomplete production lots.
3. Aggregate shift metrics including gross production tally, machine availability percentage, and unresolved interlocks.
4. Format structured shift handover dossier for incoming operator sign-off and computerized log ingestion.

## Interface
CLI and browser-based shift handover dashboard with chronological alarm logs and sign-off confirmation controls.

## Data
Clone the open62541 repository and run local mock server examples to emit simulated machine telemetry and event node records into JSON.
Starter examples below are synthetic. They are not downloaded records.

## Source
[open62541 OPC UA](https://raw.githubusercontent.com/open62541/open62541/master/README.md)
References the open62541 C-based OPC UA information model and event handling node architecture described in the repository documentation.

## Tools
pydantic-ai, fastapi, pytest.
Pydantic AI enforces type validation across complex OPC UA node telemetry structures and handover summary schemas.
Requires hosted Claude API or capable local model with strict structured output schema enforcement.

## Deliverables
Submit runnable source, pinned dependencies, setup commands, a working interface, example outputs, and a recorded end-to-end demo. Include tests and an action log.

## Acceptance
- Parses simulated open62541 node event JSON records without schema violations.
- Accurately extracts all active alarm nodes with severities exceeding critical limits.
- Produces valid JSON handover reports containing machine availability and operator sign-off status.
- Flags incomplete shifts where production counts fail to meet baseline plan targets.

## Starter Examples
```json
[
  {
    "input": {
      "shift_id": "SHIFT-2025-05-A",
      "cell_id": "CELL-PACK-01",
      "opc_nodes": [
        {
          "node_id": "ns=2;s=MachineState",
          "value": "RUNNING",
          "timestamp": "2025-05-10T06:00:00Z"
        },
        {
          "node_id": "ns=2;s=AlarmActive",
          "value": true,
          "severity": 750,
          "timestamp": "2025-05-10T13:45:00Z"
        },
        {
          "node_id": "ns=2;s=GoodPartsCount",
          "value": 1420,
          "timestamp": "2025-05-10T14:00:00Z"
        }
      ],
      "target_count": 1500
    },
    "expected_output": {
      "shift_id": "SHIFT-2025-05-A",
      "cell_id": "CELL-PACK-01",
      "handover_status": "ACTION_REQUIRED",
      "unresolved_alarms": [
        {
          "node_id": "ns=2;s=AlarmActive",
          "severity": 750
        }
      ],
      "metrics": {
        "good_parts": 1420,
        "target_delta": -80,
        "completion_pct": 94.67
      },
      "sign_off_ready": false
    }
  },
  {
    "input": {
      "shift_id": "SHIFT-2025-05-B",
      "cell_id": "CELL-PACK-02",
      "opc_nodes": [
        {
          "node_id": "ns=2;s=MachineState",
          "value": "STOPPED",
          "timestamp": "2025-05-10T14:00:00Z"
        }
      ],
      "target_count": 1000
    },
    "expected_output": {
      "shift_id": "SHIFT-2025-05-B",
      "cell_id": "CELL-PACK-02",
      "handover_status": "INCOMPLETE_DATA",
      "unresolved_alarms": [],
      "metrics": {
        "good_parts": 0,
        "target_delta": -1000,
        "completion_pct": 0
      },
      "sign_off_ready": false
    }
  }
]
```

## Safety
Ensures all handover records remain advisory and prevents automated equipment restart without manual operator verification.
Use mock external writes. Require human review before any real deployment.