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

All tests pass

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