Details about the Sparkplug EdgeNodes connected at Engine can be found in the Engine Info > Edge Nodes folder in the MQTT Engine tag provider.

 

where:

Name

Data Type

Description

Last Node to ConnectStringThe Sparkplug ID of the last node to connect
Last Node To DisconnectStringThe Sparkplug ID of the last node to disconnect
NodesOfflineIntegerThe number of Sparkplug Edge Nodes offline. This is determined by whether the last lifecycle message was an NBIRTH or NDEATH
NodesOnlineIntegerThe number of Sparkplug Edge Nodes online. This is determined by whether the last lifecycle message was an NBIRTH or NDEATH
NodeUnitCountIntegerThe total number of Sparkplug Edge Nodes as determined by the received NBIRTH messages
Offline NodesDatasetA dataset containing the Sparkplug ID and timestamp for all offline Sparkplug edge nodes
Online NodesDatasetA dataset containing the Sparkplug ID and timestamp for all online Sparkplug edge nodes 


Executing the code below in the Ignition Script Console will print out the values in the Offline Nodes and Online Nodes datasets for review:

onlineEdgeNodes = system.dataset.toPyDataSet(system.tag.readBlocking("[MQTT Engine]Engine Info/Edge Nodes/Online Nodes")[0].value)      
print "Online Sparkplug EdgeNodes: " + str(system.tag.readBlocking("[MQTT Engine]Engine Info/Edge Nodes/NodesOnline")[0].value)
if system.tag.readBlocking("[MQTT Engine]Engine Info/Edge Nodes/NodesOnline")[0].value > 0:
	for row in onlineEdgeNodes:
		data = []
		data.append(["Sparkplug EdgeNode Descriptor", row[0]])
		data.append(["Last Connect Date", row["Date"]])
		print data
		
offlineEdgeNodes = system.dataset.toPyDataSet(system.tag.readBlocking("[MQTT Engine]Engine Info/Edge Nodes/Offline Nodes")[0].value)      
print "Offline Sparkplug EdgeNodes: " + str(system.tag.readBlocking("[MQTT Engine]Engine Info/Edge Nodes/NodesOffline")[0].value)
if system.tag.readBlocking("[MQTT Engine]Engine Info/Edge Nodes/NodesOffline")[0].value > 0:
	for row in offlineEdgeNodes:
		data = []
		data.append(["Sparkplug EdgeNode Descriptor", row[0]])
		data.append(["Last Connect Date", row["Date"]])
		print data


Example result from the Engine Info > Edge Nodes above

>>> 
Online Sparkplug EdgeNodes: 1
[['Sparkplug EdgeNode Descriptor', u'G1/E1'], ['Last Connect Date', Tue Sep 26 08:59:01 CDT 2023]]
Offline Sparkplug EdgeNodes: 1
[['Sparkplug EdgeNode Descriptor', u'MyGroup/MyEdgeNode'], ['Last Connect Date', Tue Sep 26 09:06:49 CDT 2023]]
>>>


Additional Resources





  • No labels