Event Logging in Edge

Hey everyone,

I’m trying to accomplish event logging in Ignition Edge, and it’s been giving me real trouble with each solution I try to come up with. I’m wanting to accomplish something like the following. The yellow lines indicate additional rows generated from event string changes.

Essentially, we are looking for a black-box type of data logging within Edge to fit out needs. We need this data as it will allow us to see an event (“User Did XYZ”) as well as the associated data with that action (Breathing Air PSI, etc.). This is useful as it allows us to see the state of the system when a user decides to take certain actions. It’s vital in our project since the user is controlling life-supporting equipment.

So far, I’ve tried the following with no success:

  • Creating a gateway tag change script that generates a dataset/array of applicable data when the event string changes. This dataset/array has history enabled on change. I found that this does not work since datasets can’t be stored in the historian, and when an array is used, each write to the array causes the “sub-tags” to update their history. This means that if I change [1, 2, 3, 4, 5, 6] to [6, 5, 4, 3, 2, 1], there will be 6 different rows generated even if the array is changed at once (system.tag.write(path, arr)).

  • Using alarms with associated data. The alarm is diagnostic level and associated with a “logging” group to separate it from other alarms. It also has the associated data baked into the alarm. This doesn’t work since I can’t pull that data into a table/reporting once synced to the central ignition server.

  • Creating history-enabled UDTs. This results in the same problems I have with the first bullet point.

It seems like each thing I do has a miniscule, blocking factor to it that prevents me from accomplishing what are essentially transaction groups. The cellular connection at our remote sites isn’t the best, so using the central server for logging is a no-go for our use case. We would need the store-and-forward capabilities of either the Tag Historian, Alarm Journal, or Audit Log. I’m really at a loss here and would really appreciate some guidance and help with accomplishing this within Ignition Edge. I’m interested to hear about possible alternative solutions- even if it includes making our own module

Thanks!

To me what your trying to do would work best with regular database access which Edge was never intended to have. The only thought I have for how you might be able to accomplish it would be to create your own expression string of the tags you want. In my example I’m separating each value with commas. Then you can have the historian log this tag which would keep your values together.

image
image

Thanks for the suggestion! I ended up creating an expression string that combines all of the required fields, including the event string. I setup a gateway tag change script to request a tag group execution when the event string is changed, allowing the delimited data to be logged in the historian upon request. This tag group has an execution rate of -1 to prevent it from updating unless requested.

From there, I created a script that can be queried with the RunScript expression function along with parameters (Historical Path, Start Date, End Date, etc…). This script parses the delimited data and returns the requested dataset depending on the parameters received.

The following is unrefined and not optimized for edge cases, but it demonstrates how it can be done:

Gateway Tag Change Script:

system.tag.requestGroupExecution("edge", "Insert Tag Group with poll rate of -1 here")

History Request Script:

def getDataset(path, start, end):
	try:
		tagHistory = system.tag.queryTagHistory(paths=["prov:edge:/tag:Event Datasets/Power"], startDate=start)
		
		arr = system.dataset.toPyDataSet(tagHistory)
		col = arr.getColumnName(1)
		finalData = []
		finalHeaders = []
		
		for row in arr:
			data = []
			headers = []
			for idx, entry in enumerate(row[col].split(",")):
				if (idx % 2 == 0):
					headers.append(entry)
				else:
					data.append(entry)
					
			finalHeaders = headers
			finalData.append(data)
			
		return system.dataset.toDataSet(finalHeaders, finalData)
	except Exception as error:
		return system.dataset.toDataSet(["Error retrieving requested event data"], [[error]])

Expression for Table, Power Table, Reporting, etc.:

runScript('Events.getDataset', 1000, {.../historyPath}, {.../startDate}, {.../endDate})