Skip to content
Snippets Groups Projects
Commit ad43a815 authored by al.schwinn's avatar al.schwinn
Browse files

rename "multiplexed" to "cycle-bound" for fess 7.3.0

Support for FESA Version: 7.3.0
- Add unit tests for Fesa 7.3.0
- Run unit-tests only for latest FESA version
parent 04f58e6e
No related branches found
No related tags found
No related merge requests found
Showing
with 513 additions and 960 deletions
#!/usr/bin/python
# Copyright 2016 CERN and GSI
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import fesa.fillFesaDeployUnitBase
import fesa.fesa_3_1_0.fillFESADeployUnit
def fillDeployUnit(fesaVersion, className, workspacePath,fesaDesignXSDPath,logTopics={'errorlog': True}):
generator = fesa.fesa_3_1_0.fillFESADeployUnit.FESADeployUnitGenerator3_0_0() # identical with FESA 3.1.0
fesa.fillFesaDeployUnitBase.fillFesaDeployUnitBase(generator,fesaVersion, className, workspacePath,fesaDesignXSDPath,logTopics)
#!/usr/bin/python
# Copyright 2016 CERN and GSI
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import fesa.fesa_3_1_0.generateBuildEnvironment
def genMakefileClass(projectPath, centralMakefilePath, logTopics={'errorlog': True} ):
return fesa.fesa_3_1_0.generateBuildEnvironment.genMakefileClass(projectPath, centralMakefilePath, logTopics )
def genMakefileDU(projectPath, silecsBasePath, snap7BasePath, logTopics={'errorlog': True}):
return fesa.fesa_3_1_0.generateBuildEnvironment.genMakefileDU(projectPath, silecsBasePath, snap7BasePath, logTopics )
def genCProjectFile(projectPath, logTopics={'errorlog': True}):
return fesa.fesa_3_1_0.generateBuildEnvironment.genCProjectFile(projectPath, logTopics )
#!/usr/bin/python
# Copyright 2016 CERN and GSI
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import fesa.fillFesaDesignBase
import fesa.fesa_3_1_0.generateFesaDesign
from iecommon import *
def fillDesignFile(fesaVersion, className, workspacePath,fesaDesignXSDPath,logTopics={'errorlog': True}):
generator = FESADesignGenerator7_3_0()
fesa.fillFesaDesignBase.fillDesignFileBase(generator,fesaVersion, className, workspacePath,fesaDesignXSDPath,logTopics)
class FESADesignGenerator7_3_0(fesa.fesa_3_1_0.generateFesaDesign.FESADesignGenerator3_1_0):
#overwrite 3_0_0 version (multiplexed --> cycle-bound)
def getOrCreateAcquisitionProperty(self,parent,actionsNode,block):
iecommon.logDebug('Generating AcquisitionProperty for Block: ' + block.name, {'debuglog': True})
prop = ""
if( hasChildren(parent)):
prop = getOrCreateNamedPreviousSiblingElement(parent,getFirstChild(parent), 'acquisition-property',block.getFesaName())
else:
prop = getOrCreateNamedChildElement(parent,'acquisition-property',block.getFesaName())
fillAttributes(prop, {'visibility': 'development', 'subscribable': 'true', 'cycle-bound': 'false', 'on-change': 'true'})
self.getOrCreateRegisterValueItems(prop,block,"OUT")
self.getOrCreateAcqStampItem(prop)
self.getOrCreateUpdateFlagItem(prop)
self.getOrCreateCyleNameItem(prop)
self.getOrCreateCyleStampItem(prop)
self.getOrCreateAction(prop,block.fesaGetServerActionName,'get',actionsNode,'custom')
return prop
#overwrite 3_0_0 version (multiplexed --> cycle-bound)
def getOrCreateGSIAcquisitionProperty(self,parent,actionsNode,block):
iecommon.logDebug('Generating GSIAcquisitionProperty for Block: ' + block.name, {'debuglog': True})
versionProps = parent.xpathEval('GSI-Version-Property')
if len(versionProps) == 0:
raise Exception("Error: A GSI-Version-Property needs to be available to generate a GSIAcquisitionProperty")
prop = getOrCreateNamedPreviousSiblingElement(parent,versionProps[0], 'GSI-Acquisition-Property',block.getFesaName())
fillAttributes(prop, {'visibility': 'development', 'subscribable': 'true', 'cycle-bound': 'false', 'on-change': 'true'})
self.getOrCreateRegisterValueItems(prop,block,"OUT")
self.getOrCreateAcqStampItem(prop)
self.getOrCreateUpdateFlagItem(prop)
self.getOrCreateCyleNameItem(prop)
self.getOrCreateCyleStampItem(prop)
self.getOrCreateAction(prop,block.fesaGetServerActionName,'get',actionsNode,'custom')
self.getOrCreateAcquisitionContextItem(prop)
return prop
#overwrite 3_0_0 version (multiplexed --> cycle-bound for acquisition fileds)
def genData(self,designClass, doc,logTopics):
iecommon.logDebug("Creating data fields", logTopics)
dataNode = doc.xpathEval('/equipment-model/data')[0]
iecommon.logError("len(dataNode)" + dataNode.get_name(), logTopics)
deviceDataNode = getOrCreateChildElement(dataNode,'device-data')
configurationNode = getOrCreateChildElement(deviceDataNode,'configuration')
settingNode = getOrCreateChildElement(deviceDataNode,'setting')
acquisitionNode = getOrCreateChildElement(deviceDataNode,'acquisition')
self.getOrCreatePLCHostNameField(configurationNode)
self.getOrCreatePLCDeviceLabelField(configurationNode)
for block in designClass.getDesignBlocks():
for reg in block.getDesignRegisters():
if reg.isSetting():
fieldNode = self.getOrCreateFieldNode(settingNode,reg)
fillAttributes(fieldNode, {'multiplexed': 'false', 'persistent': 'true'})
elif reg.isAcquisition():
fieldNode = self.getOrCreateFieldNode(acquisitionNode,reg)
fillAttributes(fieldNode, {'cycle-bound': 'false', 'persistent': 'false'})
elif reg.isConfiguration():
fieldNode = self.getOrCreateFieldNode(configurationNode,reg)
else:
raise Exception( "Cannot identify register-type to use for register:" + reg.name )
self.getOrCreateType(fieldNode,reg)
globalDataNode = getOrCreateChildElement(dataNode,'global-data')
globalConfigurationNode = ""
if len(globalDataNode.xpathEval("configuration")) == 0:
if len( globalDataNode.xpathEval("*")) == 0:
globalConfigurationNode = getOrCreateChildElement(globalDataNode,'configuration')
else:
globalConfigurationNode = getOrCreatePreviousSiblingElement(getFirstChild(globalDataNode),'configuration')
else:
globalConfigurationNode = globalDataNode.xpathEval("configuration")[0]
self.getOrCreatePLCClassVersionField(globalConfigurationNode,designClass.version)
#!/usr/bin/python
# Copyright 2016 CERN and GSI
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import fesa.fesa_3_0_0.generateSourceCode
def genHSource(className, silecsRoot, fesaRoot, sourcePath,logTopics):
return fesa.fesa_3_0_0.generateSourceCode.genHSource(className, silecsRoot, fesaRoot, sourcePath,logTopics)
def genCppSource(className, silecsRoot, fesaRoot, sourcePath,logTopics):
return fesa.fesa_3_0_0.generateSourceCode.genCppSource(className, silecsRoot, fesaRoot, sourcePath,logTopics)
def genCppFiles(className, workspacePath, silecsDesignFilePath,logTopics={'errorlog': True}):
return fesa.fesa_3_0_0.generateSourceCode.genCppFiles(className, workspacePath, silecsDesignFilePath,logTopics)
This diff is collapsed.
......@@ -6,10 +6,8 @@
<class-minor-version>1</class-minor-version>
<class-tiny-version>0</class-tiny-version>
<type>Final</type>
<state>development</state>
<description>An Empty design</description>
<fesa-version>0.9.0</fesa-version>
<repository-path>undefined</repository-path>
</information>
<ownership>
<responsible name="Undefined" />
......@@ -55,6 +53,51 @@
</bypass-action-item>
</diagnostic-property>
</setting>
<acquisition>
<metrics-property visibility="expert" name="Metrics" on-change="false" subscribable="false" cycle-bound="false">
<description>Generic property to retrieve deploy-unit's metrics</description>
<cmw-server name="cmwServer" direction="OUT">
<array type="char">
<dim>160</dim>
</array>
</cmw-server>
<concurrency-layers name="concurrencyLayers" direction="OUT">
<array type="char">
<dim>2000</dim>
</array>
</concurrency-layers>
<event-sources name="eventSources" direction="OUT">
<array type="char">
<dim>2000</dim>
</array>
</event-sources>
<logical-events name="logicalEvents" direction="OUT">
<array type="char">
<dim>2000</dim>
</array>
</logical-events>
<notification-queue name="notificationQueue" direction="OUT">
<array type="char">
<dim>50</dim>
</array>
</notification-queue>
<ondemand-queues name="ondemandQueues" direction="OUT">
<array type="char">
<dim>2000</dim>
</array>
</ondemand-queues>
<rt-actions name="rtActions" direction="OUT">
<array type="char">
<dim>5000</dim>
</array>
</rt-actions>
<server-actions name="serverActions" direction="OUT">
<array type="char">
<dim>5000</dim>
</array>
</server-actions>
</metrics-property>
</acquisition>
</global-interface>
</interface>
<builtin-types>
......
......@@ -17,8 +17,9 @@
import sys
from test.testBase import *
import fesa.fesa_3_0_0.generateFesaDesign
import fesa.fesa_3_1_0.generateFesaDesign
import fesa.fesa_7_3_0.generateFesaDesign
fesa_version = "7.3.0"
import libxml2
import unittest
......@@ -51,41 +52,15 @@ simpleSilecsDesign = '''<?xml version="1.0" encoding="UTF-8"?>
</SILECS-Design>'''
simpleSilecsDesignRoot = libxml2.parseDoc(simpleSilecsDesign)
def testFillXML_EmptyTemplate_3_0_0(generator):
fesaRoot = libxml2.parseFile("test/fesa/emptyTemplateFESA300.xml")
generator.fillXML('3.0.0', 'MyClass', fesaRoot,simpleSilecsDesignRoot,logTopics={'errorlog': True})
assertTrue( fesaRoot.xpathEval('/equipment-model/events') != None )
assertTrue( fesaRoot.xpathEval('/equipment-model/scheduling-units') != None )
def testFillXML_GSITemplate_3_0_0(generator):
fesaRoot = libxml2.parseFile("test/fesa/GSIClassTemplateFESA300.xml")
generator.fillXML('3.0.0', 'MyClass', fesaRoot,simpleSilecsDesignRoot,logTopics={'errorlog': True})
assertTrue( fesaRoot.xpathEval('/equipment-model/events') != None )
assertTrue( fesaRoot.xpathEval('/equipment-model/scheduling-units') != None )
acquisition = fesaRoot.xpathEval('/equipment-model/interface/device-interface/acquisition')[0]
firstGSIAcqProp = acquisition.xpathEval('GSI-Acquisition-Property')[0]
assertTrue( acquisition.xpathEval('*')[0].prop('name') != firstGSIAcqProp.prop('name') ) # check if generated at right position
assertEqual( firstGSIAcqProp.prop('name'),"Acquisition" )
firstGSIAcqProp.shellPrintNode() #for debug
valueItem = firstGSIAcqProp.xpathEval('value-item')[0]
assertTrue( valueItem != None )
setting = fesaRoot.xpathEval('/equipment-model/interface/device-interface/setting')[0]
firstGSISettingProp = setting.xpathEval('GSI-Setting-Property')[0]
assertTrue( acquisition.xpathEval('*')[0].prop('name') != firstGSISettingProp.prop('name') ) # check if generated at right position
def testFillXML_EmptyTemplate_3_1_0(generator):
fesaRoot = libxml2.parseFile("test/fesa/emptyTemplateFESA300.xml")
generator.fillXML('3.1.0', 'MyClass', fesaRoot,simpleSilecsDesignRoot,logTopics={'errorlog': True})
def testFillXML_EmptyTemplate(generator):
fesaRoot = libxml2.parseFile("test/fesa/emptyTemplate.xml")
generator.fillXML(fesa_version, 'MyClass', fesaRoot,simpleSilecsDesignRoot,logTopics={'errorlog': True})
assertTrue( fesaRoot.xpathEval('/equipment-model/events') != None )
assertTrue( fesaRoot.xpathEval('/equipment-model/scheduling-units') != None )
def testFillXML_GSITemplate_3_1_0(generator):
fesaRoot = libxml2.parseFile("test/fesa/GSIClassTemplateFESA300.xml")
generator.fillXML('3.1.0', 'MyClass', fesaRoot,simpleSilecsDesignRoot,logTopics={'errorlog': True})
def testFillXML_GSITemplate(generator):
fesaRoot = libxml2.parseFile("test/fesa/GSIClassTemplate.xml")
generator.fillXML(fesa_version, 'MyClass', fesaRoot,simpleSilecsDesignRoot,logTopics={'errorlog': True})
assertTrue( fesaRoot.xpathEval('/equipment-model/events') != None )
assertTrue( fesaRoot.xpathEval('/equipment-model/scheduling-units') != None )
......@@ -101,34 +76,34 @@ def testFillXML_GSITemplate_3_1_0(generator):
firstGSISettingProp = setting.xpathEval('GSI-Setting-Property')[0]
assertTrue( acquisition.xpathEval('*')[0].prop('name') != firstGSISettingProp.prop('name') ) # check if generated at right position
def testFillXML_GSITemplate_3_1_0_Exceptions(generator):
fesaRoot = libxml2.parseFile("test/fesa/GSIClassTemplateFESA300.xml")
def testFillXML_GSITemplate_Exceptions(generator):
fesaRoot = libxml2.parseFile("test/fesa/GSIClassTemplate.xml")
myRoot = simpleSilecsDesignRoot
commandBlock = myRoot.xpathEval('/SILECS-Design/SILECS-Class/Command-Block')[0]
commandBlock.setProp("name", "Init")
try:
generator.fillXML('3.1.0', 'MyClass', fesaRoot,myRoot,logTopics={'errorlog': True})
generator.fillXML(fesa_version, 'MyClass', fesaRoot,myRoot,logTopics={'errorlog': True})
except:
print("test passed")
else:
print("Test Failed: testFillXML_GSITemplate_3_1_0_Exceptions - Init \n No Exception was thrown")
print("Test Failed: testFillXML_GSITemplateExceptions - Init \n No Exception was thrown")
sys.exit(1)
commandBlock.setProp("name", "Reset")
try:
generator.fillXML('3.1.0', 'MyClass', fesaRoot,myRoot,logTopics={'errorlog': True})
generator.fillXML(fesa_version, 'MyClass', fesaRoot,myRoot,logTopics={'errorlog': True})
except:
print("test passed")
else:
print("Test Failed: testFillXML_GSITemplate_3_1_0_Exceptions - Reset \n No Exception was thrown")
print("Test Failed: testFillXML_GSITemplateExceptions - Reset \n No Exception was thrown")
sys.exit(1)
def testFillXML_AllTypes_4_3_1(generator):
fesaRoot = libxml2.parseFile("test/fesa/GSIClassTemplateFESA431.xml")
def testFillXML_AllTypes(generator):
fesaRoot = libxml2.parseFile("test/fesa/GSIClassTemplate.xml")
silecsRoot = libxml2.parseFile("test/AllTypesFESA.silecsdesign")
fesaRoot = generator.fillXML('4.3.0', 'MyClass', fesaRoot,silecsRoot,logTopics={'errorlog': True})
fesaRoot = generator.fillXML(fesa_version, 'MyClass', fesaRoot,silecsRoot,logTopics={'errorlog': True})
fesaNewDocPath = "test/generated_temp/AllTypesFESA.design"
fesaCompareDocPath = "test/generated_correct/AllTypesFESA.design"
with open(fesaNewDocPath, 'w') as fd:
......@@ -138,14 +113,11 @@ def testFillXML_AllTypes_4_3_1(generator):
assertFileEqual( fesaNewDocPath, fesaCompareDocPath)
def runTests():
# No need to further test that old stuff .. probably can be dropped
generator300 = fesa.fesa_3_0_0.generateFesaDesign.FESADesignGenerator3_0_0();
testFillXML_EmptyTemplate_3_0_0(generator300)
testFillXML_GSITemplate_3_0_0(generator300)
generator310 = fesa.fesa_3_1_0.generateFesaDesign.FESADesignGenerator3_1_0();
testFillXML_EmptyTemplate_3_1_0(generator310)
testFillXML_GSITemplate_3_1_0(generator310)
testFillXML_AllTypes_4_3_1(generator310)
testFillXML_GSITemplate_3_1_0_Exceptions(generator310)
# Always only test the latest supported Fesa Version
generator = fesa.fesa_7_3_0.generateFesaDesign.FESADesignGenerator7_3_0();
testFillXML_EmptyTemplate(generator)
testFillXML_GSITemplate(generator)
testFillXML_AllTypes(generator)
testFillXML_GSITemplate_Exceptions(generator)
allTestsOk()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment