Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the benefit of defining enumerators as a DUT?

The main goal of defining enumerators is to assign a variable to some numbers and their equal strings as I understand.

We can define var a as an enum everywhere in the initializing section of our Program or Function Block like this:

a:(start,stop,operate);

tough I don't know why we can't see that in tabular view but there there is a big question that:

What is the benefit of defining enumerators as a DUT?

like image 576
asys Avatar asked Oct 15 '25 11:10

asys


2 Answers

There are 3 main benefits for me:

  1. You can use the same enum in multiples function blocks
  2. You can use TO_STRING on enums declared as DUTs (After enabling it with {attribute 'to_string'} Infosys
  3. You can use refactoring on names of each component, which is impossible with local enums
like image 57
Jacek Domański Avatar answered Oct 18 '25 08:10

Jacek Domański


When defining an enum as a DUT it is available everywhere in your code (global scope). This is helpful in many cases, but in general it is not good programming practice to have a lot of stuff available in the global scope.

Here is a bit elaboration on the topic.

like image 21
Mikkel Avatar answered Oct 18 '25 08:10

Mikkel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!