Commit 7eb9b6ee authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

All tests pass

parent fed14ef6
......@@ -369,6 +369,7 @@ class asn1Editor(QTreeView):
boolValue = value == 'True'
ptr.Set(boolValue)
elif asnType == 'ENUMERATED':
print 'SET ENUMERATED', value
intMappings = root.child(i, 3).data(INTMAP)
for enumerant, num in intMappings.viewitems():
if enumerant == value:
......@@ -445,7 +446,7 @@ class asn1Editor(QTreeView):
break
else:
raise TypeError('CHOICE ROW not found')
print 'coucou', value, rownb
print 'READING CHOICE', value, rownb
self.parseModel(root, dest=dest, choice=rownb)
intMappings = self.model.item(row, 3).data(INTMAP)
for enumerant, num in intMappings.viewitems():
......@@ -457,9 +458,9 @@ class asn1Editor(QTreeView):
else:
self.parseModel(root, dest=dest)
def updateModel(self, root, ptr, nbRows=-1):
def updateModel(self, root, ptr, nbRows=-1, choice=-1):
''' Recursive update of the values in the GUI from ASN.1 instance '''
def fillRow(root, i, dest, choice=False, seqOf=False):
def fillRow(root, i, dest, seqOf=False):
name = root.child(i, 0).text().replace('-', '_')
asnType = root.child(i, 1).text()
child = root.child(i, 3)
......@@ -504,7 +505,7 @@ class asn1Editor(QTreeView):
for rowNb, choiceName in enumerate(choiceList):
if choiceName == enumerant:
fillRow(root.child(i),
rowNb, dest=ptr, choice=True)
rowNb, dest=ptr)
break
else:
raise TypeError('CHOICE ROW not found')
......@@ -518,15 +519,20 @@ class asn1Editor(QTreeView):
child.setText(str(size))
self.updateModel(root.child(i), ptr, nbRows=size)
if root.hasChildren():
seqOf = True if nbRows != -1 else False
if not seqOf:
nbRows = root.rowCount()
if choice != -1:
stateBefore = ptr.GetState()
fillRow(root, choice, ptr)
ptr.Reset(stateBefore)
else:
if root.hasChildren():
seqOf = True if nbRows != -1 else False
if not seqOf:
nbRows = root.rowCount()
for i in xrange(nbRows):
stateBefore = ptr.GetState()
fillRow(root, i, ptr, seqOf=seqOf)
ptr.Reset(stateBefore)
for i in xrange(nbRows):
stateBefore = ptr.GetState()
fillRow(root, i, ptr, seqOf=seqOf)
ptr.Reset(stateBefore)
def updateVariable(self, root=None, asn1Var=None):
''' Update the variable value (when loading a TC or receiving a TM) '''
......@@ -552,8 +558,14 @@ class asn1Editor(QTreeView):
else:
self.log.error("CHOICE index not found in DV.py")
self.model.item(row, 3).setText(enumerant)
# decode the actual value
self.updateModel(root, asn1Instance)
print 'SETTING CHOICE = ', enumerant
# Find the row and set the value
for rownb in xrange(root.rowCount()):
if enumerant == root.child(rownb, 0).text():
break
else:
raise TypeError('(SET) CHOICE ROW not found')
self.updateModel(root, asn1Instance, choice=rownb)
elif asnType in ('INTEGER', 'REAL'):
self.model.item(row, 3).setText(str(asn1Instance.Get()))
elif asnType == 'BOOLEAN':
......
Supports Markdown
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