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 594 additions and 490 deletions
...@@ -43,13 +43,13 @@ def genClassHeader(workspacePath, deploy, design, funcGetSilecsDesignFilePath, f ...@@ -43,13 +43,13 @@ def genClassHeader(workspacePath, deploy, design, funcGetSilecsDesignFilePath, f
classDeclarations += genduwrappertemplate.getBlockClass(block,registerInitializerList,registerGetterSetter,registersDimentionsDeclaration,registersDeclaration) classDeclarations += genduwrappertemplate.getBlockClass(block,registerInitializerList,registerGetterSetter,registersDimentionsDeclaration,registersDeclaration)
blockGetters = "" blockGetters = ""
sendRecvBlocks = genduwrappertemplate.getDeviceSendRecvBlocks(designClass.getBlockNodes()) sendRecvBlocks = genduwrappertemplate.getDeviceSendRecvBlocks(designClass.getBlockNodes(), designClass.customTypesXmlNode)
for block in designClass.getDesignBlocks(): for block in designClass.getDesignBlocks():
blockGetters += genduwrappertemplate.getDeviceBlockGetterSetter(block) blockGetters += genduwrappertemplate.getDeviceBlockGetterSetter(block)
classDeclarations += genduwrappertemplate.getDeviceClass(blockGetters,sendRecvBlocks) classDeclarations += genduwrappertemplate.getDeviceClass(blockGetters,sendRecvBlocks)
sendRecvBlocks = genduwrappertemplate.getControllerSendRecvBlocks(designClass.getBlockNodes()) sendRecvBlocks = genduwrappertemplate.getControllerSendRecvBlocks(designClass.getBlockNodes(), designClass.customTypesXmlNode)
classDeclarations = genduwrappertemplate.getDesignClass(design.name, design.version) classDeclarations = genduwrappertemplate.getDesignClass(design.name, design.version)
designWrapper = genduwrappertemplate.designFileTemplate.substitute({'designNameCapitalized' : iecommon.capitalizeString(design.name),'designNameUpper' : design.name.upper(),'classDeclarations' : classDeclarations}) designWrapper = genduwrappertemplate.designFileTemplate.substitute({'designNameCapitalized' : iecommon.capitalizeString(design.name),'designNameUpper' : design.name.upper(),'classDeclarations' : classDeclarations})
......
...@@ -337,10 +337,10 @@ controllerSendTemplate = string.Template("""\ ...@@ -337,10 +337,10 @@ controllerSendTemplate = string.Template("""\
""") """)
def getControllerSendRecvBlocks(blockList): def getControllerSendRecvBlocks(blockList, customTypesXmlNode):
text = "" text = ""
for blockNode in blockList: for blockNode in blockList:
block = DesignBlock(blockNode) block = DesignBlock(blockNode, customTypesXmlNode)
map = {'blockName' : block.name, map = {'blockName' : block.name,
'blockNameCapitalized' : block.getNameCapitalized()} 'blockNameCapitalized' : block.getNameCapitalized()}
if block.isReadable(): if block.isReadable():
...@@ -405,39 +405,39 @@ ${blockInitialization}\ ...@@ -405,39 +405,39 @@ ${blockInitialization}\
matrixRegisterAssignementGetter = string.Template("""\ matrixRegisterAssignementGetter = string.Template("""\
// Copy register ${regName} // Copy register ${regName}
${cType} *__${regName} = new ${cType}[block.${regName}Dim1 * block.${regName}Dim2]; ${cType} *__${regName} = new ${cType}[block.${regName}Dim1 * block.${regName}Dim2];
getSilecsDevice()->getRegister("${regName}")->getVal${silecsTypeCapitalized}Array2D(__${regName}, block.${regName}Dim1, block.${regName}Dim2); getSilecsDevice()->getRegister("${regName}")->getValArray2D<${cType}>(__${regName}, block.${regName}Dim1, block.${regName}Dim2);
block.set${regNameCapitalized}(__${regName}); block.set${regNameCapitalized}(__${regName});
delete[] __${regName}; delete[] __${regName};
""") """)
arrayRegisterAssignementGetter = string.Template("""\ arrayRegisterAssignementGetter = string.Template("""\
// Copy register ${regName} // Copy register ${regName}
${cType} *__${regName} = new ${cType}[block.${regName}Dim1]; ${cType} *__${regName} = new ${cType}[block.${regName}Dim1];
getSilecsDevice()->getRegister("${regName}")->getVal${silecsTypeCapitalized}Array(__${regName}, block.${regName}Dim1); getSilecsDevice()->getRegister("${regName}")->getValArray<${cType}>(__${regName}, block.${regName}Dim1);
block.set${regNameCapitalized}(__${regName}); block.set${regNameCapitalized}(__${regName});
delete[] __${regName}; delete[] __${regName};
""") """)
scalarRegisterAssignementGetter = string.Template("""\ scalarRegisterAssignementGetter = string.Template("""\
// Copy register ${regName} // Copy register ${regName}
block.set${regNameCapitalized}(getSilecsDevice()->getRegister("${regName}")->getVal${silecsTypeCapitalized}()); block.set${regNameCapitalized}(getSilecsDevice()->getRegister("${regName}")->getVal<${cType}>());
""") """)
matrixRegisterAssignementSetter = string.Template("""\ matrixRegisterAssignementSetter = string.Template("""\
// Copy register ${regName} // Copy register ${regName}
${cType} *__${regName} = new ${cType}[block.${regName}Dim1 * block.${regName}Dim2]; ${cType} *__${regName} = new ${cType}[block.${regName}Dim1 * block.${regName}Dim2];
block.get${regNameCapitalized}(__${regName}); block.get${regNameCapitalized}(__${regName});
getSilecsDevice()->getRegister("${regName}")->setVal${silecsTypeCapitalized}Array2D(__${regName}, block.${regName}Dim1, block.${regName}Dim2); getSilecsDevice()->getRegister("${regName}")->setValArray2D<${cType}>(__${regName}, block.${regName}Dim1, block.${regName}Dim2);
delete[] __${regName}; delete[] __${regName};
""") """)
arrayRegisterAssignementSetter = string.Template("""\ arrayRegisterAssignementSetter = string.Template("""\
// Copy register ${regName} // Copy register ${regName}
${cType} *__${regName} = new ${cType}[block.${regName}Dim1]; ${cType} *__${regName} = new ${cType}[block.${regName}Dim1];
block.get${regNameCapitalized}(__${regName}); block.get${regNameCapitalized}(__${regName});
getSilecsDevice()->getRegister("${regName}")->setVal${silecsTypeCapitalized}Array(__${regName}, block.${regName}Dim1); getSilecsDevice()->getRegister("${regName}")->setValArray<${cType}>(__${regName}, block.${regName}Dim1);
delete[] __${regName}; delete[] __${regName};
""") """)
scalarRegisterAssignementSetter = string.Template("""\ scalarRegisterAssignementSetter = string.Template("""\
// Copy register ${regName} // Copy register ${regName}
getSilecsDevice()->getRegister("${regName}")->setVal${silecsTypeCapitalized}(block.get${regNameCapitalized}()); getSilecsDevice()->getRegister("${regName}")->setVal<${cType}>(block.get${regNameCapitalized}());
""") """)
def getDeviceBlockGetterSetter(block): def getDeviceBlockGetterSetter(block):
...@@ -447,7 +447,6 @@ def getDeviceBlockGetterSetter(block): ...@@ -447,7 +447,6 @@ def getDeviceBlockGetterSetter(block):
for register in block.getDesignRegisters(): for register in block.getDesignRegisters():
map = {'regName' : register.name, map = {'regName' : register.name,
'regNameCapitalized' : register.getNameCapitalized(), 'regNameCapitalized' : register.getNameCapitalized(),
'silecsTypeCapitalized' : register.getSilecsTypeCapitalized(),
'cType' : register.getCType()} 'cType' : register.getCType()}
if register.isArray2D(): if register.isArray2D():
blockInitialization += matrixRegisterAssignementGetter.substitute(map) blockInitialization += matrixRegisterAssignementGetter.substitute(map)
...@@ -465,7 +464,6 @@ def getDeviceBlockGetterSetter(block): ...@@ -465,7 +464,6 @@ def getDeviceBlockGetterSetter(block):
for register in block.getDesignRegisters(): for register in block.getDesignRegisters():
map = {'regName' : register.name, map = {'regName' : register.name,
'regNameCapitalized' : register.getNameCapitalized(), 'regNameCapitalized' : register.getNameCapitalized(),
'silecsTypeCapitalized' : register.getSilecsTypeCapitalized(),
'cType' : register.getCType()} 'cType' : register.getCType()}
if register.isArray2D(): if register.isArray2D():
blockInitialization += matrixRegisterAssignementSetter.substitute(map) blockInitialization += matrixRegisterAssignementSetter.substitute(map)
...@@ -502,10 +500,10 @@ deviceSendTemplate = string.Template("""\ ...@@ -502,10 +500,10 @@ deviceSendTemplate = string.Template("""\
""") """)
def getDeviceSendRecvBlocks(blockList): def getDeviceSendRecvBlocks(blockList, customTypesXmlNode):
text = "" text = ""
for blockNode in blockList: for blockNode in blockList:
block = DesignBlock(blockNode) block = DesignBlock(blockNode, customTypesXmlNode)
map = {'blockName' : block.name, map = {'blockName' : block.name,
'blockNameCapitalized' : block.getNameCapitalized()} 'blockNameCapitalized' : block.getNameCapitalized()}
if block.isReadable(): if block.isReadable():
......
This diff is collapsed.
This diff is collapsed.
...@@ -20,7 +20,6 @@ import os ...@@ -20,7 +20,6 @@ import os
import sys import sys
import getpass import getpass
import codecs import codecs
import commands
import iecommon import iecommon
import libxml2 import libxml2
...@@ -38,7 +37,7 @@ def logError(msg, exit,logTopics={}): ...@@ -38,7 +37,7 @@ def logError(msg, exit,logTopics={}):
if 'errorlog' in logTopics: if 'errorlog' in logTopics:
if logTopics['errorlog'] == True: if logTopics['errorlog'] == True:
_logMsg = "%s%s" %(logHeader("ERROR"), msg) _logMsg = "%s%s" %(logHeader("ERROR"), msg)
print _logMsg print(_logMsg)
if exit: if exit:
raise Exception(_logMsg) raise Exception(_logMsg)
...@@ -46,13 +45,13 @@ def logInfo(msg,logTopics={}): ...@@ -46,13 +45,13 @@ def logInfo(msg,logTopics={}):
if 'infolog' in logTopics: if 'infolog' in logTopics:
if logTopics['infolog'] == True: if logTopics['infolog'] == True:
_logMsg = "%s%s" %(logHeader("INFO"), msg) _logMsg = "%s%s" %(logHeader("INFO"), msg)
print _logMsg print(_logMsg)
def logDebug(msg,logTopics={}): def logDebug(msg,logTopics={}):
if 'debuglog' in logTopics: if 'debuglog' in logTopics:
if logTopics['debuglog'] == True: if logTopics['debuglog'] == True:
_logMsg = "%s%s" %(logHeader("DEBUG"), msg) _logMsg = "%s%s" %(logHeader("DEBUG"), msg)
print _logMsg print(_logMsg)
# Append message to a text file # Append message to a text file
def logToFile(path,msg): def logToFile(path,msg):
...@@ -143,7 +142,7 @@ def getOrCreateNamedFirstChild(parent,elementName, attributeNameValue): ...@@ -143,7 +142,7 @@ def getOrCreateNamedFirstChild(parent,elementName, attributeNameValue):
return newNode return newNode
def fillAttributes(element, attrs): def fillAttributes(element, attrs):
for name,value in attrs.iteritems(): for name,value in attrs.items():
if not type(value) is str: if not type(value) is str:
raise Exception("Error: Wrong Type Parsed for attribute: " + name) raise Exception("Error: Wrong Type Parsed for attribute: " + name)
element.setProp(name, value) element.setProp(name, value)
...@@ -173,4 +172,9 @@ def getPatchSilecsVersion(silecsVersionString): ...@@ -173,4 +172,9 @@ def getPatchSilecsVersion(silecsVersionString):
secondDot = silecsVersionString.find('.',firstDot) secondDot = silecsVersionString.find('.',firstDot)
return silecsVersionString[secondDot:] return silecsVersionString[secondDot:]
def supportsDateTimeLong(controller):
if controller.brand != "SIEMENS":
return False
if controller.model in ['SIMATIC_S7-300', 'SIMATIC_S7-400']:
return False
return True
...@@ -26,9 +26,9 @@ designFormat = '.silecsdesign' ...@@ -26,9 +26,9 @@ designFormat = '.silecsdesign'
deployFormat = '.silecsdeploy' deployFormat = '.silecsdeploy'
paramFormat = '.silecsparam' paramFormat = '.silecsparam'
def loadSilecsDesignDOM(workspacePath, silecsDesign, silecsVersion, funcGetSilecsDesignFilePath): def loadSilecsDesignDOM(workspacePath, silecsDesign, silecsVersion, funcGetSilecsDesignFilePath, datetime_format=xmltemplate.DATE_AND_TIME):
if silecsDesign.name == "SilecsHeader": if silecsDesign.name == "SilecsHeader":
silecsHeader = xmltemplate.getSilecsHeader(silecsVersion) silecsHeader = xmltemplate.getSilecsHeader(silecsVersion, datetime_format)
return libxml2.parseDoc(silecsHeader) return libxml2.parseDoc(silecsHeader)
else: else:
designPath = funcGetSilecsDesignFilePath(workspacePath, silecsDesign.name) designPath = funcGetSilecsDesignFilePath(workspacePath, silecsDesign.name)
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
import os import os
import sys import sys
import ParseMigrationArgs
from migrationBase import MigrationBase from migrationBase import MigrationBase
from migration0_10_0to1_0_0.migrators import * from migration0_10_0to1_0_0.migrators import *
...@@ -26,8 +27,8 @@ import FileUtils ...@@ -26,8 +27,8 @@ import FileUtils
import shutil import shutil
class Migration(MigrationBase): class Migration(MigrationBase):
def __init__(self, arguments): def __init__(self, silecsDocument, xmlSchema, versionOld, versionNew, createBackup):
super(Migration, self).__init__() super(Migration, self).__init__(silecsDocument, xmlSchema, versionOld, versionNew, createBackup)
def migrateClass(self, context, projectDir ): def migrateClass(self, context, projectDir ):
modified = designGenerateFesaPropValueItemMigrator(context) modified = designGenerateFesaPropValueItemMigrator(context)
...@@ -42,9 +43,7 @@ class Migration(MigrationBase): ...@@ -42,9 +43,7 @@ class Migration(MigrationBase):
return modified return modified
def migrateFESAInstanceFile(self): def migrateFESAInstanceFile(self):
results = self.parser.parse_args() projectDir = FileUtils.getProjectDir(self.silecsDocument)
silecsDocument = results.silecsDocument
projectDir = FileUtils.getProjectDir(silecsDocument)
testFolder = projectDir + "/src/test" testFolder = projectDir + "/src/test"
if not os.path.isdir(testFolder): if not os.path.isdir(testFolder):
return return
...@@ -60,7 +59,18 @@ class Migration(MigrationBase): ...@@ -60,7 +59,18 @@ class Migration(MigrationBase):
if fesaInstanceFileMigrator(context): if fesaInstanceFileMigrator(context):
self._saveAndBackupFile(context,instanceFile) self._saveAndBackupFile(context,instanceFile)
if __name__ == "__main__": def main_parse():
migration = Migration(sys.argv) 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.migrate()
migration.backupOldFESAMakeSpecific() migration.backupOldFESAMakeSpecific()
if __name__ == "__main__":
main_parse()
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
import os import os
import sys import sys
import ParseMigrationArgs
from migrationBase import MigrationBase from migrationBase import MigrationBase
from migration_0_9_0to0_10_0.migrateDeployDeviceNumber import DeployDeviceNumberMigrator from migration_0_9_0to0_10_0.migrateDeployDeviceNumber import DeployDeviceNumberMigrator
...@@ -25,8 +26,8 @@ import libxml2 ...@@ -25,8 +26,8 @@ import libxml2
import sys import sys
class Migration(MigrationBase): class Migration(MigrationBase):
def __init__(self, arguments): def __init__(self, silecsDocument, xmlSchema, versionOld, versionNew, createBackup):
super(Migration, self).__init__() super(Migration, self).__init__(silecsDocument, xmlSchema, versionOld, versionNew, createBackup)
self._deployDomainMigrator = DeployDomainMigrator() self._deployDomainMigrator = DeployDomainMigrator()
self._migrateDeployDeviceNumber = DeployDeviceNumberMigrator() self._migrateDeployDeviceNumber = DeployDeviceNumberMigrator()
...@@ -39,6 +40,17 @@ class Migration(MigrationBase): ...@@ -39,6 +40,17 @@ class Migration(MigrationBase):
modified = self._migrateDeployDeviceNumber.migrate(context) modified = self._migrateDeployDeviceNumber.migrate(context)
return modified return modified
if __name__ == "__main__": def main_parse():
migration = Migration(sys.argv) 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.migrate()
if __name__ == "__main__":
main_parse()
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
import os import os
import sys import sys
import ParseMigrationArgs
from migrationBase import MigrationBase from migrationBase import MigrationBase
from migration1_0_Xto2_0_0.migrators import * from migration1_0_Xto2_0_0.migrators import *
...@@ -26,16 +27,26 @@ import FileUtils ...@@ -26,16 +27,26 @@ import FileUtils
import shutil import shutil
class Migration(MigrationBase): class Migration(MigrationBase):
def __init__(self, arguments): def __init__(self, silecsDocument, xmlSchema, versionOld, versionNew, createBackup):
super(Migration, self).__init__() super(Migration, self).__init__(silecsDocument, xmlSchema, versionOld, versionNew, createBackup)
def migrateClass(self, context, projectDir ): def migrateClass(self, context, projectDir):
modified = designValueTypeMigrator(context) modified = designValueTypeMigrator(context)
modified |= designBlockRegisterMigrator(context) modified |= designBlockRegisterMigrator(context)
return modified return modified
def main_parse():
arguments = ParseMigrationArgs.parse_arguments()
run_migrate(arguments.silecsDocument,
arguments.xmlSchema,
arguments.versionOld,
arguments.versionNew,
arguments.createBackup)
if __name__ == "__main__": def run_migrate(silecsDocument, xmlSchema, versionOld, versionNew, createBackup):
migration = Migration(sys.argv) migration = Migration(silecsDocument, xmlSchema, versionOld, versionNew, createBackup)
migration.migrate() migration.migrate()
migration.backupOldFESAMakeSpecific() migration.backupOldFESAMakeSpecific()
if __name__ == "__main__":
main_parse()
...@@ -50,13 +50,6 @@ def getFesaSourceFiles(fesaClassName, projectDir): ...@@ -50,13 +50,6 @@ def getFesaSourceFiles(fesaClassName, projectDir):
for root, subdirs, files in os.walk(fesaCodeFolder): for root, subdirs, files in os.walk(fesaCodeFolder):
for file in files: for file in files:
if file.endswith(".cpp") or file.endswith(".h"): if file.endswith(".cpp") or file.endswith(".h"):
print os.path.join(root,file) print(os.path.join(root,file))
sourceFiles.append(os.path.join(root,file)) sourceFiles.append(os.path.join(root,file))
return sourceFiles return sourceFiles
def replaceInFile(filePath,searchString,replaceWithString):
with open(filePath, 'r') as file :
filedata = file.read()
filedata = filedata.replace(searchString, replaceWithString)
with open(filePath, 'w') as file:
file.write(filedata)
\ No newline at end of file
This diff is collapsed.