Skip to content

Commit

Permalink
Merge pull request #720 from lnls-sirius/evg_log_conversions
Browse files Browse the repository at this point in the history
EVG log UTC Buffer in datetime format and subsec buffer in seconds
  • Loading branch information
anacso17 authored Oct 31, 2024
2 parents 43089b6 + 0dcc8bc commit cc365bb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
6 changes: 4 additions & 2 deletions pyqt-apps/siriushla/as_ti_control/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ def _create_small_group(
lay.setContentsMargins(0, 0, 0, 0)
return group

def _create_logbuffer_table(self, prop):
table = SiriusWaveformTable(self, self.get_pvname(prop))
def _create_logbuffer_table(self, prop, transform=None):
table = SiriusWaveformTable(
self, self.get_pvname(prop), transform=transform
)
table.setObjectName('tb')
table.setEnabled(False)
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
Expand Down
18 changes: 16 additions & 2 deletions pyqt-apps/siriushla/as_ti_control/low_level_devices.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""."""
import logging as _log
import numpy as _np
from datetime import datetime as _datetime

from qtpy.QtCore import Qt, Slot
from qtpy.QtGui import QColor, QBrush
Expand All @@ -13,6 +14,7 @@
from siriuspy.search import LLTimeSearch, HLTimeSearch
from siriuspy.namesys import SiriusPVName as _PVName
from siriuspy.timesys import csdev as _cstime
from siriuspy.epics import PV as _PV

from ..widgets import PyDMLed, PyDMStateButton, SiriusLedState, \
SiriusEnumComboBox, SiriusLedAlert, SiriusLabel, \
Expand Down Expand Up @@ -744,12 +746,24 @@ def _create_tstamp_dialog(self):
'', gbox_buf, (ld_bufrst, self.bt_bufrst))

ld_bufutc = QLabel('<b>UTC buffer</b>', self)
self.tb_bufutc = self._create_logbuffer_table('UTCbuffer')
fmt = "%d/%m/%y %H:%M:%S"
func = _np.vectorize(
lambda tstp: _datetime.fromtimestamp(tstp).strftime(fmt)
if tstp != 0
else 0
) # from timestamp to datetime format
self.tb_bufutc = self._create_logbuffer_table(
prop='UTCbuffer', transform=func
)
gb_bufutc = self._create_small_group(
'', gbox_buf, (ld_bufutc, self.tb_bufutc))

ld_bufsub = QLabel('<b>Subsec buffer</b>', self)
self.tb_bufsub = self._create_logbuffer_table('SUBSECbuffer')
rffreq = _PV("RF-Gen:GeneralFreq-RB").value
func = lambda vec: _np.round(vec * 4 / rffreq, decimals=10)
# from EVG clock to seconds
self.tb_bufsub = self._create_logbuffer_table(
prop='SUBSECbuffer', transform=func)
gb_bufsub = self._create_small_group(
'', gbox_buf, (ld_bufsub, self.tb_bufsub))

Expand Down
7 changes: 7 additions & 0 deletions pyqt-apps/siriushla/widgets/waveformtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
class SiriusWaveformTable(PyDMWaveformTable):
"""Handle bugs for None, float and int values."""

def __init__(self, parent=None, init_channel=None, transform=None):
"""."""
super().__init__(parent, init_channel)
self.transform = transform

def value_changed(self, new_waveform):
"""
Callback invoked when the Channel value is changed.
Expand All @@ -21,4 +26,6 @@ def value_changed(self, new_waveform):
return
elif isinstance(new_waveform, (float, int)):
new_waveform = _np.array([new_waveform])
if self.transform is not None:
new_waveform = self.transform(new_waveform)
super().value_changed(new_waveform)

0 comments on commit cc365bb

Please sign in to comment.