Commit f50eae1e authored by Valentin Valls's avatar Valentin Valls
Browse files

Allow to serialize none ref

parent 06dfd87f
......@@ -454,6 +454,8 @@ class BeaconObject:
obj_name = self.settings.get(name, None)
if obj_name is None:
return default
elif obj_name == "":
return None
else:
return self.config.config.get(obj_name)
......@@ -461,11 +463,15 @@ class BeaconObject:
def set_unmarshalling(self, value):
# first check that this object exists in beacon
if value is None:
return None
if isinstance(value, str):
obj_name = value
else:
assert hasattr(value, "name")
obj_name = value.name
if obj_name == "":
return None
assert (
obj_name in self.config.config.names_list
), f"{obj_name} does not exist in beacon config!"
......@@ -473,7 +479,7 @@ class BeaconObject:
def set_marshalling(self, value):
if value is None:
return None
return ""
elif isinstance(value, str):
return value
return value.name
......
......@@ -464,6 +464,19 @@ def test_BeaconObject_config_obj_property_setting_setter2(two_clients):
assert ctrl2.axis.name == "robz"
def test_BeaconObject_config_obj_property_setting_none(two_clients):
con1, con2 = two_clients
cfg1 = static.Config("", connection=con1)
ctrl_cfg1 = cfg1.get("hello_ctrl3")
ctrl1 = Ctrl14(ctrl_cfg1, share_hardware=False)
cfg2 = static.Config("", connection=con2)
ctrl_cfg2 = cfg2.get("hello_ctrl3")
ctrl2 = Ctrl14(ctrl_cfg2, share_hardware=False)
ctrl1.axis = None
assert ctrl2.axis is None
def test_BeaconObject_with_numpy_array(beacon):
name = "neutrino"
h = settings.HashObjSetting(f"{name}:settings")
......
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