Hi all
I am trying to get all tags used in a page. At now I am able to it by listing all the components in a page and then get the property of the linked tag. This is working quite fine because the objects in a page are iterable and it almost always possible to get the children of each component. The problems comes when one of the object is a template holder because I am not able to list its children. Is there a way to do that?As an alternative is it possible to open a template like we open a page? As an alternative of the alternative () is it possible (maybe in runtime) to get the tags used in a page ? I think that something like that should be possible , otherwise the system will never know what are the leased tags to handle with the fast or slow scan
Bindings are stored in the window’s InteractionController. Digging around in there is very much unsupported…
Thank you . Theoretically it would be the best follow the InteractionController but the lack of documentation on it make that way quite hard. At now I am able to do it by :
1)
- listing all the components in a window (looping with rootContainer.getComponent(currentComponentIndex)
- if I found I template of templates I extract all the component by using this piece of code found on the forum
def getTemplateResourceType():
"""Resource type string."""
return 'component-template'
def getTemplateFilter():
"""Filter throw away for template types."""
return lambda x: bool(x.getResourceType() == getTemplateResourceType())
def getContext(event):
"""Context."""
return event.source.parent.getAppContext()
def getProjectReference(event):
"""Project reference."""
return getContext(event).getProject()
def getTemplateInstance(event, templatePath):
"""
Return Template Instance.
Pass the path into here.
"""
context = getContext(event)
project_obj = context.getProject()
templateManager = context.getTemplateManager()
templateId = templateManager.getId(templatePath)
return templateManager.getTemplateInstance(templateId)
The only problem is the following. Each template has a custom property called tagPath (that contains of course the path to the tag in a string format). If I call the component.tagPath on a component that is on the main window I get it correctly. If I call it on a component that is a child of templateManager.getTemplateInstance it’s not working. It allow me to list all the standard templates’ properties (name,visible, border) but not the custom one “tagPath”. This sound quite strange to me and I am still fighting to figure it out
This is due to a limitation of the methods used by Ignition to wrap (java) components for use in jython. A technical discussion of this phenomenon is here:
TL/DR: Install my Simulation Aids module to fix the PyComponentWrapper.