Commit 896f78c0 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Store internal state with uPER encoding

parent 4f2f2a5c
......@@ -411,7 +411,10 @@ class sdlHandler(QObject):
for idx, (var, (sort, _)) in enumerate(self.proc.variables.viewitems()):
# get internal variables, translate them to swig, and print them
setter_ptr = getattr(target, "_set_{}".format(var))
value_asn1 = target_state[idx]
#value_asn1 = target_state[idx]
value_uper = target_state[idx]
typename = sort.ReferencedTypeName.replace('-', '_')
value_asn1 = self.decode_from_uper(value_uper, typename)
setter_ptr(value_asn1._ptr)
state_value = target_state[idx+1]
set_state = getattr(target, "_set_state")
......@@ -435,7 +438,6 @@ class sdlHandler(QObject):
.format(typename_c))
buf = ASN1.DataStream(size)
instance.Encode(buf)
print 'Encoded type {} - size {}'.format(typename_c, len(buf.GetPyString()))
return buf.GetPyString()
def decode_from_uper(self, uper_buf, typename_c, to_inst=None):
......@@ -444,11 +446,10 @@ class sdlHandler(QObject):
assert '-' not in typename_c
to_inst = to_inst or getattr(ASN1, typename_c)()
size = getattr(ASN1.DV, "{}_REQUIRED_BYTES_FOR_ENCODING"
.format(typename))
.format(typename_c))
buf = ASN1.DataStream(size)
buf.SetFromPyString(uper_buf)
to_inst.Decode(buf)
print 'Decoded type {} - size {}'.format(typename_c, len(buf.GetPyString()))
return to_inst
def change_internal_state(self):
......@@ -466,7 +467,9 @@ class sdlHandler(QObject):
# Fill up the ASN.1 instance
self.asn1_editor.getVariable(root=self.tree_items[var],
dest=asn1_instance)
new_state.append(asn1_instance)
uper_encoded = self.encode_uper(asn1_instance, typename)
#new_state.append(asn1_instance)
new_state.append(uper_encoded)
# Add the SDL state to the new global state, create a new hash, save it
state_row = self.tree_items['_states'].row()
new_sdl_state = self.asn1_editor.model.item(state_row, 3).text()
......@@ -508,7 +511,9 @@ class sdlHandler(QObject):
raise ValueError(err_msg)
else:
uper_encoded = self.encode_uper(asn1_instance, typename)
complete_state.append(asn1_instance)
#complete_state.append(asn1_instance)
# a state contains a compact version of the data
complete_state.append(uper_encoded)
# Add the SDL state to the new global state
complete_state.append(self.current_sdl_state)
# Update the SDL state in the global state panel
......
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