Skip to content

PMS Agent

Role

The PMS Agent is a Phase 1 specialist responsible for the Planned Maintenance System. It retrieves maintenance history from PostgreSQL, calculates overdue status against Alfa Laval service intervals, and returns a structured maintenance report — ready for the IOT Manager’s cross-referencing step.


Component Mapping

When the IOT Manager dispatches a PMS task for a flagged parameter, the agent maps that parameter to the relevant physical components:

Flagged ParameterComponents Investigated
UV_INTENSITYLAMP, QUARTZ-SLEEVE, UVR-UNIT, CIP
FILTER_DPFILTER, FILTER-ELEMENT, BACKWASH-MOTOR
FLOW_RATEPUMP, VALVE, FLOW-SENSOR

Per-Component Process

For each component identified in the mapping above, the PMS Agent runs the following sequence:

  1. Last Service Lookup

    Query bwts_maintenance_log for the most recent service record matching this component type. Extract the service date, work description, and technician notes.

  2. Current Runtime

    Calculate the elapsed hours or days since the last service. For hour-based components (e.g., UV lamps), use the runtime counter from bwts_iot_telemetry. For calendar-based components (e.g., quartz sleeves), use the date difference.

  3. Overdue Check

    Compare the current runtime against the Alfa Laval maintenance schedule. Classify the component using the overdue classification system.

  4. Next Service Due

    Calculate when the next service is due based on the last service date and the scheduled interval. Flag if the next service falls within the current operating session.

  5. Service History — Last 3 Records

    Retrieve the three most recent service records for this component. Look for patterns: shortening intervals between services (accelerating wear), repeated issues, or incomplete repairs.

  6. Contextual Link to Alert

    Assess whether the component’s maintenance status could explain the current alert. For example: “UV lamp has 3,247 runtime hours against a 3,000-hour service interval — 352 hours overdue. This is consistent with the observed UV intensity decline.”


Overdue Classification

The PMS Agent classifies every component into one of four statuses:

StatusCriteria
OVERDUERuntime or calendar age exceeds the scheduled service interval
DUE SOONWithin 10% of the scheduled interval (e.g., lamp at 2,700+ hours of a 3,000-hour interval)
OKWell within the scheduled interval — no maintenance concern
NO RECORDNo service history found in the database for this component. Cannot determine status.

Maintenance Schedule

Service intervals from the Alfa Laval BWTS equipment manual:

ComponentIntervalBasisNotes
UV Lamp3,000 hoursRuntimeReplace when intensity drops below rated output or at 3,000h, whichever comes first
Quartz Sleeve90 daysCalendarClean or replace. Fouling accelerates in high-turbidity waters
CIP (Clean-In-Place)30 daysCalendarChemical cleaning cycle for the UV chamber and flow path
Filter Element6 monthsCalendarReplace or deep-clean. Check differential pressure trend for early clogging
Backwash Motor12 monthsCalendarInspect bearings, seals, and electrical connections
Flow Sensor12 monthsCalendarCalibration check. Drift can cause false flow-rate alerts
UVR Unit12 monthsCalendarFull unit inspection — electronics, wiring, sensor calibration
Pump Seals6 monthsCalendarInspect for leaks. Replace if wear marks visible
Valve Actuators12 monthsCalendarFunction test all valves. Check response time against spec

Output Format

Every PMS Agent response follows the PMS REPORT structure:

SectionContent
Per-Component StatusOne block per investigated component: last service, runtime, overdue classification, next service due, service history (last 3)
SummaryOverall maintenance posture — how many components are OVERDUE, DUE SOON, OK, or NO RECORD
Maintenance GapsComponents with NO RECORD status or suspiciously long gaps between services
Data GapsMissing or incomplete records, tables that could not be queried, known data-quality issues

Tools

graph LR
PMS["PMS Agent"] --> DQ["db_query.py\nPMS query templates"]
DQ --> PG[("PostgreSQL")]
subgraph "Tables"
T1["bwts_maintenance_log\nNo vessel_id column"]
T2["bwts_iot_predictions\ncamelCase — needs double-quotes"]
T3["bwts_iot_telemetry\nRuntime counters"]
end
PG --- T1
PG --- T2
PG --- T3
style PMS fill:#1a1a2e,stroke:#e94560,stroke-width:3px,color:#fff
style DQ fill:#16213e,stroke:#0f3460,stroke-width:2px,color:#fff
style PG fill:#0d1b2a,stroke:#1b9aaa,stroke-width:2px,color:#fff
style T1 fill:#0d1b2a,stroke:#1b9aaa,stroke-width:1px,color:#fff
style T2 fill:#0d1b2a,stroke:#1b9aaa,stroke-width:1px,color:#fff
style T3 fill:#0d1b2a,stroke:#1b9aaa,stroke-width:1px,color:#fff
TemplatePurpose
last_serviceRetrieve the most recent service record for a given component type
current_runtimeCalculate hours or days since the last service event
service_historyRetrieve the last N service records for a component (default: 3)
overdue_componentsList all components where runtime or calendar age exceeds the scheduled interval
component_by_equipmentList all components associated with a given equipment tag

What It Does NOT Do

No Scheduling Recommendations

Reports maintenance status (overdue, due soon, OK) but never recommends when to schedule the next service. Scheduling decisions belong to the fleet manager.

No Sensor Analysis

Does not analyse sensor trends, detect anomalies, or interpret telemetry data. That is the Data Analysis Agent’s responsibility. Uses telemetry tables only for runtime counters.

No Manual Search

Equipment manual lookups, documented-cause searches, and troubleshooting guides are the Manual Agent’s domain.

No Report Generation or Email

Writes its findings to the task system. Never generates client-facing reports, HTML documents, or sends emails. All external communication flows through the Report Agent.