Commit 784ce1b2 authored by Michael Büsch's avatar Michael Büsch

Prepare for array in interface

Signed-off-by: Michael Büsch's avatarMichael Buesch <[email protected]>
parent bc7df042
......@@ -39,16 +39,13 @@ class BlockInterfaceField(object):
FTYPE_TEMP = EnumGen.item
EnumGen.end
def __init__(self, name, dataType, initialValue=None):
def __init__(self, name, dataType):
# name -> The name string of the field, as defined
# in the block interface definition.
# dataType -> One of AwlDataType instance.
# initialValue -> Initial value for this field, as defined in
# the block interface definition.
self.name = name
self.dataType = dataType
self.fieldType = self.FTYPE_UNKNOWN
self.initialValue = initialValue
def __repr__(self):
ftype = {
......
......@@ -176,14 +176,9 @@ class S7CPU(object):
return insns
def __translateInterfaceField(self, rawVar):
dtype = AwlDataType.makeByName(rawVar.typeTokens)
if rawVar.valueTokens is None:
initialValue = None
else:
initialValue = dtype.parseMatchingImmediate(rawVar.valueTokens)
dtype = AwlDataType.makeByName(rawVar.typeTokens, rawVar.dimensions)
field = BlockInterfaceField(name = rawVar.name,
dataType = dtype,
initialValue = initialValue)
dataType = dtype)
return field
def __translateCodeBlock(self, rawBlock, blockClass):
......@@ -194,6 +189,7 @@ class S7CPU(object):
for rawVar in rawBlock.vars_out:
block.interface.addField_OUT(self.__translateInterfaceField(rawVar))
if rawBlock.retTypeTokens:
#FIXME ARRAY?
dtype = AwlDataType.makeByName(rawBlock.retTypeTokens)
if dtype.type != AwlDataType.TYPE_VOID:
field = BlockInterfaceField(name = "RET_VAL",
......@@ -265,6 +261,7 @@ class S7CPU(object):
db.allocate()
# Initialize the data structure fields
for f in rawDB.fields:
#TODO ARRAY
dtype = interface.getFieldByName(f.name).dataType
value = dtype.parseMatchingImmediate(f.valueTokens)
db.structInstance.setFieldDataByName(f.name, value)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment