Tag Browser in a Window

I wanted a quick way to show tags in a project, without adding a ton of labels. I know I can drag and drop tags to a window and create a control, but I wanted the name too.

I came up with this: use a tree view to show the tag database, bind it to a tableview to show the tags and values.

  1. Create a tree view. Populate it with this SQL. Set the FROM clause accordingly
SELECT path,name as text,'' as selectedtext
  FROM [ignTest].[dbo].[sqlt_core]
  where tagtype=6 and deleted=0
group by path,name
  order by path,name
  1. Create a list view - add a custom property called ‘path’ and bind it to the selectedPath of the tree view

  2. use this SQL in the list view:

SELECT name, CASE datatype when 0 then 'Int1' when 1 then 'Int2' when 2 then 'Int4' when 3 then 'Int8' when 4 then 'Float4' when 5 then 'Float8' when 6 then 'Boolean' when 7 then 'String' when 8 then 'DateTime' when 9 then 'DataSet' end as Type, CASE datatype when 0 then convert(varchar,intvalue) when 1 then convert(varchar,intvalue) when 2 then convert(varchar,intvalue) when 3 then convert(varchar,intvalue) when 4 then convert(varchar,floatvalue) when 5 then convert(varchar,floatvalue) when 6 then convert(varchar,intvalue) when 7 then convert(varchar,stringvalue) when 8 then convert(varchar,datevalue) when 9 then 'na' end as Value, --valuechange, case dataintegrity when 192 then 'Good' else 'Not Good' end as Integrity FROM [ignTest].[dbo].[sqlt_core] where path = '{Root Container.Tree View.selectedPath}'+'/' and deleted=0 and tagtype in (0,1)

Note that not all cases are handled, and this works for me. I just didn’t see anything quite like it when I was looking for this. I’m also thinking of using this as a way to get a trend of any point in the system, as I can trigger an event on the table view to bring up a pop up of the graph.


This looks pretty cool Tom.

I have to think abit on it, but I think I can turn this idea into a bulk edit screen :wink:


Add pop-up Trend:

  1. Create a pop window
  2. add two custom string properties on the root container: tagpath and tagname
  3. add an easychart
  4. use a SQL query on the Tag Pens property and use this code:
SELECT '['+meta.stringval+']'+path+core.name as tag_path,
FROM sqlt_core as core
left join sqlt_meta as meta
on core.id=meta.tagid and meta.name='PrimaryHistoryProvider'
WHERE path = '{Root Container.tagpath}'+'/'
and core.name = '{Root Container.tagname}'
and deleted=0
and enabled=1

Go back to your table in the tag browser window and add this to the mouseClicked event. I chose a double click to open a trend.

if event.clickCount == 2:
	r = event.source.selectedRow
	if r >= 0:
		tagname = event.source.data.getValueAt(r, "name")
	system.nav.openWindow('Popups/PopupTrend', {'tagname' : tagname,'tagpath':event.source.path})

Modify paths and names of windows accordingly.

All great information! However, this should probably be posted in the “User Submitted Content” section of the forums.

I was thinking that too. Can you move this thread there?

Edit: I see it’s been moved.

Is it work with internal tag or only with external source ?
Is it possible to access to sql_core table (for internal tag) with the sql query script function ?

Right now it is not possible to access tags stored in the internal database.