1# @Language: Markdown
2# @Software: VS Code/MacDown/Typora/Vim
3# @Author : Di Wang
4# @Email : [email protected]
See epics examples
用法
log可以有JSON格式, 需要epics 7.0.1以上.
server可以使用iocLogServer.
1<IOC app name>_DBD += caPutLog.dbd # For standard format
2<IOC app name>_DBD += caPutJsonLog.dbd # For JSON format (Exists only if module is compiled with supported version of base)
3<IOC app name>_LIBS += caPutLog # Required for both output formats
需要首先配置Access security, 对于DEFAULT
group, 添加RULE(1,WRITE,TRAPWRITE)
. 然后在iocsh中, 设置
1caPutLogInit "host[:port]" [config]
2caPutJsonLogInit "host[:port]" [config]
3# for example
4caPutLogInit "localhost:7011" 0
5caPutJsonLogInit $(CAPUTLOG_INET):$(CAPUTLOG_INET_PORT=8002) $(CAPUTLOG_OPTION=0)
6
7# 重新加载配置
8caPutLogReconf config
9caPutJsonLogReconf config
10
11# info
12caPutLogShow level
13caPutJsonLogShow level
14
15# 修改日期格式
16caPutLogSetTimeFmt "<date_time_format>"
17
18# log to a PV
19epicsEnvSet(EPICS_AS_PUT_LOG_PV, "pv.VAL$")
20epicsEnvSet(EPICS_AS_PUT_JSON_LOG_PV, "pv.VAL$")
21
22# debug
23var caPutLogDebug,1
示例
首先启动iocLogServer. 启动命令如下.
1INSTALL_BIN=/home/sdcswd/epics/R7.0.8/base/bin/linux-x86_64
2
3# To change the default values for the EPICS Environment parameters,
4# uncomment and modify the relevant lines below.
5
6# EPICS_IOC_LOG_PORT="6500" export EPICS_IOC_LOG_PORT
7EPICS_IOC_LOG_FILE_NAME="ioclog.log" export EPICS_IOC_LOG_FILE_NAME
8# EPICS_IOC_LOG_FILE_LIMIT="1000000" export EPICS_IOC_LOG_FILE_LIMIT
9
10if [ $1 = "start" ]; then
11 if [ -x $INSTALL_BIN/iocLogServer ]; then
12 echo "Starting EPICS Log Server "
13 $INSTALL_BIN/iocLogServer &
14 fi
15else
16 if [ $1 = "stop" ]; then
17 pid=`ps -e | sed -ne '/iocLogSe/s/^ *\([1-9][0-9]*\).*$/\1/p'`
18 if [ "${pid}" != "" ]; then
19 echo "Stopping EPICS Log Server "
20 kill ${pid}
21 fi
22 fi
23fi
然后在st.cmd中
1dbLoadTemplate("db/user.substitutions")
2
3epicsEnvSet(EPICS_IOC_LOG_INET, "localhost")
4#epicsEnvSet(EPICS_IOC_LOG_PORT, "$(LOG_INET_PORT)")
5epicsEnvSet(iocLogDisable, "$(LOGDISABLE=0)")
6
7asSetFilename("access.acf")
8iocLogPrefix("${IOC} ")
9
10cd "${TOP}/iocBoot/${IOC}"
11iocInit
12
13caPutLogInit "localhost:7004" 0
14iocLogInit()
然后在ioclog.log文件中, 可以同时得到iocLog(前两行)和caPutLog(后两行)的内容.
1localhost:55142 Sun May 12 15:26:47 2024 iocexample iocPause: IOC suspended
2localhost:55142 Sun May 12 15:26:47 2024 iocexample iocRun: IOC restarted
3localhost:55128 Sun May 12 15:26:57 2024 iocexample 12-May-24 15:26:51 zephyrus sdcswd sdcswd:circle:step new=2 old=1
4localhost:55128 Sun May 12 15:27:02 2024 iocexample 12-May-24 15:26:57 zephyrus sdcswd sdcswd:circle:step new=1 old=2