hans gerritsen wrote:Hi Patrick,
I have already a working version but your solution would much much better!!
But I only need those tags which are ReadWrite or Write and I have to know what kind of type it is (Bool, INT16, etc). I can't find how to do that.
Thanks in advance.
Let us reference back to my previous post [
HERE] near the bottom you will find this code snippet...
Code: Select all
ListBox1.Items.Clear();
foreach(GlobalDataItem gdi in Globals.Tags.GetTags<GlobalDataItem>()){
ListBox1.Items.Add(string.Format("{0}={1}",gdi.Name, gdi.Value));
}
As you are quite aware the line
ListBox1.Items.Add(string.Format("{0}={1}",gdi.Name, gdi.Value)); is simply using string format to generate a string from the various properties on a GlobalDataItem [bolded] and in this case Name and Value (of type VariantValue). This is simply calling the properties .ToString() method implicitly.
Other properties of interest are .AccessRight, .DataType, and .GlobalDataType.
To determine if a tag is Read, Write or ReadWrite you can access the AccessRight property which returns an enum of type
Neo.ApplicationFramework.Interfaces.AccessRights ... [gdi.AccessRight]
Simply checking if it is AccessRights.Write, or AccessRights.ReadWrite should indicate if the value can be changed as a result of a "load from CSV" (Assuming you get the VariantValue conversion correct).
GlobalDataType and DataType are both enums of type
Neo.ApplicationFramework.Interop.DataSource.BEDATATYPE and pertain to columns A and C respectively. Column B is determined by the afformentioned .AccessRight property. see next image.
- DynamicTagList_PropCoor.png (43.11 KiB) Viewed 22318 times
and using this updated bit of code...
Code: Select all
ListBox1.Items.Clear();
foreach(GlobalDataItem gdi in Globals.Tags.GetTags<GlobalDataItem>()){
ListBox1.Items.Add(string.Format("{0,5}={1,15} [{2,12}, {3,10}, {4,12}]",
gdi.Name,
gdi.Value,
gdi.GlobalDataType,
gdi.AccessRight,
gdi.DataType));
}
we see this...
- DynamicTagList_v2.png (15.24 KiB) Viewed 22318 times
as you can see DT_REAL4 is a Float (I would guess DT_REAL8 to be a Double) DT_INTEGER2 is a "INT16" so a DT_INTEGER4 should be an "INT32" etc.
I'm sure with a little trial and error you should be able to figure out the other enumeration options (i.e. DT_* enum values for other data types).