On this page

Water Pump Simulation Server

An OPC UA server that implements a simple water pump machine simulation.

Water Pump Simulation Server is created using OPC UA for the Water Pump and Qt Quick Water Pump examples.

The Simulation

The OPC UA server runs a simulation of a machine containing two tanks, a water pump, and a valve. Water can be pumped from the first tank into the second tank and then be flushed from the second tank by opening the valve. Both operations have a user-configurable setpoint, allowing control over the amount of water pumped into or flushed from the second tank.

The following nodes exist on the server:

NodeIdFunction
ns=2;s=MachineThe folder containing the method and variable nodes for the machine
ns=2;s=Machine.StateThe state of the machine
ns=2;s=Machine.Tank1.PercentFilledThe current fill status of the first tank
ns=2;s=Machine.Tank2.PercentFilledThe current fill status of the second tank
ns=2;s=Machine.Tank2.TargetPercentThe setpoint for pumping and flushing
ns=2;s=Machine.Tank2.ValveStateThe state of the valve of the second tank
ns=2;s=Machine.DesignationA human readable designation of the machine for display purposes
ns=2;s=Machine.StartCall this method to start the pump
ns=2;s=Machine.StopCall this method to stop the pump
ns=2;s=Machine.FlushTank2Call this method to flush tank 2
ns=2;s=Machine.ResetCall this method to reset the simulation

All methods return Good in case of success and BadUserAccessDenied if the operation is illegal (for example, trying to start the pump if the first tank is empty).

Building a Copy of the Server

The server is a standalone open62541 application and needs the open62541 library. When building with CMake, the example uses a system open62541 library if CMake finds one. Otherwise, it compiles open62541.c from the Qt OPC UA sources, which it finds automatically when built from the Qt OPC UA source tree or from the sources installed next to Qt. If you build a copy of the example somewhere else, either install the open62541 system library or set the variable QTOPCUA_OPEN62541_SOURCE_DIR to the directory that contains open62541.c (src/3rdparty/open62541 in the Qt OPC UA sources). Setting the variable takes precedence over a system library.

When building with qmake, the example always compiles open62541.c, and QTOPCUA_OPEN62541_SOURCE_DIR is the qmake variable to set.

Example project @ code.qt.io

See also Qt Quick Water Pump and Water Pump.

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.