From ae995d1cc1074368067aee9f566b9d39f1aaa466 Mon Sep 17 00:00:00 2001 From: "Pete R. Jemian" Date: Thu, 16 Jul 2020 10:36:32 -0500 Subject: [PATCH 1/5] MNT #356 make the PVs --- apstools/beamtime/apsbss.db | 4 ++++ apstools/beamtime/apsbss_makedb.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apstools/beamtime/apsbss.db b/apstools/beamtime/apsbss.db index cdd0d774e..9a6a5c212 100644 --- a/apstools/beamtime/apsbss.db +++ b/apstools/beamtime/apsbss.db @@ -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") { diff --git a/apstools/beamtime/apsbss_makedb.py b/apstools/beamtime/apsbss_makedb.py index 3408b29b6..5c7e3d4dc 100755 --- a/apstools/beamtime/apsbss_makedb.py +++ b/apstools/beamtime/apsbss_makedb.py @@ -14,6 +14,8 @@ raw_data = """ status stringout +ioc_host stringout +ioc_user stringout esaf:cycle stringout esaf:description waveform 4096 esaf:endDate stringout @@ -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")') From f2729b4fc1f005f8fef11d2a9e42b3fec0806277 Mon Sep 17 00:00:00 2001 From: "Pete R. Jemian" Date: Thu, 16 Jul 2020 10:36:57 -0500 Subject: [PATCH 2/5] MNT #356 implement in shell script --- apstools/beamtime/apsbss_ioc.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apstools/beamtime/apsbss_ioc.sh b/apstools/beamtime/apsbss_ioc.sh index 96403e467..591d48ab9 100755 --- a/apstools/beamtime/apsbss_ioc.sh +++ b/apstools/beamtime/apsbss_ioc.sh @@ -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}" @@ -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} } @@ -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 } From a24668ff376dfbac3ee11bda3ca9ee39bcc8b9e0 Mon Sep 17 00:00:00 2001 From: "Pete R. Jemian" Date: Thu, 16 Jul 2020 10:37:11 -0500 Subject: [PATCH 3/5] MNT #356 ophyd interface --- apstools/beamtime/apsbss_ophyd.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apstools/beamtime/apsbss_ophyd.py b/apstools/beamtime/apsbss_ophyd.py index 99c80d128..df022c4c4 100644 --- a/apstools/beamtime/apsbss_ophyd.py +++ b/apstools/beamtime/apsbss_ophyd.py @@ -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): From 26fd013bc2abf691558a9f0b68310ee24c61e947 Mon Sep 17 00:00:00 2001 From: "Pete R. Jemian" Date: Thu, 16 Jul 2020 10:37:25 -0500 Subject: [PATCH 4/5] TST #356 --- tests/__main__.py | 4 ++-- tests/{test_beamtime.py => test_apsbss.py} | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) rename tests/{test_beamtime.py => test_apsbss.py} (97%) diff --git a/tests/__main__.py b/tests/__main__.py index 65406de17..1731e5e94 100644 --- a/tests/__main__.py +++ b/tests/__main__.py @@ -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 @@ -26,7 +26,7 @@ def suite(*args, **kw): test_exceltable, test_commandlist, test_utils, - test_beamtime, + test_apsbss, ] test_suite = unittest.TestSuite() diff --git a/tests/test_beamtime.py b/tests/test_apsbss.py similarity index 97% rename from tests/test_beamtime.py rename to tests/test_apsbss.py index 8e262f09c..3ccb153c7 100644 --- a/tests/test_beamtime.py +++ b/tests/test_apsbss.py @@ -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): From 92929edf7ed6a1b6e40c4b2ac9ee9e581b58e9e2 Mon Sep 17 00:00:00 2001 From: "Pete R. Jemian" Date: Thu, 16 Jul 2020 10:45:18 -0500 Subject: [PATCH 5/5] TST #356 Codacy --- apstools/beamtime/apsbss_ioc.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apstools/beamtime/apsbss_ioc.sh b/apstools/beamtime/apsbss_ioc.sh index 591d48ab9..c577deef6 100755 --- a/apstools/beamtime/apsbss_ioc.sh +++ b/apstools/beamtime/apsbss_ioc.sh @@ -134,8 +134,8 @@ function start() { CMD="screen -dm -S ${SESSION_NAME} -h 5000 ${START_IOC_COMMAND}" ${CMD} sleep 1 - ${CAPUT} ${IOC_PREFIX}ioc_host ${HOSTNAME} - ${CAPUT} ${IOC_PREFIX}ioc_user ${USER} + "${CAPUT}" "${IOC_PREFIX}ioc_host" "${HOSTNAME}" + "${CAPUT}" "${IOC_PREFIX}ioc_user" "${USER}" fi }