Metering station monitoring
An information system that watches crude-oil metering stations for a pipeline operator's metrologists. I built most of its reports and the inspection documents module.
34
SSRS reports I authored, of 73 in the system
How it was measured
Report files whose first version I committed, counted in the final reporting repository.
54%
of commits to the reporting repository
How it was measured
My non-merge commits in the SSRS reporting repository, Oct 2020 - Jul 2022: 229 of 424.
94
validation messages in the inspection act import
How it was measured
Distinct error and status codes in the Excel import of inspection acts, each logged with file name and row.
On this page
Context
Crude oil changes hands at metering stations: flow meters, density and quality analysers and a test lab measure every transfer. For a pipeline operator these readings are commercial data, and every instrument is under metrological control, with schedules for maintenance, checks and verification.
The system watches these stations for the operator's metrologists. Sensor data flows into a PI System, analysis services turn it into events, and reports and a portal show them by subsidiary, region, custody transfer point and station. I worked on it at CROC, mostly on reports and on the inspection documents module.
Problem & constraints
- Maintenance, checks and verification follow regulated schedules, and every violation has to be flagged per instrument and station.
- Time series live in PI and everything else in SQL Server. Reports have to join the two.
- Data quality: missing data, non-numeric values and stations with uneven flow.
- A deep hierarchy and many filters: subsidiary, region, transfer point, station, instrument. Some reports take 21 parameters.
- Inspection acts come from the field as Excel workbooks and must match reference data. The output must be ready to print as official forms.
Architecture
Scroll the diagram sideways
Key decisions
Volume-weighted figures in the station analysis report
- Context
- The report compares line and station flow, mass and density by month and year. Plain averages of percentages misstate stations with uneven flow.
- Options considered
- A: an arithmetic mean of hourly deviations. B: weight by volume: density as Σ(ρ·Q) / ΣQ, relative error as Σ abs(ΔQ) / ΣQ.
- Trade-offs
- B carries flow values through every level of aggregation and needs guards against zero flow. The query grew to about 690 lines.
- Outcome
- Chose B. The report also highlights deviations above 10% and links to check and verification records.
Validate the whole act, then save it once
- Context
- Inspection commissions send acts as Excel workbooks with four sheets. Wrong names, dates or duplicate rows must not leave half an act in the database.
- Options considered
- A: insert row by row and stop at the first error. B: read columns by name, validate every sheet in memory, save everything in one call and log every error with sheet and row.
- Trade-offs
- B keeps the whole act in memory and needs a large set of error codes: 94. In return users see every problem at once, and the database never holds a partial act.
- Outcome
- Chose B. Users can also download a template prefilled for their transfer point and check type, to avoid matching errors.
One template per document, as Excel, Word or PDF
- Context
- Acts, plans and schedules are official forms. Users need them as editable files and as PDF.
- Options considered
- A: build the PDF separately from the templates. B: keep one Excel or Word template per document and save it as xlsx, doc or PDF.
- Trade-offs
- B ties output to one document library, and conditional formatting had to move into code. In return every format comes from one template.
- Outcome
- Chose B. I added the PDF path, multi-sheet export and 14 Excel templates, and generated documents can be attached to a plan or schedule.
Results
- 34 SSRS reports across all five report areas, including 13 of the 17 inspection reports.
- The station operation analysis report, with volume-weighted monthly and yearly figures.
- Excel import of inspection acts: prefilled template download, 94 validation messages, an import log and status.
- Excel, Word and PDF export of acts, plans, schedules and the acknowledgement journal.
- PDF export of PI Vision station schematics drawn in Visio or Inkscape.
- A config-driven GIS integration job with parallel attribute reads, and monitoring metrics for the input validation service.
What I'd do differently
- I would keep report queries in versioned views in the reports database, not inside report files. My reports carried about 4,650 lines of SQL in RDL XML, which was hard to review and reuse.
- I would split the act importer into a validator per sheet and test it on sample workbooks. It grew into one 1,674-line class with no tests of its own.
- In the GIS job I would read each station's attributes in one bulk call instead of parallel loops with shared state.