Skip to content

Latest commit

 

History

History
56 lines (48 loc) · 3.75 KB

File metadata and controls

56 lines (48 loc) · 3.75 KB

Iec012 - Parameter type needs correct DataType attribute

Severity: Error Error

The [DataType] attribute of parameters has to fit to the parameter type.

IEC methods that can have parameters are methods that either:

  • have the attribute [User] (here the [DataType] attribute for the Output parameter is defined on the method instead of the parameter)
  • have the attribute [Execution], are called __Process and are in a class with the attribute [Function] (here the [DataType] attribute for the Output parameter is defined on the class instead of the parameter)
  • have the attribute [Function] and are in a class with the attribute [FunctionContainer] (here the [DataType] attribute for the Output parameter is defined on the method instead of the parameter)

One correct mapping is a user defined type (structs with attributes [Structure], [Array] or [String] or enums with the [Enumeration] attribute) and its name. The correct mapping is shown inside the Readme.txt of each VS Template and looks like this:

IEC 61131-3 .NET Framework C#
BOOL System.Boolean bool
SINT System.SByte sbyte
INT System.Int16 short
DINT System.Int32 int
LINT System.Int64 long
USINT System.Byte byte
UINT System.UInt16 ushort
UDINT System.UInt32 uint
ULINT System.UInt64 ulong
REAL System.Single float
LREAL System.Double double
TIME System.Int32 int
LTIME System.Int64 long
LDATE System.Int64 long
LTIME_OF_DAY System.Int64 long
LDATE_AND_TIME System.Int64 long
BYTE System.Byte byte
WORD System.UInt16 ushort
DWORD System.UInt32 uint
LWORD System.UInt64 ulong
STRING System.Iec61131Lib.IecStringEx --------
STRING System.Iec61131Lib.IecString80 --------
WSTRING System.Iec61131Lib.IecWString --------
WSTRING System.Iec61131Lib.IecWString80 --------
ANY System.Iec61131Lib.Any --------
ANY_MAGNITUDE System.Iec61131Lib.Any --------
ANY_NUM System.Iec61131Lib.Any --------
ANY_INT System.Iec61131Lib.Any --------
ANY_SIGNED System.Iec61131Lib.Any --------
ANY_UNSIGNED System.Iec61131Lib.Any --------
ANY_REAL System.Iec61131Lib.Any --------
ANY_BIT System.Iec61131Lib.Any --------
ANY_ELEMENTARY System.Iec61131Lib.Any --------
ANY_STRING System.Iec61131Lib.Any --------

Solution

You can also use the provided automatic Code Fixes to change the [DataType] attribute argument to one of the possible mappings. ( Press Alt + Enter on the Error line to find the Code Fix in the context menu)

Change parameter type or IEC type in the [DataType] attribute to fit to each other.