1# @Language: Markdown
2# @Software: VS Code/MacDown/Typora/Vim
3# @Author : Di Wang
4# @Email : [email protected]
See epics examples
当设定一个motor时, 我们需要确定设置已经完成, 再进行下一步操作(比如开启快门). 采集数据, 完成后然后关闭快门. 这中间, motor移动的时间不确定, 采集数据的时间不确定. 而使用轮询的方式又显得不可靠.
安装
用法
首先使用put-callback修改一个record的值, 这个record的FLNK或OUT link指向busy record. 当busy record的值为1时, callback不会返回. 直到busy record的值变为0(通过CA 或者 asyn device support等), callback才会完成.
如果使用CA的话, 使用-c
指定asynchronous put, -w
指定等待时间, 默认为1秒.
1caput –c –w 20 DemoDevice 5
2caput –c –w 20 DemoDevice 1
3caput –c DemoDevice 5
4caput –c DemoDevice 4
1# Demo of 'busy' record
2#
3# Basic idea:
4# When writing a "1" to the busy record,
5# it remains in the active/busy/processing state
6# until something writes a "0" to it.
7#
8# This example simulates a slow device
9# with a "DemoDevice" setpoint
10# and a "DemoDeviceReadback" readback
11# that slowly follows the setpoint.
12#
13# Writing to the setpoints sets the busy record.
14# Since the DemoDevice has an FLNK & OUT chain
15# to the busy record, performing a "put callback"
16# via channel access will thus hang while
17# the busy record is active.
18record(ai, "DemoDevice")
19{
20 field(DESC, "Setpoint")
21 field(FLNK, "DemoDeviceStart")
22}
23
24record(ao, "DemoDeviceStart")
25{
26 field(DOL, "1")
27 field(OUT, "DemoDeviceBusy PP")
28}
29
30record(busy, "DemoDeviceBusy")
31{
32 field(DESC, "BUSY Record")
33}
34
35# Readback slowly follows the setpoint
36record(calc, "DemoDeviceReadback")
37{
38 field(DESC, "Readback")
39 field(INPA, "DemoDeviceReadback")
40 field(INPB, "DemoDevice")
41 field(CALC, "(A>B)?(A-0.1):((A<B)?(A+0.1):B)")
42 field(SCAN, ".1 second")
43 field(PREC, "2")
44 field(FLNK, "DemoDeviceDone")
45}
46
47# When readback matches the setpoint,
48# busy record is cleared and a pending
49# "put callback" will complete
50record(calcout, "DemoDeviceDone")
51{
52 field(INPA, "DemoDeviceReadback")
53 field(INPB, "DemoDevice")
54 field(CALC, "ABS(A-B)>0.2")
55 field(OOPT, "Transition To Zero")
56 field(OUT, "DemoDeviceBusy PP")
57}
asyn
busy record有三种device support,
1device(busy,CONSTANT,devBusySoft,"Soft Channel")
2device(busy,CONSTANT,devBusySoftRaw,"Raw Soft Channel")
3device(busy,INST_IO,asynBusyInt32,"asynInt32")
对于asyn device support, 在使用autosave时初始化有一些问题, 详见: https://epics-modules.github.io/busy/busyReleaseNotes.html