Skip to content

Commit

Permalink
Merge pull request #364 from BCDA-APS/356-PVs
Browse files Browse the repository at this point in the history
apsbss: add PVs for ioc_host and ioc_user
  • Loading branch information
prjemian authored Jul 16, 2020
2 parents 6669e57 + 92929ed commit aacd1a7
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
4 changes: 4 additions & 0 deletions apstools/beamtime/apsbss.db
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

record(stringout, "$(P)status")

record(stringout, "$(P)ioc_host")

record(stringout, "$(P)ioc_user")

record(stringout, "$(P)esaf:cycle")

record(waveform, "$(P)esaf:description") {
Expand Down
10 changes: 9 additions & 1 deletion apstools/beamtime/apsbss_ioc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ SESSION_NAME=${2:-"${DEFAULT_SESSION_NAME}"}
IOC_PREFIX=${3:-"${DEFAULT_IOC_PREFIX}"}

IOC_BINARY=softIoc
CAPUT=caput
EPICS_DATABASE=apsbss.db
START_IOC_COMMAND="${IOC_BINARY} -m P=${IOC_PREFIX} -d ${EPICS_DATABASE}"

Expand Down Expand Up @@ -106,7 +107,11 @@ function restart() {
}

function run_ioc() {
# only use this for diagnostic purposes
exit_if_running
echo "After IOC starts, need to execute these two commands from linux command line:"
echo " ${CAPUT} ${IOC_PREFIX}ioc_host ${HOSTNAME}"
echo " ${CAPUT} ${IOC_PREFIX}ioc_user ${USER}"
${START_IOC_COMMAND}
}

Expand All @@ -127,7 +132,10 @@ function start() {
cd "${IOC_STARTUP_DIR}"
# Run SESSION_NAME inside a screen session
CMD="screen -dm -S ${SESSION_NAME} -h 5000 ${START_IOC_COMMAND}"
$CMD
${CMD}
sleep 1
"${CAPUT}" "${IOC_PREFIX}ioc_host" "${HOSTNAME}"
"${CAPUT}" "${IOC_PREFIX}ioc_user" "${USER}"
fi
}

Expand Down
4 changes: 3 additions & 1 deletion apstools/beamtime/apsbss_makedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

raw_data = """
status stringout
ioc_host stringout
ioc_user stringout
esaf:cycle stringout
esaf:description waveform 4096
esaf:endDate stringout
Expand Down Expand Up @@ -172,7 +174,7 @@ def main():
fields = []
if rtyp == "waveform" and len(parts) == 3:
fields.append('field(FTVL, "CHAR")')
fields.append('field(NELM, {length})')
fields.append(f'field(NELM, {parts[2]})')
# fields.append('field(VAL, 0)')
elif rtyp == "bo":
fields.append('field(ZNAM, "OFF")')
Expand Down
3 changes: 3 additions & 0 deletions apstools/beamtime/apsbss_ophyd.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ class EpicsBssDevice(Device):

esaf = Component(EpicsEsafDevice, "esaf:")
proposal = Component(EpicsProposalDevice, "proposal:")

ioc_host = Component(EpicsSignal, "ioc_host", string=True, kind="omitted")
ioc_user = Component(EpicsSignal, "ioc_user", string=True, kind="omitted")
status_msg = Component(EpicsSignal, "status", string=True, kind="omitted")

def clear(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

def suite(*args, **kw):

from tests import test_beamtime
from tests import test_apsbss
from tests import test_simple
from tests import test_filewriter
from tests import test_export_json
Expand All @@ -26,7 +26,7 @@ def suite(*args, **kw):
test_exceltable,
test_commandlist,
test_utils,
test_beamtime,
test_apsbss,
]

test_suite = unittest.TestSuite()
Expand Down
8 changes: 4 additions & 4 deletions tests/test_beamtime.py → 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), 372)
self.assertEqual(len(db), 376)
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[24], 'record(stringout, "$(P)esaf:id")')
self.assertEqual(db[130], ' field(ONAM, "ON")')
self.assertEqual(db[273], 'record(bo, "$(P)proposal:user5:piFlag") {')
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") {')


class Test_ProgramCommands(unittest.TestCase):
Expand Down

0 comments on commit aacd1a7

Please sign in to comment.