PLCgen: Re-organize how generators exchange information
In the current setup, the target creates all generators and stores their references. Many generators store a reference to the target and use that to obtain a reference to other generators in order to exchange information or results between them.
This worked nicely to avoid cluttering the constructor interface and to avoid awkward generator construction order. Also, there wasn't a need for a central "main" program that leads the code generation process. Each generator knew what to do, and just needed a gentle "do it" message to activate it.
A few months ago however, it was found that each generator doing its thing is less useful if several forms of PLC output are desired. A different result could need a different interaction pattern between generators, and it is not clear whether changing those patterns will not break the result in some cases. A more centrally guided approach seems useful here.
In addition, the PLC code generators are currently stable in what part of the code generation they cover. Also, the current order of the gentle "do it" calls is working. That current order of processing is the current "main program".
The order of processing however also includes generators talking to other generators, so this should be pulled out of the generators and up into the main program as well. In that way, communication between generators becomes explicit in the main program. It becomes easier to understand and analyze how various parts of the code generation are related.
The optimal end-result is alike to how an application is performing cif2cif pre-processing. Sequentially create transformations and apply them, one at a time. Very likely this result is not fully obtainable. The cif2cif transformations are much more independent of each other than the generators in PLCgen.
The conversion process should basically eliminate the target functionality that is not target related. That is, make target know only about properties of the target and (hopefully) nothing else.
Generators to modify:
-
NameGenerator
,DefaultNameGenerator
. (!1069 (merged)) -
TypeGenerator
,DefaultTypeGenerator
. (!1069 (merged)) -
CifProcessor
-
ContinuousVariablesGenerator
,DefaultContinuousVariablesGenerator
-
TransitionGenerator
,DefaultTransitionGenerator
-
VariableStorage
,DefaultVariableStorage
-
InputOutputGenerator
-
PlcCodeStorage
The name-generator and type-generator are used differently from the other generators.
They provide a general service that many other generators need. The name generator only returns results directly to its callers.
The type generator also returns a result directly to its callers and to code-storage. The latter however only needs those results at near the end of the code generation process.
The other generators all receive one call from the main program, and all except code-storage immediately share their results with other generators.
Addresses #679