INGEAR.NET.Logix

 

Tag.DataType Property

Sets / Returns one of the enumerated Tag.ATOMIC types.

[Visual Basic]
Public Property DataType As ATOMIC
[C#]
public Tag.ATOMIC DataType {get; set;}

Remarks

If you perform a WriteTag operation prior to a ReadTag you must explicitly set the .DataType or NetType property.

You must always set this property for BOOL Arrays and STRING tags

Example

VB
Try
  ' ********************************
  ' * initialize controller and tag
   Dim MyPLC as New Logix.Controller("192.168.1.31")
   Dim MyTag as New Logix.Tag("MyTag")
   ' *******************************
   ' * Read tag
   MyPLC.ReadTag(MyTag)
   ' *******************************
   ' * check the status
   If ResultCode.QUAL_GOOD = MyTag.QualityCode Then
      Console.WriteLine(MyTag.Timestamp.ToString())
      Select Case MyTag.DataType
        Case Tag.ATOMIC.BOOL
          Console.WriteLine("Tag is type Boolean")
        Case Tag.ATOMIC.SINT
          Console.WriteLine("Tag is type SINT")  
        Case Tag.ATOMIC.INT
          Console.WriteLine("Tag is type INT")
        Case Tag.ATOMIC.DINT
          Console.WriteLine("Tag is type DINT")
        Case Tag.ATOMIC.REAL
          Console.WriteLine("Tag is type REAL")
        Case Tag.ATOMIC.STRING
          Console.WriteLine("Tag is type STRING")


        Case Tag.ATOMIC.LINT
          Console.WriteLine("Tag is type LINT")
        Case Tag.ATOMIC.OBJECT
          Console.WriteLine("Tag is type OBJECT")      End Case                 Else      Console.WriteLine(MyTag.ErrorString)   End If   Console.WriteLine(MyTag.QualityString) Catch ex As System.Exception   Console.WriteLine(ex.Message) End Try    C# try {  //////////////////////////////////  // initialize controller and tag  Logix.Controller MyPLC = new Logix.Controller("192.168.1.31");  Logix.Tag MyTag = new Logix.Tag("MyTag");  /////////////////////////////////  // write value to PLC  MyPLC.ReadTag(MyTag);  //////////////////////////////////  // check results  if(ResultCode.QUAL_GOOD == MyTag.QualityCode)    Console.WriteLine(MyTag.Timestamp.ToString());    switch(MyTag.DataType)    {        case Tag.ATOMIC.BOOL:          Console.WriteLine("Tag is type BOOL");          break;        case Tag.ATOMIC.SINT:          Console.WriteLine("Tag is type SINT");          break;        case Tag.ATOMIC.INT:          Console.WriteLine("Tag is type INT");          break;        case Tag.ATOMIC.DINT:          Console.WriteLine("Tag is type DINT");          break;        case Tag.ATOMIC.REAL:              Console.WriteLine("Tag is type REAL");          break;        case Tag.ATOMIC.STRING:          Console.WriteLine("Tag is type STRING");          break;
        case Tag.ATOMIC.LINT:             
          Console.WriteLine("Tag is type LINT");          
          break;
        case Tag.ATOMIC.OBJECT:
          Console.WriteLine("Tag is type OBJECT");
          break;
    }           else    Console.WriteLine(MyTag.ErrorCode);  Console.WriteLine(MyTag.QualityString);     } catch(System.Exception ex) {  Console.WriteLine(ex.Message); }  

See Also

Tag Class | Logix Namespace | NetType