Getting started with Kanzi Monitor

After you extract the Kanzi Monitor package to <KanziWorkspace>/Engine/plugins/monitor/, the next step is to add Kanzi Monitor to your Kanzi application.

Kanzi Monitor supports two usage modes:

  • In a Kanzi application project — Integrate Kanzi Monitor into your project build system. This gives full access to all features and is the primary use case.

  • In Kanzi Studio — Import the Kanzi Monitor DLL directly in Kanzi Studio as a plugin. Some Kanzi Monitor features are not available in the Kanzi Studio Preview.

The rest of this page covers the application project path.

Integrating into your application project

To add Kanzi Monitor to your application project, follow the integration steps for your target platform and build system.

See Integrating Kanzi Monitor into existing projects.

When integration is complete, the plugin loads when the application starts and all services run with their default settings.

Enabling features that depend on the Application instance

Some features of Kanzi Monitor require access to the Application instance. To enable these features, provide the Application instance to the Kanzi Monitor plugin using the API for your platform.

Using the application framework (appfw) in C++

To provide the Application instance in a C++ application:

In the Application-derived class, include the Kanzi Monitor header and call the C++ API in the onConfigure(...) function:

#include <kanzimonitor_module.hpp>

KanziMonitorModule::ApplicationReference::get().setApplication(this);

Using the Android framework (droidfw) in Java

To provide the Application instance in an Android application:

In the Activity class, call the Java API in the KanziViewListener.onAttachedToWindow function:

KanziView kzView = (KanziView) view;
// Set the native runtime object.
KanziMonitorPlugin.setNativeRuntime(kzView.getRuntime().getNative());

Enabling features that depend on the scene

Some features of Kanzi Monitor require access to the Kanzi node tree. The Kanzi Monitor plugin automatically registers the node tree when loading the Startup Prefab from the kzb file. You can configure this automatic registration using the NodeRegisteringScreenEnabled setting in kanzimonitor.cfg. The automatic registration is enabled by default.

If you disable automatic registration, or create the node tree with application code, register the root explicitly using an API call. If you register the root explicitly, also unregister the root during application shutdown.

For convenience, if there are no root nodes registered, Kanzi Monitor attempts to access the node tree from the Application, if it is available. See Enabling features that depend on the Application instance.

Registering the root node in C++

To register the root node in a C++ application:

In the Application-derived class, register the root node in the onProjectLoaded(...) function:

// The Monitor plugin automatically registers the Startup Prefab node tree by default.
// If the automatic registration is disabled or does not work,
// the application can register it explicitly.
// If the registration is done explicitly, unregister the tree during shutdown.
KanziMonitorModule::ApplicationReference::get().registerRoot(...);

Registering the root node in Java

To register the root node in an Android application:

In the Activity class, register the root node in the KanziViewListener.onAttachedToWindow function:

KanziView kzView = (KanziView) view;

// When the node tree is created with code, the application must register it explicitly.
// If the registration is done explicitly, unregister the tree during shutdown.
//
// KanziMonitorPlugin.registerNativeViewRoot(...);
// KanziMonitorPlugin.unregisterNativeViewRoot(...);

// Register the native view root object.
KanziMonitorPlugin.registerNativeViewRoot(kzView.getRoot().getNative());

Because droidfw supports multiple views, you can register multiple view root objects in the Kanzi Monitor plugin.

Setting permissions

Android

Kanzi Monitor requires privileges to write files and open TCP sockets. On Android, you must add these permissions to the application manifest and grant them on the device before using Kanzi Monitor.

See Setting permissions on Android.

Serial port communication

Communication over serial ports is optional, and the default configuration setting is disabled. If you want to use serial communication, ensure that UART privileges are granted on the device.

See Using the serial console.

See also

Integrating Kanzi Monitor into existing projects

Configuring Kanzi Monitor

Working with Kanzi Monitor services