From 76d0cfcaf1da74ee9a7cc38c62a41193de5e03cf Mon Sep 17 00:00:00 2001 From: JackEAllen Date: Tue, 10 Aug 2021 15:18:10 +0100 Subject: [PATCH 01/12] Create basic Emulator, tests and EPICS records for PEARL IOC --- .gitignore | 20 ++ Makefile | 32 +++ PearlPCSup/Makefile | 11 + PearlPCSup/PearlPC.proto | 79 ++++++ PearlPCSup/devPearl.db | 225 ++++++++++++++++ configure/CONFIG | 13 + configure/CONFIG_APP | 21 ++ configure/Makefile | 13 + configure/RELEASE | 5 + configure/RULES | 5 + configure/RULES_DIRS | 2 + configure/RULES_TOP | 3 + system_tests/.idea/.gitignore | 3 + .../inspectionProfiles/profiles_settings.xml | 6 + system_tests/.idea/misc.xml | 4 + system_tests/.idea/modules.xml | 8 + system_tests/.idea/system_tests.iml | 15 ++ system_tests/.idea/vcs.xml | 6 + system_tests/__init__.py | 2 + .../lewis_emulators/PearlPC/__init__.py | 5 + .../lewis_emulators/PearlPC/device.py | 42 +++ .../PearlPC/interfaces/__init__.py | 3 + .../PearlPC/interfaces/stream_interface.py | 250 ++++++++++++++++++ .../lewis_emulators/PearlPC/states.py | 5 + system_tests/lewis_emulators/__init__.py | 2 + .../lewis_emulators/lewis_versions.py | 2 + system_tests/lewis_versions.py | 2 + system_tests/run_tests.bat | 13 + ...ilLoadTestsuiteTestCase-20210804115226.xml | 64 +++++ ...ts.pearlpc.PEARLPCTests-20210726153045.xml | 4 + ...ts.pearlpc.PEARLPCTests-20210726153138.xml | 4 + ...ts.pearlpc.PEARLPCTests-20210726154011.xml | 4 + ...ts.pearlpc.PEARLPCTests-20210726154436.xml | 4 + ...ts.pearlpc.PEARLPCTests-20210726155211.xml | 4 + ...ts.pearlpc.PEARLPCTests-20210726155957.xml | 4 + ...ts.pearlpc.PEARLPCTests-20210726161117.xml | 18 ++ ...ts.pearlpc.PEARLPCTests-20210726161813.xml | 20 ++ ...ts.pearlpc.PEARLPCTests-20210726162431.xml | 4 + ...ts.pearlpc.PEARLPCTests-20210727152353.xml | 33 +++ ...ts.pearlpc.PEARLPCTests-20210727153648.xml | 5 + ...ts.pearlpc.PEARLPCTests-20210728091312.xml | 11 + ...ts.pearlpc.PEARLPCTests-20210728091856.xml | 17 ++ ...ts.pearlpc.PEARLPCTests-20210728092544.xml | 17 ++ ...ts.pearlpc.PEARLPCTests-20210728092650.xml | 11 + ...ts.pearlpc.PEARLPCTests-20210728092730.xml | 11 + ...ts.pearlpc.PEARLPCTests-20210728092854.xml | 4 + system_tests/tests/__init__.py | 0 system_tests/tests/pearlpc.py | 127 +++++++++ 48 files changed, 1163 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 PearlPCSup/Makefile create mode 100644 PearlPCSup/PearlPC.proto create mode 100644 PearlPCSup/devPearl.db create mode 100644 configure/CONFIG create mode 100644 configure/CONFIG_APP create mode 100644 configure/Makefile create mode 100644 configure/RELEASE create mode 100644 configure/RULES create mode 100644 configure/RULES_DIRS create mode 100644 configure/RULES_TOP create mode 100644 system_tests/.idea/.gitignore create mode 100644 system_tests/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 system_tests/.idea/misc.xml create mode 100644 system_tests/.idea/modules.xml create mode 100644 system_tests/.idea/system_tests.iml create mode 100644 system_tests/.idea/vcs.xml create mode 100644 system_tests/__init__.py create mode 100644 system_tests/lewis_emulators/PearlPC/__init__.py create mode 100644 system_tests/lewis_emulators/PearlPC/device.py create mode 100644 system_tests/lewis_emulators/PearlPC/interfaces/__init__.py create mode 100644 system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py create mode 100644 system_tests/lewis_emulators/PearlPC/states.py create mode 100644 system_tests/lewis_emulators/__init__.py create mode 100644 system_tests/lewis_emulators/lewis_versions.py create mode 100644 system_tests/lewis_versions.py create mode 100644 system_tests/run_tests.bat create mode 100644 system_tests/test-reports/TEST-ReportFailLoadTestsuiteTestCase-20210804115226.xml create mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726153045.xml create mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726153138.xml create mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726154011.xml create mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726154436.xml create mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726155211.xml create mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726155957.xml create mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726161117.xml create mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726161813.xml create mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726162431.xml create mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210727152353.xml create mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210727153648.xml create mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728091312.xml create mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728091856.xml create mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092544.xml create mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092650.xml create mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092730.xml create mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092854.xml create mode 100644 system_tests/tests/__init__.py create mode 100644 system_tests/tests/pearlpc.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d0f8a46 --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +__pycache__/ +*.py[cod] +*$py.class +/test-reports/ + +O.*/ +/db +/bin +/dbd +/include +/lib +/templates +envPaths +cdCommands +dllPath.bat +runIOC.bat +runIOC.sh +relPaths.sh +.project +/data diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d96db48 --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +TOP = . +include $(TOP)/configure/CONFIG + +DIRS += configure +DIRS += $(wildcard *Sup) +DIRS += $(wildcard *App) +DIRS += $(wildcard *Top) +DIRS += $(wildcard iocBoot) + +# The build order is controlled by these dependency rules: + +# All dirs except configure depend on configure +$(foreach dir, $(filter-out configure, $(DIRS)), \ + $(eval $(dir)_DEPEND_DIRS += configure)) + +# Any *App dirs depend on all *Sup dirs +$(foreach dir, $(filter %App, $(DIRS)), \ + $(eval $(dir)_DEPEND_DIRS += $(filter %Sup, $(DIRS)))) + +# Any *Top dirs depend on all *Sup and *App dirs +$(foreach dir, $(filter %Top, $(DIRS)), \ + $(eval $(dir)_DEPEND_DIRS += $(filter %Sup %App, $(DIRS)))) + +# iocBoot depends on all *App dirs +iocBoot_DEPEND_DIRS += $(filter %App,$(DIRS)) + +# Add any additional dependency rules here: + +include $(TOP)/configure/RULES_TOP + +ioctests: + .\system_tests\run_tests.bat diff --git a/PearlPCSup/Makefile b/PearlPCSup/Makefile new file mode 100644 index 0000000..42fb596 --- /dev/null +++ b/PearlPCSup/Makefile @@ -0,0 +1,11 @@ +TOP=.. +include $(TOP)/configure/CONFIG +#======================================= + +# Install .dbd and .db files +DATA += PearlPC.proto + +DB += devPearl.db + +#======================================= +include $(TOP)/configure/RULES diff --git a/PearlPCSup/PearlPC.proto b/PearlPCSup/PearlPC.proto new file mode 100644 index 0000000..979fabf --- /dev/null +++ b/PearlPCSup/PearlPC.proto @@ -0,0 +1,79 @@ +OutTerminator = "\r\n"; +InTerminator = "\r\r\n"; + +ReplyTimeout = 2000; + +get_st { + out "st"; + in "%(\$1.A)d %(\$1.B)d %(\$1.C)d %(\$1.D)d %(\$1.E)d %(\$1.F)d %(\$1.G)d %(\$1.H)d %(\$1.I)d %(\$1.J)d %(\$1.K)d %(\$2.A)d %(\$2.B)d %(\$2.C)d %(\$2.D)d"; +} + +set_ra{ + out "ra%#04d" +} + +set_mx{ + out "mx%#04d" +} + +set_mn{ + out "mn%#04d" +} + +set_sp{ + out "sp%#04d" +} + +set_sf{ + out "sf%#04d" +} + +set_si{ + out "si%#04d" +} + +set_sd{ + out "sd%#04d" +} + +set_sloop{ + out "sloop%#01d" +} + +set_by{ + out "By%#01d" +} + +set_ru{ + out "Ru%#01d" +} + +set_re{ + out "Re%#01d" +} + +set_St{ + out "St%#01d" +} + +set_EM{ + out "Em%#01d" +} + +set_ER{ + out "Er%#01d" +} + +set_AM{ + out "AM%#01d" +} + +set_GO{ + out "GO%d" +} + +get_id { + ExtraInput = Ignore; + out "id"; + in "%/[0-9]{4} [0-9]{4}/"; +} diff --git a/PearlPCSup/devPearl.db b/PearlPCSup/devPearl.db new file mode 100644 index 0000000..a4639da --- /dev/null +++ b/PearlPCSup/devPearl.db @@ -0,0 +1,225 @@ +record(bo, "$(P)$(IOC_NAME)DISABLE") +{ + field(DESC, "Disable comms") + field(PINI, "YES") + field(VAL, "$(DISABLE=0)") + field(OMSL, "supervisory") + field(ZNAM, "COMMS ENABLED") + field(ONAM, "COMMS DISABLED") +} + +record(calc, "$(P)$(IOC_NAME)BUFFER1"){ + field(CALC, "0") + field(INPL, "$(P)$(IOC_NAME)STATUS") + field(FLNK, "$(P)$(IOC_NAME)BUFFER2") +} + +record(calc, "$(P)$(IOC_NAME)BUFFER2"){ + field(CALC, "0") + field(INPL, "$(P)$(IOC_NAME)STATUS") +} + +record(ao, "$(P)$(IOC_NAME)PRESSURE:SP"){ + field(DESC, "Set Pressure") + field(DTYP, "stream") + field(OUT, "@PearlPC.proto set_ra $(PORT)") +} + +record(ai, "$(P)$(IOC_NAME)PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER1.K CP MS") + field(DESC, "Get Pressure") + field(DTYP, "Soft Channel") +} + +record(ai, "$(P)$(IOC_NAME)STATUS"){ + field(DESC, "Get Pressure") + field(DTYP, "stream") + field(INP, "@PearlPC.proto get_st($(P)$(IOC_NAME)BUFFER1, $(P)$(IOC_NAME)BUFFER2) $(PORT)") + field(SCAN, "1 second") + field(FLNK, "$(P)$(IOC_NAME)BUFFER1") +} + +record(ao, "$(P)$(IOC_NAME)MX_PRESSURE:SP"){ + field(DESC, "Set Max Pressure Value") + field(DTYP, "stream") + field(OUT, "@PearlPC.proto set_mx $(PORT)") +} + +record(ai, "$(P)$(IOC_NAME)MX_PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER2.C CP MS") + field(DESC, "Get Max Pressure") + field(DTYP, "Soft Channel") +} + +record(ao, "$(P)$(IOC_NAME)MN_PRESSURE:SP"){ + field(DESC, "Set Min Pressure Value") + field(DTYP, "stream") + field(OUT, "@PearlPC.proto set_mn $(PORT)") +} + +record(ai, "$(P)$(IOC_NAME)MN_PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER2.A CP MS") + field(DESC, "Get Min Pressure") + field(DTYP, "Soft Channel") +} + +record(ao, "$(P)$(IOC_NAME)SP_PRESSURE:SP"){ + field(DESC, "Set Setpoint Pressure Value") + field(DTYP, "stream") + field(OUT, "@PearlPC.proto set_sp $(PORT)") +} + +record(ai, "$(P)$(IOC_NAME)SP_PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER2.B CP MS") + field(DESC, "Get Setpoint Pressure") + field(DTYP, "Soft Channel") +} + +record(ao, "$(P)$(IOC_NAME)SF_PRESSURE:SP"){ + field(DESC, "Set Seal Fail Pressure Value") + field(DTYP, "stream") + field(OUT, "@PearlPC.proto set_sf $(PORT)") +} + +record(ai, "$(P)$(IOC_NAME)SF_PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER1.I CP MS") + field(DESC, "Get Seal Fail Pressure") + field(DTYP, "Soft Channel") +} + +record(ao, "$(P)$(IOC_NAME)SI_PRESSURE:SP"){ + field(DESC, "Set initial ID prefix") + field(DTYP, "stream") + field(OUT, "@PearlPC.proto set_si $(PORT)") +} + +record(ai, "$(P)$(IOC_NAME)SI_PRESSURE"){ + field(DESC, "Get initial ID prefix") + field(DTYP, "Soft Channel") +} + +record(ao, "$(P)$(IOC_NAME)SD_PRESSURE:SP"){ + field(DESC, "Set secondary ID prefix") + field(DTYP, "stream") + field(OUT, "@PearlPC.proto set_sd $(PORT)") +} + +record(ai, "$(P)$(IOC_NAME)SD_PRESSURE"){ + field(DESC, "Get secondary ID prefix") + field(DTYP, "Soft Channel") +} + +record(stringin, "$(P)$(IOC_NAME)ID_PRESSURE") { + field(DESC, "Get ID prefix") + field(DTYP, "stream") + field(INP, "@PearlPC.proto get_id $(PORT)") + field(SCAN, "1 second") +} + +record(ao, "$(P)$(IOC_NAME)SL_PRESSURE:SP"){ + field(DESC, "Set toggle for loop pressure mode") + field(DTYP, "stream") + field(OUT, "@PearlPC.proto set_sloop $(PORT)") +} + +record(ai, "$(P)$(IOC_NAME)SL_PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER1.H CP MS") + field(DESC, "Get loop pressure mode") + field(DTYP, "Soft Channel") +} + +record(ao, "$(P)$(IOC_NAME)BY_PRESSURE:SP") { + field(DESC, "Set Busy bit if busy or not") + field(DTYP, "stream") + field(OUT, "@PearlPC.proto set_by $(PORT)") +} + +record(ai, "$(P)$(IOC_NAME)BY_PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER1.E CP MS") + field(DESC, "Get Busy bit if busy or not") + field(DTYP, "Soft Channel") +} + +record(ao, "$(P)$(IOC_NAME)RU_PRESSURE:SP") { + field(DESC, "Set Mechanically active status") + field(DTYP, "stream") + field(OUT, "@PearlPC.proto set_ru $(PORT)") +} + +record(ai, "$(P)$(IOC_NAME)RU_PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER1.B CP MS") + field(DESC, "Get Mechanically active status") + field(DTYP, "Soft Channel") +} + +record(ao, "$(P)$(IOC_NAME)RE_PRESSURE:SP") { + field(DESC, "Reset stage for each piston") + field(DTYP, "stream") + field(OUT, "@PearlPC.proto set_re $(PORT)") +} + +record(ai, "$(P)$(IOC_NAME)RE_PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER1.C CP MS") + field(DESC, "Reset stage for each piston") + field(DTYP, "Soft Channel") +} + +record(ao, "$(P)$(IOC_NAME)St_PRESSURE:SP") { + field(DESC, "Stop bit after each move/manually") + field(DTYP, "stream") + field(OUT, "@PearlPC.proto set_St $(PORT)") +} + +record(ai, "$(P)$(IOC_NAME)St_PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER1.D CP MS") + field(DESC, "Stop bit after each move/manually") + field(DTYP, "Soft Channel") +} + +record(ao, "$(P)$(IOC_NAME)EM_PRESSURE:SP") { + field(DESC, "EM stop circuit status") + field(DTYP, "stream") + field(OUT, "@PearlPC.proto set_EM $(PORT)") +} + +record(ai, "$(P)$(IOC_NAME)EM_PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER1.A CP MS") + field(DESC, "EM stop circuit status") + field(DTYP, "Soft Channel") +} + +record(ao, "$(P)$(IOC_NAME)ER_PRESSURE:SP") { + field(DESC, "Last Error Code returned") + field(DTYP, "stream") + field(OUT, "@PearlPC.proto set_ER $(PORT)") +} + +record(ai, "$(P)$(IOC_NAME)ER_PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER1.J CP MS") + field(DESC, "Last Error Code returned") + field(DTYP, "Soft Channel") +} + +record(ao, "$(P)$(IOC_NAME)AM_PRESSURE:SP") { + field(DESC, "Sets auto/manual switch position") + field(DTYP, "stream") + field(OUT, "@PearlPC.proto set_AM $(PORT)") +} + +record(ai, "$(P)$(IOC_NAME)AM_PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER1.G CP MS") + field(DESC, "Gets auto/manual switch position") + field(DTYP, "Soft Channel") +} + +record(ao, "$(P)$(IOC_NAME)GO_PRESSURE:SP") { + field(DESC, "Set system initiated by host status") + field(DTYP, "stream") + field(OUT, "@PearlPC.proto set_GO $(PORT)") +} + +record(ai, "$(P)$(IOC_NAME)GO_PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER1.F CP MS") + field(DESC, "Get system initiated by host status") + field(DTYP, "Soft Channel") +} diff --git a/configure/CONFIG b/configure/CONFIG new file mode 100644 index 0000000..bf5e617 --- /dev/null +++ b/configure/CONFIG @@ -0,0 +1,13 @@ +#CONFIG +include $(TOP)/configure/CONFIG_APP +# Add any changes to make definitions here + +#CROSS_COMPILER_TARGET_ARCHS = vxWorks-68040 + +# Use this when your IOC and the host use different paths +# to access the application. Typically this will be +# used with the Microsoft FTP server or with NFS mounts. Use +# is indicated by failure of the cdCommands script on +# vxWorks. You must rebuild in the iocBoot directory +# before this takes effect. +#IOCS_APPL_TOP = diff --git a/configure/CONFIG_APP b/configure/CONFIG_APP new file mode 100644 index 0000000..b1f4ba1 --- /dev/null +++ b/configure/CONFIG_APP @@ -0,0 +1,21 @@ +# CONFIG_APP + +include $(TOP)/configure/RELEASE +-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH) +-include $(TOP)/configure/RELEASE.Common.$(T_A) +-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).$(T_A) + +CONFIG=$(EPICS_BASE)/configure +include $(CONFIG)/CONFIG + +INSTALL_LOCATION = $(TOP) +ifdef INSTALL_LOCATION_APP +INSTALL_LOCATION = $(INSTALL_LOCATION_APP) +endif + +ifdef T_A +-include $(TOP)/configure/O.$(T_A)/CONFIG_APP_INCLUDE +endif + +# dbst based database optimization (default: NO) +DB_OPT = NO diff --git a/configure/Makefile b/configure/Makefile new file mode 100644 index 0000000..8f3ca15 --- /dev/null +++ b/configure/Makefile @@ -0,0 +1,13 @@ +## configure/Makefile + +TOP=.. +include $(TOP)/configure/CONFIG + +# Set the following to NO to disable consistency checking of +# the support applications defined in $(TOP)/configure/RELEASE +CHECK_RELEASE = YES + +TARGETS = $(CONFIG_TARGETS) +CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS))) + +include $(TOP)/configure/RULES diff --git a/configure/RELEASE b/configure/RELEASE new file mode 100644 index 0000000..7fc8365 --- /dev/null +++ b/configure/RELEASE @@ -0,0 +1,5 @@ +# optional extra local definitions here +-include $(TOP)/configure/RELEASE.private + +include $(TOP)/../../../ISIS_CONFIG +-include $(TOP)/../../../ISIS_CONFIG.$(EPICS_HOST_ARCH) diff --git a/configure/RULES b/configure/RULES new file mode 100644 index 0000000..ffee54a --- /dev/null +++ b/configure/RULES @@ -0,0 +1,5 @@ +#CONFIG +include $(EPICS_BASE)/configure/RULES + +# Library should be rebuilt because LIBOBJS may have changed. +$(LIBNAME): ../Makefile diff --git a/configure/RULES_DIRS b/configure/RULES_DIRS new file mode 100644 index 0000000..804faee --- /dev/null +++ b/configure/RULES_DIRS @@ -0,0 +1,2 @@ +#RULES_DIRS +include $(EPICS_BASE)/configure/RULES_DIRS diff --git a/configure/RULES_TOP b/configure/RULES_TOP new file mode 100644 index 0000000..0620f08 --- /dev/null +++ b/configure/RULES_TOP @@ -0,0 +1,3 @@ +#RULES_TOP +include $(EPICS_BASE)/configure/RULES_TOP + diff --git a/system_tests/.idea/.gitignore b/system_tests/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/system_tests/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/system_tests/.idea/inspectionProfiles/profiles_settings.xml b/system_tests/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/system_tests/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/system_tests/.idea/misc.xml b/system_tests/.idea/misc.xml new file mode 100644 index 0000000..d1e22ec --- /dev/null +++ b/system_tests/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/system_tests/.idea/modules.xml b/system_tests/.idea/modules.xml new file mode 100644 index 0000000..953bfe7 --- /dev/null +++ b/system_tests/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/system_tests/.idea/system_tests.iml b/system_tests/.idea/system_tests.iml new file mode 100644 index 0000000..bfb361f --- /dev/null +++ b/system_tests/.idea/system_tests.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/system_tests/.idea/vcs.xml b/system_tests/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/system_tests/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/system_tests/__init__.py b/system_tests/__init__.py new file mode 100644 index 0000000..ad92558 --- /dev/null +++ b/system_tests/__init__.py @@ -0,0 +1,2 @@ +# DO NOT DELETE THIS FILE - LEWIS FRAMEWORK REQUIRES THE DIRECTORY TO BE IMPORTABLE +from __future__ import absolute_import diff --git a/system_tests/lewis_emulators/PearlPC/__init__.py b/system_tests/lewis_emulators/PearlPC/__init__.py new file mode 100644 index 0000000..6326cc7 --- /dev/null +++ b/system_tests/lewis_emulators/PearlPC/__init__.py @@ -0,0 +1,5 @@ +from .device import SimulatedCCD100 +from ..lewis_versions import LEWIS_LATEST + +framework_version = LEWIS_LATEST +__all__ = ['SimulatedCCD100'] diff --git a/system_tests/lewis_emulators/PearlPC/device.py b/system_tests/lewis_emulators/PearlPC/device.py new file mode 100644 index 0000000..c77d2da --- /dev/null +++ b/system_tests/lewis_emulators/PearlPC/device.py @@ -0,0 +1,42 @@ +from lewis.devices import StateMachineDevice +from lewis.core import approaches +from .states import DefaultState +from collections import OrderedDict + + +class SimulatedCCD100(StateMachineDevice): + + def _initialize_data(self): + self.initial_id_prefix = "1111" + self.secondary_id_prefix = "1111" + self.em_stop_status = 0 # Bool [0-1] + self.run_bit = 0 # Bool [0-1] + self.reset_value = 0 + self.stop_bit = 0 # Bool [0-1]\ + self.busy_bit = 0 # Bool [0-1] + self.go_status = 0 + self.am_mode = 0 + self.loop_mode = 0 # Bool [0-1] + self.seal_fail_value = 0 + self.last_error_code = 0 + self.pressure_rate = 0 + self.min_value_pre_servoing = 0 + self.setpoint_value = 0 + self.max_value_pre_servoing = 0 + + # When the device is in an error state it can respond with junk + self.is_giving_errors = False + self.out_error = "}{<7f>w" + self.out_terminator_in_error = "" + + def _get_state_handlers(self): + return { + 'default': DefaultState(), + } + + def _get_initial_state(self): + return 'default' + + def _get_transition_handlers(self): + return OrderedDict([]) + diff --git a/system_tests/lewis_emulators/PearlPC/interfaces/__init__.py b/system_tests/lewis_emulators/PearlPC/interfaces/__init__.py new file mode 100644 index 0000000..c164a27 --- /dev/null +++ b/system_tests/lewis_emulators/PearlPC/interfaces/__init__.py @@ -0,0 +1,3 @@ +from .stream_interface import PearlPCStreamInterface + +__all__ = ['PearlPCStreamInterface'] diff --git a/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py b/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py new file mode 100644 index 0000000..03d70e3 --- /dev/null +++ b/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py @@ -0,0 +1,250 @@ +from lewis.adapters.stream import StreamInterface, Cmd +from lewis.utils.command_builder import CmdBuilder +from lewis.core.logging import has_log +from lewis.utils.replies import conditional_reply + + +@has_log +class PearlPCStreamInterface(StreamInterface): + commands = { + # Get status and id prefixes + CmdBuilder("get_st").escape("st").eos().build(), + CmdBuilder("get_id_prefix").escape("id").eos().build(), + # Set ID prefixes + CmdBuilder("set_si").escape("si").arg("[0-9]{4}").eos().build(), + CmdBuilder("set_sd").escape("sd").arg("[0-9]{4}").eos().build(), + # Device Set commands + CmdBuilder("set_em_stop_status").escape("Em").arg("[0-1]{1}").eos().build(), + CmdBuilder("set_ru").escape("Ru").arg("[0-1]{1}").eos().build(), + CmdBuilder("set_re").escape("Re").arg("[0-4]{1}").eos().build(), + CmdBuilder("set_stop_bit").escape("St").arg("[0-1]{1}").eos().build(), + CmdBuilder("set_by").escape("By").arg("[0-1]{1}").eos().build(), + CmdBuilder("set_go").escape("GO").arg("[0-1]{1}").eos().build(), + CmdBuilder("set_am").escape("AM").arg("[0-1]{1}").eos().build(), + CmdBuilder("set_sloop").escape("sloop").arg("[0-1]{1}").eos().build(), + CmdBuilder("set_sf").escape("sf").arg("[0-9]{4}").eos().build(), + CmdBuilder("set_er").escape("Er").arg("[0-9]{1,2}").eos().build(), + CmdBuilder("set_ra").escape("ra").arg("[0-9]{4}").eos().build(), + CmdBuilder("set_mn").escape("mn").arg("[0-9]{4}").eos().build(), + CmdBuilder("set_sp").escape("sp").arg("[0-9]{4}").eos().build(), + CmdBuilder("set_mx").escape("mx").arg("[0-9]{4}").eos().build() + } + + in_terminator = "\r\n" + good_out_terminator = "\r\r\n" + + def __init__(self, status_dictionary=None): + super().__init__() + if status_dictionary is None: + status_dictionary = {} + self.status_dictionary = status_dictionary + + def set_ra(self, pressure_rate): + """ + Set rate of pressure application in Bar/min + A value of 0000 will be used to represent maximum slew rate of the motor. + Normally set to 0010 + @param pressure_rate: (int) Pressure rate within range [0001-0040] + """ + print(f"Pressure Rate Received: {pressure_rate}") + self._device.pressure_rate = pressure_rate + self.add_to_dict(value_id="ra", unvalidated_value=self._device.pressure_rate) + + def get_st(self): + """ + Get the device status on request + @return: (str) A formatted string containing all set device parameters describing current device status. + """ + return f"{self._device.em_stop_status} " \ + f"{self._device.run_bit} " \ + f"{self._device.reset_value} " \ + f"{self._device.stop_bit} " \ + f"{self._device.busy_bit} " \ + f"{self._device.go_status} " \ + f"{self._device.am_mode} " \ + f"{self._device.loop_mode} " \ + f"{self._device.seal_fail_value} " \ + f"{self._device.last_error_code} " \ + f"{self._device.pressure_rate} " \ + f"{self._device.min_value_pre_servoing} " \ + f"{self._device.setpoint_value} " \ + f"{self._device.max_value_pre_servoing} " \ + f"0" + + def set_mx(self, max_measured: int): + """ + set the maximum measured value before re-servoing + @param max_measured: (integer) maximum measured value before re-servoing - range [0001-9999] + """ + print(f"Maximum measured value before re-servoing received: {max_measured}") + self._device.max_value_pre_servoing = max_measured + self.add_to_dict(value_id="mx", unvalidated_value=self._device.max_value_pre_servoing) + + def set_mn(self, min_measured: int): + """ + Set the minimum value before re-servoing. + This will only be acted upon in closed loop mode. + @param min_measured: (int) minimum pressure value before re-servoing - range [0001-9999] + """ + print(f"Minimum value before re-servoing received: {min_measured}") + self._device.min_value_pre_servoing = min_measured + self.add_to_dict(value_id="mn", unvalidated_value=self._device.min_value_pre_servoing) + + def set_sp(self, setpoint: int): + """ + Set a setpoint to be initially reached if the measured pressure exceeds maximum value (mx) + or falls below minimum value (mn) and the servo loop is closed. + The motor will operate until the pressure is restored to the setpoint value + @param setpoint: (int) Set Point trigger value - range [0001-1000] + """ + print(f"Setpoint value received: {setpoint}") + self._device.setpoint_value = setpoint + self.add_to_dict(value_id="sp", unvalidated_value=self._device.setpoint_value) + + def set_sf(self, seal_fail_value: int): + """ + Set Seal Fail drop value. + Sets the pressure drop required to trigger Seal Fail mode. + @param seal_fail_value: (int) Seal Fail Mode Trigger Value - range [0001-0999] + """ + print(f"Seal Fail mode trigger value received: {seal_fail_value}") + self._device.seal_fail_value = seal_fail_value + self.add_to_dict(value_id="sf", unvalidated_value=self._device.seal_fail_value) + + def set_si(self, id_prefix: int): + """ + Set initial ID Prefix. ID should form a unique number for each unit. + The ID allows for communication with each associated unit. + @param id_prefix: (int) Prefix to ID for a unit - range [0000-9999] + """ + print(f"ID prefix value received: {id_prefix}") + self._device.initial_id_prefix = id_prefix + self.add_to_dict(value_id="si", unvalidated_value=self._device.initial_id_prefix) + + def set_sd(self, secondary_id_prefix: int): + """ + Set Secondary ID Prefix. ID should form a unique number for each unit. + ID allows for communication with each associated unit. + Secondary ID prefix is usually set to be the same at initial ID prefix + @param secondary_id_prefix: (int) Prefix to ID for a unit - range [0000-9999] + """ + print(f"ID prefix value received: {secondary_id_prefix}") + self._device.secondary_id_prefix = secondary_id_prefix + self.add_to_dict(value_id="sd", unvalidated_value=self._device.secondary_id_prefix) + + def set_sloop(self, sloop: int): + """ + Represents binary bit to set loop mode + 0 = open loop mode + 1 = close loop mode + Open loop mode ramps to pressure in control system and then stop until anther command is sent. + Close loop mode will ramp to setpoint pressure value and remain active monitoring delivered pressure, + acting on mn and mx pressure values. + @param sloop: (int) integer value setting system to open or closed loop - range [0-1] + """ + + print(f"sloop value recieved: {sloop}") + self._device.loop_mode = sloop + self.add_to_dict(value_id="sloop", unvalidated_value=self._device.loop_mode) + + def add_to_dict(self, value_id: str, unvalidated_value: object): + """ + Add device state parameters to a dictionary. + @param value_id: (str) dictionary key for each device parameter + @param unvalidated_value: (object) device parameter set to describe system status + """ + self.status_dictionary[value_id] = unvalidated_value + + def get_id_prefix(self): + """ + Returns ID prefixes (first 2 numbers selectable by the user formatted as: " ") + @return: (str) formatted string returning ID prefixes set by default or by user. + """ + print(f"ID prefix set to: {self._device.initial_id_prefix} {self._device.secondary_id_prefix}") + return f"{self._device.initial_id_prefix} {self._device.secondary_id_prefix}" + + def set_by(self, busy_bit: int): + """ + Set the busy bit status + 1 denotes that the device is busy and 0 not busy + @type busy_bit: (int) integer representing if device is mechanically active - range [0-1] + """ + print(f"Received busy bit {busy_bit}") + self._device.busy_bit = busy_bit + self.add_to_dict(value_id="by", unvalidated_value=self._device.busy_bit) + + def set_ru(self, run_bit: int): + """ + Set Run Bit which denotes is mechanically active + @param run_bit: (int) Value to start servo loop execution, + pumping to achieve the setpoint pressure - range [0-1] + """ + print(f"Received run bit: {run_bit}") + self._device.run_bit = run_bit + self.add_to_dict(value_id="ru", unvalidated_value=self._device.run_bit) + + def set_re(self, reset_value: int): + """ + Set the reset value to represent the 4 stages of resetting the pistons + @param reset_value: (int) value representing each stage during piston reset - range [0-4] + """ + print(f"Received reset value: {reset_value}") + self._device.reset_value = reset_value + self.add_to_dict(value_id="re", unvalidated_value=self._device.reset_value) + + def set_stop_bit(self, stop_bit: int): + """ + Set the stop bit to 1 or 0 where 1 requests the system to stop. This value is + set automatically at the end of a move or set to stop system manually + @param stop_bit: (int) status value to stop system at the end of a move or by request - range [0-1] + """ + print(f"Received stop bit command: {stop_bit}") + self._device.stop_bit = stop_bit + self.add_to_dict(value_id="St", unvalidated_value=self._device.stop_bit) + + def set_em_stop_status(self, em_stop_status: int): + """ + Set emergency stop circuit status. + 1 denotes that the system has stopped. 0 denotes the system is running + @param em_stop_status: (int) Device status value for requesting emergency stop circuit - range [0-1] + """ + + print(f"Received EM stop circuit status: {em_stop_status}") + self._device.em_stop_status = em_stop_status + self.add_to_dict(value_id="EM", unvalidated_value=self._device.em_stop_status) + + def set_er(self, last_error_code: int): + """ + Set the last error code + @param last_error_code: (int) Last error status received by device - range [0-19] + """ + print(f"Received last error code: {last_error_code}") + self._device.last_error_code = last_error_code + self.add_to_dict(value_id="ER", unvalidated_value=self._device.last_error_code) + + def set_am(self, am_mode: int): + """ + Set AM auto/manual switch position mode + @param am_mode: (int) Set Auto/manual switch position - range [0-1] + """ + print(f"Received last AM modeL: {am_mode}") + self._device.am_mode = am_mode + self.add_to_dict(value_id="AM", unvalidated_value=self._device.am_mode) + + def set_go(self, go_status: int): + """ + Set GO status to to 1 if system was initiated by host. + 1 - set by host + 0 - not set by host + @param go_status (int) set if command initiated by host - range [0-1] + """ + print(f"Received GO status: {go_status}") + self._device.go_status = go_status + self.add_to_dict(value_id="GO", unvalidated_value=self._device.go_status) + + def handle_error(self, request, error): + """ + Return any errors which have occurred when sending requests to device. + @rtype: object + """ + print("An error occurred at request " + repr(request) + ": " + repr(error)) diff --git a/system_tests/lewis_emulators/PearlPC/states.py b/system_tests/lewis_emulators/PearlPC/states.py new file mode 100644 index 0000000..fc1a11d --- /dev/null +++ b/system_tests/lewis_emulators/PearlPC/states.py @@ -0,0 +1,5 @@ +from lewis.core.statemachine import State + + +class DefaultState(State): + pass \ No newline at end of file diff --git a/system_tests/lewis_emulators/__init__.py b/system_tests/lewis_emulators/__init__.py new file mode 100644 index 0000000..ad92558 --- /dev/null +++ b/system_tests/lewis_emulators/__init__.py @@ -0,0 +1,2 @@ +# DO NOT DELETE THIS FILE - LEWIS FRAMEWORK REQUIRES THE DIRECTORY TO BE IMPORTABLE +from __future__ import absolute_import diff --git a/system_tests/lewis_emulators/lewis_versions.py b/system_tests/lewis_emulators/lewis_versions.py new file mode 100644 index 0000000..0f6c45a --- /dev/null +++ b/system_tests/lewis_emulators/lewis_versions.py @@ -0,0 +1,2 @@ +LEWIS_1_3_0 = "1.3.0" +LEWIS_LATEST = LEWIS_1_3_0 diff --git a/system_tests/lewis_versions.py b/system_tests/lewis_versions.py new file mode 100644 index 0000000..0f6c45a --- /dev/null +++ b/system_tests/lewis_versions.py @@ -0,0 +1,2 @@ +LEWIS_1_3_0 = "1.3.0" +LEWIS_LATEST = LEWIS_1_3_0 diff --git a/system_tests/run_tests.bat b/system_tests/run_tests.bat new file mode 100644 index 0000000..56f9c25 --- /dev/null +++ b/system_tests/run_tests.bat @@ -0,0 +1,13 @@ +@echo off +REM Run this directory's tests using the IOC Testing Framework + +SET CurrentDir=%~dp0 + +call "%~dp0..\..\..\..\config_env.bat" + +set "PYTHONUNBUFFERED=1" + +REM Command line arguments always passed to the test script +SET ARGS=--test_and_emulator %~dp0 +call %PYTHON3% "%EPICS_KIT_ROOT%\support\IocTestFramework\master\run_tests.py" %ARGS% %* +IF %ERRORLEVEL% NEQ 0 EXIT /b %errorlevel% diff --git a/system_tests/test-reports/TEST-ReportFailLoadTestsuiteTestCase-20210804115226.xml b/system_tests/test-reports/TEST-ReportFailLoadTestsuiteTestCase-20210804115226.xml new file mode 100644 index 0000000..641613a --- /dev/null +++ b/system_tests/test-reports/TEST-ReportFailLoadTestsuiteTestCase-20210804115226.xml @@ -0,0 +1,64 @@ + + + + + + + diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726153045.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726153045.xml new file mode 100644 index 0000000..0eb49d1 --- /dev/null +++ b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726153045.xml @@ -0,0 +1,4 @@ + + + + diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726153138.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726153138.xml new file mode 100644 index 0000000..26906fd --- /dev/null +++ b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726153138.xml @@ -0,0 +1,4 @@ + + + + diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726154011.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726154011.xml new file mode 100644 index 0000000..771665e --- /dev/null +++ b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726154011.xml @@ -0,0 +1,4 @@ + + + + diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726154436.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726154436.xml new file mode 100644 index 0000000..2a1472a --- /dev/null +++ b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726154436.xml @@ -0,0 +1,4 @@ + + + + diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726155211.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726155211.xml new file mode 100644 index 0000000..967de0e --- /dev/null +++ b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726155211.xml @@ -0,0 +1,4 @@ + + + + diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726155957.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726155957.xml new file mode 100644 index 0000000..e6db70f --- /dev/null +++ b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726155957.xml @@ -0,0 +1,4 @@ + + + + diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726161117.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726161117.xml new file mode 100644 index 0000000..2c5ab4c --- /dev/null +++ b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726161117.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726161813.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726161813.xml new file mode 100644 index 0000000..920f656 --- /dev/null +++ b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726161813.xml @@ -0,0 +1,20 @@ + + + + + + diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726162431.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726162431.xml new file mode 100644 index 0000000..c740209 --- /dev/null +++ b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726162431.xml @@ -0,0 +1,4 @@ + + + + diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210727152353.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210727152353.xml new file mode 100644 index 0000000..3665ab3 --- /dev/null +++ b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210727152353.xml @@ -0,0 +1,33 @@ + + + + + + + + + diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210727153648.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210727153648.xml new file mode 100644 index 0000000..3aff425 --- /dev/null +++ b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210727153648.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728091312.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728091312.xml new file mode 100644 index 0000000..1b0aded --- /dev/null +++ b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728091312.xml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728091856.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728091856.xml new file mode 100644 index 0000000..68887e6 --- /dev/null +++ b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728091856.xml @@ -0,0 +1,17 @@ + + + + + + + diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092544.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092544.xml new file mode 100644 index 0000000..17d3826 --- /dev/null +++ b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092544.xml @@ -0,0 +1,17 @@ + + + + + + + diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092650.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092650.xml new file mode 100644 index 0000000..74016f0 --- /dev/null +++ b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092650.xml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092730.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092730.xml new file mode 100644 index 0000000..b759201 --- /dev/null +++ b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092730.xml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092854.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092854.xml new file mode 100644 index 0000000..82a8dd7 --- /dev/null +++ b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092854.xml @@ -0,0 +1,4 @@ + + + + diff --git a/system_tests/tests/__init__.py b/system_tests/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/system_tests/tests/pearlpc.py b/system_tests/tests/pearlpc.py new file mode 100644 index 0000000..5ffc05b --- /dev/null +++ b/system_tests/tests/pearlpc.py @@ -0,0 +1,127 @@ +import unittest +from time import sleep + +from utils.test_modes import TestModes +from utils.channel_access import ChannelAccess +from utils.ioc_launcher import get_default_ioc_dir +from utils.testing import get_running_lewis_and_ioc, assert_log_messages, skip_if_recsim, unstable_test +from parameterized import parameterized + +# Device prefix +DEVICE_A_PREFIX = "PEARLPC_01" + +EMULATOR_DEVICE = "PearlPC" + +IOCS = [ + { + "name": DEVICE_A_PREFIX, + "directory": get_default_ioc_dir("PEARLPC"), + "emulator": EMULATOR_DEVICE, + "emulator_id": DEVICE_A_PREFIX, + }, +] + +TEST_MODES = [TestModes.DEVSIM] + + +class PEARLPCTests(unittest.TestCase): + """ + General Unit tests for the PEARLPC_01. + """ + + def setUp(self): + self.pressure_value = 1000 + self.set_loop_status = 1 + self.lewis, self.ioc = get_running_lewis_and_ioc(DEVICE_A_PREFIX, DEVICE_A_PREFIX) + self.ca = ChannelAccess(default_timeout=20, default_wait_time=0.0, device_prefix=DEVICE_A_PREFIX) + + def test_WHEN_max_pressure_set_THEN_max_pressure_set_correctly(self): + self.ca.set_pv_value("MX_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("MX_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("BUFFER2.C", self.pressure_value) + # self.ca.assert_setting_setpoint_sets_readback(self.pressure_value, "MX_PRESSURE") + + def test_WHEN_pressure_set_THEN_pressure_read_back_correctly(self): + self.ca.set_pv_value("PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("BUFFER1.K", self.pressure_value) + # self.ca.assert_setting_setpoint_sets_readback(self.pressure_value, "PRESSURE") + + def test_WHEN_min_pressure_set_THEN_min_pressure_read_back_correctly(self): + self.ca.set_pv_value("MN_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("MN_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("BUFFER2.A", self.pressure_value) + # self.ca.assert_setting_setpoint_sets_readback(self.pressure_value, "MN_PRESSURE") + + def test_WHEN_setpoint_pressure_set_THEN_setpoint_pressure_read_back_correctly(self): + self.ca.set_pv_value("SP_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("SP_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("BUFFER2.B", self.pressure_value) + # self.ca.assert_setting_setpoint_sets_readback(self.pressure_value, "SP_PRESSURE") + + def test_WHEN_Seal_Fail_pressure_set_THEN_Seal_Fail_pressure_read_back_correctly(self): + self.ca.set_pv_value("SF_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("SF_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("BUFFER1.I", self.pressure_value) + # self.ca.assert_setting_setpoint_sets_readback(self.pressure_value, "SF_PRESSURE") + + def test_WHEN_initial_ID_prefix_set_THEN_initial_ID_prefix_read_back_correctly(self): + self.ca.set_pv_value("SI_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("SI_PRESSURE:SP", self.pressure_value) + # self.ca.assert_setting_setpoint_sets_readback(self.pressure_value, "SI_PRESSURE") + + def test_WHEN_secondary_ID_prefix_set_THEN_secondary_ID_prefix_read_back_correctly(self): + self.ca.set_pv_value("SD_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("SD_PRESSURE:SP", self.pressure_value) + # self.ca.assert_setting_setpoint_sets_readback(self.pressure_value, "SD_PRESSURE") + + def test_WHEN_id_prefixes_set_THEN_id_prefixes_read_back_correctly(self): + self.ca.set_pv_value("SI_PRESSURE:SP", self.pressure_value) + self.ca.set_pv_value("SD_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("ID_PRESSURE", f"{self.pressure_value} {self.pressure_value}") + + def test_WHEN_loop_mode_set_THEN_loop_mode_read_back_correctly(self): + self.ca.set_pv_value("SL_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("SL_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("BUFFER1.H", self.set_loop_status) + + def test_WHEN_busy_bit_set_THEN_busy_bit_read_back_correctly(self): + self.ca.set_pv_value("BY_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("BY_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("BUFFER1.E", self.set_loop_status) + # self.ca.assert_that_pv_is("BUFFER1.E", str(self.set_loop_status)) #TODO Fix buffer read test + + def test_WHEN_run_bit_set_THEN_run_bit_read_back_correctly(self): + self.ca.set_pv_value("RU_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("RU_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("BUFFER1.B", self.set_loop_status) + + def test_WHEN_reset_value_set_THEN_reset_value_read_back_correctly(self): + self.ca.set_pv_value("RE_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("RE_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("BUFFER1.C", self.set_loop_status) + + def test_WHEN_stop_bit_set_THEN_stop_bit_value_read_back_correctly(self): + self.ca.set_pv_value("St_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("St_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("BUFFER1.D", self.set_loop_status) + + def test_WHEN_em_stop_bit_set_THEN_em_stop_bit_value_read_back_correctly(self): + self.ca.set_pv_value("EM_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("EM_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("BUFFER1.A", self.set_loop_status) + + def test_WHEN_er_last_error_code_set_THEN_er_last_error_code_read_back_correctly(self): + self.ca.set_pv_value("ER_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("ER_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("BUFFER1.J", self.set_loop_status) + + def test_WHEN_AM_mode_set_THEN_AM_mode_read_back_correctly(self): + self.ca.set_pv_value("AM_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("AM_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("BUFFER1.G", self.set_loop_status) + + def test_WHEN_GO_status_set_THEN_GO_status_read_back_correctly(self): + self.ca.set_pv_value("GO_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("GO_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("BUFFER1.F", self.set_loop_status) From d7baff4b00759e43478c27578162b5b0b5f1aa1f Mon Sep 17 00:00:00 2001 From: JackEAllen Date: Wed, 11 Aug 2021 10:20:33 +0100 Subject: [PATCH 02/12] Update tests and stream_interface code cleanup --- .../PearlPC/interfaces/stream_interface.py | 6 ++-- system_tests/tests/pearlpc.py | 30 ++++++++++++++----- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py b/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py index 03d70e3..ed68b75 100644 --- a/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py +++ b/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py @@ -242,9 +242,9 @@ def set_go(self, go_status: int): self._device.go_status = go_status self.add_to_dict(value_id="GO", unvalidated_value=self._device.go_status) - def handle_error(self, request, error): + def handle_error(self, request:object, error:object): """ Return any errors which have occurred when sending requests to device. - @rtype: object + @return: (str) Formatted error message """ - print("An error occurred at request " + repr(request) + ": " + repr(error)) + print(f"An error occurred at request {repr(request)} : {repr(error)}") diff --git a/system_tests/tests/pearlpc.py b/system_tests/tests/pearlpc.py index 5ffc05b..0d9f36a 100644 --- a/system_tests/tests/pearlpc.py +++ b/system_tests/tests/pearlpc.py @@ -32,48 +32,52 @@ class PEARLPCTests(unittest.TestCase): def setUp(self): self.pressure_value = 1000 self.set_loop_status = 1 + self.default_initial_value = 0 + self.default_id_prefix = 0 self.lewis, self.ioc = get_running_lewis_and_ioc(DEVICE_A_PREFIX, DEVICE_A_PREFIX) self.ca = ChannelAccess(default_timeout=20, default_wait_time=0.0, device_prefix=DEVICE_A_PREFIX) def test_WHEN_max_pressure_set_THEN_max_pressure_set_correctly(self): + self.ca.assert_that_pv_is("BUFFER2.C", self.default_initial_value) self.ca.set_pv_value("MX_PRESSURE:SP", self.pressure_value) self.ca.assert_that_pv_is("MX_PRESSURE:SP", self.pressure_value) self.ca.assert_that_pv_is("BUFFER2.C", self.pressure_value) # self.ca.assert_setting_setpoint_sets_readback(self.pressure_value, "MX_PRESSURE") def test_WHEN_pressure_set_THEN_pressure_read_back_correctly(self): + self.ca.assert_that_pv_is("BUFFER1.K", self.default_initial_value) self.ca.set_pv_value("PRESSURE:SP", self.pressure_value) self.ca.assert_that_pv_is("PRESSURE:SP", self.pressure_value) self.ca.assert_that_pv_is("BUFFER1.K", self.pressure_value) - # self.ca.assert_setting_setpoint_sets_readback(self.pressure_value, "PRESSURE") def test_WHEN_min_pressure_set_THEN_min_pressure_read_back_correctly(self): + self.ca.assert_that_pv_is("BUFFER2.A", self.default_id_prefix) self.ca.set_pv_value("MN_PRESSURE:SP", self.pressure_value) self.ca.assert_that_pv_is("MN_PRESSURE:SP", self.pressure_value) self.ca.assert_that_pv_is("BUFFER2.A", self.pressure_value) - # self.ca.assert_setting_setpoint_sets_readback(self.pressure_value, "MN_PRESSURE") def test_WHEN_setpoint_pressure_set_THEN_setpoint_pressure_read_back_correctly(self): + self.ca.assert_that_pv_is("BUFFER2.B", self.default_id_prefix) self.ca.set_pv_value("SP_PRESSURE:SP", self.pressure_value) self.ca.assert_that_pv_is("SP_PRESSURE:SP", self.pressure_value) self.ca.assert_that_pv_is("BUFFER2.B", self.pressure_value) - # self.ca.assert_setting_setpoint_sets_readback(self.pressure_value, "SP_PRESSURE") def test_WHEN_Seal_Fail_pressure_set_THEN_Seal_Fail_pressure_read_back_correctly(self): + self.ca.assert_that_pv_is("BUFFER1.I", self.default_id_prefix) self.ca.set_pv_value("SF_PRESSURE:SP", self.pressure_value) self.ca.assert_that_pv_is("SF_PRESSURE:SP", self.pressure_value) self.ca.assert_that_pv_is("BUFFER1.I", self.pressure_value) - # self.ca.assert_setting_setpoint_sets_readback(self.pressure_value, "SF_PRESSURE") def test_WHEN_initial_ID_prefix_set_THEN_initial_ID_prefix_read_back_correctly(self): self.ca.set_pv_value("SI_PRESSURE:SP", self.pressure_value) self.ca.assert_that_pv_is("SI_PRESSURE:SP", self.pressure_value) - # self.ca.assert_setting_setpoint_sets_readback(self.pressure_value, "SI_PRESSURE") def test_WHEN_secondary_ID_prefix_set_THEN_secondary_ID_prefix_read_back_correctly(self): self.ca.set_pv_value("SD_PRESSURE:SP", self.pressure_value) self.ca.assert_that_pv_is("SD_PRESSURE:SP", self.pressure_value) - # self.ca.assert_setting_setpoint_sets_readback(self.pressure_value, "SD_PRESSURE") + + def test_WHEN_id_prefixes_not_set_THEN_default_id_prefixes_read_back_correctly(self): + self.ca.assert_that_pv_is("ID_PRESSURE", f"{self.default_id_prefix} {self.default_id_prefix}") def test_WHEN_id_prefixes_set_THEN_id_prefixes_read_back_correctly(self): self.ca.set_pv_value("SI_PRESSURE:SP", self.pressure_value) @@ -81,47 +85,59 @@ def test_WHEN_id_prefixes_set_THEN_id_prefixes_read_back_correctly(self): self.ca.assert_that_pv_is("ID_PRESSURE", f"{self.pressure_value} {self.pressure_value}") def test_WHEN_loop_mode_set_THEN_loop_mode_read_back_correctly(self): + self.ca.assert_that_pv_is("BUFFER1.H", self.default_initial_value) self.ca.set_pv_value("SL_PRESSURE:SP", self.set_loop_status) self.ca.assert_that_pv_is("SL_PRESSURE:SP", self.set_loop_status) self.ca.assert_that_pv_is("BUFFER1.H", self.set_loop_status) def test_WHEN_busy_bit_set_THEN_busy_bit_read_back_correctly(self): + self.ca.assert_that_pv_is("BUFFER1.E", self.default_initial_value) self.ca.set_pv_value("BY_PRESSURE:SP", self.set_loop_status) self.ca.assert_that_pv_is("BY_PRESSURE:SP", self.set_loop_status) self.ca.assert_that_pv_is("BUFFER1.E", self.set_loop_status) - # self.ca.assert_that_pv_is("BUFFER1.E", str(self.set_loop_status)) #TODO Fix buffer read test def test_WHEN_run_bit_set_THEN_run_bit_read_back_correctly(self): + self.ca.assert_that_pv_is("BUFFER1.B", self.default_initial_value) self.ca.set_pv_value("RU_PRESSURE:SP", self.set_loop_status) self.ca.assert_that_pv_is("RU_PRESSURE:SP", self.set_loop_status) self.ca.assert_that_pv_is("BUFFER1.B", self.set_loop_status) def test_WHEN_reset_value_set_THEN_reset_value_read_back_correctly(self): + self.ca.assert_that_pv_is("BUFFER1.C", self.default_initial_value) self.ca.set_pv_value("RE_PRESSURE:SP", self.set_loop_status) self.ca.assert_that_pv_is("RE_PRESSURE:SP", self.set_loop_status) self.ca.assert_that_pv_is("BUFFER1.C", self.set_loop_status) def test_WHEN_stop_bit_set_THEN_stop_bit_value_read_back_correctly(self): + self.ca.assert_that_pv_is("BUFFER1.D", self.default_initial_value) self.ca.set_pv_value("St_PRESSURE:SP", self.set_loop_status) self.ca.assert_that_pv_is("St_PRESSURE:SP", self.set_loop_status) self.ca.assert_that_pv_is("BUFFER1.D", self.set_loop_status) def test_WHEN_em_stop_bit_set_THEN_em_stop_bit_value_read_back_correctly(self): + self.ca.assert_that_pv_is("BUFFER1.A", self.default_initial_value) self.ca.set_pv_value("EM_PRESSURE:SP", self.set_loop_status) self.ca.assert_that_pv_is("EM_PRESSURE:SP", self.set_loop_status) self.ca.assert_that_pv_is("BUFFER1.A", self.set_loop_status) def test_WHEN_er_last_error_code_set_THEN_er_last_error_code_read_back_correctly(self): + self.ca.assert_that_pv_is("BUFFER1.J", self.default_initial_value) self.ca.set_pv_value("ER_PRESSURE:SP", self.set_loop_status) self.ca.assert_that_pv_is("ER_PRESSURE:SP", self.set_loop_status) self.ca.assert_that_pv_is("BUFFER1.J", self.set_loop_status) def test_WHEN_AM_mode_set_THEN_AM_mode_read_back_correctly(self): + self.ca.assert_that_pv_is("BUFFER1.G", self.default_initial_value) self.ca.set_pv_value("AM_PRESSURE:SP", self.set_loop_status) self.ca.assert_that_pv_is("AM_PRESSURE:SP", self.set_loop_status) self.ca.assert_that_pv_is("BUFFER1.G", self.set_loop_status) def test_WHEN_GO_status_set_THEN_GO_status_read_back_correctly(self): + self.ca.assert_that_pv_is("BUFFER1.F", self.default_initial_value) self.ca.set_pv_value("GO_PRESSURE:SP", self.set_loop_status) self.ca.assert_that_pv_is("GO_PRESSURE:SP", self.set_loop_status) self.ca.assert_that_pv_is("BUFFER1.F", self.set_loop_status) + + # def test_WHEN_buffer_values_set_THEN_buffer_read_back_correctly_updated(self): + # self.ca.set_pv_value("GO_PRESSURE:SP", self.set_loop_status) + # self.ca.assert_that_pv_is From 3f5af086635b120b8d82d722a1b47147a5426bcd Mon Sep 17 00:00:00 2001 From: JackEAllen Date: Wed, 11 Aug 2021 11:16:00 +0100 Subject: [PATCH 03/12] Code cleanup and unit test fixes --- PearlPCSup/devPearl.db | 192 ++++++++-------- .../PearlPC/interfaces/stream_interface.py | 210 +++++++++--------- system_tests/tests/pearlpc.py | 120 +++++----- 3 files changed, 260 insertions(+), 262 deletions(-) diff --git a/PearlPCSup/devPearl.db b/PearlPCSup/devPearl.db index a4639da..b01aa8c 100644 --- a/PearlPCSup/devPearl.db +++ b/PearlPCSup/devPearl.db @@ -19,18 +19,6 @@ record(calc, "$(P)$(IOC_NAME)BUFFER2"){ field(INPL, "$(P)$(IOC_NAME)STATUS") } -record(ao, "$(P)$(IOC_NAME)PRESSURE:SP"){ - field(DESC, "Set Pressure") - field(DTYP, "stream") - field(OUT, "@PearlPC.proto set_ra $(PORT)") -} - -record(ai, "$(P)$(IOC_NAME)PRESSURE"){ - field(INP, "$(P)$(IOC_NAME)BUFFER1.K CP MS") - field(DESC, "Get Pressure") - field(DTYP, "Soft Channel") -} - record(ai, "$(P)$(IOC_NAME)STATUS"){ field(DESC, "Get Pressure") field(DTYP, "stream") @@ -39,54 +27,6 @@ record(ai, "$(P)$(IOC_NAME)STATUS"){ field(FLNK, "$(P)$(IOC_NAME)BUFFER1") } -record(ao, "$(P)$(IOC_NAME)MX_PRESSURE:SP"){ - field(DESC, "Set Max Pressure Value") - field(DTYP, "stream") - field(OUT, "@PearlPC.proto set_mx $(PORT)") -} - -record(ai, "$(P)$(IOC_NAME)MX_PRESSURE"){ - field(INP, "$(P)$(IOC_NAME)BUFFER2.C CP MS") - field(DESC, "Get Max Pressure") - field(DTYP, "Soft Channel") -} - -record(ao, "$(P)$(IOC_NAME)MN_PRESSURE:SP"){ - field(DESC, "Set Min Pressure Value") - field(DTYP, "stream") - field(OUT, "@PearlPC.proto set_mn $(PORT)") -} - -record(ai, "$(P)$(IOC_NAME)MN_PRESSURE"){ - field(INP, "$(P)$(IOC_NAME)BUFFER2.A CP MS") - field(DESC, "Get Min Pressure") - field(DTYP, "Soft Channel") -} - -record(ao, "$(P)$(IOC_NAME)SP_PRESSURE:SP"){ - field(DESC, "Set Setpoint Pressure Value") - field(DTYP, "stream") - field(OUT, "@PearlPC.proto set_sp $(PORT)") -} - -record(ai, "$(P)$(IOC_NAME)SP_PRESSURE"){ - field(INP, "$(P)$(IOC_NAME)BUFFER2.B CP MS") - field(DESC, "Get Setpoint Pressure") - field(DTYP, "Soft Channel") -} - -record(ao, "$(P)$(IOC_NAME)SF_PRESSURE:SP"){ - field(DESC, "Set Seal Fail Pressure Value") - field(DTYP, "stream") - field(OUT, "@PearlPC.proto set_sf $(PORT)") -} - -record(ai, "$(P)$(IOC_NAME)SF_PRESSURE"){ - field(INP, "$(P)$(IOC_NAME)BUFFER1.I CP MS") - field(DESC, "Get Seal Fail Pressure") - field(DTYP, "Soft Channel") -} - record(ao, "$(P)$(IOC_NAME)SI_PRESSURE:SP"){ field(DESC, "Set initial ID prefix") field(DTYP, "stream") @@ -116,27 +56,15 @@ record(stringin, "$(P)$(IOC_NAME)ID_PRESSURE") { field(SCAN, "1 second") } -record(ao, "$(P)$(IOC_NAME)SL_PRESSURE:SP"){ - field(DESC, "Set toggle for loop pressure mode") - field(DTYP, "stream") - field(OUT, "@PearlPC.proto set_sloop $(PORT)") -} - -record(ai, "$(P)$(IOC_NAME)SL_PRESSURE"){ - field(INP, "$(P)$(IOC_NAME)BUFFER1.H CP MS") - field(DESC, "Get loop pressure mode") - field(DTYP, "Soft Channel") -} - -record(ao, "$(P)$(IOC_NAME)BY_PRESSURE:SP") { - field(DESC, "Set Busy bit if busy or not") +record(ao, "$(P)$(IOC_NAME)EM_PRESSURE:SP") { + field(DESC, "EM stop circuit status") field(DTYP, "stream") - field(OUT, "@PearlPC.proto set_by $(PORT)") + field(OUT, "@PearlPC.proto set_EM $(PORT)") } -record(ai, "$(P)$(IOC_NAME)BY_PRESSURE"){ - field(INP, "$(P)$(IOC_NAME)BUFFER1.E CP MS") - field(DESC, "Get Busy bit if busy or not") +record(ai, "$(P)$(IOC_NAME)EM_PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER1.A CP MS") + field(DESC, "EM stop circuit status") field(DTYP, "Soft Channel") } @@ -176,27 +104,27 @@ record(ai, "$(P)$(IOC_NAME)St_PRESSURE"){ field(DTYP, "Soft Channel") } -record(ao, "$(P)$(IOC_NAME)EM_PRESSURE:SP") { - field(DESC, "EM stop circuit status") +record(ao, "$(P)$(IOC_NAME)BY_PRESSURE:SP") { + field(DESC, "Set Busy bit if busy or not") field(DTYP, "stream") - field(OUT, "@PearlPC.proto set_EM $(PORT)") + field(OUT, "@PearlPC.proto set_by $(PORT)") } -record(ai, "$(P)$(IOC_NAME)EM_PRESSURE"){ - field(INP, "$(P)$(IOC_NAME)BUFFER1.A CP MS") - field(DESC, "EM stop circuit status") +record(ai, "$(P)$(IOC_NAME)BY_PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER1.E CP MS") + field(DESC, "Get Busy bit if busy or not") field(DTYP, "Soft Channel") } -record(ao, "$(P)$(IOC_NAME)ER_PRESSURE:SP") { - field(DESC, "Last Error Code returned") +record(ao, "$(P)$(IOC_NAME)GO_PRESSURE:SP") { + field(DESC, "Set system initiated by host status") field(DTYP, "stream") - field(OUT, "@PearlPC.proto set_ER $(PORT)") + field(OUT, "@PearlPC.proto set_GO $(PORT)") } -record(ai, "$(P)$(IOC_NAME)ER_PRESSURE"){ - field(INP, "$(P)$(IOC_NAME)BUFFER1.J CP MS") - field(DESC, "Last Error Code returned") +record(ai, "$(P)$(IOC_NAME)GO_PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER1.F CP MS") + field(DESC, "Get system initiated by host status") field(DTYP, "Soft Channel") } @@ -212,14 +140,86 @@ record(ai, "$(P)$(IOC_NAME)AM_PRESSURE"){ field(DTYP, "Soft Channel") } -record(ao, "$(P)$(IOC_NAME)GO_PRESSURE:SP") { - field(DESC, "Set system initiated by host status") +record(ao, "$(P)$(IOC_NAME)SL_PRESSURE:SP"){ + field(DESC, "Set toggle for loop pressure mode") field(DTYP, "stream") - field(OUT, "@PearlPC.proto set_GO $(PORT)") + field(OUT, "@PearlPC.proto set_sloop $(PORT)") } -record(ai, "$(P)$(IOC_NAME)GO_PRESSURE"){ - field(INP, "$(P)$(IOC_NAME)BUFFER1.F CP MS") - field(DESC, "Get system initiated by host status") +record(ai, "$(P)$(IOC_NAME)SL_PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER1.H CP MS") + field(DESC, "Get loop pressure mode") + field(DTYP, "Soft Channel") +} + +record(ao, "$(P)$(IOC_NAME)SF_PRESSURE:SP"){ + field(DESC, "Set Seal Fail Pressure Value") + field(DTYP, "stream") + field(OUT, "@PearlPC.proto set_sf $(PORT)") +} + +record(ai, "$(P)$(IOC_NAME)SF_PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER1.I CP MS") + field(DESC, "Get Seal Fail Pressure") + field(DTYP, "Soft Channel") +} + +record(ao, "$(P)$(IOC_NAME)ER_PRESSURE:SP") { + field(DESC, "Last Error Code returned") + field(DTYP, "stream") + field(OUT, "@PearlPC.proto set_ER $(PORT)") +} + +record(ai, "$(P)$(IOC_NAME)ER_PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER1.J CP MS") + field(DESC, "Last Error Code returned") + field(DTYP, "Soft Channel") +} + +record(ao, "$(P)$(IOC_NAME)PRESSURE:SP"){ + field(DESC, "Set Pressure") + field(DTYP, "stream") + field(OUT, "@PearlPC.proto set_ra $(PORT)") +} + +record(ai, "$(P)$(IOC_NAME)PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER1.K CP MS") + field(DESC, "Get Pressure") + field(DTYP, "Soft Channel") +} + +record(ao, "$(P)$(IOC_NAME)MN_PRESSURE:SP"){ + field(DESC, "Set Min Pressure Value") + field(DTYP, "stream") + field(OUT, "@PearlPC.proto set_mn $(PORT)") +} + +record(ai, "$(P)$(IOC_NAME)MN_PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER2.A CP MS") + field(DESC, "Get Min Pressure") + field(DTYP, "Soft Channel") +} + +record(ao, "$(P)$(IOC_NAME)SP_PRESSURE:SP"){ + field(DESC, "Set Setpoint Pressure Value") + field(DTYP, "stream") + field(OUT, "@PearlPC.proto set_sp $(PORT)") +} + +record(ai, "$(P)$(IOC_NAME)SP_PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER2.B CP MS") + field(DESC, "Get Setpoint Pressure") + field(DTYP, "Soft Channel") +} + +record(ao, "$(P)$(IOC_NAME)MX_PRESSURE:SP"){ + field(DESC, "Set Max Pressure Value") + field(DTYP, "stream") + field(OUT, "@PearlPC.proto set_mx $(PORT)") +} + +record(ai, "$(P)$(IOC_NAME)MX_PRESSURE"){ + field(INP, "$(P)$(IOC_NAME)BUFFER2.C CP MS") + field(DESC, "Get Max Pressure") field(DTYP, "Soft Channel") } diff --git a/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py b/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py index ed68b75..390d2fd 100644 --- a/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py +++ b/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py @@ -39,16 +39,13 @@ def __init__(self, status_dictionary=None): status_dictionary = {} self.status_dictionary = status_dictionary - def set_ra(self, pressure_rate): + def add_to_dict(self, value_id: str, unvalidated_value: object): """ - Set rate of pressure application in Bar/min - A value of 0000 will be used to represent maximum slew rate of the motor. - Normally set to 0010 - @param pressure_rate: (int) Pressure rate within range [0001-0040] + Add device state parameters to a dictionary. + @param value_id: (str) dictionary key for each device parameter + @param unvalidated_value: (object) device parameter set to describe system status """ - print(f"Pressure Rate Received: {pressure_rate}") - self._device.pressure_rate = pressure_rate - self.add_to_dict(value_id="ra", unvalidated_value=self._device.pressure_rate) + self.status_dictionary[value_id] = unvalidated_value def get_st(self): """ @@ -71,45 +68,13 @@ def get_st(self): f"{self._device.max_value_pre_servoing} " \ f"0" - def set_mx(self, max_measured: int): - """ - set the maximum measured value before re-servoing - @param max_measured: (integer) maximum measured value before re-servoing - range [0001-9999] - """ - print(f"Maximum measured value before re-servoing received: {max_measured}") - self._device.max_value_pre_servoing = max_measured - self.add_to_dict(value_id="mx", unvalidated_value=self._device.max_value_pre_servoing) - - def set_mn(self, min_measured: int): - """ - Set the minimum value before re-servoing. - This will only be acted upon in closed loop mode. - @param min_measured: (int) minimum pressure value before re-servoing - range [0001-9999] - """ - print(f"Minimum value before re-servoing received: {min_measured}") - self._device.min_value_pre_servoing = min_measured - self.add_to_dict(value_id="mn", unvalidated_value=self._device.min_value_pre_servoing) - - def set_sp(self, setpoint: int): - """ - Set a setpoint to be initially reached if the measured pressure exceeds maximum value (mx) - or falls below minimum value (mn) and the servo loop is closed. - The motor will operate until the pressure is restored to the setpoint value - @param setpoint: (int) Set Point trigger value - range [0001-1000] - """ - print(f"Setpoint value received: {setpoint}") - self._device.setpoint_value = setpoint - self.add_to_dict(value_id="sp", unvalidated_value=self._device.setpoint_value) - - def set_sf(self, seal_fail_value: int): + def get_id_prefix(self): """ - Set Seal Fail drop value. - Sets the pressure drop required to trigger Seal Fail mode. - @param seal_fail_value: (int) Seal Fail Mode Trigger Value - range [0001-0999] + Returns ID prefixes (first 2 numbers selectable by the user formatted as: " ") + @return: (str) formatted string returning ID prefixes set by default or by user. """ - print(f"Seal Fail mode trigger value received: {seal_fail_value}") - self._device.seal_fail_value = seal_fail_value - self.add_to_dict(value_id="sf", unvalidated_value=self._device.seal_fail_value) + print(f"ID prefix set to: {self._device.initial_id_prefix} {self._device.secondary_id_prefix}") + return f"{self._device.initial_id_prefix} {self._device.secondary_id_prefix}" def set_si(self, id_prefix: int): """ @@ -120,7 +85,7 @@ def set_si(self, id_prefix: int): print(f"ID prefix value received: {id_prefix}") self._device.initial_id_prefix = id_prefix self.add_to_dict(value_id="si", unvalidated_value=self._device.initial_id_prefix) - + def set_sd(self, secondary_id_prefix: int): """ Set Secondary ID Prefix. ID should form a unique number for each unit. @@ -132,46 +97,15 @@ def set_sd(self, secondary_id_prefix: int): self._device.secondary_id_prefix = secondary_id_prefix self.add_to_dict(value_id="sd", unvalidated_value=self._device.secondary_id_prefix) - def set_sloop(self, sloop: int): - """ - Represents binary bit to set loop mode - 0 = open loop mode - 1 = close loop mode - Open loop mode ramps to pressure in control system and then stop until anther command is sent. - Close loop mode will ramp to setpoint pressure value and remain active monitoring delivered pressure, - acting on mn and mx pressure values. - @param sloop: (int) integer value setting system to open or closed loop - range [0-1] - """ - - print(f"sloop value recieved: {sloop}") - self._device.loop_mode = sloop - self.add_to_dict(value_id="sloop", unvalidated_value=self._device.loop_mode) - - def add_to_dict(self, value_id: str, unvalidated_value: object): - """ - Add device state parameters to a dictionary. - @param value_id: (str) dictionary key for each device parameter - @param unvalidated_value: (object) device parameter set to describe system status - """ - self.status_dictionary[value_id] = unvalidated_value - - def get_id_prefix(self): - """ - Returns ID prefixes (first 2 numbers selectable by the user formatted as: " ") - @return: (str) formatted string returning ID prefixes set by default or by user. - """ - print(f"ID prefix set to: {self._device.initial_id_prefix} {self._device.secondary_id_prefix}") - return f"{self._device.initial_id_prefix} {self._device.secondary_id_prefix}" - - def set_by(self, busy_bit: int): + def set_em_stop_status(self, em_stop_status: int): """ - Set the busy bit status - 1 denotes that the device is busy and 0 not busy - @type busy_bit: (int) integer representing if device is mechanically active - range [0-1] + Set emergency stop circuit status. + 1 denotes that the system has stopped. 0 denotes the system is running + @param em_stop_status: (int) Device status value for requesting emergency stop circuit - range [0-1] """ - print(f"Received busy bit {busy_bit}") - self._device.busy_bit = busy_bit - self.add_to_dict(value_id="by", unvalidated_value=self._device.busy_bit) + print(f"Received EM stop circuit status: {em_stop_status}") + self._device.em_stop_status = em_stop_status + self.add_to_dict(value_id="EM", unvalidated_value=self._device.em_stop_status) def set_ru(self, run_bit: int): """ @@ -191,7 +125,7 @@ def set_re(self, reset_value: int): print(f"Received reset value: {reset_value}") self._device.reset_value = reset_value self.add_to_dict(value_id="re", unvalidated_value=self._device.reset_value) - + def set_stop_bit(self, stop_bit: int): """ Set the stop bit to 1 or 0 where 1 requests the system to stop. This value is @@ -202,16 +136,59 @@ def set_stop_bit(self, stop_bit: int): self._device.stop_bit = stop_bit self.add_to_dict(value_id="St", unvalidated_value=self._device.stop_bit) - def set_em_stop_status(self, em_stop_status: int): + def set_by(self, busy_bit: int): """ - Set emergency stop circuit status. - 1 denotes that the system has stopped. 0 denotes the system is running - @param em_stop_status: (int) Device status value for requesting emergency stop circuit - range [0-1] + Set the busy bit status + 1 denotes that the device is busy and 0 not busy + @type busy_bit: (int) integer representing if device is mechanically active - range [0-1] """ + print(f"Received busy bit {busy_bit}") + self._device.busy_bit = busy_bit + self.add_to_dict(value_id="by", unvalidated_value=self._device.busy_bit) - print(f"Received EM stop circuit status: {em_stop_status}") - self._device.em_stop_status = em_stop_status - self.add_to_dict(value_id="EM", unvalidated_value=self._device.em_stop_status) + def set_go(self, go_status: int): + """ + Set GO status to to 1 if system was initiated by host. + 1 - set by host + 0 - not set by host + @param go_status (int) set if command initiated by host - range [0-1] + """ + print(f"Received GO status: {go_status}") + self._device.go_status = go_status + self.add_to_dict(value_id="GO", unvalidated_value=self._device.go_status) + + def set_am(self, am_mode: int): + """ + Set AM auto/manual switch position mode + @param am_mode: (int) Set Auto/manual switch position - range [0-1] + """ + print(f"Received last AM modeL: {am_mode}") + self._device.am_mode = am_mode + self.add_to_dict(value_id="AM", unvalidated_value=self._device.am_mode) + + def set_sloop(self, sloop: int): + """ + Represents binary bit to set loop mode + 0 = open loop mode + 1 = close loop mode + Open loop mode ramps to pressure in control system and then stop until anther command is sent. + Close loop mode will ramp to setpoint pressure value and remain active monitoring delivered pressure, + acting on mn and mx pressure values. + @param sloop: (int) integer value setting system to open or closed loop - range [0-1] + """ + print(f"sloop value recieved: {sloop}") + self._device.loop_mode = sloop + self.add_to_dict(value_id="sloop", unvalidated_value=self._device.loop_mode) + + def set_sf(self, seal_fail_value: int): + """ + Set Seal Fail drop value. + Sets the pressure drop required to trigger Seal Fail mode. + @param seal_fail_value: (int) Seal Fail Mode Trigger Value - range [0001-0999] + """ + print(f"Seal Fail mode trigger value received: {seal_fail_value}") + self._device.seal_fail_value = seal_fail_value + self.add_to_dict(value_id="sf", unvalidated_value=self._device.seal_fail_value) def set_er(self, last_error_code: int): """ @@ -222,25 +199,46 @@ def set_er(self, last_error_code: int): self._device.last_error_code = last_error_code self.add_to_dict(value_id="ER", unvalidated_value=self._device.last_error_code) - def set_am(self, am_mode: int): + def set_ra(self, pressure_rate): """ - Set AM auto/manual switch position mode - @param am_mode: (int) Set Auto/manual switch position - range [0-1] + Set rate of pressure application in Bar/min + A value of 0000 will be used to represent maximum slew rate of the motor. + Normally set to 0010 + @param pressure_rate: (int) Pressure rate within range [0001-0040] """ - print(f"Received last AM modeL: {am_mode}") - self._device.am_mode = am_mode - self.add_to_dict(value_id="AM", unvalidated_value=self._device.am_mode) + print(f"Pressure Rate Received: {pressure_rate}") + self._device.pressure_rate = pressure_rate + self.add_to_dict(value_id="ra", unvalidated_value=self._device.pressure_rate) - def set_go(self, go_status: int): + def set_mn(self, min_measured: int): """ - Set GO status to to 1 if system was initiated by host. - 1 - set by host - 0 - not set by host - @param go_status (int) set if command initiated by host - range [0-1] + Set the minimum value before re-servoing. + This will only be acted upon in closed loop mode. + @param min_measured: (int) minimum pressure value before re-servoing - range [0001-9999] """ - print(f"Received GO status: {go_status}") - self._device.go_status = go_status - self.add_to_dict(value_id="GO", unvalidated_value=self._device.go_status) + print(f"Minimum value before re-servoing received: {min_measured}") + self._device.min_value_pre_servoing = min_measured + self.add_to_dict(value_id="mn", unvalidated_value=self._device.min_value_pre_servoing) + + def set_sp(self, setpoint: int): + """ + Set a setpoint to be initially reached if the measured pressure exceeds maximum value (mx) + or falls below minimum value (mn) and the servo loop is closed. + The motor will operate until the pressure is restored to the setpoint value + @param setpoint: (int) Set Point trigger value - range [0001-1000] + """ + print(f"Setpoint value received: {setpoint}") + self._device.setpoint_value = setpoint + self.add_to_dict(value_id="sp", unvalidated_value=self._device.setpoint_value) + + def set_mx(self, max_measured: int): + """ + set the maximum measured value before re-servoing + @param max_measured: (integer) maximum measured value before re-servoing - range [0001-9999] + """ + print(f"Maximum measured value before re-servoing received: {max_measured}") + self._device.max_value_pre_servoing = max_measured + self.add_to_dict(value_id="mx", unvalidated_value=self._device.max_value_pre_servoing) def handle_error(self, request:object, error:object): """ diff --git a/system_tests/tests/pearlpc.py b/system_tests/tests/pearlpc.py index 0d9f36a..0308b61 100644 --- a/system_tests/tests/pearlpc.py +++ b/system_tests/tests/pearlpc.py @@ -33,41 +33,10 @@ def setUp(self): self.pressure_value = 1000 self.set_loop_status = 1 self.default_initial_value = 0 - self.default_id_prefix = 0 + self.default_id_prefix = 1111 self.lewis, self.ioc = get_running_lewis_and_ioc(DEVICE_A_PREFIX, DEVICE_A_PREFIX) self.ca = ChannelAccess(default_timeout=20, default_wait_time=0.0, device_prefix=DEVICE_A_PREFIX) - def test_WHEN_max_pressure_set_THEN_max_pressure_set_correctly(self): - self.ca.assert_that_pv_is("BUFFER2.C", self.default_initial_value) - self.ca.set_pv_value("MX_PRESSURE:SP", self.pressure_value) - self.ca.assert_that_pv_is("MX_PRESSURE:SP", self.pressure_value) - self.ca.assert_that_pv_is("BUFFER2.C", self.pressure_value) - # self.ca.assert_setting_setpoint_sets_readback(self.pressure_value, "MX_PRESSURE") - - def test_WHEN_pressure_set_THEN_pressure_read_back_correctly(self): - self.ca.assert_that_pv_is("BUFFER1.K", self.default_initial_value) - self.ca.set_pv_value("PRESSURE:SP", self.pressure_value) - self.ca.assert_that_pv_is("PRESSURE:SP", self.pressure_value) - self.ca.assert_that_pv_is("BUFFER1.K", self.pressure_value) - - def test_WHEN_min_pressure_set_THEN_min_pressure_read_back_correctly(self): - self.ca.assert_that_pv_is("BUFFER2.A", self.default_id_prefix) - self.ca.set_pv_value("MN_PRESSURE:SP", self.pressure_value) - self.ca.assert_that_pv_is("MN_PRESSURE:SP", self.pressure_value) - self.ca.assert_that_pv_is("BUFFER2.A", self.pressure_value) - - def test_WHEN_setpoint_pressure_set_THEN_setpoint_pressure_read_back_correctly(self): - self.ca.assert_that_pv_is("BUFFER2.B", self.default_id_prefix) - self.ca.set_pv_value("SP_PRESSURE:SP", self.pressure_value) - self.ca.assert_that_pv_is("SP_PRESSURE:SP", self.pressure_value) - self.ca.assert_that_pv_is("BUFFER2.B", self.pressure_value) - - def test_WHEN_Seal_Fail_pressure_set_THEN_Seal_Fail_pressure_read_back_correctly(self): - self.ca.assert_that_pv_is("BUFFER1.I", self.default_id_prefix) - self.ca.set_pv_value("SF_PRESSURE:SP", self.pressure_value) - self.ca.assert_that_pv_is("SF_PRESSURE:SP", self.pressure_value) - self.ca.assert_that_pv_is("BUFFER1.I", self.pressure_value) - def test_WHEN_initial_ID_prefix_set_THEN_initial_ID_prefix_read_back_correctly(self): self.ca.set_pv_value("SI_PRESSURE:SP", self.pressure_value) self.ca.assert_that_pv_is("SI_PRESSURE:SP", self.pressure_value) @@ -83,19 +52,13 @@ def test_WHEN_id_prefixes_set_THEN_id_prefixes_read_back_correctly(self): self.ca.set_pv_value("SI_PRESSURE:SP", self.pressure_value) self.ca.set_pv_value("SD_PRESSURE:SP", self.pressure_value) self.ca.assert_that_pv_is("ID_PRESSURE", f"{self.pressure_value} {self.pressure_value}") - - def test_WHEN_loop_mode_set_THEN_loop_mode_read_back_correctly(self): - self.ca.assert_that_pv_is("BUFFER1.H", self.default_initial_value) - self.ca.set_pv_value("SL_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("SL_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("BUFFER1.H", self.set_loop_status) - - def test_WHEN_busy_bit_set_THEN_busy_bit_read_back_correctly(self): - self.ca.assert_that_pv_is("BUFFER1.E", self.default_initial_value) - self.ca.set_pv_value("BY_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("BY_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("BUFFER1.E", self.set_loop_status) - + + def test_WHEN_em_stop_bit_set_THEN_em_stop_bit_value_read_back_correctly(self): + self.ca.assert_that_pv_is("BUFFER1.A", self.default_initial_value) + self.ca.set_pv_value("EM_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("EM_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("BUFFER1.A", self.set_loop_status) + def test_WHEN_run_bit_set_THEN_run_bit_read_back_correctly(self): self.ca.assert_that_pv_is("BUFFER1.B", self.default_initial_value) self.ca.set_pv_value("RU_PRESSURE:SP", self.set_loop_status) @@ -114,17 +77,17 @@ def test_WHEN_stop_bit_set_THEN_stop_bit_value_read_back_correctly(self): self.ca.assert_that_pv_is("St_PRESSURE:SP", self.set_loop_status) self.ca.assert_that_pv_is("BUFFER1.D", self.set_loop_status) - def test_WHEN_em_stop_bit_set_THEN_em_stop_bit_value_read_back_correctly(self): - self.ca.assert_that_pv_is("BUFFER1.A", self.default_initial_value) - self.ca.set_pv_value("EM_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("EM_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("BUFFER1.A", self.set_loop_status) + def test_WHEN_busy_bit_set_THEN_busy_bit_read_back_correctly(self): + self.ca.assert_that_pv_is("BUFFER1.E", self.default_initial_value) + self.ca.set_pv_value("BY_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("BY_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("BUFFER1.E", self.set_loop_status) - def test_WHEN_er_last_error_code_set_THEN_er_last_error_code_read_back_correctly(self): - self.ca.assert_that_pv_is("BUFFER1.J", self.default_initial_value) - self.ca.set_pv_value("ER_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("ER_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("BUFFER1.J", self.set_loop_status) + def test_WHEN_GO_status_set_THEN_GO_status_read_back_correctly(self): + self.ca.assert_that_pv_is("BUFFER1.F", self.default_initial_value) + self.ca.set_pv_value("GO_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("GO_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("BUFFER1.F", self.set_loop_status) def test_WHEN_AM_mode_set_THEN_AM_mode_read_back_correctly(self): self.ca.assert_that_pv_is("BUFFER1.G", self.default_initial_value) @@ -132,11 +95,48 @@ def test_WHEN_AM_mode_set_THEN_AM_mode_read_back_correctly(self): self.ca.assert_that_pv_is("AM_PRESSURE:SP", self.set_loop_status) self.ca.assert_that_pv_is("BUFFER1.G", self.set_loop_status) - def test_WHEN_GO_status_set_THEN_GO_status_read_back_correctly(self): - self.ca.assert_that_pv_is("BUFFER1.F", self.default_initial_value) - self.ca.set_pv_value("GO_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("GO_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("BUFFER1.F", self.set_loop_status) + def test_WHEN_loop_mode_set_THEN_loop_mode_read_back_correctly(self): + self.ca.assert_that_pv_is("BUFFER1.H", self.default_initial_value) + self.ca.set_pv_value("SL_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("SL_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("BUFFER1.H", self.set_loop_status) + + def test_WHEN_Seal_Fail_pressure_set_THEN_Seal_Fail_pressure_read_back_correctly(self): + self.ca.assert_that_pv_is("BUFFER1.I", self.default_initial_value) + self.ca.set_pv_value("SF_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("SF_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("BUFFER1.I", self.pressure_value) + + def test_WHEN_er_last_error_code_set_THEN_er_last_error_code_read_back_correctly(self): + self.ca.assert_that_pv_is("BUFFER1.J", self.default_initial_value) + self.ca.set_pv_value("ER_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("ER_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("BUFFER1.J", self.set_loop_status) + + def test_WHEN_pressure_set_THEN_pressure_read_back_correctly(self): + self.ca.assert_that_pv_is("BUFFER1.K", self.default_initial_value) + self.ca.set_pv_value("PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("BUFFER1.K", self.pressure_value) + + def test_WHEN_min_pressure_set_THEN_min_pressure_read_back_correctly(self): + self.ca.assert_that_pv_is("BUFFER2.A", self.default_initial_value) + self.ca.set_pv_value("MN_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("MN_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("BUFFER2.A", self.pressure_value) + + def test_WHEN_setpoint_pressure_set_THEN_setpoint_pressure_read_back_correctly(self): + self.ca.assert_that_pv_is("BUFFER2.B", self.default_initial_value) + self.ca.set_pv_value("SP_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("SP_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("BUFFER2.B", self.pressure_value) + + def test_WHEN_max_pressure_set_THEN_max_pressure_set_correctly(self): + self.ca.assert_that_pv_is("BUFFER2.C", self.default_initial_value) + self.ca.set_pv_value("MX_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("MX_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("BUFFER2.C", self.pressure_value) + # self.ca.assert_setting_setpoint_sets_readback(self.pressure_value, "MX_PRESSURE") # def test_WHEN_buffer_values_set_THEN_buffer_read_back_correctly_updated(self): # self.ca.set_pv_value("GO_PRESSURE:SP", self.set_loop_status) From a1d2c51d6a4c9bde2965895cd4a2d23b403f9b74 Mon Sep 17 00:00:00 2001 From: JackEAllen Date: Wed, 11 Aug 2021 16:25:10 +0100 Subject: [PATCH 04/12] Update EPICS records and tests to reflect record changes --- PearlPCSup/devPearl.db | 28 +++++++++---------- .../PearlPC/interfaces/stream_interface.py | 2 +- system_tests/tests/pearlpc.py | 14 +++++----- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/PearlPCSup/devPearl.db b/PearlPCSup/devPearl.db index b01aa8c..fc09c9f 100644 --- a/PearlPCSup/devPearl.db +++ b/PearlPCSup/devPearl.db @@ -56,25 +56,25 @@ record(stringin, "$(P)$(IOC_NAME)ID_PRESSURE") { field(SCAN, "1 second") } -record(ao, "$(P)$(IOC_NAME)EM_PRESSURE:SP") { +record(bo, "$(P)$(IOC_NAME)EM_PRESSURE:SP") { field(DESC, "EM stop circuit status") field(DTYP, "stream") field(OUT, "@PearlPC.proto set_EM $(PORT)") } -record(ai, "$(P)$(IOC_NAME)EM_PRESSURE"){ +record(bi, "$(P)$(IOC_NAME)EM_PRESSURE"){ field(INP, "$(P)$(IOC_NAME)BUFFER1.A CP MS") field(DESC, "EM stop circuit status") field(DTYP, "Soft Channel") } -record(ao, "$(P)$(IOC_NAME)RU_PRESSURE:SP") { +record(bo, "$(P)$(IOC_NAME)RU_PRESSURE:SP") { field(DESC, "Set Mechanically active status") field(DTYP, "stream") field(OUT, "@PearlPC.proto set_ru $(PORT)") } -record(ai, "$(P)$(IOC_NAME)RU_PRESSURE"){ +record(bi, "$(P)$(IOC_NAME)RU_PRESSURE"){ field(INP, "$(P)$(IOC_NAME)BUFFER1.B CP MS") field(DESC, "Get Mechanically active status") field(DTYP, "Soft Channel") @@ -92,61 +92,61 @@ record(ai, "$(P)$(IOC_NAME)RE_PRESSURE"){ field(DTYP, "Soft Channel") } -record(ao, "$(P)$(IOC_NAME)St_PRESSURE:SP") { +record(bo, "$(P)$(IOC_NAME)St_PRESSURE:SP") { field(DESC, "Stop bit after each move/manually") field(DTYP, "stream") field(OUT, "@PearlPC.proto set_St $(PORT)") } -record(ai, "$(P)$(IOC_NAME)St_PRESSURE"){ +record(bi, "$(P)$(IOC_NAME)St_PRESSURE"){ field(INP, "$(P)$(IOC_NAME)BUFFER1.D CP MS") field(DESC, "Stop bit after each move/manually") field(DTYP, "Soft Channel") } -record(ao, "$(P)$(IOC_NAME)BY_PRESSURE:SP") { +record(bo, "$(P)$(IOC_NAME)BY_PRESSURE:SP") { field(DESC, "Set Busy bit if busy or not") field(DTYP, "stream") field(OUT, "@PearlPC.proto set_by $(PORT)") } -record(ai, "$(P)$(IOC_NAME)BY_PRESSURE"){ +record(bi, "$(P)$(IOC_NAME)BY_PRESSURE"){ field(INP, "$(P)$(IOC_NAME)BUFFER1.E CP MS") field(DESC, "Get Busy bit if busy or not") field(DTYP, "Soft Channel") } -record(ao, "$(P)$(IOC_NAME)GO_PRESSURE:SP") { +record(bo, "$(P)$(IOC_NAME)GO_PRESSURE:SP") { field(DESC, "Set system initiated by host status") field(DTYP, "stream") field(OUT, "@PearlPC.proto set_GO $(PORT)") } -record(ai, "$(P)$(IOC_NAME)GO_PRESSURE"){ +record(bi, "$(P)$(IOC_NAME)GO_PRESSURE"){ field(INP, "$(P)$(IOC_NAME)BUFFER1.F CP MS") field(DESC, "Get system initiated by host status") field(DTYP, "Soft Channel") } -record(ao, "$(P)$(IOC_NAME)AM_PRESSURE:SP") { +record(bo, "$(P)$(IOC_NAME)AM_PRESSURE:SP") { field(DESC, "Sets auto/manual switch position") field(DTYP, "stream") field(OUT, "@PearlPC.proto set_AM $(PORT)") } -record(ai, "$(P)$(IOC_NAME)AM_PRESSURE"){ +record(bi, "$(P)$(IOC_NAME)AM_PRESSURE"){ field(INP, "$(P)$(IOC_NAME)BUFFER1.G CP MS") field(DESC, "Gets auto/manual switch position") field(DTYP, "Soft Channel") } -record(ao, "$(P)$(IOC_NAME)SL_PRESSURE:SP"){ +record(bo, "$(P)$(IOC_NAME)SL_PRESSURE:SP"){ field(DESC, "Set toggle for loop pressure mode") field(DTYP, "stream") field(OUT, "@PearlPC.proto set_sloop $(PORT)") } -record(ai, "$(P)$(IOC_NAME)SL_PRESSURE"){ +record(bi, "$(P)$(IOC_NAME)SL_PRESSURE"){ field(INP, "$(P)$(IOC_NAME)BUFFER1.H CP MS") field(DESC, "Get loop pressure mode") field(DTYP, "Soft Channel") diff --git a/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py b/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py index 390d2fd..ce2d1e2 100644 --- a/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py +++ b/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py @@ -14,7 +14,7 @@ class PearlPCStreamInterface(StreamInterface): CmdBuilder("set_si").escape("si").arg("[0-9]{4}").eos().build(), CmdBuilder("set_sd").escape("sd").arg("[0-9]{4}").eos().build(), # Device Set commands - CmdBuilder("set_em_stop_status").escape("Em").arg("[0-1]{1}").eos().build(), + CmdBuilder("set_em_stop_status").escape("Em").arg("[0-1]").eos().build(), CmdBuilder("set_ru").escape("Ru").arg("[0-1]{1}").eos().build(), CmdBuilder("set_re").escape("Re").arg("[0-4]{1}").eos().build(), CmdBuilder("set_stop_bit").escape("St").arg("[0-1]{1}").eos().build(), diff --git a/system_tests/tests/pearlpc.py b/system_tests/tests/pearlpc.py index 0308b61..a4a9525 100644 --- a/system_tests/tests/pearlpc.py +++ b/system_tests/tests/pearlpc.py @@ -56,13 +56,13 @@ def test_WHEN_id_prefixes_set_THEN_id_prefixes_read_back_correctly(self): def test_WHEN_em_stop_bit_set_THEN_em_stop_bit_value_read_back_correctly(self): self.ca.assert_that_pv_is("BUFFER1.A", self.default_initial_value) self.ca.set_pv_value("EM_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("EM_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("EM_PRESSURE:SP.RVAL", self.set_loop_status) self.ca.assert_that_pv_is("BUFFER1.A", self.set_loop_status) def test_WHEN_run_bit_set_THEN_run_bit_read_back_correctly(self): self.ca.assert_that_pv_is("BUFFER1.B", self.default_initial_value) self.ca.set_pv_value("RU_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("RU_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("RU_PRESSURE:SP.RVAL", self.set_loop_status) self.ca.assert_that_pv_is("BUFFER1.B", self.set_loop_status) def test_WHEN_reset_value_set_THEN_reset_value_read_back_correctly(self): @@ -74,31 +74,31 @@ def test_WHEN_reset_value_set_THEN_reset_value_read_back_correctly(self): def test_WHEN_stop_bit_set_THEN_stop_bit_value_read_back_correctly(self): self.ca.assert_that_pv_is("BUFFER1.D", self.default_initial_value) self.ca.set_pv_value("St_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("St_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("St_PRESSURE:SP.RVAL", self.set_loop_status) self.ca.assert_that_pv_is("BUFFER1.D", self.set_loop_status) def test_WHEN_busy_bit_set_THEN_busy_bit_read_back_correctly(self): self.ca.assert_that_pv_is("BUFFER1.E", self.default_initial_value) self.ca.set_pv_value("BY_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("BY_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("BY_PRESSURE:SP.RVAL", self.set_loop_status) self.ca.assert_that_pv_is("BUFFER1.E", self.set_loop_status) def test_WHEN_GO_status_set_THEN_GO_status_read_back_correctly(self): self.ca.assert_that_pv_is("BUFFER1.F", self.default_initial_value) self.ca.set_pv_value("GO_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("GO_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("GO_PRESSURE:SP.RVAL", self.set_loop_status) self.ca.assert_that_pv_is("BUFFER1.F", self.set_loop_status) def test_WHEN_AM_mode_set_THEN_AM_mode_read_back_correctly(self): self.ca.assert_that_pv_is("BUFFER1.G", self.default_initial_value) self.ca.set_pv_value("AM_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("AM_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("AM_PRESSURE:SP.RVAL", self.set_loop_status) self.ca.assert_that_pv_is("BUFFER1.G", self.set_loop_status) def test_WHEN_loop_mode_set_THEN_loop_mode_read_back_correctly(self): self.ca.assert_that_pv_is("BUFFER1.H", self.default_initial_value) self.ca.set_pv_value("SL_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("SL_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("SL_PRESSURE:SP.RVAL", self.set_loop_status) self.ca.assert_that_pv_is("BUFFER1.H", self.set_loop_status) def test_WHEN_Seal_Fail_pressure_set_THEN_Seal_Fail_pressure_read_back_correctly(self): From 9c51a1c24059a03631f005774482d4c0bfbc05a4 Mon Sep 17 00:00:00 2001 From: JackEAllen Date: Wed, 25 Aug 2021 16:00:18 +0100 Subject: [PATCH 05/12] Create Pressure Increase Decrease DB logic --- PearlPCSup/PearlPC.proto | 9 ++ PearlPCSup/devPearl.db | 100 ++++++++++++++++-- .../lewis_emulators/PearlPC/device.py | 5 +- .../PearlPC/interfaces/stream_interface.py | 19 +++- ...ilLoadTestsuiteTestCase-20210804115226.xml | 64 ----------- ...ts.pearlpc.PEARLPCTests-20210726153045.xml | 4 - ...ts.pearlpc.PEARLPCTests-20210726153138.xml | 4 - ...ts.pearlpc.PEARLPCTests-20210726154011.xml | 4 - ...ts.pearlpc.PEARLPCTests-20210726154436.xml | 4 - ...ts.pearlpc.PEARLPCTests-20210726155211.xml | 4 - ...ts.pearlpc.PEARLPCTests-20210726155957.xml | 4 - ...ts.pearlpc.PEARLPCTests-20210726161117.xml | 18 ---- ...ts.pearlpc.PEARLPCTests-20210726161813.xml | 20 ---- ...ts.pearlpc.PEARLPCTests-20210726162431.xml | 4 - ...ts.pearlpc.PEARLPCTests-20210727152353.xml | 33 ------ ...ts.pearlpc.PEARLPCTests-20210727153648.xml | 5 - ...ts.pearlpc.PEARLPCTests-20210728091312.xml | 11 -- ...ts.pearlpc.PEARLPCTests-20210728091856.xml | 17 --- ...ts.pearlpc.PEARLPCTests-20210728092544.xml | 17 --- ...ts.pearlpc.PEARLPCTests-20210728092650.xml | 11 -- ...ts.pearlpc.PEARLPCTests-20210728092730.xml | 11 -- ...ts.pearlpc.PEARLPCTests-20210728092854.xml | 4 - system_tests/tests/pearlpc.py | 7 ++ 23 files changed, 127 insertions(+), 252 deletions(-) delete mode 100644 system_tests/test-reports/TEST-ReportFailLoadTestsuiteTestCase-20210804115226.xml delete mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726153045.xml delete mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726153138.xml delete mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726154011.xml delete mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726154436.xml delete mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726155211.xml delete mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726155957.xml delete mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726161117.xml delete mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726161813.xml delete mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726162431.xml delete mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210727152353.xml delete mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210727153648.xml delete mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728091312.xml delete mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728091856.xml delete mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092544.xml delete mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092650.xml delete mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092730.xml delete mode 100644 system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092854.xml diff --git a/PearlPCSup/PearlPC.proto b/PearlPCSup/PearlPC.proto index 979fabf..949cd72 100644 --- a/PearlPCSup/PearlPC.proto +++ b/PearlPCSup/PearlPC.proto @@ -77,3 +77,12 @@ get_id { out "id"; in "%/[0-9]{4} [0-9]{4}/"; } + +set_reset_status { + out "reset%#01d" +} + +get_piston_status { + out "reset"; + in "%/[0-1]"; +} diff --git a/PearlPCSup/devPearl.db b/PearlPCSup/devPearl.db index fc09c9f..e0aff06 100644 --- a/PearlPCSup/devPearl.db +++ b/PearlPCSup/devPearl.db @@ -33,10 +33,10 @@ record(ao, "$(P)$(IOC_NAME)SI_PRESSURE:SP"){ field(OUT, "@PearlPC.proto set_si $(PORT)") } -record(ai, "$(P)$(IOC_NAME)SI_PRESSURE"){ - field(DESC, "Get initial ID prefix") - field(DTYP, "Soft Channel") -} +# record(ai, "$(P)$(IOC_NAME)SI_PRESSURE"){ +# field(DESC, "Get initial ID prefix") +# field(DTYP, "Soft Channel") +# } record(ao, "$(P)$(IOC_NAME)SD_PRESSURE:SP"){ field(DESC, "Set secondary ID prefix") @@ -44,10 +44,10 @@ record(ao, "$(P)$(IOC_NAME)SD_PRESSURE:SP"){ field(OUT, "@PearlPC.proto set_sd $(PORT)") } -record(ai, "$(P)$(IOC_NAME)SD_PRESSURE"){ - field(DESC, "Get secondary ID prefix") - field(DTYP, "Soft Channel") -} +# record(ai, "$(P)$(IOC_NAME)SD_PRESSURE"){ +# field(DESC, "Get secondary ID prefix") +# field(DTYP, "Soft Channel") +# } record(stringin, "$(P)$(IOC_NAME)ID_PRESSURE") { field(DESC, "Get ID prefix") @@ -72,12 +72,16 @@ record(bo, "$(P)$(IOC_NAME)RU_PRESSURE:SP") { field(DESC, "Set Mechanically active status") field(DTYP, "stream") field(OUT, "@PearlPC.proto set_ru $(PORT)") + field(ZNAM, "Start") + field(ONAM, "Stop") } record(bi, "$(P)$(IOC_NAME)RU_PRESSURE"){ field(INP, "$(P)$(IOC_NAME)BUFFER1.B CP MS") field(DESC, "Get Mechanically active status") field(DTYP, "Soft Channel") + field(ZNAM, "Start") + field(ONAM, "Stop") } record(ao, "$(P)$(IOC_NAME)RE_PRESSURE:SP") { @@ -144,12 +148,16 @@ record(bo, "$(P)$(IOC_NAME)SL_PRESSURE:SP"){ field(DESC, "Set toggle for loop pressure mode") field(DTYP, "stream") field(OUT, "@PearlPC.proto set_sloop $(PORT)") + field(ZNAM, "OFF") + field(ONAM, "ON") } record(bi, "$(P)$(IOC_NAME)SL_PRESSURE"){ field(INP, "$(P)$(IOC_NAME)BUFFER1.H CP MS") field(DESC, "Get loop pressure mode") field(DTYP, "Soft Channel") + field(ZNAM, "OFF") + field(ONAM, "ON") } record(ao, "$(P)$(IOC_NAME)SF_PRESSURE:SP"){ @@ -186,6 +194,66 @@ record(ai, "$(P)$(IOC_NAME)PRESSURE"){ field(INP, "$(P)$(IOC_NAME)BUFFER1.K CP MS") field(DESC, "Get Pressure") field(DTYP, "Soft Channel") + # field(FLNK, "$(P)$(IOC_NAME)PRESSURE_COMPARISON") +} + +record(calc, "$(P)$(IOC_NAME)PRESSURE_COMPARISON"){ + field(SCAN, "1 second") # change to .1 seconds for production? + field(CALC, "A - B; B := A") + # field(LA, "A") + field(INPA, "$(P)$(IOC_NAME)PRESSURE") + # field(INPB, "$(P)$(IOC_NAME)PRESSURE") + field(FLNK, "$(P)$(IOC_NAME)PRESSURE_FANOUT") +} + +record(fanout, "$(P)$(IOC_NAME)PRESSURE_FANOUT") { + field(DESC, "description") + # field(SELM, "All Specified Mask") + # field(SELN, "1") + field(LNK1, "$(P)$(IOC_NAME)DECREASING_PRESSURE_CHECK") + field(LNK2, "$(P)$(IOC_NAME)INCREASING_PRESSURE_CHECK") +} + +record(calcout, "$(P)$(IOC_NAME)DECREASING_PRESSURE_CHECK") { + field(DESC, "description") + field(CALC, "A < 0 ? 1 : 0") + field(INPA, "$(P)$(IOC_NAME)PRESSURE_COMPARISON") + # field(OUT, "$(P)$(IOC_NAME)DECREASING_PRESSURE") + field(FLNK, "$(P)$(IOC_NAME)DECREASING_PRESSURE") +} + +# record(calc, "$(P)$(IOC_NAME)UNCHANGING_PRESSURE_CHECK") { +# field(DESC, "description") +# field(CALC, "A==0? 1:0") +# field(INPA, "$(P)$(IOC_NAME)PRESSURE_COMPARISON") +# } + +record(calcout, "$(P)$(IOC_NAME)INCREASING_PRESSURE_CHECK") { + field(DESC, "description") + field(CALC, "A > 0 ? 1 : 0") + field(INPA, "$(P)$(IOC_NAME)PRESSURE_COMPARISON") + field(FLNK, "$(P)$(IOC_NAME)INCREASING_PRESSURE") +} + +record(bi, "$(P)$(IOC_NAME)DECREASING_PRESSURE") { + field(DESC, "description") + field(ZNAM, "zero_name") + field(ONAM, "one_name") + field(INP, "$(P)$(IOC_NAME)DECREASING_PRESSURE_CHECK") +} + +# record(bi, "$(P)$(IOC_NAME)UNCHANGING_PRESSURE") { +# field(DESC, "description") +# field(ZNAM, "zero_name") +# field(ONAM, "one_name") +# field(INP, "$(P)$(IOC_NAME)UNCHANGING_PRESSURE_CHECK") +# } + +record(bi, "$(P)$(IOC_NAME)INCREASING_PRESSURE") { + field(DESC, "description") + field(ZNAM, "zero_name") + field(ONAM, "one_name") + field(INP, "$(P)$(IOC_NAME)INCREASING_PRESSURE_CHECK") } record(ao, "$(P)$(IOC_NAME)MN_PRESSURE:SP"){ @@ -223,3 +291,19 @@ record(ai, "$(P)$(IOC_NAME)MX_PRESSURE"){ field(DESC, "Get Max Pressure") field(DTYP, "Soft Channel") } + +record(bi, "$(P)$(IOC_NAME)RESET_PRESSURE:SP") { + field(DESC, "Return pistons to open/closed") + field(DTYP, "Soft Channel") + field(OUT, "@PearlPC.proto set_reset_pistons $(PORT)") + field(ZNAM, "CLOSE") + field(ONAM, "OPEN") +} + +record(bo, "$(P)$(IOC_NAME)RESET_PRESSURE") { + field(INP, "$(P)$(IOC_NAME)BUFFER1.D CP MS") + field(DESC, "Return pistons to open/closed") + field(DTYP, "stream") + field(ZNAM, "CLOSE") + field(ONAM, "OPEN") +} diff --git a/system_tests/lewis_emulators/PearlPC/device.py b/system_tests/lewis_emulators/PearlPC/device.py index c77d2da..93ea0ca 100644 --- a/system_tests/lewis_emulators/PearlPC/device.py +++ b/system_tests/lewis_emulators/PearlPC/device.py @@ -11,8 +11,9 @@ def _initialize_data(self): self.secondary_id_prefix = "1111" self.em_stop_status = 0 # Bool [0-1] self.run_bit = 0 # Bool [0-1] - self.reset_value = 0 - self.stop_bit = 0 # Bool [0-1]\ + self.reset_value = 0 # Bool [0-1] + self.piston_reset_phase = 0 + self.stop_bit = 0 # Bool [0-1] self.busy_bit = 0 # Bool [0-1] self.go_status = 0 self.am_mode = 0 diff --git a/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py b/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py index ce2d1e2..352e208 100644 --- a/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py +++ b/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py @@ -27,7 +27,8 @@ class PearlPCStreamInterface(StreamInterface): CmdBuilder("set_ra").escape("ra").arg("[0-9]{4}").eos().build(), CmdBuilder("set_mn").escape("mn").arg("[0-9]{4}").eos().build(), CmdBuilder("set_sp").escape("sp").arg("[0-9]{4}").eos().build(), - CmdBuilder("set_mx").escape("mx").arg("[0-9]{4}").eos().build() + CmdBuilder("set_mx").escape("mx").arg("[0-9]{4}").eos().build(), + CmdBuilder("set_reset").escape("reset").arg("[0-1]{1}").eos().build(), } in_terminator = "\r\n" @@ -117,14 +118,26 @@ def set_ru(self, run_bit: int): self._device.run_bit = run_bit self.add_to_dict(value_id="ru", unvalidated_value=self._device.run_bit) - def set_re(self, reset_value: int): + def set_re(self, piston_reset_phase: int): """ Set the reset value to represent the 4 stages of resetting the pistons @param reset_value: (int) value representing each stage during piston reset - range [0-4] """ + print(f"Received reset phase value: {piston_reset_phase}") + self._device.reset_value = piston_reset_phase + self.add_to_dict(value_id="re", unvalidated_value=self._device.piston_reset_phase) + + def set_reset(self, reset_value: int): + """ + Set the reset bit to fully open pistons + 1: Pistons open + 0: Pistons closed + @param reset_value: (int) value representing if pistons are open or closed range [0-1] + """ print(f"Received reset value: {reset_value}") self._device.reset_value = reset_value - self.add_to_dict(value_id="re", unvalidated_value=self._device.reset_value) + return f"{reset_value}" + # self.add_to_dict(value_id="re", unvalidated_value=self._device.reset_value) def set_stop_bit(self, stop_bit: int): """ diff --git a/system_tests/test-reports/TEST-ReportFailLoadTestsuiteTestCase-20210804115226.xml b/system_tests/test-reports/TEST-ReportFailLoadTestsuiteTestCase-20210804115226.xml deleted file mode 100644 index 641613a..0000000 --- a/system_tests/test-reports/TEST-ReportFailLoadTestsuiteTestCase-20210804115226.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726153045.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726153045.xml deleted file mode 100644 index 0eb49d1..0000000 --- a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726153045.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726153138.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726153138.xml deleted file mode 100644 index 26906fd..0000000 --- a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726153138.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726154011.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726154011.xml deleted file mode 100644 index 771665e..0000000 --- a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726154011.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726154436.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726154436.xml deleted file mode 100644 index 2a1472a..0000000 --- a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726154436.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726155211.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726155211.xml deleted file mode 100644 index 967de0e..0000000 --- a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726155211.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726155957.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726155957.xml deleted file mode 100644 index e6db70f..0000000 --- a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726155957.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726161117.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726161117.xml deleted file mode 100644 index 2c5ab4c..0000000 --- a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726161117.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726161813.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726161813.xml deleted file mode 100644 index 920f656..0000000 --- a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726161813.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726162431.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726162431.xml deleted file mode 100644 index c740209..0000000 --- a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210726162431.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210727152353.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210727152353.xml deleted file mode 100644 index 3665ab3..0000000 --- a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210727152353.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210727153648.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210727153648.xml deleted file mode 100644 index 3aff425..0000000 --- a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210727153648.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728091312.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728091312.xml deleted file mode 100644 index 1b0aded..0000000 --- a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728091312.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728091856.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728091856.xml deleted file mode 100644 index 68887e6..0000000 --- a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728091856.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092544.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092544.xml deleted file mode 100644 index 17d3826..0000000 --- a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092544.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092650.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092650.xml deleted file mode 100644 index 74016f0..0000000 --- a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092650.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092730.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092730.xml deleted file mode 100644 index b759201..0000000 --- a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092730.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - diff --git a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092854.xml b/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092854.xml deleted file mode 100644 index 82a8dd7..0000000 --- a/system_tests/test-reports/TEST-tests.pearlpc.PEARLPCTests-20210728092854.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/system_tests/tests/pearlpc.py b/system_tests/tests/pearlpc.py index a4a9525..1915eb8 100644 --- a/system_tests/tests/pearlpc.py +++ b/system_tests/tests/pearlpc.py @@ -138,6 +138,13 @@ def test_WHEN_max_pressure_set_THEN_max_pressure_set_correctly(self): self.ca.assert_that_pv_is("BUFFER2.C", self.pressure_value) # self.ca.assert_setting_setpoint_sets_readback(self.pressure_value, "MX_PRESSURE") + def test_WHEN_reset_bit_value_set_THEN_reset_bit_value_read_back_correctly(self): + # self.ca.assert_that_pv_is("BUFFER1.C", self.default_initial_value) + self.ca.set_pv_value("RESET_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("RESET_PRESSURE:SP", self.set_loop_status) + # self.ca.assert_that_pv_is("BUFFER1.C", self.set_loop_status) + + # def test_WHEN_buffer_values_set_THEN_buffer_read_back_correctly_updated(self): # self.ca.set_pv_value("GO_PRESSURE:SP", self.set_loop_status) # self.ca.assert_that_pv_is From 5683aa560036e310bad5d8c093ecc78a7c06b1b5 Mon Sep 17 00:00:00 2001 From: JackEAllen Date: Wed, 25 Aug 2021 16:11:29 +0100 Subject: [PATCH 06/12] Create Pressure Increase Decrease EPICS Logic --- .gitignore | 1 + PearlPCSup/devPearl.db | 75 ++++++++++++++++-------------------------- 2 files changed, 30 insertions(+), 46 deletions(-) diff --git a/.gitignore b/.gitignore index d0f8a46..8be16d3 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ runIOC.sh relPaths.sh .project /data +.idea/ \ No newline at end of file diff --git a/PearlPCSup/devPearl.db b/PearlPCSup/devPearl.db index e0aff06..b65997d 100644 --- a/PearlPCSup/devPearl.db +++ b/PearlPCSup/devPearl.db @@ -1,5 +1,4 @@ -record(bo, "$(P)$(IOC_NAME)DISABLE") -{ +record(bo, "$(P)$(IOC_NAME)DISABLE"){ field(DESC, "Disable comms") field(PINI, "YES") field(VAL, "$(DISABLE=0)") @@ -9,18 +8,20 @@ record(bo, "$(P)$(IOC_NAME)DISABLE") } record(calc, "$(P)$(IOC_NAME)BUFFER1"){ + field(DESC, "Buffer 1 status values A-K") field(CALC, "0") field(INPL, "$(P)$(IOC_NAME)STATUS") field(FLNK, "$(P)$(IOC_NAME)BUFFER2") } record(calc, "$(P)$(IOC_NAME)BUFFER2"){ + field(DESC, "Buffer 2 status values A-D") field(CALC, "0") field(INPL, "$(P)$(IOC_NAME)STATUS") } record(ai, "$(P)$(IOC_NAME)STATUS"){ - field(DESC, "Get Pressure") + field(DESC, "Get Pressure Device Status") field(DTYP, "stream") field(INP, "@PearlPC.proto get_st($(P)$(IOC_NAME)BUFFER1, $(P)$(IOC_NAME)BUFFER2) $(PORT)") field(SCAN, "1 second") @@ -77,8 +78,8 @@ record(bo, "$(P)$(IOC_NAME)RU_PRESSURE:SP") { } record(bi, "$(P)$(IOC_NAME)RU_PRESSURE"){ - field(INP, "$(P)$(IOC_NAME)BUFFER1.B CP MS") field(DESC, "Get Mechanically active status") + field(INP, "$(P)$(IOC_NAME)BUFFER1.B CP MS") field(DTYP, "Soft Channel") field(ZNAM, "Start") field(ONAM, "Stop") @@ -91,8 +92,8 @@ record(ao, "$(P)$(IOC_NAME)RE_PRESSURE:SP") { } record(ai, "$(P)$(IOC_NAME)RE_PRESSURE"){ - field(INP, "$(P)$(IOC_NAME)BUFFER1.C CP MS") field(DESC, "Reset stage for each piston") + field(INP, "$(P)$(IOC_NAME)BUFFER1.C CP MS") field(DTYP, "Soft Channel") } @@ -103,8 +104,8 @@ record(bo, "$(P)$(IOC_NAME)St_PRESSURE:SP") { } record(bi, "$(P)$(IOC_NAME)St_PRESSURE"){ - field(INP, "$(P)$(IOC_NAME)BUFFER1.D CP MS") field(DESC, "Stop bit after each move/manually") + field(INP, "$(P)$(IOC_NAME)BUFFER1.D CP MS") field(DTYP, "Soft Channel") } @@ -115,8 +116,8 @@ record(bo, "$(P)$(IOC_NAME)BY_PRESSURE:SP") { } record(bi, "$(P)$(IOC_NAME)BY_PRESSURE"){ - field(INP, "$(P)$(IOC_NAME)BUFFER1.E CP MS") field(DESC, "Get Busy bit if busy or not") + field(INP, "$(P)$(IOC_NAME)BUFFER1.E CP MS") field(DTYP, "Soft Channel") } @@ -127,8 +128,8 @@ record(bo, "$(P)$(IOC_NAME)GO_PRESSURE:SP") { } record(bi, "$(P)$(IOC_NAME)GO_PRESSURE"){ - field(INP, "$(P)$(IOC_NAME)BUFFER1.F CP MS") field(DESC, "Get system initiated by host status") + field(INP, "$(P)$(IOC_NAME)BUFFER1.F CP MS") field(DTYP, "Soft Channel") } @@ -139,8 +140,8 @@ record(bo, "$(P)$(IOC_NAME)AM_PRESSURE:SP") { } record(bi, "$(P)$(IOC_NAME)AM_PRESSURE"){ - field(INP, "$(P)$(IOC_NAME)BUFFER1.G CP MS") field(DESC, "Gets auto/manual switch position") + field(INP, "$(P)$(IOC_NAME)BUFFER1.G CP MS") field(DTYP, "Soft Channel") } @@ -153,8 +154,8 @@ record(bo, "$(P)$(IOC_NAME)SL_PRESSURE:SP"){ } record(bi, "$(P)$(IOC_NAME)SL_PRESSURE"){ - field(INP, "$(P)$(IOC_NAME)BUFFER1.H CP MS") field(DESC, "Get loop pressure mode") + field(INP, "$(P)$(IOC_NAME)BUFFER1.H CP MS") field(DTYP, "Soft Channel") field(ZNAM, "OFF") field(ONAM, "ON") @@ -167,8 +168,8 @@ record(ao, "$(P)$(IOC_NAME)SF_PRESSURE:SP"){ } record(ai, "$(P)$(IOC_NAME)SF_PRESSURE"){ - field(INP, "$(P)$(IOC_NAME)BUFFER1.I CP MS") field(DESC, "Get Seal Fail Pressure") + field(INP, "$(P)$(IOC_NAME)BUFFER1.I CP MS") field(DTYP, "Soft Channel") } @@ -179,8 +180,8 @@ record(ao, "$(P)$(IOC_NAME)ER_PRESSURE:SP") { } record(ai, "$(P)$(IOC_NAME)ER_PRESSURE"){ - field(INP, "$(P)$(IOC_NAME)BUFFER1.J CP MS") field(DESC, "Last Error Code returned") + field(INP, "$(P)$(IOC_NAME)BUFFER1.J CP MS") field(DTYP, "Soft Channel") } @@ -191,66 +192,48 @@ record(ao, "$(P)$(IOC_NAME)PRESSURE:SP"){ } record(ai, "$(P)$(IOC_NAME)PRESSURE"){ + field(DESC, "Get Pressure from buffer1") field(INP, "$(P)$(IOC_NAME)BUFFER1.K CP MS") - field(DESC, "Get Pressure") field(DTYP, "Soft Channel") - # field(FLNK, "$(P)$(IOC_NAME)PRESSURE_COMPARISON") } record(calc, "$(P)$(IOC_NAME)PRESSURE_COMPARISON"){ + field(DESC, "Compare pressure against previous val") field(SCAN, "1 second") # change to .1 seconds for production? field(CALC, "A - B; B := A") - # field(LA, "A") field(INPA, "$(P)$(IOC_NAME)PRESSURE") - # field(INPB, "$(P)$(IOC_NAME)PRESSURE") field(FLNK, "$(P)$(IOC_NAME)PRESSURE_FANOUT") } record(fanout, "$(P)$(IOC_NAME)PRESSURE_FANOUT") { - field(DESC, "description") - # field(SELM, "All Specified Mask") - # field(SELN, "1") + field(DESC, "Fanout to decrease and increase calcs") field(LNK1, "$(P)$(IOC_NAME)DECREASING_PRESSURE_CHECK") field(LNK2, "$(P)$(IOC_NAME)INCREASING_PRESSURE_CHECK") } record(calcout, "$(P)$(IOC_NAME)DECREASING_PRESSURE_CHECK") { - field(DESC, "description") + field(DESC, "Check if pressure is decreasing") field(CALC, "A < 0 ? 1 : 0") field(INPA, "$(P)$(IOC_NAME)PRESSURE_COMPARISON") - # field(OUT, "$(P)$(IOC_NAME)DECREASING_PRESSURE") field(FLNK, "$(P)$(IOC_NAME)DECREASING_PRESSURE") } -# record(calc, "$(P)$(IOC_NAME)UNCHANGING_PRESSURE_CHECK") { -# field(DESC, "description") -# field(CALC, "A==0? 1:0") -# field(INPA, "$(P)$(IOC_NAME)PRESSURE_COMPARISON") -# } - -record(calcout, "$(P)$(IOC_NAME)INCREASING_PRESSURE_CHECK") { - field(DESC, "description") - field(CALC, "A > 0 ? 1 : 0") - field(INPA, "$(P)$(IOC_NAME)PRESSURE_COMPARISON") - field(FLNK, "$(P)$(IOC_NAME)INCREASING_PRESSURE") -} - record(bi, "$(P)$(IOC_NAME)DECREASING_PRESSURE") { - field(DESC, "description") + field(DESC, "Pressure decreasing") field(ZNAM, "zero_name") field(ONAM, "one_name") field(INP, "$(P)$(IOC_NAME)DECREASING_PRESSURE_CHECK") } -# record(bi, "$(P)$(IOC_NAME)UNCHANGING_PRESSURE") { -# field(DESC, "description") -# field(ZNAM, "zero_name") -# field(ONAM, "one_name") -# field(INP, "$(P)$(IOC_NAME)UNCHANGING_PRESSURE_CHECK") -# } +record(calcout, "$(P)$(IOC_NAME)INCREASING_PRESSURE_CHECK") { + field(DESC, "Check if pressure is increasing") + field(CALC, "A > 0 ? 1 : 0") + field(INPA, "$(P)$(IOC_NAME)PRESSURE_COMPARISON") + field(FLNK, "$(P)$(IOC_NAME)INCREASING_PRESSURE") +} record(bi, "$(P)$(IOC_NAME)INCREASING_PRESSURE") { - field(DESC, "description") + field(DESC, "Pressure increasing") field(ZNAM, "zero_name") field(ONAM, "one_name") field(INP, "$(P)$(IOC_NAME)INCREASING_PRESSURE_CHECK") @@ -263,8 +246,8 @@ record(ao, "$(P)$(IOC_NAME)MN_PRESSURE:SP"){ } record(ai, "$(P)$(IOC_NAME)MN_PRESSURE"){ - field(INP, "$(P)$(IOC_NAME)BUFFER2.A CP MS") field(DESC, "Get Min Pressure") + field(INP, "$(P)$(IOC_NAME)BUFFER2.A CP MS") field(DTYP, "Soft Channel") } @@ -275,8 +258,8 @@ record(ao, "$(P)$(IOC_NAME)SP_PRESSURE:SP"){ } record(ai, "$(P)$(IOC_NAME)SP_PRESSURE"){ - field(INP, "$(P)$(IOC_NAME)BUFFER2.B CP MS") field(DESC, "Get Setpoint Pressure") + field(INP, "$(P)$(IOC_NAME)BUFFER2.B CP MS") field(DTYP, "Soft Channel") } @@ -287,8 +270,8 @@ record(ao, "$(P)$(IOC_NAME)MX_PRESSURE:SP"){ } record(ai, "$(P)$(IOC_NAME)MX_PRESSURE"){ - field(INP, "$(P)$(IOC_NAME)BUFFER2.C CP MS") field(DESC, "Get Max Pressure") + field(INP, "$(P)$(IOC_NAME)BUFFER2.C CP MS") field(DTYP, "Soft Channel") } @@ -301,8 +284,8 @@ record(bi, "$(P)$(IOC_NAME)RESET_PRESSURE:SP") { } record(bo, "$(P)$(IOC_NAME)RESET_PRESSURE") { - field(INP, "$(P)$(IOC_NAME)BUFFER1.D CP MS") field(DESC, "Return pistons to open/closed") + field(INP, "$(P)$(IOC_NAME)BUFFER1.D CP MS") field(DTYP, "stream") field(ZNAM, "CLOSE") field(ONAM, "OPEN") From 8ad4963b2492c7943c8f2836a9d2b40cc8680912 Mon Sep 17 00:00:00 2001 From: JackEAllen Date: Wed, 25 Aug 2021 17:15:34 +0100 Subject: [PATCH 07/12] Update system tests --- system_tests/tests/pearlpc.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/system_tests/tests/pearlpc.py b/system_tests/tests/pearlpc.py index 1915eb8..08ae409 100644 --- a/system_tests/tests/pearlpc.py +++ b/system_tests/tests/pearlpc.py @@ -68,7 +68,7 @@ def test_WHEN_run_bit_set_THEN_run_bit_read_back_correctly(self): def test_WHEN_reset_value_set_THEN_reset_value_read_back_correctly(self): self.ca.assert_that_pv_is("BUFFER1.C", self.default_initial_value) self.ca.set_pv_value("RE_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("RE_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("RE_PRESSURE", self.set_loop_status) self.ca.assert_that_pv_is("BUFFER1.C", self.set_loop_status) def test_WHEN_stop_bit_set_THEN_stop_bit_value_read_back_correctly(self): @@ -104,47 +104,42 @@ def test_WHEN_loop_mode_set_THEN_loop_mode_read_back_correctly(self): def test_WHEN_Seal_Fail_pressure_set_THEN_Seal_Fail_pressure_read_back_correctly(self): self.ca.assert_that_pv_is("BUFFER1.I", self.default_initial_value) self.ca.set_pv_value("SF_PRESSURE:SP", self.pressure_value) - self.ca.assert_that_pv_is("SF_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("SF_PRESSURE", self.pressure_value) self.ca.assert_that_pv_is("BUFFER1.I", self.pressure_value) def test_WHEN_er_last_error_code_set_THEN_er_last_error_code_read_back_correctly(self): self.ca.assert_that_pv_is("BUFFER1.J", self.default_initial_value) self.ca.set_pv_value("ER_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("ER_PRESSURE:SP", self.set_loop_status) + self.ca.assert_that_pv_is("ER_PRESSURE", self.set_loop_status) self.ca.assert_that_pv_is("BUFFER1.J", self.set_loop_status) def test_WHEN_pressure_set_THEN_pressure_read_back_correctly(self): self.ca.assert_that_pv_is("BUFFER1.K", self.default_initial_value) self.ca.set_pv_value("PRESSURE:SP", self.pressure_value) - self.ca.assert_that_pv_is("PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("PRESSURE", self.pressure_value) self.ca.assert_that_pv_is("BUFFER1.K", self.pressure_value) def test_WHEN_min_pressure_set_THEN_min_pressure_read_back_correctly(self): self.ca.assert_that_pv_is("BUFFER2.A", self.default_initial_value) self.ca.set_pv_value("MN_PRESSURE:SP", self.pressure_value) - self.ca.assert_that_pv_is("MN_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("MN_PRESSURE", self.pressure_value) self.ca.assert_that_pv_is("BUFFER2.A", self.pressure_value) def test_WHEN_setpoint_pressure_set_THEN_setpoint_pressure_read_back_correctly(self): self.ca.assert_that_pv_is("BUFFER2.B", self.default_initial_value) self.ca.set_pv_value("SP_PRESSURE:SP", self.pressure_value) - self.ca.assert_that_pv_is("SP_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("SP_PRESSURE", self.pressure_value) self.ca.assert_that_pv_is("BUFFER2.B", self.pressure_value) def test_WHEN_max_pressure_set_THEN_max_pressure_set_correctly(self): self.ca.assert_that_pv_is("BUFFER2.C", self.default_initial_value) self.ca.set_pv_value("MX_PRESSURE:SP", self.pressure_value) - self.ca.assert_that_pv_is("MX_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("MX_PRESSURE", self.pressure_value) self.ca.assert_that_pv_is("BUFFER2.C", self.pressure_value) # self.ca.assert_setting_setpoint_sets_readback(self.pressure_value, "MX_PRESSURE") def test_WHEN_reset_bit_value_set_THEN_reset_bit_value_read_back_correctly(self): # self.ca.assert_that_pv_is("BUFFER1.C", self.default_initial_value) self.ca.set_pv_value("RESET_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("RESET_PRESSURE:SP", self.set_loop_status) - # self.ca.assert_that_pv_is("BUFFER1.C", self.set_loop_status) - - - # def test_WHEN_buffer_values_set_THEN_buffer_read_back_correctly_updated(self): - # self.ca.set_pv_value("GO_PRESSURE:SP", self.set_loop_status) - # self.ca.assert_that_pv_is + self.ca.assert_that_pv_is("RESET_PRESSURE:SP", "OPEN") + # self.ca.assert_that_pv_is("BUFFER1.C", self.set_loop_status) \ No newline at end of file From 45bb563860cf9879368f67eac7c27e91cbc023f3 Mon Sep 17 00:00:00 2001 From: JackEAllen Date: Tue, 14 Sep 2021 14:10:50 +0100 Subject: [PATCH 08/12] Add more DB logic to reflect LabView VI functionality and update tests accordingly --- PearlPCSup/PearlPC.proto | 4 +- PearlPCSup/devPearl.db | 142 +++++++++++++++++++++++++++++----- system_tests/tests/pearlpc.py | 44 +++++++++-- 3 files changed, 161 insertions(+), 29 deletions(-) diff --git a/PearlPCSup/PearlPC.proto b/PearlPCSup/PearlPC.proto index 949cd72..7f6515b 100644 --- a/PearlPCSup/PearlPC.proto +++ b/PearlPCSup/PearlPC.proto @@ -78,11 +78,11 @@ get_id { in "%/[0-9]{4} [0-9]{4}/"; } -set_reset_status { +set_reset_pistons { out "reset%#01d" } get_piston_status { out "reset"; - in "%/[0-1]"; + in "%/[0-1]{1}"; } diff --git a/PearlPCSup/devPearl.db b/PearlPCSup/devPearl.db index b65997d..3a96df4 100644 --- a/PearlPCSup/devPearl.db +++ b/PearlPCSup/devPearl.db @@ -34,22 +34,12 @@ record(ao, "$(P)$(IOC_NAME)SI_PRESSURE:SP"){ field(OUT, "@PearlPC.proto set_si $(PORT)") } -# record(ai, "$(P)$(IOC_NAME)SI_PRESSURE"){ -# field(DESC, "Get initial ID prefix") -# field(DTYP, "Soft Channel") -# } - record(ao, "$(P)$(IOC_NAME)SD_PRESSURE:SP"){ field(DESC, "Set secondary ID prefix") field(DTYP, "stream") field(OUT, "@PearlPC.proto set_sd $(PORT)") } -# record(ai, "$(P)$(IOC_NAME)SD_PRESSURE"){ -# field(DESC, "Get secondary ID prefix") -# field(DTYP, "Soft Channel") -# } - record(stringin, "$(P)$(IOC_NAME)ID_PRESSURE") { field(DESC, "Get ID prefix") field(DTYP, "stream") @@ -171,6 +161,23 @@ record(ai, "$(P)$(IOC_NAME)SF_PRESSURE"){ field(DESC, "Get Seal Fail Pressure") field(INP, "$(P)$(IOC_NAME)BUFFER1.I CP MS") field(DTYP, "Soft Channel") + field(FLNK, "$(P)$(IOC_NAME)DETECT_SEAL_FAIL CP") +} + +record(calcout, "$(P)$(IOC_NAME)DETECT_SEAL_FAIL") { + field(DESC, "Detect pressure seal fail") + field(CALC, "(A < B) && ((A - B) > C) ? 1 : 0 ; B := A") + field(INPA, "$(P)$(IOC_NAME)PRESSURE") + field(INPC, "$(P)$(IOC_NAME)SF_PRESSURE") + field(OUT, "$(P)$(IOC_NAME)SF_MODE_PRESSURE CP") +} + +record(bi, "$(P)$(IOC_NAME)SF_MODE_PRESSURE"){ + field(DESC, "Set Seal Fail Mode") + field(DTYP, "Soft Channel") + field(INP, "$(P)$(IOC_NAME)DETECT_SEAL_FAIL") + field(ZNAM, "OFF") + field(ONAM, "ON") } record(ao, "$(P)$(IOC_NAME)ER_PRESSURE:SP") { @@ -180,28 +187,47 @@ record(ao, "$(P)$(IOC_NAME)ER_PRESSURE:SP") { } record(ai, "$(P)$(IOC_NAME)ER_PRESSURE"){ - field(DESC, "Last Error Code returned") + field(DESC, "Last Error Code returned") field(INP, "$(P)$(IOC_NAME)BUFFER1.J CP MS") field(DTYP, "Soft Channel") + field(FLNK, "$(P)$(IOC_NAME)GENERAL_ERROR_CHECK CP") +} + +record(calcout, "$(P)$(IOC_NAME)GENERAL_ERROR_CHECK") { + field(DESC, "Check if error code higher than 0 present") + field(CALC, "A != 0? 1 : 0") + field(INPA, "$(P)$(IOC_NAME)ER_PRESSURE") + field(FLNK, "$(P)$(IOC_NAME)GENERAL_ERROR") +} + +record(bi, "$(P)$(IOC_NAME)GENERAL_ERROR") { + field(DESC, "Bool indicating if error has occured") + field(DTYP, "Soft Channel") + field(INP, "$(P)$(IOC_NAME)GENERAL_ERROR_CHECK") + field(ZNAM, "OFF") + field(ONAM, "ONE") } record(ao, "$(P)$(IOC_NAME)PRESSURE:SP"){ field(DESC, "Set Pressure") field(DTYP, "stream") field(OUT, "@PearlPC.proto set_ra $(PORT)") + field(DRVH, "1000") + field(DRVL, "10") } record(ai, "$(P)$(IOC_NAME)PRESSURE"){ field(DESC, "Get Pressure from buffer1") field(INP, "$(P)$(IOC_NAME)BUFFER1.K CP MS") field(DTYP, "Soft Channel") + field(FLNK, "$(P)$(IOC_NAME)HIGH_PRESSURE_RESET_CHECK") } record(calc, "$(P)$(IOC_NAME)PRESSURE_COMPARISON"){ field(DESC, "Compare pressure against previous val") - field(SCAN, "1 second") # change to .1 seconds for production? + field(SCAN, "1 second") field(CALC, "A - B; B := A") - field(INPA, "$(P)$(IOC_NAME)PRESSURE") + field(INPA, "$(P)$(IOC_NAME)PRESSURE CP") field(FLNK, "$(P)$(IOC_NAME)PRESSURE_FANOUT") } @@ -243,6 +269,15 @@ record(ao, "$(P)$(IOC_NAME)MN_PRESSURE:SP"){ field(DESC, "Set Min Pressure Value") field(DTYP, "stream") field(OUT, "@PearlPC.proto set_mn $(PORT)") + field(FLNK, "$(P)$(IOC_NAME)MN_PRESSURE_FANOUT CP") +} + +record(dfanout, "$(P)$(IOC_NAME)MN_PRESSURE_FANOUT") { + field(DESC, "dfanout min Pressure value") + field(OUTA, "$(P)$(IOC_NAME)PRESSURE:SP.DRVL") + field(DOL, "$(P)$(IOC_NAME)MN_PRESSURE:SP") + field(OMSL, "closed_loop") + field(FLNK, "$(P)$(IOC_NAME)PRESSURE:SP") } record(ai, "$(P)$(IOC_NAME)MN_PRESSURE"){ @@ -267,6 +302,14 @@ record(ao, "$(P)$(IOC_NAME)MX_PRESSURE:SP"){ field(DESC, "Set Max Pressure Value") field(DTYP, "stream") field(OUT, "@PearlPC.proto set_mx $(PORT)") + field(FLNK, "$(P)$(IOC_NAME)MX_PRESSURE_FANOUT PP") +} + +record(dfanout, "$(P)$(IOC_NAME)MX_PRESSURE_FANOUT") { + field(DESC, "dfanout max Pressure value") + field(OUTA, "$(P)$(IOC_NAME)PRESSURE:SP.DRVH") + field(DOL, "$(P)$(IOC_NAME)MX_PRESSURE:SP") + field(OMSL, "closed_loop") } record(ai, "$(P)$(IOC_NAME)MX_PRESSURE"){ @@ -275,18 +318,75 @@ record(ai, "$(P)$(IOC_NAME)MX_PRESSURE"){ field(DTYP, "Soft Channel") } -record(bi, "$(P)$(IOC_NAME)RESET_PRESSURE:SP") { +record(bo, "$(P)$(IOC_NAME)RESET_PRESSURE:SP") { field(DESC, "Return pistons to open/closed") field(DTYP, "Soft Channel") field(OUT, "@PearlPC.proto set_reset_pistons $(PORT)") - field(ZNAM, "CLOSE") - field(ONAM, "OPEN") + field(ZNAM, "RESET") + field(ONAM, "RESETTING") + field(FLNK, "$(P)$(IOC_NAME)RESET_PRESSURE_STATUS CP") +} + +record(calcout, "$(P)$(IOC_NAME)RESET_PRESSURE_STATUS") { + field(DESC, "Check pressure is < 100 bar to reset") + field(CALC, "(B = 1) && (A < 100) ? 1 : 0") + field(INPA, "$(P)$(IOC_NAME)PRESSURE") + field(INPB, "$(P)$(IOC_NAME)RESET_PRESSURE:SP") + field(FLNK, "$(P)$(IOC_NAME)RESET_PRESSURE CP") } -record(bo, "$(P)$(IOC_NAME)RESET_PRESSURE") { +record(bi, "$(P)$(IOC_NAME)RESET_PRESSURE") { field(DESC, "Return pistons to open/closed") - field(INP, "$(P)$(IOC_NAME)BUFFER1.D CP MS") - field(DTYP, "stream") - field(ZNAM, "CLOSE") - field(ONAM, "OPEN") + field(INP, "$(P)$(IOC_NAME)RESET_PRESSURE_STATUS") + field(ZNAM, "RESET") + field(ONAM, "RESETTING") +} + +record(calcout, "$(P)$(IOC_NAME)HIGH_PRESSURE_RESET_CHECK") { + field(DESC, "Check pressure is < 100 bar to reset") + field(CALC, "(A < 100) ? 0 : 1") + field(INPA, "$(P)$(IOC_NAME)PRESSURE") + field(FLNK, "$(P)$(IOC_NAME)RESET_PRESSURE_TOO_HIGH CP") +} + +record(bi, "$(P)$(IOC_NAME)RESET_PRESSURE_TOO_HIGH") { + field(DESC, "Pressure too high to reset") + field(INP, "$(P)$(IOC_NAME)HIGH_PRESSURE_RESET_CHECK") + field(ZNAM, "LOW") + field(ONAM, "HIGH") +} + +record(mbbo, "PRESSURE_RESTART_STAGES") { + field(DESC, "Display stages of pressure restart") + field(DTYP, "Soft Channel") + field(OUT, "$(dev):range PP") + field(ONVL, "0") + field(TWVL, "1") + field(THVL, "2") + field(FRVL, "3") + field(FVVL, "4") + field(ONST, "Not Resetting or Purging") + field(TWST, "Reset complete – now power down!") + field(THST, "Resetting") + field(FRST, "Purge done") + field(FVST, "Purging") +} + +record(calcout, "$(P)$(IOC_NAME)READY_STATE_CHECKS") { + field(DESC, "Ready state check validation") + field(CALC, "!A & !B & !C & !D & !E & !F") + field(INPA, "$(P)$(IOC_NAME)RESET_PRESSURE") # Not restarting must be 0 + field(INPB, "$(P)$(IOC_NAME)SF_MODE_PRESSURE") # Not in Seal fail must be 0/RVAl OFF + field(INPC, "$(P)$(IOC_NAME)ER_PRESSURE") # General error must be 0 + field(INPE, "$(P)$(IOC_NAME)INCREASING_PRESSURE") # Must be 0 - no increase + field(INPF, "$(P)$(IOC_NAME)DECREASING_PRESSURE") # Must be 0 - no decrease + field(OUT, "$(P)$(IOC_NAME)READY_STATE CP") + field(SCAN, "1 second") } + +record(bi, "$(P)$(IOC_NAME)READY_STATE") { + field(DESC, "Ready for operation in man/auto") + field(INP, "$(P)$(IOC_NAME)READY_STATE_CHECKS") + field(ZNAM, "NOT READY") + field(ONAM, "READY") +} \ No newline at end of file diff --git a/system_tests/tests/pearlpc.py b/system_tests/tests/pearlpc.py index 08ae409..cea450e 100644 --- a/system_tests/tests/pearlpc.py +++ b/system_tests/tests/pearlpc.py @@ -34,6 +34,7 @@ def setUp(self): self.set_loop_status = 1 self.default_initial_value = 0 self.default_id_prefix = 1111 + self.low_pressure = 50 self.lewis, self.ioc = get_running_lewis_and_ioc(DEVICE_A_PREFIX, DEVICE_A_PREFIX) self.ca = ChannelAccess(default_timeout=20, default_wait_time=0.0, device_prefix=DEVICE_A_PREFIX) @@ -119,6 +120,19 @@ def test_WHEN_pressure_set_THEN_pressure_read_back_correctly(self): self.ca.assert_that_pv_is("PRESSURE", self.pressure_value) self.ca.assert_that_pv_is("BUFFER1.K", self.pressure_value) + # def test_WHEN_pressure_set_THEN_min_and_max_drv_fields_set_correctly(self): + + # self.ca.set_pv_value("MX_PRESSURE:SP", 100) + # self.ca.set_pv_value("PRESSURE:SP", self.pressure_value) + # self.ca.assert_that_pv_is("PRESSURE:SP.DRVL", 10) + # self.ca.assert_that_pv_is("PRESSURE:SP.DRVH", 1000) + # pass + + def test_WHEN_pressure_set_lower_than_drvl_field_THEN_read_back_correctly(self): + self.ca.set_pv_value("MN_PRESSURE:SP", 10) + self.ca.set_pv_value("PRESSURE:SP", 5) + self.ca.assert_that_pv_is("PRESSURE", 10) + def test_WHEN_min_pressure_set_THEN_min_pressure_read_back_correctly(self): self.ca.assert_that_pv_is("BUFFER2.A", self.default_initial_value) self.ca.set_pv_value("MN_PRESSURE:SP", self.pressure_value) @@ -136,10 +150,28 @@ def test_WHEN_max_pressure_set_THEN_max_pressure_set_correctly(self): self.ca.set_pv_value("MX_PRESSURE:SP", self.pressure_value) self.ca.assert_that_pv_is("MX_PRESSURE", self.pressure_value) self.ca.assert_that_pv_is("BUFFER2.C", self.pressure_value) - # self.ca.assert_setting_setpoint_sets_readback(self.pressure_value, "MX_PRESSURE") - def test_WHEN_reset_bit_value_set_THEN_reset_bit_value_read_back_correctly(self): - # self.ca.assert_that_pv_is("BUFFER1.C", self.default_initial_value) - self.ca.set_pv_value("RESET_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("RESET_PRESSURE:SP", "OPEN") - # self.ca.assert_that_pv_is("BUFFER1.C", self.set_loop_status) \ No newline at end of file + def test_WHEN_reset_bit_value_set_THEN_reset_bit_value_read_back_correctly_HIGH_PRESSURE(self): + self.ca.set_pv_value("RESET_PRESSURE:SP", 0) + self.ca.set_pv_value("MN_PRESSURE:SP", 10) + self.ca.set_pv_value("PRESSURE:SP", 1000) + self.ca.set_pv_value("PRESSURE:SP", 500) + self.ca.assert_that_pv_is("PRESSURE", 500) + self.ca.set_pv_value("RESET_PRESSURE:SP", 1) + self.ca.assert_that_pv_is("RESET_PRESSURE", "RESET") + + # def test_WHEN_reset_bit_value_set_THEN_reset_bit_value_read_back_correctly_CLOSED(self): + # self.ca.assert_that_pv_is("RESET_PRESSURE", "RESETTING") + + + def test_WHEN_pressure_value_increases_THEN_increasing_pressure_record_processed(self): + pass + + def test_WHEN_pressure_value_decreases_THEN_decreasing_pressure_record_processed(self): + pass + + def test_WHEN_pressure_changed_THEN_pressure_comparison_with_previous_value_processed(self): + pass + + def test_WHEN_pv_values_set_THEN_interface_status_readback_correctly(self): + pass From dbac59c73e1708b37339d7540cf52a2ddd8a1200 Mon Sep 17 00:00:00 2001 From: JackEAllen Date: Fri, 17 Sep 2021 16:38:00 +0100 Subject: [PATCH 09/12] Refactor tests to use parameterized and add bi/bo value descriptions to DB --- PearlPCSup/devPearl.db | 22 ++++- system_tests/tests/pearlpc.py | 148 ++++++++++------------------------ 2 files changed, 63 insertions(+), 107 deletions(-) diff --git a/PearlPCSup/devPearl.db b/PearlPCSup/devPearl.db index 3a96df4..2fe9d16 100644 --- a/PearlPCSup/devPearl.db +++ b/PearlPCSup/devPearl.db @@ -51,12 +51,16 @@ record(bo, "$(P)$(IOC_NAME)EM_PRESSURE:SP") { field(DESC, "EM stop circuit status") field(DTYP, "stream") field(OUT, "@PearlPC.proto set_EM $(PORT)") + field(ZNAM, "Start") + field(ONAM, "Stop") } record(bi, "$(P)$(IOC_NAME)EM_PRESSURE"){ field(INP, "$(P)$(IOC_NAME)BUFFER1.A CP MS") field(DESC, "EM stop circuit status") field(DTYP, "Soft Channel") + field(ZNAM, "Start") + field(ONAM, "Stop") } record(bo, "$(P)$(IOC_NAME)RU_PRESSURE:SP") { @@ -91,48 +95,64 @@ record(bo, "$(P)$(IOC_NAME)St_PRESSURE:SP") { field(DESC, "Stop bit after each move/manually") field(DTYP, "stream") field(OUT, "@PearlPC.proto set_St $(PORT)") + field(ZNAM, "Running") + field(ONAM, "Stopped") } record(bi, "$(P)$(IOC_NAME)St_PRESSURE"){ field(DESC, "Stop bit after each move/manually") field(INP, "$(P)$(IOC_NAME)BUFFER1.D CP MS") field(DTYP, "Soft Channel") + field(ZNAM, "Running") + field(ONAM, "Stopped") } record(bo, "$(P)$(IOC_NAME)BY_PRESSURE:SP") { field(DESC, "Set Busy bit if busy or not") field(DTYP, "stream") field(OUT, "@PearlPC.proto set_by $(PORT)") + field(ZNAM, "Inactive") + field(ONAM, "Active") } record(bi, "$(P)$(IOC_NAME)BY_PRESSURE"){ field(DESC, "Get Busy bit if busy or not") field(INP, "$(P)$(IOC_NAME)BUFFER1.E CP MS") field(DTYP, "Soft Channel") + field(ZNAM, "Inactive") + field(ONAM, "Active") } record(bo, "$(P)$(IOC_NAME)GO_PRESSURE:SP") { field(DESC, "Set system initiated by host status") field(DTYP, "stream") field(OUT, "@PearlPC.proto set_GO $(PORT)") + field(ZNAM, "FALSE") + field(ONAM, "TRUE") } record(bi, "$(P)$(IOC_NAME)GO_PRESSURE"){ field(DESC, "Get system initiated by host status") field(INP, "$(P)$(IOC_NAME)BUFFER1.F CP MS") field(DTYP, "Soft Channel") + field(ZNAM, "FALSE") + field(ONAM, "TRUE") } record(bo, "$(P)$(IOC_NAME)AM_PRESSURE:SP") { field(DESC, "Sets auto/manual switch position") field(DTYP, "stream") field(OUT, "@PearlPC.proto set_AM $(PORT)") + field(ZNAM, "Manual") + field(ONAM, "Auto") } record(bi, "$(P)$(IOC_NAME)AM_PRESSURE"){ field(DESC, "Gets auto/manual switch position") field(INP, "$(P)$(IOC_NAME)BUFFER1.G CP MS") field(DTYP, "Soft Channel") + field(ZNAM, "Manual") + field(ONAM, "Auto") } record(bo, "$(P)$(IOC_NAME)SL_PRESSURE:SP"){ @@ -205,7 +225,7 @@ record(bi, "$(P)$(IOC_NAME)GENERAL_ERROR") { field(DTYP, "Soft Channel") field(INP, "$(P)$(IOC_NAME)GENERAL_ERROR_CHECK") field(ZNAM, "OFF") - field(ONAM, "ONE") + field(ONAM, "ON") } record(ao, "$(P)$(IOC_NAME)PRESSURE:SP"){ diff --git a/system_tests/tests/pearlpc.py b/system_tests/tests/pearlpc.py index cea450e..b7f8c18 100644 --- a/system_tests/tests/pearlpc.py +++ b/system_tests/tests/pearlpc.py @@ -49,129 +49,65 @@ def test_WHEN_secondary_ID_prefix_set_THEN_secondary_ID_prefix_read_back_correct def test_WHEN_id_prefixes_not_set_THEN_default_id_prefixes_read_back_correctly(self): self.ca.assert_that_pv_is("ID_PRESSURE", f"{self.default_id_prefix} {self.default_id_prefix}") + @parameterized.expand([ + ("EM_PRESSURE" ,"EM_PRESSURE", "BUFFER1.A", "Stop", 1), + ("RU_PRESSURE" ,"RU_PRESSURE", "BUFFER1.B", "Stop", 1), + ("RE_PRESSURE" ,"RE_PRESSURE", "BUFFER1.C", 1, 1), + ("St_PRESSURE" ,"St_PRESSURE", "BUFFER1.D", "Stopped", 1), + ("BY_PRESSURE" ,"BY_PRESSURE", "BUFFER1.E", "Active", 1), + ("GO_PRESSURE" ,"GO_PRESSURE", "BUFFER1.F", "TRUE", 1), + ("AM_PRESSURE" ,"AM_PRESSURE", "BUFFER1.G", "Auto", 1), + ("SL_PRESSURE" ,"SL_PRESSURE", "BUFFER1.H", "ON", 1), + ("SF_PRESSURE" ,"SF_PRESSURE", "BUFFER1.I", 1, 1), + ("ER_PRESSURE" ,"ER_PRESSURE", "BUFFER1.J", 1, 1), + ("PRESSURE", "PRESSURE", "BUFFER1.K", 1000, 1000), + ("MN_PRESSURE", "MN_PRESSURE", "BUFFER2.A", 1000, 1000), + ("SP_PRESSURE", "SP_PRESSURE", "BUFFER2.B", 1000, 1000), + ("MX_PRESSURE", "MX_PRESSURE", "BUFFER2.C", 1000, 1000) + ]) + def test_WHEN_pv_set_THEN_pv_and_buffer_readback_correctly(self, _, pv_record, buffer_location, setpoint_value, buffer_value): + self.ca.set_pv_value("{}:SP".format(pv_record), setpoint_value) + self.ca.assert_that_pv_is(pv_record, setpoint_value) + self.ca.assert_that_pv_is(buffer_location, buffer_value) + def test_WHEN_id_prefixes_set_THEN_id_prefixes_read_back_correctly(self): self.ca.set_pv_value("SI_PRESSURE:SP", self.pressure_value) self.ca.set_pv_value("SD_PRESSURE:SP", self.pressure_value) self.ca.assert_that_pv_is("ID_PRESSURE", f"{self.pressure_value} {self.pressure_value}") - - def test_WHEN_em_stop_bit_set_THEN_em_stop_bit_value_read_back_correctly(self): - self.ca.assert_that_pv_is("BUFFER1.A", self.default_initial_value) - self.ca.set_pv_value("EM_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("EM_PRESSURE:SP.RVAL", self.set_loop_status) - self.ca.assert_that_pv_is("BUFFER1.A", self.set_loop_status) - - def test_WHEN_run_bit_set_THEN_run_bit_read_back_correctly(self): - self.ca.assert_that_pv_is("BUFFER1.B", self.default_initial_value) - self.ca.set_pv_value("RU_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("RU_PRESSURE:SP.RVAL", self.set_loop_status) - self.ca.assert_that_pv_is("BUFFER1.B", self.set_loop_status) - - def test_WHEN_reset_value_set_THEN_reset_value_read_back_correctly(self): - self.ca.assert_that_pv_is("BUFFER1.C", self.default_initial_value) - self.ca.set_pv_value("RE_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("RE_PRESSURE", self.set_loop_status) - self.ca.assert_that_pv_is("BUFFER1.C", self.set_loop_status) - - def test_WHEN_stop_bit_set_THEN_stop_bit_value_read_back_correctly(self): - self.ca.assert_that_pv_is("BUFFER1.D", self.default_initial_value) - self.ca.set_pv_value("St_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("St_PRESSURE:SP.RVAL", self.set_loop_status) - self.ca.assert_that_pv_is("BUFFER1.D", self.set_loop_status) - - def test_WHEN_busy_bit_set_THEN_busy_bit_read_back_correctly(self): - self.ca.assert_that_pv_is("BUFFER1.E", self.default_initial_value) - self.ca.set_pv_value("BY_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("BY_PRESSURE:SP.RVAL", self.set_loop_status) - self.ca.assert_that_pv_is("BUFFER1.E", self.set_loop_status) - - def test_WHEN_GO_status_set_THEN_GO_status_read_back_correctly(self): - self.ca.assert_that_pv_is("BUFFER1.F", self.default_initial_value) - self.ca.set_pv_value("GO_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("GO_PRESSURE:SP.RVAL", self.set_loop_status) - self.ca.assert_that_pv_is("BUFFER1.F", self.set_loop_status) - - def test_WHEN_AM_mode_set_THEN_AM_mode_read_back_correctly(self): - self.ca.assert_that_pv_is("BUFFER1.G", self.default_initial_value) - self.ca.set_pv_value("AM_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("AM_PRESSURE:SP.RVAL", self.set_loop_status) - self.ca.assert_that_pv_is("BUFFER1.G", self.set_loop_status) - - def test_WHEN_loop_mode_set_THEN_loop_mode_read_back_correctly(self): - self.ca.assert_that_pv_is("BUFFER1.H", self.default_initial_value) - self.ca.set_pv_value("SL_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("SL_PRESSURE:SP.RVAL", self.set_loop_status) - self.ca.assert_that_pv_is("BUFFER1.H", self.set_loop_status) - - def test_WHEN_Seal_Fail_pressure_set_THEN_Seal_Fail_pressure_read_back_correctly(self): - self.ca.assert_that_pv_is("BUFFER1.I", self.default_initial_value) - self.ca.set_pv_value("SF_PRESSURE:SP", self.pressure_value) - self.ca.assert_that_pv_is("SF_PRESSURE", self.pressure_value) - self.ca.assert_that_pv_is("BUFFER1.I", self.pressure_value) - - def test_WHEN_er_last_error_code_set_THEN_er_last_error_code_read_back_correctly(self): - self.ca.assert_that_pv_is("BUFFER1.J", self.default_initial_value) - self.ca.set_pv_value("ER_PRESSURE:SP", self.set_loop_status) - self.ca.assert_that_pv_is("ER_PRESSURE", self.set_loop_status) - self.ca.assert_that_pv_is("BUFFER1.J", self.set_loop_status) - - def test_WHEN_pressure_set_THEN_pressure_read_back_correctly(self): - self.ca.assert_that_pv_is("BUFFER1.K", self.default_initial_value) - self.ca.set_pv_value("PRESSURE:SP", self.pressure_value) - self.ca.assert_that_pv_is("PRESSURE", self.pressure_value) - self.ca.assert_that_pv_is("BUFFER1.K", self.pressure_value) - - # def test_WHEN_pressure_set_THEN_min_and_max_drv_fields_set_correctly(self): - - # self.ca.set_pv_value("MX_PRESSURE:SP", 100) - # self.ca.set_pv_value("PRESSURE:SP", self.pressure_value) - # self.ca.assert_that_pv_is("PRESSURE:SP.DRVL", 10) - # self.ca.assert_that_pv_is("PRESSURE:SP.DRVH", 1000) - # pass def test_WHEN_pressure_set_lower_than_drvl_field_THEN_read_back_correctly(self): self.ca.set_pv_value("MN_PRESSURE:SP", 10) self.ca.set_pv_value("PRESSURE:SP", 5) self.ca.assert_that_pv_is("PRESSURE", 10) - def test_WHEN_min_pressure_set_THEN_min_pressure_read_back_correctly(self): - self.ca.assert_that_pv_is("BUFFER2.A", self.default_initial_value) - self.ca.set_pv_value("MN_PRESSURE:SP", self.pressure_value) - self.ca.assert_that_pv_is("MN_PRESSURE", self.pressure_value) - self.ca.assert_that_pv_is("BUFFER2.A", self.pressure_value) - - def test_WHEN_setpoint_pressure_set_THEN_setpoint_pressure_read_back_correctly(self): - self.ca.assert_that_pv_is("BUFFER2.B", self.default_initial_value) - self.ca.set_pv_value("SP_PRESSURE:SP", self.pressure_value) - self.ca.assert_that_pv_is("SP_PRESSURE", self.pressure_value) - self.ca.assert_that_pv_is("BUFFER2.B", self.pressure_value) - - def test_WHEN_max_pressure_set_THEN_max_pressure_set_correctly(self): - self.ca.assert_that_pv_is("BUFFER2.C", self.default_initial_value) - self.ca.set_pv_value("MX_PRESSURE:SP", self.pressure_value) - self.ca.assert_that_pv_is("MX_PRESSURE", self.pressure_value) - self.ca.assert_that_pv_is("BUFFER2.C", self.pressure_value) - def test_WHEN_reset_bit_value_set_THEN_reset_bit_value_read_back_correctly_HIGH_PRESSURE(self): self.ca.set_pv_value("RESET_PRESSURE:SP", 0) self.ca.set_pv_value("MN_PRESSURE:SP", 10) - self.ca.set_pv_value("PRESSURE:SP", 1000) - self.ca.set_pv_value("PRESSURE:SP", 500) - self.ca.assert_that_pv_is("PRESSURE", 500) + self.ca.assert_setting_setpoint_sets_readback(500, "PRESSURE") self.ca.set_pv_value("RESET_PRESSURE:SP", 1) self.ca.assert_that_pv_is("RESET_PRESSURE", "RESET") - # def test_WHEN_reset_bit_value_set_THEN_reset_bit_value_read_back_correctly_CLOSED(self): - # self.ca.assert_that_pv_is("RESET_PRESSURE", "RESETTING") - + def test_WHEN_General_error_occurs_THEN_general_error_readback_correctly(self): + self.ca.assert_that_pv_is("GENERAL_ERROR", "OFF") + # self.ca.assert_setting_setpoint_sets_readback("GENERAL_ERROR", 1) + self.ca.set_pv_value("ER_PRESSURE:SP", 1) + self.ca.assert_that_pv_is("GENERAL_ERROR", "ON") + + #TODO: Rework Test + # def test_WHEN_pressure_decreasing_THEN_decreasing_pressure_readback_correctly(self): + # self.ca.set_pv_value("PRESSURE:SP", 100) + # self.ca.set_pv_value("PRESSURE:SP", 95) + # self.ca.set_pv_value("PRESSURE:SP", 90) + # self.ca.set_pv_value("PRESSURE:SP", 70) + # self.ca.assert_that_pv_is("DECREASING_PRESSURE", "one_name") + + #TODO: Complete intial buffer value checks + # def test_WHEN_np_pv_set_THEN_intitial_buffer_value_readback_correctly(self): + # pass - def test_WHEN_pressure_value_increases_THEN_increasing_pressure_record_processed(self): - pass + #TODO: Complete status return readback test + # def test_WHEN_all_pvs_set_THEN_status_readback_correctly(self): + # pass - def test_WHEN_pressure_value_decreases_THEN_decreasing_pressure_record_processed(self): - pass - def test_WHEN_pressure_changed_THEN_pressure_comparison_with_previous_value_processed(self): - pass - def test_WHEN_pv_values_set_THEN_interface_status_readback_correctly(self): - pass From 91abd09524e40ac19e1749d89aa88e712d393687 Mon Sep 17 00:00:00 2001 From: JackEAllen Date: Tue, 21 Sep 2021 14:44:04 +0100 Subject: [PATCH 10/12] system test cleanup and EPICS Logic rework --- PearlPCSup/PearlPC.proto | 11 +++++- PearlPCSup/devPearl.db | 67 ++++++++++++++++++++++++----------- system_tests/tests/pearlpc.py | 46 +++++++++++++++--------- 3 files changed, 87 insertions(+), 37 deletions(-) diff --git a/PearlPCSup/PearlPC.proto b/PearlPCSup/PearlPC.proto index 7f6515b..498af1a 100644 --- a/PearlPCSup/PearlPC.proto +++ b/PearlPCSup/PearlPC.proto @@ -3,10 +3,19 @@ InTerminator = "\r\r\n"; ReplyTimeout = 2000; +# get_st { +# out "st"; +# in "%(\$1.A)d %(\$1.B)d %(\$1.C)d %(\$1.D)d %(\$1.E)d %(\$1.F)d %(\$1.G)d %(\$1.H)d %(\$1.I)d %(\$1.J)d %(\$1.K)d %(\$2.A)d %(\$2.B)d %(\$2.C)d %(\$2.D)d"; +# } + get_st { out "st"; - in "%(\$1.A)d %(\$1.B)d %(\$1.C)d %(\$1.D)d %(\$1.E)d %(\$1.F)d %(\$1.G)d %(\$1.H)d %(\$1.I)d %(\$1.J)d %(\$1.K)d %(\$2.A)d %(\$2.B)d %(\$2.C)d %(\$2.D)d"; + in "%(\$1.A \$1.B \$1.C \$1.D \$1.E \$1.F \$1.G \$1.H \$1.I \$1.J \$1.K \$2.A \$2.B \$2.C \$2.D)d"; } +# get_st { +# out "st"; +# in "%(\$1.K)d"; +# } set_ra{ out "ra%#04d" diff --git a/PearlPCSup/devPearl.db b/PearlPCSup/devPearl.db index 2fe9d16..4344f40 100644 --- a/PearlPCSup/devPearl.db +++ b/PearlPCSup/devPearl.db @@ -28,6 +28,25 @@ record(ai, "$(P)$(IOC_NAME)STATUS"){ field(FLNK, "$(P)$(IOC_NAME)BUFFER1") } +# record(aai, "$(P)$(IOC_NAME)STATUS"){ +# field(DESC, "Get Pressure Device Status") +# field(DTYP, "stream") +# field(NELM, "14") +# field(FTVL, "SHORT") +# field(INP, "@PearlPC.proto get_st($(P)$(IOC_NAME)BUFFER1, $(P)$(IOC_NAME)BUFFER2) $(PORT)") +# field(SCAN, "1 second") +# field(FLNK, "$(P)$(IOC_NAME)BUFFER1") +# } + +record(stringin, "$(P)$(IOC_NAME)RETURN_STATUS"){ + # TODO: return st string + field(DESC, "Get Pressure Device Status") + field(DTYP, "stream") + field(INP, "@PearlPC.proto get_st_array($(P)$(IOC_NAME)BUFFER1, $(P)$(IOC_NAME)BUFFER2) $(PORT)") + field(SCAN, "1 second") + field(FLNK, "$(P)$(IOC_NAME)BUFFER1") +} + record(ao, "$(P)$(IOC_NAME)SI_PRESSURE:SP"){ field(DESC, "Set initial ID prefix") field(DTYP, "stream") @@ -83,11 +102,13 @@ record(ao, "$(P)$(IOC_NAME)RE_PRESSURE:SP") { field(DESC, "Reset stage for each piston") field(DTYP, "stream") field(OUT, "@PearlPC.proto set_re $(PORT)") + field(FLNK, "$(P)$(IOC_NAME)RE_PRESSURE CP") } record(ai, "$(P)$(IOC_NAME)RE_PRESSURE"){ field(DESC, "Reset stage for each piston") - field(INP, "$(P)$(IOC_NAME)BUFFER1.C CP MS") + field(INP, "$(P)$(IOC_NAME)RE_PRESSURE:SP") + # field(INP, "$(P)$(IOC_NAME)BUFFER1.C CP MS") field(DTYP, "Soft Channel") } @@ -266,8 +287,8 @@ record(calcout, "$(P)$(IOC_NAME)DECREASING_PRESSURE_CHECK") { record(bi, "$(P)$(IOC_NAME)DECREASING_PRESSURE") { field(DESC, "Pressure decreasing") - field(ZNAM, "zero_name") - field(ONAM, "one_name") + field(ZNAM, "Nominal") + field(ONAM, "Decreasing") field(INP, "$(P)$(IOC_NAME)DECREASING_PRESSURE_CHECK") } @@ -280,8 +301,8 @@ record(calcout, "$(P)$(IOC_NAME)INCREASING_PRESSURE_CHECK") { record(bi, "$(P)$(IOC_NAME)INCREASING_PRESSURE") { field(DESC, "Pressure increasing") - field(ZNAM, "zero_name") - field(ONAM, "one_name") + field(ZNAM, "Nominal") + field(ONAM, "Increasing") field(INP, "$(P)$(IOC_NAME)INCREASING_PRESSURE_CHECK") } @@ -376,31 +397,37 @@ record(bi, "$(P)$(IOC_NAME)RESET_PRESSURE_TOO_HIGH") { field(ONAM, "HIGH") } -record(mbbo, "PRESSURE_RESTART_STAGES") { +record(mbbi, "PRESSURE_RESTART_STAGES") { + field(DESC, "Get stage of pressure restart") + field(INP, "$(P)$(IOC_NAME)BUFFER1.C CP MS") + field(ZRST, "Not Resetting or Purging") field(ZRVL, "0") + field(ONST, "Reset complete – now power down!") field(ONVL, "1") + field(TWST, "Resetting") field(TWVL, "2") + field(THST, "Purge done") field(THVL, "3") + field(FRST, "Purging") field(FRVL, "4") +} + +record(mbbo, "$(P)$(IOC_NAME)PRESSURE_RESTART_STAGES:SP") { field(DESC, "Display stages of pressure restart") - field(DTYP, "Soft Channel") - field(OUT, "$(dev):range PP") - field(ONVL, "0") - field(TWVL, "1") - field(THVL, "2") - field(FRVL, "3") - field(FVVL, "4") - field(ONST, "Not Resetting or Purging") - field(TWST, "Reset complete – now power down!") - field(THST, "Resetting") - field(FRST, "Purge done") - field(FVST, "Purging") + field(DTYP, "Soft Channel") + field(OUT, "@PearlPC.proto set_reset_pistons $(PORT)") + field(ZRST, "Not Resetting or Purging" ) field(ZRVL, "0") + field(ONST, "Reset complete – now power down!") field(ONVL, "1") + field(TWST, "Resetting") field(TWVL, "2") + field(THST, "Purge done") field(THVL, "3") + field(FRST, "Purging") field(FRVL, "4") } record(calcout, "$(P)$(IOC_NAME)READY_STATE_CHECKS") { field(DESC, "Ready state check validation") - field(CALC, "!A & !B & !C & !D & !E & !F") + field(CALC, "(!A & !B & !C & !D & !E & !F)? 1:0") field(INPA, "$(P)$(IOC_NAME)RESET_PRESSURE") # Not restarting must be 0 field(INPB, "$(P)$(IOC_NAME)SF_MODE_PRESSURE") # Not in Seal fail must be 0/RVAl OFF field(INPC, "$(P)$(IOC_NAME)ER_PRESSURE") # General error must be 0 field(INPE, "$(P)$(IOC_NAME)INCREASING_PRESSURE") # Must be 0 - no increase field(INPF, "$(P)$(IOC_NAME)DECREASING_PRESSURE") # Must be 0 - no decrease - field(OUT, "$(P)$(IOC_NAME)READY_STATE CP") + # field(OUT, "$(P)$(IOC_NAME)READY_STATE CP") + field(FLNK, "$(P)$(IOC_NAME)READY_STATE CP") field(SCAN, "1 second") } diff --git a/system_tests/tests/pearlpc.py b/system_tests/tests/pearlpc.py index b7f8c18..181b840 100644 --- a/system_tests/tests/pearlpc.py +++ b/system_tests/tests/pearlpc.py @@ -38,17 +38,6 @@ def setUp(self): self.lewis, self.ioc = get_running_lewis_and_ioc(DEVICE_A_PREFIX, DEVICE_A_PREFIX) self.ca = ChannelAccess(default_timeout=20, default_wait_time=0.0, device_prefix=DEVICE_A_PREFIX) - def test_WHEN_initial_ID_prefix_set_THEN_initial_ID_prefix_read_back_correctly(self): - self.ca.set_pv_value("SI_PRESSURE:SP", self.pressure_value) - self.ca.assert_that_pv_is("SI_PRESSURE:SP", self.pressure_value) - - def test_WHEN_secondary_ID_prefix_set_THEN_secondary_ID_prefix_read_back_correctly(self): - self.ca.set_pv_value("SD_PRESSURE:SP", self.pressure_value) - self.ca.assert_that_pv_is("SD_PRESSURE:SP", self.pressure_value) - - def test_WHEN_id_prefixes_not_set_THEN_default_id_prefixes_read_back_correctly(self): - self.ca.assert_that_pv_is("ID_PRESSURE", f"{self.default_id_prefix} {self.default_id_prefix}") - @parameterized.expand([ ("EM_PRESSURE" ,"EM_PRESSURE", "BUFFER1.A", "Stop", 1), ("RU_PRESSURE" ,"RU_PRESSURE", "BUFFER1.B", "Stop", 1), @@ -70,6 +59,18 @@ def test_WHEN_pv_set_THEN_pv_and_buffer_readback_correctly(self, _, pv_record, b self.ca.assert_that_pv_is(pv_record, setpoint_value) self.ca.assert_that_pv_is(buffer_location, buffer_value) + def test_WHEN_initial_ID_prefix_set_THEN_initial_ID_prefix_read_back_correctly(self): + self.ca.set_pv_value("SI_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("SI_PRESSURE:SP", self.pressure_value) + # self.ca.assert_setting_setpoint_sets_readback(self.pressure_value, "SI_PRESSURE") + + def test_WHEN_secondary_ID_prefix_set_THEN_secondary_ID_prefix_read_back_correctly(self): + self.ca.set_pv_value("SD_PRESSURE:SP", self.pressure_value) + self.ca.assert_that_pv_is("SD_PRESSURE:SP", self.pressure_value) + + def test_WHEN_id_prefixes_not_set_THEN_default_id_prefixes_read_back_correctly(self): + self.ca.assert_that_pv_is("ID_PRESSURE", f"{self.default_id_prefix} {self.default_id_prefix}") + def test_WHEN_id_prefixes_set_THEN_id_prefixes_read_back_correctly(self): self.ca.set_pv_value("SI_PRESSURE:SP", self.pressure_value) self.ca.set_pv_value("SD_PRESSURE:SP", self.pressure_value) @@ -95,11 +96,12 @@ def test_WHEN_General_error_occurs_THEN_general_error_readback_correctly(self): #TODO: Rework Test # def test_WHEN_pressure_decreasing_THEN_decreasing_pressure_readback_correctly(self): - # self.ca.set_pv_value("PRESSURE:SP", 100) - # self.ca.set_pv_value("PRESSURE:SP", 95) - # self.ca.set_pv_value("PRESSURE:SP", 90) - # self.ca.set_pv_value("PRESSURE:SP", 70) - # self.ca.assert_that_pv_is("DECREASING_PRESSURE", "one_name") + # pass + # self.ca.set_pv_value("PRESSURE:SP", 100) + # self.ca.set_pv_value("PRESSURE:SP", 95) + # self.ca.set_pv_value("PRESSURE:SP", 90) + # self.ca.set_pv_value("PRESSURE:SP", 70) + # self.ca.assert_that_pv_is("DECREASING_PRESSURE", "one_name") #TODO: Complete intial buffer value checks # def test_WHEN_np_pv_set_THEN_intitial_buffer_value_readback_correctly(self): @@ -109,5 +111,17 @@ def test_WHEN_General_error_occurs_THEN_general_error_readback_correctly(self): # def test_WHEN_all_pvs_set_THEN_status_readback_correctly(self): # pass + # def test_WHEN_correct_conditions_met_THEN_device_ready_state_readback_correctly(self): + # # self._lewis.backdoor_set_on_device("READY_STATE", "READY") + # # self.log.debug() + # # self.ca.assert_that_pv_is("RESET_PRESSURE", 1) + # # self.lewis.backdoor_set_on_device("READY_STATE_CHECKS", 0) + + # self.ca.assert_that_pv_is("READY_STATE", "READY") + + def test_WHEN_conditions_are_not_met_THEN_device_ready_state_readback_correctly(self): + self.ca.set_pv_value("RESET_PRESSURE", 1) + self.ca.assert_that_pv_is("READY_STATE", "NOT READY") + From d7d7672843e939403cb6acaebf2071c892e43762 Mon Sep 17 00:00:00 2001 From: JackEAllen Date: Tue, 21 Sep 2021 17:31:38 +0100 Subject: [PATCH 11/12] Return status DB logic and corresponding test --- PearlPCSup/PearlPC.proto | 16 +++++------- PearlPCSup/devPearl.db | 47 +++++++++++++++++++---------------- system_tests/tests/pearlpc.py | 4 +++ 3 files changed, 36 insertions(+), 31 deletions(-) diff --git a/PearlPCSup/PearlPC.proto b/PearlPCSup/PearlPC.proto index 498af1a..d4e706c 100644 --- a/PearlPCSup/PearlPC.proto +++ b/PearlPCSup/PearlPC.proto @@ -3,19 +3,15 @@ InTerminator = "\r\r\n"; ReplyTimeout = 2000; -# get_st { -# out "st"; -# in "%(\$1.A)d %(\$1.B)d %(\$1.C)d %(\$1.D)d %(\$1.E)d %(\$1.F)d %(\$1.G)d %(\$1.H)d %(\$1.I)d %(\$1.J)d %(\$1.K)d %(\$2.A)d %(\$2.B)d %(\$2.C)d %(\$2.D)d"; -# } - get_st { out "st"; - in "%(\$1.A \$1.B \$1.C \$1.D \$1.E \$1.F \$1.G \$1.H \$1.I \$1.J \$1.K \$2.A \$2.B \$2.C \$2.D)d"; + in "%(\$1.A)d %(\$1.B)d %(\$1.C)d %(\$1.D)d %(\$1.E)d %(\$1.F)d %(\$1.G)d %(\$1.H)d %(\$1.I)d %(\$1.J)d %(\$1.K)d %(\$2.A)d %(\$2.B)d %(\$2.C)d %(\$2.D)d"; +} + +get_st_array { + out "st"; + in "%d"; } -# get_st { -# out "st"; -# in "%(\$1.K)d"; -# } set_ra{ out "ra%#04d" diff --git a/PearlPCSup/devPearl.db b/PearlPCSup/devPearl.db index 4344f40..f9cf9e0 100644 --- a/PearlPCSup/devPearl.db +++ b/PearlPCSup/devPearl.db @@ -20,6 +20,19 @@ record(calc, "$(P)$(IOC_NAME)BUFFER2"){ field(INPL, "$(P)$(IOC_NAME)STATUS") } +# record(scalcout, "$(P)$(IOC_NAME)BUFFER1"){ +# field(DESC, "Buffer 1 status values A-K") +# field(CALC, "L = A + B + C + D + E + F + G + H + I + J + K") +# field(INPL, "$(P)$(IOC_NAME)STATUS") +# field(FLNK, "$(P)$(IOC_NAME)BUFFER2") +# } + +# record(scalcout, "$(P)$(IOC_NAME)BUFFER2"){ +# field(DESC, "Buffer 2 status values A-D") +# field(CALC, "L = A + B + C + D + E + F + G + H + I + J + K") +# field(INPL, "$(P)$(IOC_NAME)STATUS") +# } + record(ai, "$(P)$(IOC_NAME)STATUS"){ field(DESC, "Get Pressure Device Status") field(DTYP, "stream") @@ -28,6 +41,15 @@ record(ai, "$(P)$(IOC_NAME)STATUS"){ field(FLNK, "$(P)$(IOC_NAME)BUFFER1") } +record(waveform, "$(P)$(IOC_NAME)record_name") { + field(DESC, "Return status") + field(DTYP, "stream") + field(INP, "@PearlPC.proto get_st_array $(PORT)") + field(NELM, "15") + field(SCAN, "1 second") + field(FTVL, "DOUBLE") +} + # record(aai, "$(P)$(IOC_NAME)STATUS"){ # field(DESC, "Get Pressure Device Status") # field(DTYP, "stream") @@ -38,14 +60,7 @@ record(ai, "$(P)$(IOC_NAME)STATUS"){ # field(FLNK, "$(P)$(IOC_NAME)BUFFER1") # } -record(stringin, "$(P)$(IOC_NAME)RETURN_STATUS"){ - # TODO: return st string - field(DESC, "Get Pressure Device Status") - field(DTYP, "stream") - field(INP, "@PearlPC.proto get_st_array($(P)$(IOC_NAME)BUFFER1, $(P)$(IOC_NAME)BUFFER2) $(PORT)") - field(SCAN, "1 second") - field(FLNK, "$(P)$(IOC_NAME)BUFFER1") -} +# record(ao, "$(P)$(IOC_NAME)SI_PRESSURE:SP"){ field(DESC, "Set initial ID prefix") @@ -397,7 +412,9 @@ record(bi, "$(P)$(IOC_NAME)RESET_PRESSURE_TOO_HIGH") { field(ONAM, "HIGH") } -record(mbbi, "PRESSURE_RESTART_STAGES") { +# THis record is currently not processed +# The device should populate this PV after reset command set to 1 +record(mbbi, "$(P)$(IOC_NAME)PRESSURE_RESTART_STAGES") { field(DESC, "Get stage of pressure restart") field(INP, "$(P)$(IOC_NAME)BUFFER1.C CP MS") field(ZRST, "Not Resetting or Purging") field(ZRVL, "0") @@ -407,17 +424,6 @@ record(mbbi, "PRESSURE_RESTART_STAGES") { field(FRST, "Purging") field(FRVL, "4") } -record(mbbo, "$(P)$(IOC_NAME)PRESSURE_RESTART_STAGES:SP") { - field(DESC, "Display stages of pressure restart") - field(DTYP, "Soft Channel") - field(OUT, "@PearlPC.proto set_reset_pistons $(PORT)") - field(ZRST, "Not Resetting or Purging" ) field(ZRVL, "0") - field(ONST, "Reset complete – now power down!") field(ONVL, "1") - field(TWST, "Resetting") field(TWVL, "2") - field(THST, "Purge done") field(THVL, "3") - field(FRST, "Purging") field(FRVL, "4") -} - record(calcout, "$(P)$(IOC_NAME)READY_STATE_CHECKS") { field(DESC, "Ready state check validation") field(CALC, "(!A & !B & !C & !D & !E & !F)? 1:0") @@ -426,7 +432,6 @@ record(calcout, "$(P)$(IOC_NAME)READY_STATE_CHECKS") { field(INPC, "$(P)$(IOC_NAME)ER_PRESSURE") # General error must be 0 field(INPE, "$(P)$(IOC_NAME)INCREASING_PRESSURE") # Must be 0 - no increase field(INPF, "$(P)$(IOC_NAME)DECREASING_PRESSURE") # Must be 0 - no decrease - # field(OUT, "$(P)$(IOC_NAME)READY_STATE CP") field(FLNK, "$(P)$(IOC_NAME)READY_STATE CP") field(SCAN, "1 second") } diff --git a/system_tests/tests/pearlpc.py b/system_tests/tests/pearlpc.py index 181b840..2bb0c53 100644 --- a/system_tests/tests/pearlpc.py +++ b/system_tests/tests/pearlpc.py @@ -94,6 +94,10 @@ def test_WHEN_General_error_occurs_THEN_general_error_readback_correctly(self): self.ca.set_pv_value("ER_PRESSURE:SP", 1) self.ca.assert_that_pv_is("GENERAL_ERROR", "ON") + def test_WHEN_value_set_THEN_status_readback_correctly(self): + self.ca.set_pv_value("PRESSURE:SP", 500) + self.ca.assert_that_pv_is("STATUS_ARRAY.RVAL", "1 0 0 0 0 0 0 0 0 0 500 0 0 0") + #TODO: Rework Test # def test_WHEN_pressure_decreasing_THEN_decreasing_pressure_readback_correctly(self): # pass From aa30f0e1ab53480933c6ca872d06cbfb80101f8c Mon Sep 17 00:00:00 2001 From: JackEAllen Date: Wed, 29 Sep 2021 15:29:56 +0100 Subject: [PATCH 12/12] Update db return status logic and corresponding system tests --- PearlPCSup/devPearl.db | 36 +++---------------- .../lewis_emulators/PearlPC/device.py | 35 +++++++++--------- system_tests/tests/pearlpc.py | 36 +++++-------------- 3 files changed, 32 insertions(+), 75 deletions(-) diff --git a/PearlPCSup/devPearl.db b/PearlPCSup/devPearl.db index f9cf9e0..8123c40 100644 --- a/PearlPCSup/devPearl.db +++ b/PearlPCSup/devPearl.db @@ -20,19 +20,6 @@ record(calc, "$(P)$(IOC_NAME)BUFFER2"){ field(INPL, "$(P)$(IOC_NAME)STATUS") } -# record(scalcout, "$(P)$(IOC_NAME)BUFFER1"){ -# field(DESC, "Buffer 1 status values A-K") -# field(CALC, "L = A + B + C + D + E + F + G + H + I + J + K") -# field(INPL, "$(P)$(IOC_NAME)STATUS") -# field(FLNK, "$(P)$(IOC_NAME)BUFFER2") -# } - -# record(scalcout, "$(P)$(IOC_NAME)BUFFER2"){ -# field(DESC, "Buffer 2 status values A-D") -# field(CALC, "L = A + B + C + D + E + F + G + H + I + J + K") -# field(INPL, "$(P)$(IOC_NAME)STATUS") -# } - record(ai, "$(P)$(IOC_NAME)STATUS"){ field(DESC, "Get Pressure Device Status") field(DTYP, "stream") @@ -41,27 +28,15 @@ record(ai, "$(P)$(IOC_NAME)STATUS"){ field(FLNK, "$(P)$(IOC_NAME)BUFFER1") } -record(waveform, "$(P)$(IOC_NAME)record_name") { +record(waveform, "$(P)$(IOC_NAME)STATUS_ARRAY") { field(DESC, "Return status") field(DTYP, "stream") field(INP, "@PearlPC.proto get_st_array $(PORT)") field(NELM, "15") field(SCAN, "1 second") - field(FTVL, "DOUBLE") + field(FTVL, "SHORT") } -# record(aai, "$(P)$(IOC_NAME)STATUS"){ -# field(DESC, "Get Pressure Device Status") -# field(DTYP, "stream") -# field(NELM, "14") -# field(FTVL, "SHORT") -# field(INP, "@PearlPC.proto get_st($(P)$(IOC_NAME)BUFFER1, $(P)$(IOC_NAME)BUFFER2) $(PORT)") -# field(SCAN, "1 second") -# field(FLNK, "$(P)$(IOC_NAME)BUFFER1") -# } - -# - record(ao, "$(P)$(IOC_NAME)SI_PRESSURE:SP"){ field(DESC, "Set initial ID prefix") field(DTYP, "stream") @@ -123,7 +98,6 @@ record(ao, "$(P)$(IOC_NAME)RE_PRESSURE:SP") { record(ai, "$(P)$(IOC_NAME)RE_PRESSURE"){ field(DESC, "Reset stage for each piston") field(INP, "$(P)$(IOC_NAME)RE_PRESSURE:SP") - # field(INP, "$(P)$(IOC_NAME)BUFFER1.C CP MS") field(DTYP, "Soft Channel") } @@ -250,7 +224,7 @@ record(ai, "$(P)$(IOC_NAME)ER_PRESSURE"){ } record(calcout, "$(P)$(IOC_NAME)GENERAL_ERROR_CHECK") { - field(DESC, "Check if error code higher than 0 present") + field(DESC, "Check error code < 0 present") field(CALC, "A != 0? 1 : 0") field(INPA, "$(P)$(IOC_NAME)ER_PRESSURE") field(FLNK, "$(P)$(IOC_NAME)GENERAL_ERROR") @@ -412,13 +386,13 @@ record(bi, "$(P)$(IOC_NAME)RESET_PRESSURE_TOO_HIGH") { field(ONAM, "HIGH") } -# THis record is currently not processed +# This record is currently not processed # The device should populate this PV after reset command set to 1 record(mbbi, "$(P)$(IOC_NAME)PRESSURE_RESTART_STAGES") { field(DESC, "Get stage of pressure restart") field(INP, "$(P)$(IOC_NAME)BUFFER1.C CP MS") field(ZRST, "Not Resetting or Purging") field(ZRVL, "0") - field(ONST, "Reset complete – now power down!") field(ONVL, "1") + field(ONST, "Reset complete") field(ONVL, "1") field(TWST, "Resetting") field(TWVL, "2") field(THST, "Purge done") field(THVL, "3") field(FRST, "Purging") field(FRVL, "4") diff --git a/system_tests/lewis_emulators/PearlPC/device.py b/system_tests/lewis_emulators/PearlPC/device.py index 93ea0ca..d534394 100644 --- a/system_tests/lewis_emulators/PearlPC/device.py +++ b/system_tests/lewis_emulators/PearlPC/device.py @@ -7,6 +7,25 @@ class SimulatedCCD100(StateMachineDevice): def _initialize_data(self): + self.re_initialise() + + # When the device is in an error state it can respond with junk + self.is_giving_errors = False + self.out_error = "}{<7f>w" + self.out_terminator_in_error = "" + + def _get_state_handlers(self): + return { + 'default': DefaultState(), + } + + def _get_initial_state(self): + return 'default' + + def _get_transition_handlers(self): + return OrderedDict([]) + + def re_initialise(self): self.initial_id_prefix = "1111" self.secondary_id_prefix = "1111" self.em_stop_status = 0 # Bool [0-1] @@ -25,19 +44,3 @@ def _initialize_data(self): self.setpoint_value = 0 self.max_value_pre_servoing = 0 - # When the device is in an error state it can respond with junk - self.is_giving_errors = False - self.out_error = "}{<7f>w" - self.out_terminator_in_error = "" - - def _get_state_handlers(self): - return { - 'default': DefaultState(), - } - - def _get_initial_state(self): - return 'default' - - def _get_transition_handlers(self): - return OrderedDict([]) - diff --git a/system_tests/tests/pearlpc.py b/system_tests/tests/pearlpc.py index 2bb0c53..01131db 100644 --- a/system_tests/tests/pearlpc.py +++ b/system_tests/tests/pearlpc.py @@ -37,6 +37,7 @@ def setUp(self): self.low_pressure = 50 self.lewis, self.ioc = get_running_lewis_and_ioc(DEVICE_A_PREFIX, DEVICE_A_PREFIX) self.ca = ChannelAccess(default_timeout=20, default_wait_time=0.0, device_prefix=DEVICE_A_PREFIX) + self.lewis.backdoor_run_function_on_device("re_initialise") @parameterized.expand([ ("EM_PRESSURE" ,"EM_PRESSURE", "BUFFER1.A", "Stop", 1), @@ -62,7 +63,6 @@ def test_WHEN_pv_set_THEN_pv_and_buffer_readback_correctly(self, _, pv_record, b def test_WHEN_initial_ID_prefix_set_THEN_initial_ID_prefix_read_back_correctly(self): self.ca.set_pv_value("SI_PRESSURE:SP", self.pressure_value) self.ca.assert_that_pv_is("SI_PRESSURE:SP", self.pressure_value) - # self.ca.assert_setting_setpoint_sets_readback(self.pressure_value, "SI_PRESSURE") def test_WHEN_secondary_ID_prefix_set_THEN_secondary_ID_prefix_read_back_correctly(self): self.ca.set_pv_value("SD_PRESSURE:SP", self.pressure_value) @@ -90,38 +90,18 @@ def test_WHEN_reset_bit_value_set_THEN_reset_bit_value_read_back_correctly_HIGH_ def test_WHEN_General_error_occurs_THEN_general_error_readback_correctly(self): self.ca.assert_that_pv_is("GENERAL_ERROR", "OFF") - # self.ca.assert_setting_setpoint_sets_readback("GENERAL_ERROR", 1) self.ca.set_pv_value("ER_PRESSURE:SP", 1) self.ca.assert_that_pv_is("GENERAL_ERROR", "ON") def test_WHEN_value_set_THEN_status_readback_correctly(self): self.ca.set_pv_value("PRESSURE:SP", 500) - self.ca.assert_that_pv_is("STATUS_ARRAY.RVAL", "1 0 0 0 0 0 0 0 0 0 500 0 0 0") - - #TODO: Rework Test - # def test_WHEN_pressure_decreasing_THEN_decreasing_pressure_readback_correctly(self): - # pass - # self.ca.set_pv_value("PRESSURE:SP", 100) - # self.ca.set_pv_value("PRESSURE:SP", 95) - # self.ca.set_pv_value("PRESSURE:SP", 90) - # self.ca.set_pv_value("PRESSURE:SP", 70) - # self.ca.assert_that_pv_is("DECREASING_PRESSURE", "one_name") - - #TODO: Complete intial buffer value checks - # def test_WHEN_np_pv_set_THEN_intitial_buffer_value_readback_correctly(self): - # pass - - #TODO: Complete status return readback test - # def test_WHEN_all_pvs_set_THEN_status_readback_correctly(self): - # pass - - # def test_WHEN_correct_conditions_met_THEN_device_ready_state_readback_correctly(self): - # # self._lewis.backdoor_set_on_device("READY_STATE", "READY") - # # self.log.debug() - # # self.ca.assert_that_pv_is("RESET_PRESSURE", 1) - # # self.lewis.backdoor_set_on_device("READY_STATE_CHECKS", 0) - - # self.ca.assert_that_pv_is("READY_STATE", "READY") + self.ca.assert_that_pv_is("STATUS_ARRAY", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 0, 0, 0, 0]) + + def test_WHEN_np_pv_set_THEN_intitial_buffer_value_readback_correctly(self): + self.ca.assert_that_pv_is("STATUS_ARRAY", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) + + def test_WHEN_correct_conditions_met_THEN_device_ready_state_readback_correctly(self): + self.ca.assert_that_pv_is("READY_STATE", "READY") def test_WHEN_conditions_are_not_met_THEN_device_ready_state_readback_correctly(self): self.ca.set_pv_value("RESET_PRESSURE", 1)