Ejemplo n.º 1
0
 def test_metadata_default(self):
     cell = PollingCell(
         target=NoInherentCellSpecimen(),
         key='value',
         changes='never')
     self.assertEqual(cell.metadata().naming, EnumRow(
         label='value',
         sort_key='value'))
Ejemplo n.º 2
0
 def test_metadata_default(self):
     cell = PollingCell(
         target=NoInherentCellSpecimen(),
         key='value',
         changes='never')
     self.assertEqual(cell.metadata().naming, EnumRow(
         label='value',
         sort_key='value'))
Ejemplo n.º 3
0
 def test_metadata_explicit(self):
     cell = PollingCell(target=NoInherentCellSpecimen(),
                        key='value',
                        changes='never',
                        label='foo',
                        description='bar',
                        sort_key='baz')
     self.assertEqual(
         cell.metadata().naming,
         EnumRow(label='foo', description='bar', sort_key='baz'))
Ejemplo n.º 4
0
 def __test_subscription(self, changes):
     o = NoInherentCellSpecimen()
     cell = PollingCell(o, 'value', changes=changes, interest_tracker=LoopbackInterestTracker())
     st = CellSubscriptionTester(cell)
     o.value = 1
     if changes == 'explicit':
         cell.poll_for_change(specific_cell=True)
     st.expect_now(1)
     st.unsubscribe()
     o.value = 2
     st.advance()  # check for unwanted callbacks
Ejemplo n.º 5
0
 def __test_subscription(self, changes):
     o = NoInherentCellSpecimen()
     cell = PollingCell(o, 'value', changes=changes)
     st = CellSubscriptionTester(cell)
     o.value = 1
     if changes == 'explicit':
         cell.poll_for_change(specific_cell=True)
     st.expect_now(1)
     st.unsubscribe()
     o.value = 2
     st.advance()  # check for unwanted callbacks
Ejemplo n.º 6
0
 def test_metadata_explicit(self):
     cell = PollingCell(
         target=NoInherentCellSpecimen(),
         key='value',
         changes='never',
         label='foo',
         description='bar',
         sort_key='baz')
     self.assertEqual(cell.metadata().naming, EnumRow(
         label='foo',
         description='bar',
         sort_key='baz'))
Ejemplo n.º 7
0
def _install_gain_cell(self, source_ref, rxd_ref, name):
    def gain_getter():
        source = source_ref[0]
        return 0 if source is None else source.get_gain(name, ch)
    
    def gain_setter(value):
        source = source_ref[0]
        if source is not None:
            source.set_gain(float(value), name, ch)
        rxd = rxd_ref[0]
        if rxd is not None:
            # The single gain and individual-stage gain controls have an unspecified relationship to each other. Thus, changing one must poll the other.
            rxd.state_changed('gain')
    
    gain_range = convert_osmosdr_range(source_ref[0].get_gain_range(name, ch), unit=units.dB)
    
    # TODO: There should be a type of Cell such that we don't have to setattr but still implement the storage unlike LooseCell
    setattr(self, 'get_' + name, gain_getter)
    setattr(self, 'set_' + name, gain_setter)
    return name, PollingCell(self, name,
        type=gain_range,
        writable=True,
        persists=True,
        changes='this_setter',
        label=name)
Ejemplo n.º 8
0
 def test_subscription_never(self):
     o = NoInherentCellSpecimen()
     cell = PollingCell(o,
                        'value',
                        changes='never',
                        interest_tracker=LoopbackInterestTracker())
     st = CellSubscriptionTester(cell, interest_tracking=False)
     o.value = 1
     st.advance()  # expected no callback even if we lie
Ejemplo n.º 9
0
 def __init__(self, send, root_object, root_url, subscription_context):
     self.__subscription_context = subscription_context
     self._send = send
     self.__root_object = root_object
     self._cell = PollingCell(self, '_root_object', type=ReferenceT(), changes='never')
     self._lastSerial = 0
     root_registration = _StateStreamObjectRegistration(ssi=self, subscription_context=self.__subscription_context, obj=self._cell, serial=0, url=root_url, refcount=0)
     self._registered_objs = {self._cell: root_registration}
     self.__registered_serials = {root_registration.serial: root_registration}
     self._send_batch = []
     self.__batch_delay = None
     self.__root_url = root_url
     root_registration.send_initial_value()
Ejemplo n.º 10
0
 def test_repr(self):
     cell = PollingCell(
         target=NoInherentCellSpecimen(),
         key='value',
         changes='never')
     self.assertEqual(repr(cell), '<PollingCell <NoInherentCellSpecimen repr>.value>')
Ejemplo n.º 11
0
 def test_subscription_never(self):
     o = NoInherentCellSpecimen()
     cell = PollingCell(o, 'value', changes='never')
     st = CellSubscriptionTester(cell)
     o.value = 1
     st.advance()  # expected no callback even if we lie