mNode Plugin API  v1
Yodiwo.mNode.Plugins.Plugin Class Reference
Inheritance diagram for Yodiwo.mNode.Plugins.Plugin:

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_RequestResultIPC_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...
 
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.NavigationContextNavigationContext => _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...
 

Member Function Documentation

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 bool Yodiwo.mNode.Plugins.Plugin.Deinitialize ( )
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

Parameters
forceUpdateFromCloudif 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)
updateTrackedoverwrite internal dictionaries with returned Things for this plugin
Returns
Current Things of this plugin
virtual RestResponse Yodiwo.mNode.Plugins.Plugin.HandleRestRequest ( RestRequest  req)
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

Parameters
req
Returns
virtual void Yodiwo.mNode.Plugins.Plugin.HandleUnexpectedMessage ( object  message)
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 PlegmaApiMsg Yodiwo.mNode.Plugins.Plugin.HandleUnexpectedRequest ( object  request)
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 bool Yodiwo.mNode.Plugins.Plugin.Initialize ( mNodeConfig  mNodeConfig,
string  PluginConfig,
string  UserConfig 
)
virtual

Initialize plugin

virtual bool Yodiwo.mNode.Plugins.Plugin.Install ( )
virtual

Called by mNode upon first time of plugin installation

virtual IPC_RequestResult Yodiwo.mNode.Plugins.Plugin.IPC_HandleRequest ( string  SourcePUID,
string  Data,
string  DataType 
)
virtual

Called when this Plugin receives an IPC request from another plugin. If handled it must answer with a valid IPC_RequestResult

Parameters
SourcePUIDPlugin Unique ID of sender plugin
Datadata sent (in string format)
DataTypedata type (in string format)
Returns
void Yodiwo.mNode.Plugins.Plugin.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

Parameters
puidPlugin Unique ID to send message to
datadata to send to plugin (will be received as-is)
datatypedata type of data sent to plugin (will be received as-is)
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

Parameters
puidPlugin Unique ID to send request to
datadata to send to plugin (will be received as-is)
datatypedata type of data sent to plugin (will be received as-is)
Timeouttimeout to wait for reply from target plugin
Returns
virtual void Yodiwo.mNode.Plugins.Plugin.OnLinkActivated ( )
virtual

Called when Plegma link is active and can exchange user messages

virtual void Yodiwo.mNode.Plugins.Plugin.OnPortActivated ( PortKey  portKey)
virtual

Called when referenced (via PortKey) Port is newly enabled in a graph (port connected and graph deployed)

virtual void Yodiwo.mNode.Plugins.Plugin.OnPortDeactivated ( PortKey  portKey)
virtual

Called when referenced (via PortKey) Port is newly disabled (not used in any graph anymore)

virtual void Yodiwo.mNode.Plugins.Plugin.OnPortEvent ( PortEventMsg  msg)
virtual

Called when Plegma PortEvent msg is received for this plugin

virtual void Yodiwo.mNode.Plugins.Plugin.OnPortStateSet ( PortKey  pk,
string  state,
bool  isEvent 
)
virtual

Called when Plegma PortEventMsg (if isEvent == true) or PortStateSet (if isEvent == false) is sent from cloud for referenced (via PortKey) Port.

Parameters
pkPortKey of reference Port
stateValue of Port
isEventspecifies if message is due to a new event (PortEventMsg) or updating of state (PortStateSet)
virtual void Yodiwo.mNode.Plugins.Plugin.OnThingActivated ( ThingKey  thing)
virtual

Called when referenced (via ThingKey) Thing is newly enabled in a graph

virtual void Yodiwo.mNode.Plugins.Plugin.OnThingDeactivated ( ThingKey  thing)
virtual

Called when referenced (via ThingKey) Thing is newly disabled (not used in any graph anymore)

virtual void Yodiwo.mNode.Plugins.Plugin.OnThingsStateSet ( ThingKey  thingKey,
TupleS< PortKey, string >[]  states,
bool  isEvent 
)
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

Parameters
thingKeyThingKey of referenced in this message Thing
statesTuple of PortKeys and updated states
isEventspecifies if message is due to a new event (PortEventMsg) or updating of state (PortStateSet)
virtual void Yodiwo.mNode.Plugins.Plugin.OnTransportConnected ( string  msg)
virtual

Called when transport (YPC or MQTT) was just connected

virtual void Yodiwo.mNode.Plugins.Plugin.OnTransportDisconnected ( string  msg)
virtual

Called when transport (YPC or MQTT) was just disconnected

virtual void Yodiwo.mNode.Plugins.Plugin.OnUpdateThing ( Thing  thing,
Thing  oldCopy 
)
virtual

Called when Thing configuration is changed on Cyan

virtual void Yodiwo.mNode.Plugins.Plugin.Purge ( )
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

Parameters
MessageTypesarray/list of types to register interest in
virtual IEnumerable<Thing> Yodiwo.mNode.Plugins.Plugin.Scan ( ThingKey  tkey)
virtual

Called when Plegma eThingsOperation.Scan is requested

Returns
T Yodiwo.mNode.Plugins.Plugin.SendRequest< T > ( object  data)

Call to send RPC request towards the cloud. Will return response of type T

Template Parameters
Ttype of response
Parameters
datarequest to send
Returns
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

Parameters
pkPortKey of event
statePayload of event for selected PortKey
req_ackRequest 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

Parameters
statescollection of {PortKey, State} pairs to send to cloud
req_ackRequest acknowledgement of packet
void Yodiwo.mNode.Plugins.Plugin.TraceLine ( string  txt)

trace line to system log at "Info" level

Parameters
txt
void Yodiwo.mNode.Plugins.Plugin.TraceLine ( eTraceType  TraceType,
string  txt 
)

trace line to system log

Parameters
TraceTypelog level (eTraceType) of message
txt
virtual bool Yodiwo.mNode.Plugins.Plugin.Uninstall ( )
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

Parameters
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

Member Data Documentation

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)

Property Documentation

mNode.Plugins.PluginManifest Yodiwo.mNode.Plugins.Plugin.Manifest
getset

returns Plugins read-in manifest (as PluginManifest class)

NodeKey Yodiwo.mNode.Plugins.Plugin.NodeKey
getset

returns NodeKey currently assigned to parent Node

string Yodiwo.mNode.Plugins.Plugin.PluginDataDirectory
getset

Plugin's selected (derived from conf_file and manifest) data directory

string Yodiwo.mNode.Plugins.Plugin.PluginWorkingDirectory
getset

Plugin's selected (derived from conf_file and manifest) working directory


The documentation for this class was generated from the following file: