Events
Qatium notifies plugins of events in the app through class methods that can be overridden as required. Depending on the data changing inside Qatium’s core, plugins can subscribe to specific events.
init()
Method signature
init(): void
def init(self) -> None:
Optional
Qatium calls a plugin’s init
method only once. You can think about it as the entry point for your plugin.
- Use it to initialize things in your plugin. Examples of this include getting the bounds or the units of the network, exposing your plugin commands, or registering icons in the map.
Example
import { Bounds } from '@qatium/sdk';
class MyPlugin implements Plugin { private bounds: Bounds; init() { this.bounds = sdk.network.getBounds(); }}
from qatiumsdk import Plugin, sdkfrom qatiumsdk.network import Bounds
class MyPlugin(Plugin): def init(self): self.bounds = sdk.network.get_bounds()
run()
Method signature
run(): void
def run(self) -> None:
Optional
Qatium calls a plugin’s run
method whenever the plugin needs to be re-rendered. It will be called multiple times, with a variable frequency. This means:
- Don’t use the
run
event for any timing code. It may be called multiple times per second, or not at all. - Be mindful of resources and try not to perform heavy calculations continuously.
- Try to avoid side effects, as they might be called multiple times.
Use this method to perform any computations using the SDK.
Example
class MyPlugin implements Plugin { run() { sdk.network.getAsset('MyAssetId') }}
class MyPlugin(Plugin): def run(self): sdk.network.get_asset('MyAssetId')
onNetworkChanged()
Method signature
onNetworkChanged(): void
def onNetworkChanged(self) -> None:
Optional
Notified every time the network changes (due to scenarios initiated by the user, new SCADA readings being received, the user changing the current network date, etc.).
Example
class MyPlugin implements Plugin { onNetworkChanged() { const x = sdk.network.getPipes() }}
class MyPlugin(Plugin): def onNetworkChanged(self): x = sdk.network.get_pipes()
onZoomChanged()
Method signature
onZoomChanged(): void
def onZoomChanged(self) -> None:
Optional
Notified every time the zoom changes due to user interaction.
Example
class MyPlugin implements Plugin { onZoomChanged() { const x = sdk.map.getCamera() }}
class MyPlugin(Plugin): def onZoomChanged(self): x = sdk.map.get_camera()
reset()
Method signature
reset(): void
def reset(self) -> None:
Optional
Notified every time the scenario gets deleted, causing all previous user-made changes to be reset to the initial live model.
Example
class MyPlugin implements Plugin { reset() { // ... }}
class MyPlugin(Plugin): def reset(self): pass
cleanUp()
Method signature
cleanUp(): void
def cleanUp(self) -> None:
Optional
Notified when the plugin is getting cleaned up. This happens when the user is exiting the network view or disabling the plugin.
You can use this method, for example, to abort in-progress operations.
Example
class MyPlugin implements Plugin { cleanUp() { // ... }}
class MyPlugin(Plugin): def cleanUp(self): pass
onMessage()
Method signature
onMessage(message: any): void
def onMessage(self, message: Any) -> None:
Optional
Notified every time the plugin receives a message from the plugin UI panel.
It receives the message sent from the UI.
Example
class MyPlugin implements Plugin { onMessage(message: MessageType) { // ... }}
class MyPlugin(Plugin): def onMessage(self, message: MessageType): pass
onElementSelected()
Method signature
onElementSelected(element?: ElementIdentifier): void;
def onElementSelected(self, element: Optional[ElementIdentifier]) -> None:
Optional
Notified every time the user selects an asset in the map.
Example
class MyPlugin implements Plugin { onElementSelected(element?: ElementIdentifier) { sdk.ui.sendMessage<MessageToUI>({ event: "selected-element-changed", id: element?.id }); }}
class MyPlugin(Plugin): def onElementSelected(self, element: Optional[ElementIdentifier]): sdk.ui.send_message({ 'event': "selected-element-changed", 'id': element.id if element else None })