Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

How to create an alias or other parallel definition to a structure

trevorb
2022-10-24
2022-10-27
  • trevorb

    trevorb - 2022-10-24

    Hi All,

    Thanks in advance for any advice you can offer.

    We use the SEW-Eurodrive MoviC controller using the CodeSys platform.

    SEW in their wisdom have very long naming convention for their devices.

    For example. The bit to activate their velocity profile is Interface_Axis1.ProfileGeneration.Velocity.In.xActivate
    We would like to improve the readability by having a condensed version such as
    Axis1.PG.Vel.In.xActivate

    Any thoughts on how we could alias all or parts of their axis structure?

     
  • fajean - 2022-10-25

    I have not worked like you do with ladder diagrams, but here are a few ideas that may, or may not work for you.

    • Declare and initialize REFERENCE TO variables (similar to pointers, but typically cleaner syntax) to your most used variables. For instance, you could reduce "Interface_Axis1.ProfileGeneration" to "Ax1PG".
    • If this is an option, write your ladder diagram as a method of a function block that inherits from the manufacturer's main function block. That could allow the first level of naming to be implicit and completely skipped in the diagram.
    • Rename the first level over which you might have influence, such that * Interface_Axis1 becomes "ax1" for instance.
    • Use all of these together for combined effect, for instance by declaring references as member variables in a function block, which could give you something like "Ax1.PG", or just "PG" when used inside a method of the "Ax1" function block.
      .

    Creating additional code just to shorten identifiers trades code compactness for additional complexity and potential bugs. Be careful that the solution does not become worse than the problem, especially as time passes and you have to maintain code where many of the most used elements can be reached using different paths. Long-term readability is a multi-faceted problem, and identifier length may not be the main factor at play.

     
    πŸ‘
    1

    Last edit: fajean 2022-10-25
  • trevorb

    trevorb - 2022-10-27

    Yeah wow. That doesn't look like it will simplify things so will not go down that path.
    The reason I ask is because AB has an alias option for tags which are a direct reference to the same tag or structure just with a different name. Hoping there was a similar solution here too.

    Thanks for your response

     
  • fajean - 2022-10-27

    Maybe I am making things look more complicated than they are. Variables defined as "REFERENCE TO" are "direct reference to the same tag or structure just with a different name". I have not used AB environments, but maybe it is not so different after all?

    As for the rest, what one considers "simple" is always defined in terms of what they know and prefer, as well as the problem to be solved. My "simple" is likely, for good reasons, not the same as yours.

     

Log in to post a comment.