fix secondary demod; add same-value handling

This commit is contained in:
Jakob Ketterl 2020-03-24 00:18:10 +01:00
parent d5c2f8414e
commit cc5c130f49
3 changed files with 15 additions and 3 deletions

View File

@ -41,13 +41,15 @@ class DspManager(csdr.output):
"temporary_directory",
"center_freq",
# TODO: following properties are set from the client
# TODO: following properties are set from the client; check if it's really necessary to have the Properties
"output_rate",
"squelch_level",
"secondary_mod",
"low_cut",
"high_cut",
"offset_freq",
"mod",
"secondary_offset_freq",
)
self.dsp = csdr.dsp(self)
@ -107,8 +109,8 @@ class DspManager(csdr.output):
)
self.subscriptions += [
self.localProps.collect("secondary_mod").wire(set_secondary_mod),
self.localProps.collect("secondary_offset_freq").wire(self.dsp.set_secondary_offset_freq),
self.localProps.wireProperty("secondary_mod", set_secondary_mod),
self.localProps.wireProperty("secondary_offset_freq", self.dsp.set_secondary_offset_freq),
]
self.sdrSource.addClient(self)

View File

@ -94,6 +94,8 @@ class PropertyLayer(PropertyManager):
return self.properties[name]
def __setitem__(self, name, value):
if name in self.properties and self.properties[name] == value:
return
logger.debug("property change: %s => %s", name, value)
self.properties[name] = value
self._fireCallbacks(name, value)

View File

@ -50,3 +50,11 @@ class PropertyLayerTest(TestCase):
mock.method.assert_not_called()
pm["testkey"] = "newvalue"
mock.method.assert_called_once_with("newvalue")
def testEventPreventedWhenValueUnchanged(self):
pm = PropertyLayer()
pm["testkey"] = "testvalue"
mock = Mock()
pm.wire(mock.method)
pm["testkey"] = "testvalue"
mock.method.assert_not_called()