/// <summary>
/// Returns the Data Type of the PLC object as a string
/// </summary>
/// <param name="type">The Type of the PLC oject</param>
/// <param name="dimensions">The Dimensions of the PLC object</param>
/// <param name="isAOI">Reference bool to indicate if the PLC object is an Add On Instruction</param>
/// <param name="isArray">Reference bool to indicate if the PLC object is an Array</param>
/// <param name="isUDT">Reference bool to indicate if the PLC object is an User Defined Type</param>
/// <returns>The tag data type as string</returns>
//-----------------------------------------------------------------------------------------
public string GetTagDataType(int type, uint[] dimensions, out bool isAOI, out bool isArray, out bool isUDT)
//-----------------------------------------------------------------------------------------
{
string value = @"";
string array = @"";
isAOI = (type & 0x1000) == 0x1000;
isArray = (type & 0x2000) == 0x2000;
isUDT = (type & 0x8000) == 0x8000;
if (isArray)
{
array = @"[" + dimensions[0].ToString();
if (dimensions[1] > 0) array += @"," + dimensions[1].ToString();
if (dimensions[2] > 0) array += @"," + dimensions[2].ToString();
array += @"]";
}
type &= 0x1fff; // AOI
type &= 0x2fff; // Array
type &= 0x8fff; // UDT
switch (type)
{
case 0xC1: value = @"BOOL{0} - Boolean value, 1 bit"; break;
case 0xC2: value = @"SINT{0} - Signed 8–bit integer value"; break;
case 0xC3: value = @"INT{0} - Signed 16–bit integer value"; break;
case 0xC4: value = @"DINT{0} - Signed 32–bit integer value"; break;
case 0xC5: value = @"LINT{0} - Signed 64–bit integer value"; break;
case 0xC6: value = @"SINT{0} - Unsigned 8–bit integer value"; break;
case 0xC7: value = @"INT{0} - Unsigned 16–bit integer value"; break;
case 0xC8: value = @"DINT{0} - Unsigned 32–bit integer value"; break;
case 0xC9: value = @"LINT{0} - Unsigned 64–bit integer value"; break;
case 0xCA: value = @"REAL{0} - 32–bit floating point value, IEEE format"; break;
case 0xCB: value = @"LREAL{0} - 64–bit floating point value, IEEE format"; break;
case 0xCC: value = @"LINT{0} - Synchronous time value"; break;
case 0xCD: value = @"LINT{0} - Date value"; break;
case 0xCE: value = @"LINT{0} - Time of day value"; break;
case 0xCF: value = @"LINT{0} - Date and time of day value"; break;
case 0xD0: value = @"STRING{0} - Character string, 1 byte per character"; break;
case 0xD1: value = @"STRING{0} - 8-bit bit string"; break;
case 0xD2: value = @"STRING{0} - 16-bit bit string"; break;
case 0xD3: value = @"STRING{0} - 32-bit bit string"; break;
case 0xD4: value = @"STRING{0} - 64-bit bit string"; break;
case 0xD5: value = @"STRING{0} - Wide char character string, 2 bytes per character"; break;
case 0xD6: value = @"LINT{0} - High resolution duration value"; break;
case 0xD7: value = @"LINT{0} - Medium resolution duration value"; break;
case 0xD8: value = @"LINT{0} - Low resolution duration value"; break;
case 0xD9: value = @"STRING{0} - N-byte per char character string"; break;
case 0xDA: value = @"STRING{0} - Counted character sting with 1 byte per character and 1 byte length indicator"; break;
case 0xDB: value = @"LINT{0} - Duration in milliseconds"; break;
case 0xDC: value = @"STRING{0} - CIP path segment"; break;
case 0xDD: value = @"STRING{0} - Engineering units"; break;
case 0xDE: value = @"STRING{0} - International character string"; break;
case 0xA0: value = @"UDT{0} - Data is an abbreviated struct type, i.e. a CRC of the actual type descriptor"; break;
case 0xA1: value = @"ARRAY{0} - Data is an abbreviated array type. The limits are left off"; break;
case 0xA2: value = @"UDT{0} - Data is a struct type descriptor"; break;
case 0xA3: value = @"ARRAY{0} - Data is an array type descriptor"; break;
}
value = String.Format(value, array);
if (isAOI) value = @"AOI - Add On Instruction";
if (isUDT) value = @"UDT - User Defined Type";
return value;
}
Best regards
Jochen