Hello All,
Looking for a way to get a list of all views in a perspective application. Furthermore, can I specify a specific location to loop through the views. Like a folder of views within the project? Thanks in advance.
Frank
Hello All,
Looking for a way to get a list of all views in a perspective application. Furthermore, can I specify a specific location to loop through the views. Like a folder of views within the project? Thanks in advance.
Frank
By conventional methods is not possible I think, I tried with “advanced methods” not success yet. I don’t know if it even possible or secure to do because the only scope who needs to know all available views is the designer.
You can use system.perspective.getProjectInfo()
https://docs.inductiveautomation.com/display/DOC81/system.perspective.getProjectInfo
Ops
Of course you can do that.
Just download HMI framework resource from echange and there is script to show you how to do this. Even you can loop through objects inside view
The perspective code run in server side so you can get result only if run it in perspective scope or gateway
Bind the following code to the 'props.items' Tree component and it will create a tree view of the entire project. It is also possible to add pages by changing the code. This simple code took a few hours to write. If you improve the code, please share it.
def transform(self, value, quality, timestamp):
v = []
for item in system.perspective.getProjectInfo()['views']:
v.append(item['path'].split('/'))
return returnViews(v)
def items(label,items,data):
return {
"label": label,
"expanded": True,
"data" : data,
"items": items,
}
def returnViews(viewsArray):
chieldItem = []
pastItem = ''
idx2 = 0
v1 = []
firstMulti = True
lastFolder = False
pastFolderName = ''
viewsArraySize = 0
chieldItemLast = []
itemLast = 0
idx = 0
for idx, item in enumerate( viewsArray):
if len(viewsArray[idx])==idx2+1:
v1.append(items(viewsArray[idx][idx2+0],[],'1'))
if len(viewsArray[idx])>idx2+1:
if (pastItem != viewsArray[idx][idx2+0]) and len(chieldItem)>0:
chieldItem.append([''])
v1.append(items(pastItem,returnViews(chieldItem),'2'))
chieldItem= []
pastItem = viewsArray[idx][idx2+0]
viewsArraySub1Column = list(viewsArray[idx])
del viewsArraySub1Column[0]
chieldItem.append((viewsArraySub1Column))
if (pastItem != viewsArray[idx][idx2+0]) and chieldItem != []:
if firstMulti == False:
chieldItem.append([''])
v1.append(items(pastItem,returnViews(chieldItem),'3'))
chieldItem=[]
firstMulti = True
else:
firstMulti = False
pastItem = viewsArray[idx][idx2+0]
idx = idx + 1
return (v1)
Is it possible to get Custom Properties contained within a view via a gateway script?
We have embedded in each view a Custom Property for Configuration Management.
I want a view in the runtime that shows this info. for all views in the system.
As a separate Table view, like this
There is no such thing. You would have to implement message handlers to push that information to a central data structure (probably a top-level object in a library script).
I haven't read much about 8.3 is something coming that will enable view level Config management, Versioning at a minimum?
Perspective already stores all of its views in git-friendly format on your gateway. (I can't answer most questions about v8.3, but it is known to be even more git-friendly.)
I presumed you were wanting to track some kind of runtime dynamic configuration. That wouldn't be versioned anywhere.
Why do you need this? (It seems to me you haven't made sufficiently generic parameterized views that can cover many uses.)
Yes Git is great and we are able to use that to do version control, however we wanted to be able to show which version of what view you are running in a gateway.
Also for a "Normal" user of the system they dont want to go into Git to check if they are running the latest version of a view.
Just seem missing to me not to be able to have simple version info on a view.
Perspective scripts run in the gateway, and can call external processes. There's nothing preventing you from have views extract and display their own git revision history and branch meta-data.