using a generator feedback on sharing a generator. improvement’s on generation’s creation and...
TRANSCRIPT
Using a generator
Feedback on sharing a generator.Improvement’s on generation’s
creation and maintenance.
Outline
• CIET/SURVEY implementation overview.– Intro to the common CIET/SURVEY generator.
• Review the differences that shared generator has made:– There’s no additional complexity in the templates!
• Further improvements:– Support the approach in the UAB Core.
UAB Architecture
UAB Core
SURVEYInterX FESA
generator
SURVEYInterX
WCCOAgenerator
SURVEYSAS
FESAgenerator
SURVEYSAS
WCCOAgenerator
CIETFESA
generator
CIETWCCOA
generator
SURVEYInterX FESA
templates
SURVEYInterX
WCCOAtemplates
SURVEYSAS
FESAtemplates
SURVEYSAS
WCCOAtemplates
CIETFESA
templates
CIETWCCOA
templates
What do we do in generator?
• Execute templates:– As part of device type templates set– As a standalone template
• Provide an access to query data:– i.e. instance.getAttributeData
• Implement API for output file’s generation:– It could be one or several files– A file could be split in different sections (header,
footer, …)
UAB Architecture
UAB Core
Stub generator
Stub generator
Stub generator
Stub generator
Stub generator
SURVEYInterX FESA
templates
SURVEYInterX
WCCOAtemplates
SURVEYSAS
FESAtemplates
SURVEYSAS
WCCOAtemplates
CIETFESA
templates
CIETWCCOA
templates
SURVEY/CIET shared generator
Stub generator
UAB SURVEY/CIET
What we have now:• 1 shared class– Serves all needs
• 6 stub generators (the class name holders)– Inherits superclass behaviour with no changes– Keep a UnicosApplication.xml piece for
UABBootstrap
An example of stub generator/** * UNICOS * * Copyright (C) CERN 2013 All rights reserved */package research.ch.cern.unicos.plugins.survey.interx.feig;
import research.ch.cern.unicos.plugins.survey.core.SurveyGenerator;
public class InterXFrontEndInstancesGenerator extends SurveyGenerator {
@Override public String getVersionId() { return "1.0.0"; }
@Override public String getDescription() { return "This code generation plug-in is designed for SURVEY FrontEnd instances generation."; }}
CIET/SURVEY generator’s duties:
Serves CIET/SURVEY needs:• Generic execution workflow
– Based on UnicosApplication.xml• Generic output API
– writeInstanceInfo(filename, instanceData)– writeInstanceInfo(filename, sectionID, instanceData)– setInstanceInfo(filename, instanceData)– setInstanceInfo(filename, sectionID, instanceData)– clearInstanceInfo(filename, sectionID)– formatInstanceInfoAsXML(filename)
• Generic Oracle API
Review of implementation
1. Launching templates– Affects UA.xml and generator
2. Writing files– Affects generator and templates
3. Accessing Oracle DB– Affects UA.xml, generators and templates
There’s no additional complexity in templates!There’s not many differences from CPC!
Review: launching templates
Dedicated plugin• UnicosApplication.xml
– Any place in plugin section– PluginID:Templates list by
convention
• Generator.java– Implement which templates
to run and in which order– Can pass additional info by
parameters (very few, i.e. recipe buffer size)
Reusing the plugin• UnicosApplication.xml
– PluginID:GenerationRules list only
• Inherited logic– Run all template from the list
above– The same set of parameters– Template must get additional
info by itself
Difference: accessing additional info (from UA.xml or spec) has been moved to the templates. Templates used to have this access.
How we write files
Global PLC Template
Output.txt
DeviceA Template
DeviceB Template
DeviceC Template
#SASWinCCOAConfigGenerator#Generated Objects:#DeviceA: 2#DeviceB: 1#DeviceC: 55
#Delete;plcName;appName1PLCCONFIG;plcType;plcName;appName;..
DeviceA;1;alias_a1;…DeviceA;2;alias_a2;…
DeviceB;1;alias_b1;…
DeviceC;1;alias_c1;……
DBHeader
DeleteStatement
PlcDeclaration
Instances
UAB Generator- calls templates- provides output API
Review: writing files
Dedicated plugin• Generator.java
– Implement your way to generate files
• Templates– Call specific methods
• writeDBHeader(data)
• writeDeleteStatement(data)
Reusing the plugin• Inherited logic
– Generic API
• Templates– Call generic methods
• writeInstanceInfo(filename, HEADER_SECTION, data)• writeInstanceInfo(filename, DELETE_SECTION, data)
Difference: calculate file name and manage file section constants.
Defined in global template
Review: Accessing Oracle DB
Dedicated plugin• UnicosApplication.xml
– Nothing?
• Generator.java– Implement querying db
• Templates– Query DB
Reusing the plugin• UnicosApplication.xml
– Enable access DB
• Inherited logic– Use generic query API
• Templates– Query DB
Difference: they are the same.
Achievements
• Less java maintenance:– 6x times less for CIET/SURVEY– Higher reusability rate– Easier upgrade to the new UAB Core
• Templates have more in common– Easier to support it • writeDBHeader vs writeInstanceInfo
• New templates can reuse existing generators– Templates developers don’t need to do java
Next stepMove the shared generator to the UABCore:• Remove cross-dependencies• Allows CPC to use it• When it’s better:
– Use-case: add a new template to existing project– Use-case: add a new output file
Improve UAB Core to allow to reuse generator. Profits:• To remove stub generators
– Don’t keep the code we don’t need• Use-case: add another touch panel implementations• Fast and easy development start
– Start straight with templates, add custom generator when it’s really needed
Workflow: new UAB component
1. Install UAB development env
3. Add a generation plugin
2. Set up Eclipse
6. Develop templates
5. Create a UAB project
4. Implement a generation plugin
7. Release a generation plugin
Workflow: new UAB component
1. Install UAB development env
3. Add a generation plugin
2. Set up Eclipse
6. Develop templates
5. Create a UAB project
4. Implement a generation plugin
7. Release a generation plugin
8. Share the project
Use UAB instead!
Integration to UAB architecture
The templates should define which plugin to use.
We can think of sharing plugin between:– CPC WinCC OA and Generic SURVEY/CIET plugin– Touch panel and Generic SURVEY/CIET plugin– Schneider and CoDeSyS
We should not change the old plugins if we don’t need it.
Requirements
• Use specified in UA.xml generator class– generator name != templates folder name– We already have it: GeneralData:MainClass
• Move UnicosApplication.xml piece to the resource package– Used by bootstrap, the big change is coming
anyway with “versioning”
<Parameters> <ParameterList Name="InterXWinCCOAConfigGenerator"> <ParameterList Name="GeneralData"> <ClassParameter Name="MainClass" Value="...InterXWinCCOAConfigGenerator"/> <PathParameter Name="TemplatesFolder" Value="Resources/../Rules/"/> <StringParameter Name="TemplatesPrefix" Value="Survey_" /> <BooleanParameter Name="ProcessSemanticRules" Value="true" /> <StringParameter Name="DeviceTypeClass" Value="InterX" /> <StringParameter Name="ApplicationPlace" Value="production" /> <StringParameter Name="FESADevicesPrefix" Value="SURVEY" /> </ParameterList> <ParameterList Name="GenerationRules" > <PathParameter Name="ApplicationGeneralPLC" Value="GlobalTemplates/Survey_InterX_WinCCOA_GeneralRulesPLC.py" /> <PathParameter Name="TypeTemplatesFolder" Value="TypeTemplates/" /> </ParameterList> <ParameterList Name="OutputParameters" > <PathParameter Name="OutputFolder" Value="Output/INTERX/" /> </ParameterList> <ParameterList Name="UNICOSTypesToProcess" /> <ParameterList Name="GenerationInfo"> <PathParameter Name="InstancesConfigurationFileName" Value="" /> <DateTimeParameter Name="InstancesLastModified" Value="" /> <DateTimeParameter Name="LastGeneration" Value="" /> </ParameterList> </ParameterList> </Parameters>