Welcome Guest ( Login | Register )



All times are UTC - 7 hours [ DST ]



Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Writing tag values to a file
PostPosted: Fri Nov 23, 2012 4:52 pm 

Joined: Fri Jan 20, 2012 12:55 pm
Posts: 26

Offline
While generating a list of the Global.Tags, is there a possibility to find out if the particular tag is marked as a Bit, Bool, string etc.?
Is there also a way to find out if the tag is marked as Read, Write or Readwrite?


 Profile  
 
 Post subject: Re: Writing tag values to a file
PostPosted: Mon Nov 26, 2012 9:57 am 

Joined: Tue Mar 13, 2012 9:53 am
Posts: 824

Offline
There is no way that I know of to access the data type or tag access type through scripting.

_________________
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer


 Profile  
 
 Post subject: Re: Writing tag values to a file
PostPosted: Mon Nov 26, 2012 12:38 pm 

Joined: Fri Jan 20, 2012 12:55 pm
Posts: 26

Offline
Ok. Thanks anyway for your help on this subject.


 Profile  
 
 Post subject: Re: Writing tag values to a file
PostPosted: Mon Nov 26, 2012 1:21 pm 

Joined: Fri May 25, 2012 7:44 am
Posts: 22
Location: Charlotte, NC. USA

Offline
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:
         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.

Attachment:
DynamicTagList_PropCoor.png
DynamicTagList_PropCoor.png [ 43.11 KiB | Viewed 6223 times ]


and using this updated bit of code...
Code:
         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...
Attachment:
DynamicTagList_v2.png
DynamicTagList_v2.png [ 15.24 KiB | Viewed 6223 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).

_________________
Best Regards,
Patrick Hall


 Profile  
 
 Post subject: Re: Writing tag values to a file
PostPosted: Mon Nov 26, 2012 3:20 pm 

Joined: Fri Jan 20, 2012 12:55 pm
Posts: 26

Offline
Perfect!
Thanks a lot Patrick


 Profile  
 
 Post subject: Re: Writing tag values to a file
PostPosted: Tue Aug 27, 2013 12:01 am 

Joined: Thu Nov 17, 2011 2:10 am
Posts: 49
Location: Norway

Offline
Really helpfull, Patrick :)


 Profile  
 
 Post subject: Re: Writing tag values to a file
PostPosted: Fri Feb 05, 2016 5:44 am 

Joined: Fri Jan 20, 2012 12:55 pm
Posts: 26

Offline
I can read the GlobalDataType, AccessRight etc as described in previous topics.
How can I read if the tag is an array and the size of this array?
For example: tag 'Test' is of DataType=Bool[8]. The array size =8.


 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2

All times are UTC - 7 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: