I know this has been talked about before. When a new project is created as a child of an inheritable project it gets a copy of the vision client tags, so they're not really inherited, meaning that adding a client tag to the parent project doesn't add it to the child project.
Has anyone found a workaround for getting these client tags to update somewhat automatically, instead of just duplicating the new tags in the child project?
I probably just need to script the creation of these tags with default values if they don't already exist at the parent project level.
You could script up something that runs in the designer and duplicates the (new) parent resource definition, semi-automatically. I wouldn't really know where to begin on authoring a merge tool, via scripting. You're dealing with the neglected orphan of the tag system, in this area - it's both the legacy tag definitions and classes, plus it's the weird one-off client-scoped implementation of them. None of the modern tag editing SDK classes or scripting methods you're used to will be available to help.
I think it would be acceptable to have a designer scoped semi-automatic client tag update script. I'll have to work on that. Maybe some sort of client startup script to check that the vision client tags exist
Here's some different topics to explore as a starting point of the project system:
You're looking to remove the singleton instance of the ResourceType("com.inductiveautomation.vision", "client-tags"), then fetch it from the 'effective' resource configuration (which will give you the parent project's copy, if it exists), then write that copy back to the project.
I was thinking something along the lines of having a preset list (folder) of (unused) gateway tags that get made into client tags at client startup, if they don't exist, with the gateway tag values being the default values.
Something like:
def createVisionClientTags():
defaultTags = system.tag.browse('Vision_Client_Defaults', {'recursive':True, 'tagType':'AtomicTag'})
for tag in defaultTags:
defaultPath = str(tag['fullPath'])
clientPath = '[client]' + defaultPath.split('Vision_Client_Defaults/',1)[1]
if not system.tag.exists(clientPath):
defaultConfig = system.tag.getConfiguration(defaultPath, False)[0]
clientTagBasePath = clientPath.rsplit('/',1)[0]
#create client tag
So, in order, to do the semi-automatic "get the parent resource definition" I described above:
Create or obtain the ResourceType instance that matches the client tag project resource.
Obtain an instance of the local DesignableProject instance.
Ask the project to discardOverrides for the 'root' resource path of the resource type you care about (I forgot this method existed). So myClientTagResourceTypeReference.rootPath() to obtain the path, and myDesignerProjectReference.discardOverrides(thatPath).
Reopen the project in the designer, and Vision should automatically recreate the client tags from the parent project.