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.
- 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
-
Create a list view - add a custom property called ‘path’ and bind it to the selectedPath of the tree view
-
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.
Enjoy!