Skip to content

Latest commit

 

History

History
24 lines (17 loc) · 1.93 KB

File metadata and controls

24 lines (17 loc) · 1.93 KB

Iec010 - Field type is ambiguous in IEC and should be explicitly defined with a DataType attribute

Severity: Suggestion Suggestion

When the type of a field attributed with [Local], [Output], [Input], [InOut], [InputPort] and [OutputPort] can be mapped to multiple IEC types a default type is used. Consider using the [DataType] attribute to explicitly choose a mapped type.

Ambiguous types and their IEC types are shown in the following table (all mappings are shown inside the Readme.txt of each VS Template). If no [DataType] attribute is specified the type is mapped by default to the IEC data type in bold letters:

C# .NET Framework IEC 61131-3 types
byte System.Byte USINT, BYTE
int System.Int32 DINT, TIME
long System.Int64 LINT, LTIME, LDATE, LTIME_OF_DAY, LDATE_AND_TIME
ushort System.UInt16 UINT, WORD
uint System.UInt32 UDINT, DWORD
ulong System.UInt64 ULINT, LWORD
--- System.Iec61131Lib.Any ANY, ANY_MAGNITUDE, ANY_NUM, ANY_INT, ANY_SIGNED, ANY_UNSIGNED, ANY_REAL, ANY_BIT, ANY_ELEMENTARY, ANY_STRING

Solution

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

Insert a [DataType] attribute with the name of the IEC type you want to map to.