Files
UA-.NETStandard/samples/PumpDeviceIntegrationServer/PumpDatasheet.cs
Marc Schier a6a5275006 Add a PumpX-2000 datasheet and diagrams to the pump sample (#4138)
# Description

The `PumpDeviceIntegrationServer` sample simulates OPC 40223 pumps but
had no product documentation, a thin nameplate, and a duty point that
was not physically self-consistent. This PR gives the sample an
**official-style product datasheet** for its simulated asset and aligns
the server to it, so the document and the running address space cannot
drift apart.

### New: `samples/PumpDeviceIntegrationServer/DATASHEET.md`

A vendor-style datasheet for the fictitious *SimPump Corp PumpX-2000*
(clearly marked as a simulated device):

- Nameplate table mapped to OPC UA browse paths **and namespaces** (DI /
Machinery / Pumps)
- Best-efficiency duty point, characteristic curves and a performance
table
- Operating limits, motor / materials / dimensions data
- Instrument list (tag → browse path → unit → `EURange`) and a Mermaid
process schematic
- Alarm trip points and the deterministic simulation profile

### Server aligned to the datasheet

- `PumpDatasheet.cs` — the datasheet expressed as compile-time
constants.
- `MaterialiseNameplate` — materialises the 19 optional identification
properties through the generator-emitted `AddXxx(context)` helpers, so
each carries the browse name, namespace and DataType declared by the
model (21 nameplate fields in total per pump).
- `WithIdentification` now assigns the full datasheet nameplate to
**every** simulated unit. Product-level fields are shared; unit-level
fields (`SerialNumber`, `AssetId`, `ComponentName`, `Location`,
`FabricationNumber`) are derived from the pump number, so `--pumps N`
yields a consistent nameplate for each instance.
- **Simulation rebuilt around the datasheet curves.** Volumetric flow is
the only independent variable; differential pressure, mass flow,
efficiency and shaft power are derived from `H(Q) = 32 − 0.0104·Q²`,
`η(Q) = 72·(1 − 0.6·((Q−25)/25)²)` and `P = ρ·g·Q·H/η`, so `P = Δp·Q/η`
holds at every tick. Previously every measurement was an independent
sine and the sample published 5 kW of shaft power for 0.05 kg/s at 2 bar
Δp.
- `EURange` values now come from the datasheet; `OverTempAlarm` reports
the `BearingTemperature` chain (the correct `SourceNode` for an alarm
whose limits are in Kelvin) rather than a boolean; `Cavitation` and
`MotorOverheat` are derived from suction level and bearing temperature
with hysteresis instead of `tick % n`.

### Diagrams

The sample README gains a simulated-device summary, a link to the
datasheet, and three Mermaid diagrams: **address space**, **startup /
hosting sequence**, and **simulation + alarm dataflow**.

### Drift protection

`PumpDatasheetConformanceTests` pins the nameplate, engineering ranges,
trip points, published-value envelope and hydraulic consistency against
the datasheet, and the exact pump node-surface baseline in
`PumpInstanceNodeIdRegressionTests` covers the new identification
properties.

No changes to `src/` — this is sample, test and documentation only.

### Rebased on #4117

master has been merged into this branch. #4117 reshaped the same sample
(loop-based pump creation via `--pumps N`, `Pump_1` / `Pump_2`
BrowseNames with `Pump #n` DisplayNames, historian wiring,
`WireBoolean`, per-pump `Diagnostics` group). Both intents are
preserved:

- the datasheet nameplate is applied through upstream's per-pump
`WithIdentification(builder, pump, pumpNumber)` hook, so it scales to
`--pumps N`;
- `Program.cs` is left exactly as upstream has it — identification is
configured centrally, so the old per-pump block there is gone;
- the datasheet curve values are published through upstream's
status-code / source-timestamp plumbing, and upstream's `WireBoolean`
(TrueState/FalseState text + history) is kept;
- the node-surface baseline is the union of both identification lists;
- `docs/SourceGeneratedNodeManagers.md` was consolidated upstream into
`docs/NodeManagers.md`, so the snippet fixes were ported there.

## Related Issues

_No tracking issue; this is a documentation and sample-quality
improvement to the pump reference sample._

## Checklist

- [x] I have signed the
[CLA](https://opcfoundation.org/license/cla/ContributorLicenseAgreementv1.0.pdf)
and read the
[CONTRIBUTING](https://github.com/OPCFoundation/UA-.NETStandard/blob/master/CONTRIBUTING.md)
doc.
- [x] I have added tests that prove my fix is effective or that my
feature works and increased code coverage.
- [x] I have added all necessary documentation.
- [x] I have verified that my changes do not introduce (new) build or
analyzer warnings.
- [x] I ran **all** tests locally using the **UA.slnx** solution against
at least .net **framework** and .net **10**, and all passed.
- [ ] I fixed **all** failing and flaky tests in the CI pipelines and
**all** CodeQL warnings.
- [ ] I have addressed **all** PR feedback received.

### Verification (post-merge)

- `dotnet build samples/PumpDeviceIntegrationServer` (net10.0): 0
warnings, 0 errors
- `dotnet build tests/Opc.Ua.Di.Tests` (net10.0): 0 warnings, 0 errors
- `dotnet test tests/Opc.Ua.Di.Tests -f net10.0`: **331/331 passed**
(includes upstream's new `PumpAddressSpaceComplianceTests` and
`DiConformanceFacetTests`)
- `dotnet test tests/Opc.Ua.Di.Tests -f net48 --filter Pump`: **44/44
passed**
- Live client read against the merged sample: Δp 214 079 Pa, ṁ 8.654
kg/s, η 69.33 %, P 2 677.4 W — `Δp·(ṁ/ρ)/η` matches the published shaft
power; `Pump_1` reads SN-001 / PMP-1001 / Feed Pump A / Bay 3 and
`Pump_2` reads SN-002 / PMP-1002 / Feed Pump B / Bay 4, exactly as
documented.

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fe608993-f3c9-4779-a6b9-9a9eabfc24ba
2026-08-04 10:37:36 +02:00

233 lines
9.6 KiB
C#

/* ========================================================================
* Copyright (c) 2005-2025 The OPC Foundation, Inc. All rights reserved.
*
* OPC Foundation MIT License 1.00
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* The complete license agreement can be found here:
* http://opcfoundation.org/License/MIT/1.00/
* ======================================================================*/
namespace Pumps
{
/// <summary>
/// The published characteristics of the simulated SimPump Corp
/// PumpX-2000, exactly as documented in
/// <see href="https://github.com/OPCFoundation/UA-.NETStandard/blob/master/samples/PumpDeviceIntegrationServer/DATASHEET.md">DATASHEET.md</see>.
/// Every value the server publishes - nameplate, engineering ranges,
/// alarm trip points and simulated process values - is derived from
/// these constants, so the datasheet and the running address space
/// cannot drift apart.
/// </summary>
internal static class PumpDatasheet
{
/// <summary>
/// Nameplate data shared by every unit of the product.
/// </summary>
public static class Nameplate
{
public const string Manufacturer = "SimPump Corp";
public const string ManufacturerUri = "https://simpump.example";
public const string Model = "PumpX-2000";
public const string ProductCode = "PX2000-32-160";
public const string DeviceClass = "Pump";
public const string HardwareRevision = "1.4";
public const string SoftwareRevision = "2.5.3";
public const string ArticleNumber = "PX2000-32-160-CI";
public const string OrderProductCode = "PX2000-32-160-CI-M30";
public const string TypeOfProduct = "Centrifugal pump, end-suction";
public const string Supplier = "SimPump Corp";
public const string CountryOfOrigin = "DE";
public const string ProductInstanceUriPrefix =
"urn:simdevice:SimPump:PumpX-2000:";
public const ushort YearOfConstruction = 2025;
public const byte MonthOfConstruction = 4;
public const int DayOfConstruction = 17;
}
/// <summary>
/// Hydraulic design point and characteristic curves (section 3 of
/// the datasheet). Reference liquid is water at 20 &#176;C.
/// </summary>
public static class Hydraulics
{
/// <summary>
/// Density of the reference liquid in kg/m&#179;.
/// </summary>
public const double FluidDensity = 998.0;
/// <summary>
/// Gravitational acceleration in m/s&#178;.
/// </summary>
public const double GravitationalAcceleration = 9.81;
/// <summary>
/// Flow at the best efficiency point in m&#179;/h.
/// </summary>
public const double RatedFlow = 25.0;
/// <summary>
/// Shut-off head in m, the constant term of the head curve.
/// </summary>
public const double ShutoffHead = 32.0;
/// <summary>
/// Quadratic term of the head curve in m/(m&#179;/h)&#178;.
/// </summary>
public const double HeadCurveCoefficient = 0.0104;
/// <summary>
/// Efficiency at the best efficiency point in percent.
/// </summary>
public const double RatedEfficiency = 72.0;
/// <summary>
/// Curvature of the efficiency parabola about the best
/// efficiency point.
/// </summary>
public const double EfficiencyCurveFactor = 0.6;
/// <summary>
/// Head at the best efficiency point in m.
/// </summary>
public const double RatedHead =
ShutoffHead - (HeadCurveCoefficient * RatedFlow * RatedFlow);
/// <summary>
/// Mass flow at the best efficiency point in kg/s.
/// </summary>
public const double RatedMassFlow = FluidDensity * RatedFlow / 3600.0;
/// <summary>
/// Rated speed of the pump set in min<sup>-1</sup>. The simulated
/// shaft turns in proportion to how close the pump runs to its
/// rated mass flow.
/// </summary>
public const double RatedSpeed = 2900.0;
/// <summary>
/// Shaft power at the best efficiency point in W.
/// </summary>
public const double RatedShaftPower =
FluidDensity * GravitationalAcceleration * (RatedFlow / 3600.0) *
RatedHead / (RatedEfficiency / 100.0);
}
/// <summary>
/// Engineering ranges published as the <c>EURange</c> property of
/// each measurement (section 4 of the datasheet).
/// </summary>
public static class Ranges
{
public const double DifferentialPressureMin = 0.0;
public const double DifferentialPressureMax = 400_000.0;
public const double FluidTemperatureMin = 263.15;
public const double FluidTemperatureMax = 393.15;
public const double BearingTemperatureMin = 273.15;
public const double BearingTemperatureMax = 423.15;
public const double PumpPowerInputMin = 0.0;
public const double PumpPowerInputMax = 4_000.0;
public const double MassFlowMin = 0.0;
public const double MassFlowMax = 10.0;
public const double PumpEfficiencyMin = 0.0;
public const double PumpEfficiencyMax = 100.0;
public const double LevelMin = 0.0;
public const double LevelMax = 5.0;
}
/// <summary>
/// Bearing-temperature trip points and supervision thresholds
/// (section 7 of the datasheet), in K and m.
/// </summary>
public static class TripPoints
{
public const double BearingTemperatureHighHigh = 373.15;
public const double BearingTemperatureHigh = 363.15;
public const double BearingTemperatureLow = 283.15;
public const double BearingTemperatureLowLow = 278.15;
public const double MotorOverheatSet = 363.15;
public const double MotorOverheatClear = 361.15;
public const double CavitationSetLevel = 2.10;
public const double CavitationClearLevel = 2.20;
}
/// <summary>
/// Deterministic simulation profile (section 8 of the datasheet).
/// Angular rates are expressed in radians per 250 ms tick.
/// </summary>
public static class Simulation
{
/// <summary>
/// Relative amplitude of the flow modulation about the rated
/// flow.
/// </summary>
public const double FlowModulation = 0.30;
public const double FlowRate = 0.03;
public const double FluidTemperatureNominal = 313.15;
public const double FluidTemperatureAmplitude = 5.0;
public const double FluidTemperatureRate = 0.01;
public const double LevelNominal = 2.5;
public const double LevelAmplitude = 0.5;
public const double LevelRate = 0.02;
/// <summary>
/// Bearing temperature in K at zero load.
/// </summary>
public const double BearingTemperatureBase = 323.15;
/// <summary>
/// Bearing temperature rise in K at the rated shaft power.
/// </summary>
public const double BearingTemperatureLoadRise = 10.0;
/// <summary>
/// Length of the bearing-cooling fault cycle in ticks.
/// </summary>
public const long CoolingFaultPeriodTicks = 64;
/// <summary>
/// Tick within the cycle at which the cooling water is
/// interrupted.
/// </summary>
public const long CoolingFaultOnsetTick = 56;
/// <summary>
/// Maximum bearing temperature rise in K caused by the
/// cooling fault.
/// </summary>
public const double CoolingFaultRise = 50.0;
/// <summary>
/// Number of ticks between two simulated pump starts.
/// </summary>
public const long StartIntervalTicks = 3_600;
/// <summary>
/// Phase offset in ticks applied per simulated pump so the
/// units do not move in lockstep.
/// </summary>
public const long PhaseOffsetTicks = 17;
}
}
}