RTBase#
- class RTBase(do_mpc_object, clientOpts, namespace=None)[source]#
Bases:
object
Real Time Base. The RTBase class extends do-mpc with an OPC UA interface.
Note
The
do_mpc.estimator.MHE
class is currently not supported.Use this class to configure an OPC UA client for a previously initiated do-mpc class e.g..
do_mpc.controller.MPC
ordo_mpc.simulator.Simulator
.Configuration and setup:
Configuring and setting up the RTBase class involves the following steps:
Use
do_mpc.opcua.ClientOpts
dataclass to specify client name as well as IP adress and port number of the target server.Initiate the RTBase class with a do-mpc object and the dataclass
do_mpc.opcua.ClientOpts
.Use
set_write_tags()
andset_read_tags()
to take over the namespace tags (node IDs) from another instance of RTBase (optional).
Note
Use
set_write_tags()
andset_read_tags()
only after registering all clients with thedo_mpc.opcua.RTServer.namespace_from_client()
method.Use
connect()
to connect the client to the OPC UA server.
Use
write_to_tags()
to write initial values to the OPC UA server.Use
async_step_start()
to run the do-mpc methoddo_mpc.controller.MPC.make_step()
.
- Parameters
do_mpc_object – An instance of a do-mpc class.
clientOpts (
ClientOpts
) – Client Optionsnamespace (
Optional
[Namespace
]) – Namespace containing OPC UA node IDs
Methods#
async_run#
- async_run(self)#
This method is called inside of
async_step_start()
. It callsmake_step()
andasync_step_start()
.- Return type
None
async_step_start#
- async_step_start(self)#
This method calls the
async_run()
method in a frequency given by the do-mpc classes t_step value.- Return type
None
async_step_stop#
- async_step_stop(self)#
Stops
async_step_start()
from running.- Return type
None
connect#
- connect(self)#
Connects client to the server.
- Return type
None
disconnect#
- disconnect(self)#
Disconnects client from the server.
- Return type
None
get_default_namespace#
- get_default_namespace(self, namespace_name)#
Sets default namespace using
namespace_from_model()
.- Parameters
namespace_name (
str
) – Name given to the generated namespace- Return type
None
make_step#
- make_step(self)#
Calls the do-mpc make_step method e.g..
do_mpc.controller.MPC.make_step()
. The input for make_step is taken from node IDs specified inread_from_tags()
. The output of make_step is written to the node IDs specified inwrite_to_tags()
.- Return type
None