PLCnext / CSharpExamples

Collection of various C# sample code for PLCnext Technology controllers.
MIT License
13 stars 11 forks source link

Enums #3

Closed martinboers closed 3 years ago

martinboers commented 4 years ago

It would be interesting to see an example showing how to define and use enumerations.

mluhmann commented 3 years ago

You can use enums in C# and IEC 61131 as usual. They have to be defined in both worlds (probably the same) and to connect each other a port of type integer has to be used. This is different to the C++ implementation.

martinboers commented 3 years ago

I don't think it's necessary to define the enum in both worlds.

If a C# enum is declared with the [Enumeration] attribute (below), then it should be visible and useable in a PLCnext Engineer project, without declaring it again or connecting it using port variables.

image

An example would clearly demonstrate the use of this attribute.

mluhmann commented 3 years ago

Example will be in the next update.