Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • E escet
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Graph
    • Compare
    • Locked Files
  • Issues 92
    • Issues 92
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 5
    • Merge requests 5
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Eclipse ProjectsEclipse Projects
  • Eclipse ESCET (Supervisory Control Engineering Toolkit)
  • escet
  • Issues
  • #78
Closed
Open
Issue created May 07, 2021 by Ferdie Reijnen@freijnenDeveloper

Implement enums-to-consts CIF to CIF transformation

When code is generated from a CIF model, the CIF to CIF linearize merge transformation is used. This transformation introduced location pointers to represent the locations of an automaton. The location pointer has an enum type. Not all PLCs support enumeration types (e.g., Siemens S7-300), that's why the CIF to PLC transformation has an option Eliminate enumerations. This is the CIF to CIF elim-enums transformation.

This transformation transforms enumeration literals into integers. A downside of this transformation is that it introduces a lot of magic numbers.

An alternative solution to replace enums with constants.

If we decide to do this, we should:

  • Rename the current elim-enums to enums-to-ints.
  • Implement enums-to-consts.
  • Depricate elim-enums
  • Add CIF to PLC option to replace enums with constants.

enums-to-consts

  • Use ranged integers, similar to enums-to-ints, but the values are not numbers directly, but use constants. The constants have the names of the original enumeration literals, to keep the original names alive.
  • Scoping issues for constants: must eliminate component definition/instantiation first (or demand as pre-condition, as other CIF to CIF transformations do).
  • Works with variables of enumeration type and 'any' as initial value, due to use of ranged int type.
  • Performance similar to enums-to-ints, as it also uses integers, especially if we eliminate constants.
  • The constants are created in the same scope as the original enumeration literals, so no renaming needed.

I know @ahofkamp is working on a new version of the PLC code generator and then this might not be needed anymore. However, until then this is an easy to implement alternative. Moreover, this transformation can also be useful for other applications.

Edited May 07, 2021 by Dennis Hendriks
Assignee
Assign to
Time tracking

Copyright © Eclipse Foundation, Inc. All Rights Reserved.     Privacy Policy | Terms of Use | Copyright Agent