Skip to content

Commit

Permalink
Merge pull request #29 from BCDA-APS/12-timestamp-PVs
Browse files Browse the repository at this point in the history
add integer PVs for timestamps
  • Loading branch information
prjemian authored Dec 16, 2024
2 parents 7779183 + 07b1777 commit eb82a37
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe the future plans.

* Add support for direct access to read IS database.
* Add Server class that chooses between DM or IS interface.
* Integer timestamp PVs for ESAF start & end and Proposal start, end, & submitted.

Maintenance
-----------
Expand Down
5 changes: 5 additions & 0 deletions apsbss/apsbss.db
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ record(waveform, "$(P)esaf:description") {
}

record(stringout, "$(P)esaf:endDate")
record(longout, "$(P)esaf:endDate:timestamp")

record(longout, "$(P)esaf:id")

Expand All @@ -48,6 +49,7 @@ record(stringout, "$(P)esaf:status")
record(stringout, "$(P)esaf:sector")

record(stringout, "$(P)esaf:startDate")
record(longout, "$(P)esaf:startDate:timestamp")

record(waveform, "$(P)esaf:title") {
field(FTVL, "CHAR")
Expand Down Expand Up @@ -143,6 +145,7 @@ record(stringout, "$(P)esaf:user9:lastName")
record(stringout, "$(P)proposal:beamline")

record(stringout, "$(P)proposal:endDate")
record(longout, "$(P)proposal:endDate:timestamp")

record(bo, "$(P)proposal:mailInFlag") {
field(ZNAM, "OFF")
Expand All @@ -164,8 +167,10 @@ record(waveform, "$(P)proposal:raw") {
}

record(stringout, "$(P)proposal:startDate")
record(longout, "$(P)proposal:startDate:timestamp")

record(stringout, "$(P)proposal:submittedDate")
record(longout, "$(P)proposal:submittedDate:timestamp")

record(waveform, "$(P)proposal:title") {
field(FTVL, "CHAR")
Expand Down
12 changes: 10 additions & 2 deletions apsbss/apsbss.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import pyRestTable
import yaml

from .core import iso2dt
from .core import printColumns
from .server_interface import Server

Expand Down Expand Up @@ -149,10 +150,14 @@ def epicsUpdate(prefix):

bss.status_msg.put("set ESAF PVs ...")
bss.esaf.description.put(esaf["description"])
bss.esaf.end_date.put(esaf["experimentEndDate"])
dt = iso2dt(esaf["experimentEndDate"])
bss.esaf.end_date.put(str(dt))
bss.esaf.end_date_timestamp.put(round(dt.timestamp()))
bss.esaf.esaf_status.put(esaf["esafStatus"])
bss.esaf.raw.put(yaml.dump(esaf))
bss.esaf.start_date.put(esaf["experimentStartDate"])
dt = iso2dt(esaf["experimentStartDate"])
bss.esaf.start_date.put(str(dt))
bss.esaf.start_date_timestamp.put(round(dt.timestamp()))
bss.esaf.title.put(esaf["esafTitle"])

bss.esaf.user_last_names.put(",".join([user["lastName"] for user in esaf["experimentUsers"]]))
Expand All @@ -175,11 +180,14 @@ def epicsUpdate(prefix):

bss.status_msg.put("set Proposal PVs ...")
bss.proposal.end_date.put(str(proposal.endTime))
bss.proposal.end_date_timestamp.put(round(proposal.endTime.timestamp()))
bss.proposal.mail_in_flag.put(proposal.mail_in)
bss.proposal.proprietary_flag.put(proposal.proprietary)
bss.proposal.raw.put(yaml.dump(proposal))
bss.proposal.start_date.put(str(proposal.startTime))
bss.proposal.start_date_timestamp.put(round(proposal.startTime.timestamp()))
bss.proposal.submitted_date.put(str(proposal.submittedDate))
bss.proposal.submitted_date_timestamp.put(round(proposal.submittedDate.timestamp()))
bss.proposal.title.put(proposal.title)

bss.proposal.user_last_names.put(",".join(proposal.lastNames))
Expand Down
10 changes: 10 additions & 0 deletions apsbss/apsbss_ophyd.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,15 @@ class EpicsEsafDevice(Device):
aps_run = Component(EpicsSignal, "run", string=True)
description = Component(EpicsSignal, "description", string=True)
end_date = Component(EpicsSignal, "endDate", string=True)
end_date_timestamp = Component(EpicsSignal, "endDate:timestamp")
esaf_id = Component(EpicsSignal, "id", string=True)
esaf_status = Component(EpicsSignal, "status", string=True)
number_users_in_pvs = Component(EpicsSignal, "users_in_pvs")
number_users_total = Component(EpicsSignal, "users_total")
raw = Component(EpicsSignal, "raw", string=True, kind="omitted")
sector = Component(EpicsSignal, "sector", string=True)
start_date = Component(EpicsSignal, "startDate", string=True)
start_date_timestamp = Component(EpicsSignal, "startDate:timestamp")
title = Component(EpicsSignal, "title", string=True)
user_last_names = Component(EpicsSignal, "users", string=True)
user_badges = Component(EpicsSignal, "userBadges", string=True)
Expand Down Expand Up @@ -103,10 +105,12 @@ def clear(self):
# self.aps_run.put("") # user controls this
self.description.put("")
self.end_date.put("")
self.end_date_timestamp.put(0)
# self.esaf_id.put("") # user controls this
self.esaf_status.put("")
# self.sector.put("")
self.start_date.put("")
self.start_date_timestamp.put(0)
self.title.put("")
self.user_last_names.put("")
self.user_badges.put("")
Expand Down Expand Up @@ -169,14 +173,17 @@ class EpicsProposalDevice(Device):
beamline_name = Component(EpicsSignal, "beamline", string=True)

end_date = Component(EpicsSignal, "endDate", string=True)
end_date_timestamp = Component(EpicsSignal, "endDate:timestamp")
mail_in_flag = Component(EpicsSignal, "mailInFlag", string=True)
number_users_in_pvs = Component(EpicsSignal, "users_in_pvs")
number_users_total = Component(EpicsSignal, "users_total")
proposal_id = Component(EpicsSignal, "id", string=True)
proprietary_flag = Component(EpicsSignal, "proprietaryFlag", string=True)
raw = Component(EpicsSignal, "raw", string=True, kind="omitted")
start_date = Component(EpicsSignal, "startDate", string=True)
start_date_timestamp = Component(EpicsSignal, "startDate:timestamp")
submitted_date = Component(EpicsSignal, "submittedDate", string=True)
submitted_date_timestamp = Component(EpicsSignal, "submittedDate:timestamp")
title = Component(EpicsSignal, "title", string=True)
user_badges = Component(EpicsSignal, "userBadges", string=True)
user_last_names = Component(EpicsSignal, "users", string=True)
Expand All @@ -203,11 +210,14 @@ def clear(self):
"""
# self.beamline_name.put("") # user controls this
self.end_date.put("")
self.end_date_timestamp.put(0)
self.mail_in_flag.put(0)
# self.proposal_id.put(-1) # user controls this
self.proprietary_flag.put(0)
self.start_date.put("")
self.start_date_timestamp.put(0)
self.submitted_date.put("")
self.submitted_date_timestamp.put(0)
self.title.put("")
self.user_last_names.put("")
self.user_badges.put("")
Expand Down
2 changes: 1 addition & 1 deletion apsbss/tests/test_apsbss_ophyd.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_EpicsBssDevice(ioc):
table = ioc.bss._table()
assert isinstance(table, pyRestTable.Table)
assert len(table.labels) == 3
assert len(table.rows) == 137
assert len(table.rows) >= 137
assert len(table.rows[0]) == 3
assert table.rows[0][0] == f"{BSS_TEST_IOC_PREFIX}esaf:description"
assert table.rows[0][1] == ""
Expand Down
2 changes: 1 addition & 1 deletion apsbss/tests/test_server_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test__esaf_table():
return

table = server._esaf_table(12, "2024-3")
assert len(table.rows) == 23
assert len(table.rows) >= 23
rowNum = -1
assert len(table.rows[rowNum]) == 7
assert table.rows[rowNum][0] == 275724
Expand Down

0 comments on commit eb82a37

Please sign in to comment.