Gets / Sets the .NET Type of the PLC value
Setting this property will set the DataType property as follows:
| System.Boolean = ATOMIC.BOOL |
| System.SByte = ATOMIC.SINT |
| System.Byte = ATOMIC.SINT |
| System.Int16 = ATOMIC.INT |
| System.UInt16 = ATOMIC.INT |
| System.Int32 = ATOMIC.DINT |
| System.UInt32 = ATOMIC.DINT |
| System.Single = ATOMIC.REAL |
| System.Double = ATOMIC.REAL |
|
System.Int64 = ATOMIC.LINT |
|
System.Object = ATOMIC.OBJECT |
| Exception Type | Condition |
|---|---|
| ArgumentException | Thrown if invalid Type is set. |
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.NetType
Case System.Boolean
Console.WriteLine("Tag is type Boolean")
Case System.SByte
Console.WriteLine("Tag is type SINT")
Case System.Int16
Console.WriteLine("Tag is type INT")
Case SystemInt32
Console.WriteLine("Tag is type DINT")
Case System.Single
Console.WriteLine("Tag is type REAL")
Case System.String
Console.WriteLine("Tag is type STRING")
Case System.Int64
Console.WriteLine("Tag is type LINT")
Case System.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.NetType)
{
case System.Boolean:
Console.WriteLine("Tag is type BOOL");
break;
case System.SByte:
Console.WriteLine("Tag is type SINT");
break;
case System.Int16:
Console.WriteLine("Tag is type INT");
break;
case System.Int32:
Console.WriteLine("Tag is type DINT");
break;
case System.Single:
Console.WriteLine("Tag is type REAL");
break;
case System.String:
Console.WriteLine("Tag is type STRING");
break;
case System.Int64:
Console.WriteLine("Tag is type LINT");
break;
case System.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);
}
Tag Class | Logix Namespace | DataType | Tag.ATOMIC