EPICS集成AutoSave模块实现参数初始化
EPICS synApps是用于开发基于EPICS的输运线控制系统的软件工具集,其子模块之一的 AutoSave 可用于保存PV的值并在EPICS启动时初始化上次保存的值。
阅读本文建设你已经完成EPICS环境的安装(可参考 Ubuntu 22.04 EPICS 环境搭建 )。
一、AutoSave的编译
1、下载EPICS AutoSave模块的Release版本 https://github.com/epics-modules/autosave/releases,截止目前该模块最新发布版本为R5-11,由于笔者EPICS-Base等版本非最新,安装过程中提示支持R5-9版本;
2、将文件上传到 /opt/epics/support 目录下,解压并编译;
tar -zxvf autosave-R5-9.tar.gz
减压后切换到加压的文件夹目录的 configure 路径下,修改配置文件
cd autosave-R5-9/configure vim RELEASE
修改EPICS_BASE路径为实际路径
EPICS_BASE=/opt/epics/epics-base
修改完成后,切换回AutoSave根目录下直接 make 编译
make
二、AutoSave示例
新建一个EPICS IOC 用来来测试;
cd /opt mkdir sim-ioc cd sim-ioc
在sim-ioc路径下,通过 makeBaseApp.pl 脚本创建示例IOC,并 make 编译;
makeBaseApp.pl -t ioc sim-ioc makeBaseApp.pl -i -t ioc sim-ioc
修改 configure/RELEASE 中 epics-base 和 support 路径,示例中用到了还用到了 opcua 模块 EPICS 使用open62541 SDK集成OPC UA设备支持;
# Variables and paths to dependent modules: #MODULES = /path/to/modules #MYMODULE = $(MODULES)/my-module SUPPORT = /opt/epics/support # If using the sequencer, point SNCSEQ at its top directory: #SNCSEQ = $(MODULES)/seq-ver OPCUA = $(SUPPORT)/opcua-v0.10.0 AUTOSAVE = $(SUPPORT)/autosave-R5-9 # EPICS_BASE should appear last so earlier modules can override stuff: EPICS_BASE = /opt/epics/epics-base
修改 sim-iocApp/src/Makefile
# Include dbd files from all support applications: sim-ioc_DBD += opcua.dbd sim-ioc_DBD += asSupport.dbd # Add all the support libraries needed by this IOC sim-ioc_LIBS += opcua sim-ioc_LIBS += autosave
修改 st.cmd 文件
#!../../bin/linux-x86_64/sim-ioc #- You may have to change sim-ioc to something else #- everywhere it appears in this file < envPaths cd "${TOP}" ## Register all support components dbLoadDatabase "dbd/sim-ioc.dbd" sim_ioc_registerRecordDeviceDriver pdbbase set_requestfile_path("$(TOP)/iocBoot/$(IOC)","") set_requestfile_path("$(TOP)/iocBoot/$(IOC)","autosave") set_savefile_path("$(TOP)/iocBoot/$(IOC)/autosave") set_pass1_restoreFile("auto_settings.sav") save_restoreSet_numSeqFiles(3) save_restoreSet_SeqPeriodInSeconds(600) save_restoreSet_RetrySeconds(60) save_restoreSet_CAReconnect(1) save_restoreSet_CallbackTimeout(-1) ## Load record instances opcuaCreateSession OPC_SIM opc.tcp://192.168.142.1:53530/OPCUA/SimulationServer opcuaCreateSubscription OPC_SIM_SUB OPC_SIM 1000 dbLoadRecords("${TOP}/db/TEST-SIM.db") cd "${TOP}/iocBoot/${IOC}" iocInit create_monitor_set("auto_settings.req", 5, "P=TEST-SIM:") ## Start any sequence programs #seq sncxxx,"user=root"
在 st.cmd 同级目录下创建 autosave 目录,并新建 auto_settings.req 文件,添加需要自动保存的数据点;
$(P)Constant.VAL $(P)Setting.VAL
修改完成后 make 编译,随后切换到 ./iocBoot/sim-ioc/ 路径下,给启动脚本赋予执行权限;
cd iocBoot/sim-ioc/ chmod +x st.cmd
启动IOC,通过日志可以看到当前两个PV数据点都连接成功;
create_monitor_set("auto_settings.req", 5, "P=TEST-SIM:") ## Start any sequence programs #seq sncxxx,"user=root" auto_settings.sav: 2 of 2 PV's connected epics>
修改这两个PV值,重启IOC可观察PV值可实现上一次保存值的初始化;