From f9c9b5dba1a9e9b07c41a3ef70640ff14b010b57 Mon Sep 17 00:00:00 2001 From: Bernardo Carvalho Date: Fri, 25 Feb 2022 18:16:48 +0000 Subject: [PATCH] New temperature IOC ans systemd start script Signed-off-by: Bernardo Carvalho --- .../ISTTOKApp/Db/ISTTOKtemperature.db | 146 ++++++++++++++++++ epics/iocs/dsPICTemp/ISTTOKApp/Db/Makefile | 20 +++ epics/iocs/dsPICTemp/ISTTOKApp/Db/dspic.proto | 37 +++++ epics/iocs/dsPICTemp/ISTTOKApp/src/Makefile | 49 ++++++ .../iocBoot/iocISTTOK/isttok-temp-ioc.service | 24 +++ epics/iocs/dsPICTemp/iocBoot/iocISTTOK/st.cmd | 33 ++++ 6 files changed, 309 insertions(+) create mode 100644 epics/iocs/dsPICTemp/ISTTOKApp/Db/ISTTOKtemperature.db create mode 100644 epics/iocs/dsPICTemp/ISTTOKApp/Db/Makefile create mode 100644 epics/iocs/dsPICTemp/ISTTOKApp/Db/dspic.proto create mode 100644 epics/iocs/dsPICTemp/ISTTOKApp/src/Makefile create mode 100644 epics/iocs/dsPICTemp/iocBoot/iocISTTOK/isttok-temp-ioc.service create mode 100755 epics/iocs/dsPICTemp/iocBoot/iocISTTOK/st.cmd diff --git a/epics/iocs/dsPICTemp/ISTTOKApp/Db/ISTTOKtemperature.db b/epics/iocs/dsPICTemp/ISTTOKApp/Db/ISTTOKtemperature.db new file mode 100644 index 0000000..2deb96e --- /dev/null +++ b/epics/iocs/dsPICTemp/ISTTOKApp/Db/ISTTOKtemperature.db @@ -0,0 +1,146 @@ +################################################################### +# This records is the dspPIC uptime in seconds from last reset # +################################################################### +record(longin, "$(P)$(R)Uptime") +{ + field(DESC, "Reads dsPIC Uptime") + field(DTYP, "stream") + field(INP, "@dspic.proto getUP $(PORT)") + field(SCAN, "I/O Intr") + field(FLNK,"$(P)$(R)Diff_Uptime") #Link to update Diff_Uptime + field(ADEL,100) + field(MDEL,0) +} + +record(calc, "$(P)$(R)Diff_Uptime") { + field(DESC, "Uptime diff. between I/O Intr scans") + field(CALC,"B-A") + field(SCAN,"Passive") + field(INPA,"$(P)$(R)Last_Uptime.VAL NPP") + field(INPB,"$(P)$(R)Uptime") + field(FLNK,"$(P)$(R)Last_Uptime") + field(HIHI,"100.0") + field(HIGH,"2.0") + field(LOW, "0.0") + field(LOLO,"-10.0") +} + +record(calc, "$(P)$(R)Last_Uptime") { + field(DESC, "Last Uptime for diff. calc") + field(CALC,"A") + field(SCAN,"Passive") + field(INPA,"$(P)$(R)Uptime") +} +################################################################### +# These records read Temperatures # +################################################################### +record(ai, "$(P)$(R)VVessel-Temperature") +{ + field(DESC, "Reads TE01 Temperature") + field(DTYP, "stream") + field(INP, "@dspic.proto getTE01 $(PORT) $(A)") + field(SCAN, "I/O Intr") + field(EGU, "C") + field(PREC, "4") + field(LINR, "LINEAR") +# field(ESLO, "0.00001163358") +# See https://paulscherrerinstitute.github.io/StreamDevice/ai.html +# field(EGUL, "-1.02376") +# x 30 + field(ESLO, "0.000349007") + #field(EGUL, "-30.71") + field(EOFF, "-30.71") + field(HOPR, "140.0") + field(LOPR, "0.0") + field(HIHI,"120.0") + field(HIGH,"100.0") + field(LOW, "0.0") + field(LOLO,"-10.0") + field(HHSV,"MAJOR") + field(HSV, "MINOR") +# field(LSV, "MINOR") +# field(LLSV,"MAJOR") + field(ADEL, "1.0") # Archive Deadband +} +# Precision +# Engineering Units +# field(EGU, "Raw") +# Convertion +# val = val * ESLO + EGUL +# field(ESLO, "0.000011633582866550557") +# field(DESC,"Thermocouple 0") +# field(HIHI,"90.0") +# field(HIGH,"50.0") +# field(LOW, "20.0") +# field(LOLO,"0.0") +# field(HHSV,"MAJOR") +# field(HSV, "MINOR") +# field(LSV, "MINOR") +# field(LLSV,"MAJOR") +# field(MDEL, "0.0") # Monitor Deadband + +record(ai, "$(P)$(R)Temperature_1") +{ + field(DESC, "Reads TE02 Temperature") + field(DTYP, "stream") + field(INP, "@dspic.proto getTE02 $(PORT) $(A)") + field(SCAN, "I/O Intr") + field(EGU, "C") + field(PREC, "4") + field(LINR, "LINEAR") +# field(CALC,"A*0.000011633582866550557-1.02376") + field(ESLO, "0.00001163358") + field(EGUL, "-1.02376") +} +record(ai, "$(P)$(R)Temperature_2") +{ + field(DESC, "Reads TE03 Temperature") + field(DTYP, "stream") + field(INP, "@dspic.proto getTE03 $(PORT)") + field(SCAN, "I/O Intr") + field(EGU, "C") + field(PREC, "4") + field(LINR, "LINEAR") + field(ESLO, "0.00001163358") + field(EGUL, "-1.02376") +} +record(ai, "$(P)$(R)Temperature_3") { + field(DESC, "Reads TE04 Temperature") + field(DTYP, "stream") + field(INP, "@dspic.proto getTE04 $(PORT)") + field(SCAN, "I/O Intr") + field(EGU, "C") + field(PREC, "4") + field(LINR, "LINEAR") + field(ESLO, "0.00001163358") + field(EGUL, "-1.02376") +} +record(ai, "$(P)$(R)Capbank_Voltage") { + field(DESC, "Reads PRD01, Capitor bank Voltage PWM") + field(DTYP, "stream") + field(INP, "@dspic.proto getPRD01 $(PORT)") + field(SCAN, "I/O Intr") + field(LINR, "LINEAR") +# # val = val * ESLO + EGUL + field(ESLO, "1.0") + field(EGUL, "0.0") +# Precision + field(PREC, "1") + # Units + field(EGU, "V") +# # Alarms +} +record(stringin, $(P)$(R)idn) { + field(DESC, "Debug info blabla") + field(DTYP, "stream") + field(INP, "@dspic.proto getStr $(PORT) $(A)") + field(SCAN, "I/O Intr") +} + +record(stringin, "$(P)$(R)CurrentTime") { + field(DESC, "Current Date and Time of the IOC") + field(SCAN, "1 second") + field(DTYP, "Soft Timestamp") + field(PINI, "YES") + field(INP, "@%d/%m/%Y %H:%M:%S") +} diff --git a/epics/iocs/dsPICTemp/ISTTOKApp/Db/Makefile b/epics/iocs/dsPICTemp/ISTTOKApp/Db/Makefile new file mode 100644 index 0000000..552e85a --- /dev/null +++ b/epics/iocs/dsPICTemp/ISTTOKApp/Db/Makefile @@ -0,0 +1,20 @@ +TOP=../.. +include $(TOP)/configure/CONFIG +#---------------------------------------- +# ADD MACRO DEFINITIONS AFTER THIS LINE + +#---------------------------------------------------- +# Create and install (or just install) into /db +# databases, templates, substitutions like this +#DB += xxx.db +DB += ISTTOKtemperature.db +DB += dspic.proto + +#---------------------------------------------------- +# If .db template is not named *.template add +# _template = + +include $(TOP)/configure/RULES +#---------------------------------------- +# ADD RULES AFTER THIS LINE + diff --git a/epics/iocs/dsPICTemp/ISTTOKApp/Db/dspic.proto b/epics/iocs/dsPICTemp/ISTTOKApp/Db/dspic.proto new file mode 100644 index 0000000..8d930d7 --- /dev/null +++ b/epics/iocs/dsPICTemp/ISTTOKApp/Db/dspic.proto @@ -0,0 +1,37 @@ +# https://epics.anl.gov/tech-talk/2013/msg02051.php +Terminator = CR LF; +MaxInput = 110; +ReadTimeout = 200; +#ExtraInput = Ignore; + +getTE01 { + in "TE01_%10u TE02_%*10u %*80c"; +} + +getTE02 { +# in "TE01_%*s TE02_%10u TE03_%*10u %*70c"; + in "TE01_%*u TE02_%10u TE03_%*10u TE04_%*10u PRD01_%*10u UP_%*10u %*u %+"; +} + +getTE03 { +# in "TE01_%*s TE02_%*10u TE03_%10u %*80c"; + in "TE01_%*u TE02_%*10u TE03_%10u TE04_%*10u PRD01_%*10u UP_%*10u %*u %+"; +} + +getTE04 { +# in "TE01_%*s TE02_%*10u TE03_%*10u TE04_%10u %*40c"; + in "TE01_%*u TE02_%*10u TE03_%*10u TE04_%10u PRD01_%*10u UP_%*10u %*u %+"; +} + +getPRD01 { +# in "TE01_%*s TE02_%*10u TE03_%*10u TE04_%*10u PRD01_%10u %*30c"; + in "TE01_%*s TE02_%*10u TE03_%*10u TE04_%*10u PRD01_%10u UP_%*10u %*u %+"; +} + +getUP { + in "TE01_%*s TE02_%*10u TE03_%*10u TE04_%*10u PRD01_%*10u UP_%10u %*u %+"; +} + +getStr{ + in "TE01_%10s%*93c"; +} diff --git a/epics/iocs/dsPICTemp/ISTTOKApp/src/Makefile b/epics/iocs/dsPICTemp/ISTTOKApp/src/Makefile new file mode 100644 index 0000000..47b5507 --- /dev/null +++ b/epics/iocs/dsPICTemp/ISTTOKApp/src/Makefile @@ -0,0 +1,49 @@ +TOP=../.. + +include $(TOP)/configure/CONFIG +#---------------------------------------- +# ADD MACRO DEFINITIONS AFTER THIS LINE +#============================= + +#============================= +# Build the IOC application + +PROD_IOC = ISTTOK +# ISTTOK.dbd will be created and installed +DBD += ISTTOK.dbd + +# ISTTOK.dbd will be made up from these files: +ISTTOK_DBD += base.dbd + +# Include dbd files from all support applications: +#ISTTOK_DBD += xxx.dbd +ISTTOK_DBD += asyn.dbd +ISTTOK_DBD += drvAsynSerialPort.dbd +ISTTOK_DBD += calc.dbd +ISTTOK_DBD += stream.dbd + +# Add all the support libraries needed by this IOC +#ISTTOK_LIBS += xxx +ISTTOK_LIBS += asyn +ISTTOK_LIBS += calc +ISTTOK_LIBS += stream + +# ISTTOK_registerRecordDeviceDriver.cpp derives from ISTTOK.dbd +ISTTOK_SRCS += ISTTOK_registerRecordDeviceDriver.cpp + +# Build the main IOC entry point on workstation OSs. +ISTTOK_SRCS_DEFAULT += ISTTOKMain.cpp +ISTTOK_SRCS_vxWorks += -nil- + +# Add support from base/src/vxWorks if needed +#ISTTOK_OBJS_vxWorks += $(EPICS_BASE_BIN)/vxComLibrary + +# Finally link to the EPICS Base libraries +ISTTOK_LIBS += $(EPICS_BASE_IOC_LIBS) + +#=========================== + +include $(TOP)/configure/RULES +#---------------------------------------- +# ADD RULES AFTER THIS LINE + diff --git a/epics/iocs/dsPICTemp/iocBoot/iocISTTOK/isttok-temp-ioc.service b/epics/iocs/dsPICTemp/iocBoot/iocISTTOK/isttok-temp-ioc.service new file mode 100644 index 0000000..5c9d80b --- /dev/null +++ b/epics/iocs/dsPICTemp/iocBoot/iocISTTOK/isttok-temp-ioc.service @@ -0,0 +1,24 @@ +#https://epics-controls.org/resources-and-support/documents/howto-documents/posix-thread-priority/ +# 1) install procserv and telnet +# put this file in +# /etc/systemd/system/ +# 2) and enable service: +# sudo systemctl enable isttok-temp-ioc.service +[Unit] +Description=EPICS Soft IOC ISTTOK +Requires=network.target +After=network.target + +[Service] +WorkingDirectory=/home/oper/ISTTOK/epics/iocs/dsPICTemp/iocBoot/iocISTTOK +ExecStart=/usr/bin/procServ --foreground --quiet --port=4051 /home/oper/ISTTOK/epics/iocs/dsPICTemp/iocBoot/iocISTTOK/st.cmd +Restart=always +#User=iocuser +User=oper +RuntimeDirectory=ISTTOK +#CPUAffinity=1-3 +#LimitMEMLOCK=infinity +#LimitRTPRIO=99 + +[Install] +WantedBy=multi-user.target diff --git a/epics/iocs/dsPICTemp/iocBoot/iocISTTOK/st.cmd b/epics/iocs/dsPICTemp/iocBoot/iocISTTOK/st.cmd new file mode 100755 index 0000000..6959786 --- /dev/null +++ b/epics/iocs/dsPICTemp/iocBoot/iocISTTOK/st.cmd @@ -0,0 +1,33 @@ +#!/home/oper/ISTTOK/epics/iocs/dsPICTemp/bin/linux-x86_64/ISTTOK + +#- You may have to change ISTTOK to something else +#- everywhere it appears in this file + +< envPaths + +epicsEnvSet( "STREAM_PROTOCOL_PATH", "$(TOP)/db" ) + +epicsEnvSet( "EPICS_CA_ADDR_LIST", "localhost 192.168.1.120 192.168.1.110") + +cd "${TOP}" + +## Register all support components +dbLoadDatabase "dbd/ISTTOK.dbd" +ISTTOK_registerRecordDeviceDriver pdbbase + +drvAsynSerialPortConfigure("RS232","/dev/ttyUSB0") +asynSetOption("RS232", 0, "baud", "115200") +asynSetOption("RS232", 0, "bits", "8") +asynSetOption("RS232", 0, "parity", "none") +asynSetOption("RS232", 0, "stop", "1") +#asynSetOption("RS232", 0, "clocal", "N") +#asynSetOption("RS232", 0, "crtscts", "Y") + +## Load record instances +dbLoadRecords("db/ISTTOKtemperature.db","P=ISTTOK:,R=temperature:,PORT=RS232,A=0") + +cd "${TOP}/iocBoot/${IOC}" +iocInit + +## Start any sequence programs +#seq sncxxx,"user=oper"