Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apsbss: add PVs for numbers of users #375

Merged
merged 3 commits into from
Jul 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apstools/beamtime/apsbss.db
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ record(waveform, "$(P)esaf:users") {
field(NELM, 1024)
}

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

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

record(stringout, "$(P)esaf:user1:badgeNumber")

record(stringout, "$(P)esaf:user1:email")
Expand Down Expand Up @@ -168,6 +172,10 @@ record(waveform, "$(P)proposal:users") {
field(NELM, 1024)
}

record(longout, "$(P)proposal:users_in_pvs")

record(longout, "$(P)proposal:users_total")

record(stringout, "$(P)proposal:user1:badgeNumber")

record(stringout, "$(P)proposal:user1:email")
Expand Down
10 changes: 8 additions & 2 deletions apstools/beamtime/apsbss.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,17 @@ def epicsUpdate(prefix):
bss.esaf.user_badges.put(
",".join([user["badge"] for user in esaf["experimentUsers"]])
)
bss.esaf.number_users_in_pvs.put(0)
for i, user in enumerate(esaf["experimentUsers"]):
obj = getattr(bss.esaf, f"user{i+1}")
obj.badge_number.put(user["badge"])
obj.email.put(user["email"])
obj.first_name.put(user["firstName"])
obj.last_name.put(user["lastName"])
if i == 9:
obj.number_users_in_pvs.put(i+1)
if i == 8:
break
obj.number_users_total.put(len(esaf["experimentUsers"]))

if len(proposal_id) > 0:
bss.status_msg.put(f"get Proposal {proposal_id} from APS ...")
Expand All @@ -210,6 +213,7 @@ def epicsUpdate(prefix):
bss.proposal.user_badges.put(
",".join([user["badge"] for user in proposal["experimenters"]])
)
bss.proposal.number_users_in_pvs.put(0)
for i, user in enumerate(proposal["experimenters"]):
obj = getattr(bss.proposal, f"user{i+1}")
obj.badge_number.put(user["badge"])
Expand All @@ -220,8 +224,10 @@ def epicsUpdate(prefix):
obj.institution_id.put(str(user["instId"]))
obj.user_id.put(str(user["id"]))
obj.pi_flag.put(user.get("piFlag") in ("Y", "y"))
if i == 9:
obj.number_users_in_pvs.put(i+1)
if i == 8:
break
obj.number_users_total.put(len(proposal["experimenters"]))

bss.status_msg.put("Done")

Expand Down
4 changes: 4 additions & 0 deletions apstools/beamtime/apsbss_makedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
esaf:title waveform 1024
esaf:userBadges waveform 1024
esaf:users waveform 1024
esaf:users_in_pvs longout
esaf:users_total longout
esaf:user1:badgeNumber stringout
esaf:user1:email stringout
esaf:user1:firstName stringout
Expand Down Expand Up @@ -74,6 +76,8 @@
proposal:title waveform 1024
proposal:userBadges waveform 1024
proposal:users waveform 1024
proposal:users_in_pvs longout
proposal:users_total longout
proposal:user1:badgeNumber stringout
proposal:user1:email stringout
proposal:user1:firstName stringout
Expand Down
6 changes: 5 additions & 1 deletion apstools/beamtime/apsbss_ophyd.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class EpicsEsafDevice(Device):
end_date = Component(EpicsSignal, "endDate", string=True)
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)
Expand Down Expand Up @@ -156,14 +158,16 @@ class EpicsProposalDevice(Device):

end_date = Component(EpicsSignal, "endDate", string=True)
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)
submitted_date = Component(EpicsSignal, "submittedDate", string=True)
title = Component(EpicsSignal, "title", string=True)
user_last_names = Component(EpicsSignal, "users", string=True)
user_badges = Component(EpicsSignal, "userBadges", string=True)
user_last_names = Component(EpicsSignal, "users", string=True)

_max_users = 9 # 9 users at most?
user1 = Component(EpicsProposalExperimenterDevice, "user1:")
Expand Down
6 changes: 3 additions & 3 deletions tests/test_apsbss.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,14 @@ def test_general(self):
from tests.common import Capture_stdout
with Capture_stdout() as db:
apsbss_makedb.main()
self.assertEqual(len(db), 376)
self.assertEqual(len(db), 384)
self.assertEqual(db[0], "#")
self.assertEqual(db[1], "# file: apsbss.db")
# randomly-selected spot checks
self.assertEqual(db[13], 'record(stringout, "$(P)status")')
self.assertEqual(db[28], 'record(stringout, "$(P)esaf:id")')
self.assertEqual(db[134], ' field(ONAM, "ON")')
self.assertEqual(db[277], 'record(bo, "$(P)proposal:user5:piFlag") {')
self.assertEqual(db[138], ' field(ONAM, "ON")')
self.assertEqual(db[285], 'record(bo, "$(P)proposal:user5:piFlag") {')


class Test_ProgramCommands(unittest.TestCase):
Expand Down