Ubuntu 22.04 EPICS 环境搭建
本次示例安装在 Ubuntu 22.04 虚拟机上,真机安装系统时需要注意 BIOS 设置及硬盘分区。此外搭建环境过程中需要接入外网,方便在线安装相关依赖。
一、安装准备
1、新建Ubuntu 22.04虚拟机,具体安装步骤略,注意配置虚拟机网络连接;
2、设置root用户密码,开启ssh远程连接;
设置root用户密码
sudo passwd root
开启ssh远程连接
ifconfig sudo apt-get update sudo apt-get install net-tools sudo apt-get install openssh-server // 安装ssh
安装ssh完成后,修改配置文件,添加 PermitRootLogin yes
vim /etc/ssh/sshd_config
#LoginGraceTime 2m #PermitRootLogin prohibit-password PermitRootLogin yes #StrictModes yes #MaxAuthTries 6 #MaxSessions 10
修改完成后,重启ssh服务
/etc/init.d/ssh restart systemctl restart ssh
二、安装epics base
安装流程可参考官方帮助文档:https://docs.epics-controls.org/projects/how-tos/en/latest/getting-started/installation.html
1、安装编译环境等相关依赖;
sudo apt-get install g++ sudo apt-get install gcc sudo apt-get install c++ sudo apt-get install libreadline-dev sudo apt-get install make sudo apt-get install cmake // 用于开源库的编译
2、下载epics base并编译;
可以在EPICS官网 https://epics-controls.org/ 或github仓库 https://github.com/epics-base/epics-base 下载;
这里下载的 Base Release 3.15.9 稳定版本,该版本发布于2021年6月;V4版本后引入了PVA,后合并版本3 4为V7版本,PVA相比CA协议支持更高的性能,目前使用较多的还是标准通信协议CA。
下载后路径为 /opt/epics,解压缩并修改路径为epics-base,方便后续配置环境变量;
mkdir /opt/epics // 新建路径,并将 *.tar.gz 通过 ftp 上传至该路径 tar -zxvf epics-base-R3.15.9.tar.gz mv epics-base-R3.15.9 epics-base
切换到 /opt/epics/epics-base 路径并编译;
cd /opt/epics/epics-base make
编译完成后,配置EPICS的环境变量
vim /etc/profile
在配置文件中加入以下内容,并通过source使之生效:
export EPICS_BASE=/opt/epics/epics-base export EPICS_HOST_ARCH=$(${EPICS_BASE}/startup/EpicsHostArch) export PATH=${EPICS_BASE}/bin/${EPICS_HOST_ARCH}:${PATH}
source /etc/profile
至此,EPICS base环境已经搭建好,可新建一个EPICS IOC Example来测试;
cd /opt mkdir example-ioc cd example-ioc
在example-ioc路径下,通过 makeBaseApp.pl 脚本创建示例IOC,并 make 编译;
makeBaseApp.pl -t example example-ioc makeBaseApp.pl -i -t example example-ioc make
编译完成后,切换到 ./iocBoot/example-ioc/ 路径下,给启动脚本赋予执行权限;
cd iocBoot/example-ioc/ chmod +x st.cmd
启动IOC,并通过 dbl 查看当前IOC的数据点;
root@cimcs-server:/opt/example-ioc/iocBoot/example-ioc# ./st.cmd #!../../bin/linux-x86_64/example-ioc ## You may have to change example-ioc to something else ## everywhere it appears in this file < envPaths epicsEnvSet("IOC","example-ioc") epicsEnvSet("TOP","/opt/example-ioc") epicsEnvSet("EPICS_BASE","/opt/epics/epics-base") cd "/opt/example-ioc" ## Register all support components dbLoadDatabase "dbd/example-ioc.dbd" example_ioc_registerRecordDeviceDriver pdbbase ## Load record instances dbLoadTemplate "db/user.substitutions" dbLoadRecords "db/dbSubExample.db", "user=root" ## Set this to see messages from mySub #var mySubDebug 1 ## Run this to trace the stages of iocInit #traceIocInit cd "/opt/example-ioc/iocBoot/example-ioc" iocInit Starting iocInit ############################################################################ ## EPICS R3.15.9 ## EPICS Base built Mar 5 2024 ############################################################################ iocRun: All initialization complete ## Start any sequence programs #seq sncExample, "user=root" epics> dbl root:aSubExample root:subExample root:xxxExample root:compressExample root:calcExample root:calcExample1 root:calc1 root:calcExample2 root:calc2 root:calcExample3 root:calc3 root:aiExample root:aiExample1 root:ai1 root:aiExample2 root:ai2 root:aiExample3 root:ai3 epics>
另起一个终端,监控模拟数据点;
root@cimcs-server:/home/cimcs# cainfo root:ai1 root:ai1 State: connected Host: 192.168.142.133:5064 Access: read, write Native data type: DBF_DOUBLE Request type: DBR_DOUBLE Element count: 1 root@cimcs-server:/home/cimcs# camonitor root:ai1 root:ai1 2024-03-05 15:31:03.032647 3 LOW MINOR root:ai1 2024-03-05 15:31:04.046975 4 LOW MINOR root:ai1 2024-03-05 15:31:05.032955 5 root:ai1 2024-03-05 15:31:06.037752 6 HIGH MINOR root:ai1 2024-03-05 15:31:07.032891 7 HIGH MINOR root:ai1 2024-03-05 15:31:08.038839 8 HIHI MAJOR root:ai1 2024-03-05 15:31:09.033308 9 HIHI MAJOR root:ai1 2024-03-05 15:31:10.042908 0 LOLO MAJOR root:ai1 2024-03-05 15:31:11.035694 1 LOLO MAJOR root:ai1 2024-03-05 15:31:12.044342 2 LOLO MAJOR