![]() |
mNode Plugin API
v1
|
Classes | |
| class | IPC_RequestResult |
| Reply to an IPC request message More... | |
Public Member Functions | |
| delegate void | PortEventHandlerDelegate (string state) |
| virtual bool | Install () |
| Called by mNode upon first time of plugin installation More... | |
| virtual bool | Uninstall () |
| Called by mNode when user requests uninstall of plugin More... | |
| virtual bool | Initialize (mNodeConfig mNodeConfig, string PluginConfig, string UserConfig) |
| Initialize plugin More... | |
| virtual bool | Deinitialize () |
| DeInitialize plugin More... | |
| virtual RestResponse | HandleRestRequest (RestRequest req) |
| Handle incoming REST requests (of type RestRequest) towards this plugin. Return a RestResponse class for the HTTP response to be sent to the caller More... | |
| void | TraceLine (string txt) |
| trace line to system log at "Info" level More... | |
| void | TraceLine (eTraceType TraceType, string txt) |
| trace line to system log More... | |
| void | UpdateConfig (string data) |
| (over)write new data to Plugin's private conf/data file More... | |
| void | IPC_SendMessage (string puid, string data, string datatype) |
| Send a new IPC message to another Plugin. The operation is asynchronous and no reply is expected or returned More... | |
| Task< IPC_RequestResult > | IPC_SendRequestAsync (string puid, string data, string datatype, TimeSpan?Timeout=null) |
| Send a new IPC request message to another Plugin. The operation is asynchronous and a new Task is returned to track the reply of type IPC_RequestResult More... | |
| virtual bool | IPC_HandleMessage (string SourcePUID, string Data, string DataType) |
| virtual IPC_RequestResult | IPC_HandleRequest (string SourcePUID, string Data, string DataType) |
| Called when this Plugin receives an IPC request from another plugin. If handled it must answer with a valid IPC_RequestResult More... | |
| void | RegisterForUnexpectedMessagesCommand (IEnumerable< Type > MessageTypes) |
| Call to register interest for extra message types, not covered by Plegma API More... | |
| void | EnqueueCommand (Command command) |
| void | SetPortState (string pk, string state, bool req_ack=false) |
| Send a single new PortEventMsg towards the cloud for a single Port More... | |
| void | SetPortState (IEnumerable< TupleS< string, string >> states, bool req_ack=false) |
| Send a single new PortEventMsg towards the cloud containing updates for all referenced ports in the tuple parameter. PortKeys may only refer to Ports/Things of this plugin More... | |
| Thing | AddThing (Thing thing) |
| Thing to add to this plugin More... | |
| void | UpdateThing (Thing thing, bool send2Cloud=true) |
| Thing of this plugin to update. If send2Cloud is true, a new ThingsSet request with a eThingsOperation.Update op code will be sent More... | |
| void | DeleteThing (ThingKey thingKey) |
| thingKey of thing to delete (for this plugin). Will result in a ThingsSet request with a eThingsOperation.Delete op code More... | |
| void | AddThing (IEnumerable< Thing > things, bool send2cloud=true) |
| list of things to add to plugin. If send2cloud is true, a new ThingsSet request with a eThingsOperation.Update op code will be sent More... | |
| void | DeleteThing (IEnumerable< ThingKey > thingKeys) |
| list of thingKeys to delete (for this plugin). Will result in a ThingsSet request with a eThingsOperation.Delete op code More... | |
| IEnumerable< Thing > | GetThings (bool forceUpdateFromCloud=false, bool updateTracked=false) |
| Request Things More... | |
| T | SendRequest< T > (object data) |
| Call to send RPC request towards the cloud. Will return response of type T More... | |
| virtual IEnumerable< ThingType > | EnumerateThingTypes () |
| virtual void | OnPortStateSet (PortKey pk, string state, bool isEvent) |
| Called when Plegma PortEventMsg (if isEvent == true) or PortStateSet (if isEvent == false) is sent from cloud for referenced (via PortKey) Port. More... | |
| virtual void | OnThingsStateSet (ThingKey thingKey, TupleS< PortKey, string >[] states, bool isEvent) |
| Called when Plegma PortEventMsg (if isEvent == true) or PortStateSet (if isEvent == false) is sent from cloud for referenced (via ThingKey) Thing. Tuple of PortKeys/States is guarranteed to refer to referenced Thing More... | |
| virtual IEnumerable< Thing > | Scan (ThingKey tkey) |
| Called when Plegma eThingsOperation.Scan is requested More... | |
| virtual bool | OnThingDelete (ThingKey[] thingKeys) |
| virtual void | OnUpdateThing (Thing thing, Thing oldCopy) |
| Called when Thing configuration is changed on Cyan More... | |
| virtual void | OnThingActivated (ThingKey thing) |
| Called when referenced (via ThingKey) Thing is newly enabled in a graph More... | |
| virtual void | OnThingDeactivated (ThingKey thing) |
| Called when referenced (via ThingKey) Thing is newly disabled (not used in any graph anymore) More... | |
| virtual void | OnPortActivated (PortKey portKey) |
| Called when referenced (via PortKey) Port is newly enabled in a graph (port connected and graph deployed) More... | |
| virtual void | OnPortDeactivated (PortKey portKey) |
| Called when referenced (via PortKey) Port is newly disabled (not used in any graph anymore) More... | |
| virtual void | OnPortEvent (PortEventMsg msg) |
| Called when Plegma PortEvent msg is received for this plugin More... | |
| virtual void | OnTransportConnected (string msg) |
| Called when transport (YPC or MQTT) was just connected More... | |
| virtual void | OnTransportDisconnected (string msg) |
| Called when transport (YPC or MQTT) was just disconnected More... | |
| virtual void | OnLinkActivated () |
| Called when Plegma link is active and can exchange user messages More... | |
| virtual void | Purge () |
| Called when Plugin is to remove any saved information and be completely disabled (usually due to node unpairing) More... | |
| virtual PlegmaApiMsg | HandleUnexpectedRequest (object request) |
| Called when an unexpected (not Plegma API compliant) request received. Plugin may handle and return reply that inherits PlegmaApiMsg. The reply will be sent back to caller in RPC-like fashion must have registered type via the RegisterForUnexpectedMessagesCommand call beforehand More... | |
| virtual void | HandleUnexpectedMessage (object message) |
| Called when an unexpected (not Plegma API compliant) message received. Plugin may handle but cannot return anything must have registered type via the RegisterForUnexpectedMessagesCommand call beforehand More... | |
| void | UI_ShowMessageBox (UI.InformationType Type, string Tile, string Text) |
| void | UI_ShowNotification (UI.InformationType Type, string Tile, string Text) |
| void | UI_NotificationContextMenu_AddOrUpdate (UI.ContextMenu.MenuItemDescriptor desc) |
| void | UI_NotificationContextMenu_Remove (string menuId) |
| virtual void | UI_NotificationContextMenu_HandleClick (string[] ids, UI.ContextMenu.MenuItemDescriptor desc) |
| virtual void | UI_mNodeForms_OnNewNavigationContext (UI.Forms.NavigationContext navCtx, string StartPageUri) |
| virtual void | UI_mNodeForms_OnDestroyNavigationContext (UI.Forms.NavigationContext navCtx) |
| virtual void | UI_mNodeForms_NavigationContext_GoBack (UI.Forms.NavigationContext ctx) |
| void | Dispose () |
Public Attributes | |
| string | PUID => Manifest?.PUID |
| returns this Plugin's Unique ID (as read in from manifest) More... | |
| string | PackageName => Manifest?.Name |
| returns this Plugin's package name (as read in from manifest) More... | |
| bool | IsInitialized => _IsInitialized |
| bool | IsDisposed => _IsDisposed |
| IReadOnlySet< Thing > | TrackedThings => _TrackedThings |
| DictionaryTS< PortKey, PortEventHandlerDelegate > | PortEventHandlers = new DictionaryTS<PortKey, PortEventHandlerDelegate>() |
| IReadOnlyDictionary< Int32, UI.Forms.NavigationContext > | NavigationContext => _NavigationContext |
Static Public Attributes | |
| static string | g_mNodePackageName |
| static string | g_PUID => g_Manifest?.PUID |
| static string | g_PackageName => g_Manifest.Name |
| static string | ThingKeyPrefix => g_Manifest?.PUID?.Substring((g_mNodePackageName + ".Plugins.").Length) + ":" |
Properties | |
| string | mNodePackageName [get, set] |
| static mNode.Plugins.PluginManifest | g_Manifest [get] |
| mNode.Plugins.PluginManifest | Manifest [get, set] |
| returns Plugins read-in manifest (as PluginManifest class) More... | |
| string | PluginWorkingDirectory [get, set] |
| Plugin's selected (derived from conf_file and manifest) working directory More... | |
| string | PluginDataDirectory [get, set] |
| Plugin's selected (derived from conf_file and manifest) data directory More... | |
| NodeKey | NodeKey [get, set] |
| returns NodeKey currently assigned to parent Node More... | |
| Thing Yodiwo.mNode.Plugins.Plugin.AddThing | ( | Thing | thing | ) |
Thing to add to this plugin
| void Yodiwo.mNode.Plugins.Plugin.AddThing | ( | IEnumerable< Thing > | things, |
| bool | send2cloud = true |
||
| ) |
list of things to add to plugin. If send2cloud is true, a new ThingsSet request with a eThingsOperation.Update op code will be sent
|
virtual |
DeInitialize plugin
| void Yodiwo.mNode.Plugins.Plugin.DeleteThing | ( | ThingKey | thingKey | ) |
thingKey of thing to delete (for this plugin). Will result in a ThingsSet request with a eThingsOperation.Delete op code
| void Yodiwo.mNode.Plugins.Plugin.DeleteThing | ( | IEnumerable< ThingKey > | thingKeys | ) |
list of thingKeys to delete (for this plugin). Will result in a ThingsSet request with a eThingsOperation.Delete op code
| IEnumerable<Thing> Yodiwo.mNode.Plugins.Plugin.GetThings | ( | bool | forceUpdateFromCloud = false, |
| bool | updateTracked = false |
||
| ) |
Request Things
| forceUpdateFromCloud | if true, the returned Things will be the reply to a new ThingsGet request, filtered for this plugin. If false, the locally cached Things will be returned (filtered for this plugin) |
| updateTracked | overwrite internal dictionaries with returned Things for this plugin |
|
virtual |
Handle incoming REST requests (of type RestRequest) towards this plugin. Return a RestResponse class for the HTTP response to be sent to the caller
| req |
|
virtual |
Called when an unexpected (not Plegma API compliant) message received. Plugin may handle but cannot return anything must have registered type via the RegisterForUnexpectedMessagesCommand call beforehand
|
virtual |
Called when an unexpected (not Plegma API compliant) request received. Plugin may handle and return reply that inherits PlegmaApiMsg. The reply will be sent back to caller in RPC-like fashion must have registered type via the RegisterForUnexpectedMessagesCommand call beforehand
|
virtual |
Initialize plugin
|
virtual |
Called by mNode upon first time of plugin installation
|
virtual |
Called when this Plugin receives an IPC request from another plugin. If handled it must answer with a valid IPC_RequestResult
| SourcePUID | Plugin Unique ID of sender plugin |
| Data | data sent (in string format) |
| DataType | data type (in string format) |
| void Yodiwo.mNode.Plugins.Plugin.IPC_SendMessage | ( | string | puid, |
| string | data, | ||
| string | datatype | ||
| ) |
| Task<IPC_RequestResult> Yodiwo.mNode.Plugins.Plugin.IPC_SendRequestAsync | ( | string | puid, |
| string | data, | ||
| string | datatype, | ||
| TimeSpan? | Timeout = null |
||
| ) |
Send a new IPC request message to another Plugin. The operation is asynchronous and a new Task is returned to track the reply of type IPC_RequestResult
| puid | Plugin Unique ID to send request to |
| data | data to send to plugin (will be received as-is) |
| datatype | data type of data sent to plugin (will be received as-is) |
| Timeout | timeout to wait for reply from target plugin |
|
virtual |
Called when Plegma link is active and can exchange user messages
|
virtual |
Called when referenced (via PortKey) Port is newly enabled in a graph (port connected and graph deployed)
|
virtual |
Called when referenced (via PortKey) Port is newly disabled (not used in any graph anymore)
|
virtual |
Called when Plegma PortEvent msg is received for this plugin
|
virtual |
Called when Plegma PortEventMsg (if isEvent == true) or PortStateSet (if isEvent == false) is sent from cloud for referenced (via PortKey) Port.
| pk | PortKey of reference Port |
| state | Value of Port |
| isEvent | specifies if message is due to a new event (PortEventMsg) or updating of state (PortStateSet) |
|
virtual |
Called when referenced (via ThingKey) Thing is newly enabled in a graph
|
virtual |
Called when referenced (via ThingKey) Thing is newly disabled (not used in any graph anymore)
|
virtual |
Called when Plegma PortEventMsg (if isEvent == true) or PortStateSet (if isEvent == false) is sent from cloud for referenced (via ThingKey) Thing. Tuple of PortKeys/States is guarranteed to refer to referenced Thing
| thingKey | ThingKey of referenced in this message Thing |
| states | Tuple of PortKeys and updated states |
| isEvent | specifies if message is due to a new event (PortEventMsg) or updating of state (PortStateSet) |
|
virtual |
Called when transport (YPC or MQTT) was just connected
|
virtual |
Called when transport (YPC or MQTT) was just disconnected
|
virtual |
Called when Thing configuration is changed on Cyan
|
virtual |
Called when Plugin is to remove any saved information and be completely disabled (usually due to node unpairing)
| void Yodiwo.mNode.Plugins.Plugin.RegisterForUnexpectedMessagesCommand | ( | IEnumerable< Type > | MessageTypes | ) |
Call to register interest for extra message types, not covered by Plegma API
| MessageTypes | array/list of types to register interest in |
|
virtual |
Called when Plegma eThingsOperation.Scan is requested
| T Yodiwo.mNode.Plugins.Plugin.SendRequest< T > | ( | object | data | ) |
Call to send RPC request towards the cloud. Will return response of type T
| T | type of response |
| data | request to send |
| void Yodiwo.mNode.Plugins.Plugin.SetPortState | ( | string | pk, |
| string | state, | ||
| bool | req_ack = false |
||
| ) |
Send a single new PortEventMsg towards the cloud for a single Port
| pk | PortKey of event |
| state | Payload of event for selected PortKey |
| req_ack | Request acknowledgement of packet |
| void Yodiwo.mNode.Plugins.Plugin.SetPortState | ( | IEnumerable< TupleS< string, string >> | states, |
| bool | req_ack = false |
||
| ) |
Send a single new PortEventMsg towards the cloud containing updates for all referenced ports in the tuple parameter. PortKeys may only refer to Ports/Things of this plugin
| states | collection of {PortKey, State} pairs to send to cloud |
| req_ack | Request acknowledgement of packet |
| void Yodiwo.mNode.Plugins.Plugin.TraceLine | ( | string | txt | ) |
trace line to system log at "Info" level
| txt |
| void Yodiwo.mNode.Plugins.Plugin.TraceLine | ( | eTraceType | TraceType, |
| string | txt | ||
| ) |
trace line to system log
| TraceType | log level (eTraceType) of message |
| txt |
|
virtual |
Called by mNode when user requests uninstall of plugin
| void Yodiwo.mNode.Plugins.Plugin.UpdateConfig | ( | string | data | ) |
(over)write new data to Plugin's private conf/data file
| data |
| void Yodiwo.mNode.Plugins.Plugin.UpdateThing | ( | Thing | thing, |
| bool | send2Cloud = true |
||
| ) |
Thing of this plugin to update. If send2Cloud is true, a new ThingsSet request with a eThingsOperation.Update op code will be sent
| string Yodiwo.mNode.Plugins.Plugin.PackageName => Manifest?.Name |
returns this Plugin's package name (as read in from manifest)
| string Yodiwo.mNode.Plugins.Plugin.PUID => Manifest?.PUID |
returns this Plugin's Unique ID (as read in from manifest)
|
getset |
returns Plugins read-in manifest (as PluginManifest class)
|
getset |
returns NodeKey currently assigned to parent Node
|
getset |
Plugin's selected (derived from conf_file and manifest) data directory
|
getset |
Plugin's selected (derived from conf_file and manifest) working directory