Dataset Property Written by Script not Updating

I have this script that takes in a dataset (of tag pens from an easy chart) and replaces the storage provider portion of the path and places the resulting dataset in a different dataset property.

It seems like the script is working just fine, but the resulting dataset property never changes.

I'm triggering the script when the window the easy chart is on is opened and using a tag change script on a custom property on the component.
The component also has 2 custom dataset properties 'edge' and 'master'.


#setting windowOpened to 1 allows tag change script on the pens datasets to run
system.gui.getParentWindow(event).getComponentForPath('Root Container.Pens').windowOpened = 1


#property change script used to update the derived 'edge' dataset from the 'master' dataset
#make changes to the master dataset and they will popuplate to the edge set automatically

#root container will detect if this is the master or edge gateway and use the appropriate dataset

if event.source.parent.edge :

area_providers = [
	{0 : "[MySQL/ignition-desktop-av4v6h5:"},
	{1: "[Edge Historian/"},
	{8: "[Edge Historian/"},
	{10: "[Edge Historian/"},
	{15: "[Edge Historian/"},
	{19: "[Edge Historian/"},

def penCopy_MasterToEdge(event, area):
	#copy pens from master dataset to edge dataset when window is opened
	if event.propertyName == 'windowOpened' and event.newValue == 1:'Area '+str(area)+' Trending window opened.')
		#get historical path for replacement
		histRootPath = Trending.getHistoryProvider(area)'Historical root path is '+histRootPath+'.')
		#get master pens dataset
		data_master = event.source.master
		penData_master = system.dataset.toPyDataSet(data_master)
		#get headers for the dataset
		headers = list(data_master.getColumnNames())
		#initialize an empty list
		penData_edge = []
		#get the index for the tag path column
		TAG_PATH_index = data_master.getColumnIndex('TAG_PATH')
		#for each row in master data
		for row in penData_master:
			#create new blank row as a list
			new_row = list(row)
			#update the "area_xx" portion of the tag path to match the area for the tag provider
			new_row[TAG_PATH_index] = row['TAG_PATH'].replace(Trending.area_providers[0][0],histRootPath)
			#append the new row to the list
			penData_edge.append(new_row)'Sample row from new dataset: '+str(penData_edge[0]))
		#create dataset from list and assign to edge dataset property
		event.source.edge = system.dataset.toDataSet(headers, penData_edge)
		#reset windowOpened to 0 so that this can run again the next time the window is opened.
		event.source.windowOpened = 0

def getHistoryProvider(tagProvider = None):

	if tagProvider is None:
		area = system.tag.readBlocking(['Areas/Station_Area'])[0].value
		area = tagProvider
	for provider in Trending.area_providers:
		if area in provider:
			return str(provider[area])
	return Trending.area_providers[0][0]

My logs seem to indicate that the replace is working as intended and the dataset should be correct, but the 'edge' dataset on the component still looks like a duplicate of the 'master'.


14:45:12.790 [AWT-EventQueue-0] INFO Trending - Area 1 Trending window opened.
14:45:12.794 [AWT-EventQueue-0] INFO Trending - Historical root path is [Edge Historian/.
14:45:12.799 [AWT-EventQueue-0] INFO Trending - Sample row from new dataset: [u'Runtime', u'[Edge Historian/area_01]pumps_motors/01111-inf/runtime/total/runtime_total', u'MinMax', u'Default Axis', 1, False, java.awt.Color[r=188,g=129,b=67], u'', 0, 1.0, 0, True, False, u'Pump 1', False, False, False, True, None, False]

What am I missing?

I'm not sure what else might be going on, but you aren't filtering your propertyChange event for a particular property name via event.propertyName. This is required, as all properties' changes on a Vision component go through the same script.

It is filtered, eventually.... in penCopy_MasterToEdge This function will be used many times on many different components and I didn't want to retype that same thing on every one of them

It looks like the issue is that you aren't accessing the custom property correctly in your script. You are doing:
event.source.edge = system.dataset.toDataSet(headers, penData_edge)

but shouldn't it be:
event.source.custom.edge = system.dataset.toDataSet(headers, penData_edge)

sorry have been using perspective all day... this is vision. duh

1 Like

Vision, not perspective. I'm accessing the 'master' dataset the same way and it's coming in just fine.

1 Like

Do you have anything else configured that may be writing to that dataset? any other bindings or scripts that could overwrite it?

Have you tried clearing the value of the edge property before writing the script? Could it be an issue with your value getting overwritten by the value that is saved in the designer?

I added to the property change script to print to the logger whenever the dataset is updated. It fires an shows only one update.

I think I did find my issue though... :upside_down_face:
I had been testing this with just one set of pens and did not add the other components for the other easy charts on the same page. I was looking at pens for a dataset that had not been running that script at all yet.

We'll see if that was the only issue

1 Like

Component visibility shouldn't have anything to do with updating the dataset, correct?
This component is set to only be visible in the designer.

That was not my root issue. The dataset is still not updating from the script. If I clear out the dataset in the designer and close and open the window it's still empty.

AFAIK that should not affect whether or not you can set the custom property on the component. Have you tested it in the actual vision client by opening the screen there? I do not remember if the window opened script runs when you open the window in the designer. Just grasping at straws here :face_with_diagonal_mouth:

Yes, I'm trying both but I have no way to actually inspect the dataset short of printing the entire thing to the console.

You could throw a table on the screen temporarily and dump the results into the table's data property to see what the results are.

Added some more logging to the property change script and saw an extra 'None' dataset being return for some reason.

Add a simple if not none before assignment, like so:'Sample row from new dataset: '+str(penData_edge[0]))
#create dataset from list and assign to edge dataset property
data = system.dataset.toDataSet(headers, penData_edge)
if data is not None:
	event.source.edge = data

and we're all good now.

1 Like

It does not