Add a `trigger_all` arg to update cycle func; allows hard history updates

m4_corrections
Tyler Goodlet 2022-04-15 18:47:45 -04:00
parent 37b492eba6
commit 6d9ffc532e
3 changed files with 40 additions and 10 deletions

View File

@ -356,9 +356,11 @@ class LinkedSplits(QWidget):
self._symbol: Symbol = None
def graphics_cycle(self) -> None:
def graphics_cycle(self, **kwargs) -> None:
from . import _display
return _display.graphics_update_cycle(self.display_state)
ds = self.display_state
if ds:
return _display.graphics_update_cycle(ds, **kwargs)
@property
def symbol(self) -> Symbol:

View File

@ -290,6 +290,7 @@ async def graphics_update_loop(
def graphics_update_cycle(
ds: DisplayState,
wap_in_history: bool = False,
trigger_all: bool = False, # flag used by prepend history updates
) -> None:
@ -307,10 +308,6 @@ def graphics_update_cycle(
tick_margin = vars['tick_margin']
for sym, quote in ds.quotes.items():
brange, mx_in_view, mn_in_view, mx_vlm_in_view = ds.maxmin()
l, lbar, rbar, r = brange
mx = mx_in_view + tick_margin
mn = mn_in_view - tick_margin
# NOTE: vlm may be written by the ``brokerd`` backend
# event though a tick sample is not emitted.
@ -333,13 +330,39 @@ def graphics_update_cycle(
)
vars['i_last'] = i_step
(
brange,
mx_in_view,
mn_in_view,
mx_vlm_in_view,
) = ds.maxmin()
l, lbar, rbar, r = brange
mx = mx_in_view + tick_margin
mn = mn_in_view - tick_margin
liv = r > i_step # the last datum is in view
# don't real-time "shift" the curve to the
# left under the following conditions:
if (
(
i_diff > 0 # no new sample step
and liv
)
or trigger_all
):
# TODO: we should track and compute whether the last
# pixel in a curve should show new data based on uppx
# and then iff update curves and shift?
chart.increment_view(steps=i_diff)
if vlm_chart:
vlm_chart.update_curve_from_array('volume', array)
ds.vlm_sticky.update_from_data(*array[-1][['index', 'volume']])
if (
mx_vlm_in_view != vars['last_mx_vlm']
or mx_vlm_in_view > vars['last_mx_vlm']
mx_vlm_in_view > vars['last_mx_vlm']
or trigger_all
):
# print(f'mx vlm: {last_mx_vlm} -> {mx_vlm_in_view}')
vlm_chart.view._set_yrange(

View File

@ -50,7 +50,6 @@ from ._forms import (
mk_form,
open_form_input_handling,
)
from . import _display
from ..fsp._api import maybe_mk_fsp_shm, Fsp
from ..fsp import cascade
from ..fsp._volume import (
@ -442,7 +441,13 @@ class FspAdmin:
async with stream.subscribe() as stream:
async for msg in stream:
if msg == 'update':
self.linked.graphics_cycle()
# if the chart isn't hidden try to update
# the data on screen.
if not self.linked.isHidden():
log.info(f'Re-syncing graphics for fsp: {ns_path}')
self.linked.graphics_cycle(trigger_all=True)
else:
log.info(f'recved unexpected fsp engine msg: {msg}')
await complete.wait()