Make block definition optional for register json file

master
Simon Stürz 2022-01-28 10:19:17 +01:00 committed by Michael Zanetti
parent 1e34b07cf4
commit 4e9f98ddee
1 changed files with 37 additions and 22 deletions

View File

@ -914,6 +914,7 @@ def writeTcpHeaderFile():
writePropertyGetSetMethodDeclarationsTcp(headerFile, registerJson['registers'])
# Write block get/set method declarations
if 'blocks' in registerJson:
writeBlocksUpdateMethodDeclarations(headerFile, registerJson['blocks'])
# Write init and update method declarations
@ -929,8 +930,10 @@ def writeTcpHeaderFile():
writeLine(headerFile, ' void initializationFinished();')
writeLine(headerFile)
writePropertyChangedSignals(headerFile, registerJson['registers'])
if 'blocks' in registerJson:
for blockDefinition in registerJson['blocks']:
writePropertyChangedSignals(headerFile, blockDefinition['registers'])
writeLine(headerFile)
# Protected members
@ -944,8 +947,10 @@ def writeTcpHeaderFile():
writeLine(headerFile, ' QVector<QModbusReply *> m_pendingInitReplies;')
writeLine(headerFile)
writePrivatePropertyMembers(headerFile, registerJson['registers'])
if 'blocks' in registerJson:
for blockDefinition in registerJson['blocks']:
writePrivatePropertyMembers(headerFile, blockDefinition['registers'])
writeLine(headerFile)
writeLine(headerFile, ' void verifyInitFinished();')
writeLine(headerFile)
@ -986,6 +991,7 @@ def writeTcpSourceFile():
writePropertyGetSetMethodImplementationsTcp(sourceFile, className, registerJson['registers'])
# Block property get methods
if 'blocks' in registerJson:
for blockDefinition in registerJson['blocks']:
writePropertyGetSetMethodImplementationsTcp(sourceFile, className, blockDefinition['registers'])
@ -997,6 +1003,7 @@ def writeTcpSourceFile():
writePropertyUpdateMethodImplementationsTcp(sourceFile, className, registerJson['registers'])
# Write block update method
if 'blocks' in registerJson:
writeBlockUpdateMethodImplementationsTcp(sourceFile, className, registerJson['blocks'])
# Write internal protected property read method implementations
@ -1018,6 +1025,7 @@ def writeTcpSourceFile():
writeLine(sourceFile, ' debug.nospace().noquote() << "%s(" << %s->hostAddress().toString() << ":" << %s->port() << ")" << "\\n";' % (className, debugObjectParamName, debugObjectParamName))
writeRegistersDebugLine(sourceFile, debugObjectParamName, registerJson['registers'])
if 'blocks' in registerJson:
for blockDefinition in registerJson['blocks']:
writeRegistersDebugLine(sourceFile, debugObjectParamName, blockDefinition['registers'])
@ -1070,6 +1078,7 @@ def writeRtuHeaderFile():
writePropertyGetSetMethodDeclarationsRtu(headerFile, registerJson['registers'])
# Write block get/set method declarations
if 'blocks' in registerJson:
writeBlocksUpdateMethodDeclarations(headerFile, registerJson['blocks'])
writePropertyUpdateMethodDeclarations(headerFile, registerJson['registers'])
@ -1085,6 +1094,7 @@ def writeRtuHeaderFile():
writeLine(headerFile, ' void initializationFinished();')
writeLine(headerFile)
writePropertyChangedSignals(headerFile, registerJson['registers'])
if 'blocks' in registerJson:
for blockDefinition in registerJson['blocks']:
writePropertyChangedSignals(headerFile, blockDefinition['registers'])
writeLine(headerFile)
@ -1101,6 +1111,7 @@ def writeRtuHeaderFile():
writeLine(headerFile, ' QVector<ModbusRtuReply *> m_pendingInitReplies;')
writeLine(headerFile)
writePrivatePropertyMembers(headerFile, registerJson['registers'])
if 'blocks' in registerJson:
for blockDefinition in registerJson['blocks']:
writePrivatePropertyMembers(headerFile, blockDefinition['registers'])
@ -1155,6 +1166,7 @@ def writeRtuSourceFile():
writePropertyGetSetMethodImplementationsRtu(sourceFile, className, registerJson['registers'])
# Block property get methods
if 'blocks' in registerJson:
for blockDefinition in registerJson['blocks']:
writePropertyGetSetMethodImplementationsRtu(sourceFile, className, blockDefinition['registers'])
@ -1166,6 +1178,7 @@ def writeRtuSourceFile():
writePropertyUpdateMethodImplementationsRtu(sourceFile, className, registerJson['registers'])
# Write block update method
if 'blocks' in registerJson:
writeBlockUpdateMethodImplementationsRtu(sourceFile, className, registerJson['blocks'])
# Write internal protected property read method implementations
@ -1187,6 +1200,7 @@ def writeRtuSourceFile():
writeLine(sourceFile, ' debug.nospace().noquote() << "%s(" << %s->modbusRtuMaster()->modbusUuid().toString() << ", " << %s->modbusRtuMaster()->serialPort() << ", slave ID:" << %s->slaveId() << ")" << "\\n";' % (className, debugObjectParamName, debugObjectParamName, debugObjectParamName))
writeRegistersDebugLine(sourceFile, debugObjectParamName, registerJson['registers'])
if 'blocks' in registerJson:
for blockDefinition in registerJson['blocks']:
writeRegistersDebugLine(sourceFile, debugObjectParamName, blockDefinition['registers'])
@ -1234,7 +1248,8 @@ protocol = 'TCP'
if 'protocol' in registerJson:
protocol = registerJson['protocol']
validateBlocks(registerJson['blocks'])
if 'blocks' in registerJson:
validateBlocks(registerJson['blocks'])
if protocol == 'TCP':
writeTcpHeaderFile()