Add a `trigger_all` arg to update cycle func; allows hard history updates
parent
30656eda39
commit
8195fae289
|
@ -356,9 +356,11 @@ class LinkedSplits(QWidget):
|
||||||
|
|
||||||
self._symbol: Symbol = None
|
self._symbol: Symbol = None
|
||||||
|
|
||||||
def graphics_cycle(self) -> None:
|
def graphics_cycle(self, **kwargs) -> None:
|
||||||
from . import _display
|
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
|
@property
|
||||||
def symbol(self) -> Symbol:
|
def symbol(self) -> Symbol:
|
||||||
|
|
|
@ -290,6 +290,7 @@ async def graphics_update_loop(
|
||||||
def graphics_update_cycle(
|
def graphics_update_cycle(
|
||||||
ds: DisplayState,
|
ds: DisplayState,
|
||||||
wap_in_history: bool = False,
|
wap_in_history: bool = False,
|
||||||
|
trigger_all: bool = False, # flag used by prepend history updates
|
||||||
|
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
|
@ -307,10 +308,6 @@ def graphics_update_cycle(
|
||||||
tick_margin = vars['tick_margin']
|
tick_margin = vars['tick_margin']
|
||||||
|
|
||||||
for sym, quote in ds.quotes.items():
|
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
|
# NOTE: vlm may be written by the ``brokerd`` backend
|
||||||
# event though a tick sample is not emitted.
|
# event though a tick sample is not emitted.
|
||||||
|
@ -333,13 +330,39 @@ def graphics_update_cycle(
|
||||||
)
|
)
|
||||||
vars['i_last'] = i_step
|
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:
|
if vlm_chart:
|
||||||
vlm_chart.update_curve_from_array('volume', array)
|
vlm_chart.update_curve_from_array('volume', array)
|
||||||
ds.vlm_sticky.update_from_data(*array[-1][['index', 'volume']])
|
ds.vlm_sticky.update_from_data(*array[-1][['index', 'volume']])
|
||||||
|
|
||||||
if (
|
if (
|
||||||
mx_vlm_in_view != vars['last_mx_vlm']
|
mx_vlm_in_view > vars['last_mx_vlm']
|
||||||
or mx_vlm_in_view > vars['last_mx_vlm']
|
or trigger_all
|
||||||
):
|
):
|
||||||
# print(f'mx vlm: {last_mx_vlm} -> {mx_vlm_in_view}')
|
# print(f'mx vlm: {last_mx_vlm} -> {mx_vlm_in_view}')
|
||||||
vlm_chart.view._set_yrange(
|
vlm_chart.view._set_yrange(
|
||||||
|
|
|
@ -50,7 +50,6 @@ from ._forms import (
|
||||||
mk_form,
|
mk_form,
|
||||||
open_form_input_handling,
|
open_form_input_handling,
|
||||||
)
|
)
|
||||||
from . import _display
|
|
||||||
from ..fsp._api import maybe_mk_fsp_shm, Fsp
|
from ..fsp._api import maybe_mk_fsp_shm, Fsp
|
||||||
from ..fsp import cascade
|
from ..fsp import cascade
|
||||||
from ..fsp._volume import (
|
from ..fsp._volume import (
|
||||||
|
@ -442,7 +441,13 @@ class FspAdmin:
|
||||||
async with stream.subscribe() as stream:
|
async with stream.subscribe() as stream:
|
||||||
async for msg in stream:
|
async for msg in stream:
|
||||||
if msg == 'update':
|
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()
|
await complete.wait()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue