Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • silecs/opensilecs
  • k.fugiel/opensilecs
  • s.kupiecki/opensilecs
3 results
Show changes
Showing
with 1259 additions and 1665 deletions
......@@ -14,14 +14,10 @@
# 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 libxml2
import iecommon
import fesa.fillFesaDeployUnitBase
import fesa.fesa_3_0_0.fillFESADeployUnit
def fillDeployUnit(fesaVersion, className, workspacePath,fesaDesignXSDPath,logTopics={'errorlog': True}):
generator = fesa.fesa_3_0_0.fillFESADeployUnit.FESADeployUnitGenerator3_0_0() # identical with FESA 3.0.0
fesa.fillFesaDeployUnitBase.fillFesaDeployUnitBase(generator,fesaVersion, className, workspacePath,fesaDesignXSDPath,logTopics)
def getFesaName(node):
if(node.hasProp('fesaPropertyName')):
return node.prop('fesaPropertyName')
if(node.hasProp('fesaFieldName')):
return node.prop('fesaFieldName')
if(node.hasProp('name')):
return node.prop('name')
iecommon.logError('ERROR: Passed node has no name attribute', True, {'errorlog': True})
#!/usr/bin/python
# Copyright 2016 CERN and GSI
#
# This program is free software: you can redistribute it and/or modify
......@@ -13,25 +14,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
PROJECT = silecs
PRODUCT = communication
VERSION = 1.0.4
import fesa.fesa_3_1_0.generateBuildEnvironment
SKIP_MANIFEST = TRUE
#local
#COMMON_MAKE_PATH ?= /common/home/bel/schwinn/lnx/workspace-silecs-neon/generic-makefiles
#global
COMMON_MAKE_PATH ?= /opt/cern/buildsystem/generic/2.9.0
def genMakefileClass(projectPath, logTopics={'errorlog': True} ):
return fesa.fesa_3_1_0.generateBuildEnvironment.genMakefileClass(projectPath, logTopics )
# product configuration
LIB_NAME = comm
DBG = true
def genMakefileDU(projectPath, logTopics={'errorlog': True}):
return fesa.fesa_3_1_0.generateBuildEnvironment.genMakefileDU(projectPath, logTopics )
#COMPILER_FLAGS = -Os -fno-strict-aliasing -fexceptions -DLINUX -DARM_FIX -DDAVE_LITTLE_ENDIAN -D_GNU_SOURCE -DMAJOR=$(MAJOR) -DMINOR=$(MINOR) -DPATCH=$(PATCH)
COMPILER_FLAGS = -DMAJOR=$(MAJOR) -DMINOR=$(MINOR) -DPATCH=$(PATCH)
# Comment IN/Out to enable NI-Support
#COMPILER_FLAGS += -DNI_SUPPORT_ENABLED=TRUE
# Include the generic make file
include $(COMMON_MAKE_PATH)/Make.generic
\ No newline at end of file
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)
# Fill custom-types with enums.
enums = designClass.getEnums()
customTypesNode = doc.xpathEval('/equipment-model/custom-types')[0]
for enum in enums:
enumElement = getOrCreateNamedChildElement(customTypesNode, "enum", enum.name)
existing_items = enumElement.xpathEval("item")
to_add = []
to_edit = []
# Loop through all new enums and check which should be added and which edited.
for item in enum.items:
if item.symbol in [item.prop("symbol") for item in existing_items]:
to_edit.append(item)
else:
to_add.append(item)
# Loop though all existing enums and remove any which are not in new enums.
to_add_edit = to_add + to_edit
for existing in existing_items:
if existing.prop("symbol") not in [item.symbol for item in to_add_edit]:
existing.unlinkNode()
existing.freeNode()
# Edit existing items.
for item in to_edit:
for existing in existing_items:
if existing.prop("symbol") != item.symbol:
continue
existing.setProp("access", item.access)
existing.setProp("value", item.value)
# Add missing items.
for item in to_add:
itemElement = libxml2.newNode("item")
enumElement.addChild(itemElement)
itemElement.setProp("access", item.access)
itemElement.setProp("value", item.value)
itemElement.setProp("symbol", item.symbol)
#!/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.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -16,6 +16,7 @@
import os
import sys
import ParseMigrationArgs
from migrationBase import MigrationBase
from migration0_10_0to1_0_0.migrators import *
......@@ -26,8 +27,8 @@ import FileUtils
import shutil
class Migration(MigrationBase):
def __init__(self, arguments):
super(Migration, self).__init__()
def __init__(self, silecsDocument, xmlSchema, versionOld, versionNew, createBackup):
super(Migration, self).__init__(silecsDocument, xmlSchema, versionOld, versionNew, createBackup)
def migrateClass(self, context, projectDir ):
modified = designGenerateFesaPropValueItemMigrator(context)
......@@ -41,36 +42,8 @@ class Migration(MigrationBase):
self.migrateFESAInstanceFile()
return modified
def backupOldFESAMakeSpecific(self):
results = self.parser.parse_args()
silecsDocument = results.silecsDocument
projectDir = FileUtils.getProjectDir(silecsDocument)
makeSpecific = projectDir + "/Makefile.specific"
if os.path.isfile(makeSpecific):
os.rename(makeSpecific, makeSpecific + ".backup")
print("Backed up old FESA Make.specific file: " + makeSpecific)
def removeGenCode(self):
results = self.parser.parse_args()
silecsDocument = results.silecsDocument
projectDir = FileUtils.getProjectDir(silecsDocument)
clientFolder = projectDir + "/generated/client"
controllerFolder = projectDir + "/generated/controller"
wrapperFolder = projectDir + "/generated/wrapper"
if os.path.isdir(clientFolder):
shutil.rmtree(clientFolder)
print("removed generation folder: " + clientFolder)
if os.path.isdir(controllerFolder):
shutil.rmtree(controllerFolder)
print("removed generation folder: " + controllerFolder)
if os.path.isdir(wrapperFolder):
shutil.rmtree(wrapperFolder)
print("removed generation folder: " + wrapperFolder)
def migrateFESAInstanceFile(self):
results = self.parser.parse_args()
silecsDocument = results.silecsDocument
projectDir = FileUtils.getProjectDir(silecsDocument)
projectDir = FileUtils.getProjectDir(self.silecsDocument)
testFolder = projectDir + "/src/test"
if not os.path.isdir(testFolder):
return
......@@ -86,7 +59,18 @@ class Migration(MigrationBase):
if fesaInstanceFileMigrator(context):
self._saveAndBackupFile(context,instanceFile)
if __name__ == "__main__":
migration = Migration(sys.argv)
def main_parse():
arguments = ParseMigrationArgs.parse_arguments()
run_migrate(arguments.silecsDocument,
arguments.xmlSchema,
arguments.versionOld,
arguments.versionNew,
arguments.createBackup)
def run_migrate(silecsDocument, xmlSchema, versionOld, versionNew, createBackup):
migration = Migration(silecsDocument, xmlSchema, versionOld, versionNew, createBackup)
migration.migrate()
migration.backupOldFESAMakeSpecific()
if __name__ == "__main__":
main_parse()
This diff is collapsed.
from argparse import ArgumentParser
def parse_arguments():
parser = ArgumentParser(description='Migration script')
parser.add_argument("silecsDocument", action="store", help="The SILECS document to migrate")
parser.add_argument("xmlSchema", action="store", help="Path to the new schema")
parser.add_argument("versionOld", action="store", help="old silecs version")
parser.add_argument("versionNew", action="store", help="new silecs version")
parser.add_argument('--backup', dest='createBackup', action='store_true')
parser.add_argument('--no-backup', dest='createBackup', action='store_false')
parser.set_defaults(createBackup=False)
arguments = parser.parse_args()
return arguments